Browse Source

fix: session save

master
zhayujie 1 year ago
parent
commit
50e44dbb2a
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      bot/linkai/link_ai_bot.py

+ 3
- 1
bot/linkai/link_ai_bot.py View File

@@ -16,6 +16,7 @@ class LinkAIBot(Bot):


def __init__(self): def __init__(self):
self.base_url = "https://api.link-ai.chat/v1" 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: def reply(self, query, context: Context = None) -> Reply:
return self._chat(query, context) return self._chat(query, context)
@@ -28,7 +29,7 @@ class LinkAIBot(Bot):


try: try:
session_id = context["session_id"] 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) session = self.sessions.session_query(query, session_id)


# remove system message # remove system message
@@ -61,6 +62,7 @@ class LinkAIBot(Bot):
# execute success # execute success
reply_content = res["data"]["content"] reply_content = res["data"]["content"]
logger.info(f"[LINKAI] reply={reply_content}") logger.info(f"[LINKAI] reply={reply_content}")
self.sessions.session_reply(reply_content, session_id)
return Reply(ReplyType.TEXT, reply_content) return Reply(ReplyType.TEXT, reply_content)
except Exception as e: except Exception as e:
logger.exception(e) logger.exception(e)


Loading…
Cancel
Save