|
@@ -25,7 +25,7 @@ class Agent(Plugin):
|
|
|
cursor = connection.cursor()
|
|
|
try:
|
|
|
history_messages = msg_history_get(cursor, wx_wxid, msg.sender, msg.roomid)
|
|
|
- if dataset_id is not None:
|
|
|
+ if not dataset_id:
|
|
|
# 优化问题
|
|
|
expand_system_prompt = f"""# 任务:
|
|
|
请根据上下文信息,优化用户发送的最后一条消息,补齐消息中可能缺失的主语、谓语、宾语、定语、状语、补语句子成分。
|
|
@@ -59,6 +59,7 @@ class Agent(Plugin):
|
|
|
bot_reply = self._client_reply(self.openAiClient, messages)
|
|
|
new_history_messages = history_messages + [{"role": "user", "content": msg.content}, {"role": "assistant", "content": bot_reply}]
|
|
|
msg_history_update(cursor, wx_wxid, new_history_messages, msg.sender, msg.roomid)
|
|
|
+ connection.commit()
|
|
|
return bot_reply
|
|
|
except Exception as e:
|
|
|
# 回滚事务
|
|
@@ -66,7 +67,6 @@ class Agent(Plugin):
|
|
|
print(f"发生错误: {e}")
|
|
|
finally:
|
|
|
# 确保资源被正确释放
|
|
|
- connection.commit()
|
|
|
cursor.close()
|
|
|
connection.close()
|
|
|
|