mirror of https://github.com/Mai-with-u/MaiBot.git
修复了日程异步bug
parent
b98314da4f
commit
304562d93a
|
|
@ -23,7 +23,7 @@ class LLMModel:
|
||||||
self.model_name = model_name
|
self.model_name = model_name
|
||||||
self.params = kwargs
|
self.params = kwargs
|
||||||
|
|
||||||
async def generate_response(self, prompt: str) -> Tuple[str, str]:
|
def generate_response(self, prompt: str) -> Tuple[str, str]:
|
||||||
"""根据输入的提示生成模型的响应"""
|
"""根据输入的提示生成模型的响应"""
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": f"Bearer {self.api_key}",
|
"Authorization": f"Bearer {self.api_key}",
|
||||||
|
|
@ -42,11 +42,10 @@ class LLMModel:
|
||||||
api_url = f"{self.base_url.rstrip('/')}/chat/completions"
|
api_url = f"{self.base_url.rstrip('/')}/chat/completions"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with aiohttp.ClientSession() as session:
|
response = requests.post(api_url, headers=headers, json=data)
|
||||||
async with session.post(api_url, headers=headers, json=data) as response:
|
|
||||||
response.raise_for_status() # 检查响应状态
|
response.raise_for_status() # 检查响应状态
|
||||||
|
|
||||||
result = await response.json()
|
result = response.json()
|
||||||
if "choices" in result and len(result["choices"]) > 0:
|
if "choices" in result and len(result["choices"]) > 0:
|
||||||
content = result["choices"][0]["message"]["content"]
|
content = result["choices"][0]["message"]["content"]
|
||||||
reasoning_content = result["choices"][0]["message"].get("reasoning_content", "")
|
reasoning_content = result["choices"][0]["message"].get("reasoning_content", "")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue