them web app va README

This commit is contained in:
2026-06-12 22:13:19 +07:00
parent abddb932aa
commit c512d60160
8 changed files with 1216 additions and 155 deletions
+11 -8
View File
@@ -118,6 +118,16 @@ class LLMClient:
"Content-Type": "application/json",
}
def _post(self, payload: dict) -> dict:
resp = requests.post(
f"{self.base_url}/chat/completions",
headers=self.headers,
json=payload,
timeout=60,
)
resp.raise_for_status()
return resp.json()
def generate(self, prompt: str, temperature: float = 0.1, max_tokens: int = 1000) -> str:
payload = {
"model": self.model,
@@ -128,14 +138,7 @@ class LLMClient:
"temperature": temperature,
"max_tokens": max_tokens,
}
resp = requests.post(
f"{self.base_url}/chat/completions",
headers=self.headers,
json=payload,
timeout=60,
)
resp.raise_for_status()
return resp.json()["choices"][0]["message"]["content"].strip()
return self._post(payload)["choices"][0]["message"]["content"].strip()
def _system_prompt(self) -> str:
return """Bạn là một trợ lý AI chuyên về Orange Pi, sử dụng dữ liệu từ blog orangepi.vn (nhà phân phối chính thức Orange Pi tại Việt Nam).