修复错误代码

This commit is contained in:
taylorxie
2026-03-09 17:12:27 +08:00
parent 17c18b48dc
commit 66881b0d91
3 changed files with 31 additions and 9 deletions

View File

@@ -130,10 +130,18 @@ class AiBotPlugin(AbsExtraConfigPlugin):
# 关闭typing提示
await self.client.set_typing(event.room_id, timeout=0)
# 打开typing提示
resp_content = chat_completion.message['content']
response = TextMessageEventContent(msgtype=MessageType.TEXT, body=resp_content, format=Format.HTML,
formatted_body=markdown.render(resp_content))
await event.respond(response, in_thread=self.config['reply_in_thread'])
if chat_completion.message['result']:
if hasattr(chat_completion.message, 'content'):
resp_content = chat_completion.message['content']
response = TextMessageEventContent(msgtype=MessageType.TEXT, body=resp_content, format=Format.HTML,
formatted_body=markdown.render(resp_content))
await event.respond(response, in_thread=self.config['reply_in_thread'])
else:
resp_content = "调用失败,请检查: " + chat_completion.finish_reason
response = TextMessageEventContent(msgtype=MessageType.TEXT, body=resp_content, format=Format.HTML,
formatted_body=markdown.render(resp_content))
await event.respond(response, in_thread=self.config['reply_in_thread'])
except Exception as e:
self.log.exception(f"Something went wrong: {e}")
await event.respond(f"Something went wrong: {e}")