From 50e44dbb2aa9d3f9a80dcbf4faddf26da3fc9f57 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Sun, 28 May 2023 22:12:36 +0800 Subject: [PATCH] fix: session save --- bot/linkai/link_ai_bot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bot/linkai/link_ai_bot.py b/bot/linkai/link_ai_bot.py index 9dd18b1..e7b9703 100644 --- a/bot/linkai/link_ai_bot.py +++ b/bot/linkai/link_ai_bot.py @@ -16,6 +16,7 @@ class LinkAIBot(Bot): def __init__(self): self.base_url = "https://api.link-ai.chat/v1" + self.sessions = SessionManager(ChatGPTSession, model=conf().get("model") or "gpt-3.5-turbo") def reply(self, query, context: Context = None) -> Reply: return self._chat(query, context) @@ -28,7 +29,7 @@ class LinkAIBot(Bot): try: session_id = context["session_id"] - self.sessions = SessionManager(ChatGPTSession, model=conf().get("model") or "gpt-3.5-turbo") + session = self.sessions.session_query(query, session_id) # remove system message @@ -61,6 +62,7 @@ class LinkAIBot(Bot): # execute success reply_content = res["data"]["content"] logger.info(f"[LINKAI] reply={reply_content}") + self.sessions.session_reply(reply_content, session_id) return Reply(ReplyType.TEXT, reply_content) except Exception as e: logger.exception(e)