them web app va README
This commit is contained in:
+11
-8
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user