Skip to content

Commit

Permalink
fix: session save
Browse files Browse the repository at this point in the history
  • Loading branch information
zhayujie committed May 28, 2023
1 parent 34277a3 commit 50e44db
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bot/linkai/link_ai_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -28,7 +29,7 @@ def _chat(self, query, context, retry_count=0):

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
Expand Down Expand Up @@ -61,6 +62,7 @@ def _chat(self, query, context, retry_count=0):
# 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)
Expand Down

0 comments on commit 50e44db

Please sign in to comment.