From ae30d9a75407c912649f11c4f44ff15c869a4f98 Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期四, 21 十一月 2024 15:42:42 +0800
Subject: [PATCH] 自研agent会话保存和查询

---
 app/api/chat.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/app/api/chat.py b/app/api/chat.py
index de05de8..60d2fb8 100644
--- a/app/api/chat.py
+++ b/app/api/chat.py
@@ -209,7 +209,8 @@
                     session_id=chat_id,
                     name=question,
                     agent_id=agent_id,
-                    agent_type=AgentType.BASIC
+                    agent_type=AgentType.BASIC,
+                    user_id=current_user.id
                 )
                 if not question:
                     await websocket.send_json({"message": "Invalid request", "type": "error"})
@@ -232,6 +233,7 @@
                                 if file_name:
                                     excel_url = f"/api/files/download/?agent_id=basic_question_talk&file_id={file_name}&file_type=word"
                                 result = {"message": output, "type": "message", "file_url": excel_url}
+                                SessionService(db).update_session(session_id=chat_id, is_incr=1, message={"role":"assistant", "content": result})
                                 await websocket.send_json(result | data)
                             except json.JSONDecodeError as e:
                                 print(f"Error decoding JSON: {e}")

--
Gitblit v1.8.0