From d74138c43e8ffa86ce73eacd2726edf17919d348 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 21 十一月 2024 09:50:34 +0800
Subject: [PATCH] 智能数据agent初始化

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

diff --git a/app/api/chat.py b/app/api/chat.py
index a42c819..5e6f1da 100644
--- a/app/api/chat.py
+++ b/app/api/chat.py
@@ -14,6 +14,7 @@
 from app.service.basic import BasicService
 from app.service.ragflow import RagflowService
 from app.service.service_token import get_bisheng_token, get_ragflow_token
+from app.service.session import SessionService
 
 router = APIRouter()
 
@@ -203,6 +204,12 @@
                 # 鎺ユ敹鍓嶇娑堟伅
                 message = await websocket.receive_json()
                 question = message.get("message")
+                SessionService(db).create_session(
+                    session_id=chat_id,
+                    name=question,
+                    agent_id=agent_id,
+                    agent_type=AgentType.BASIC
+                )
                 if not question:
                     await websocket.send_json({"message": "Invalid request", "type": "error"})
                     continue
@@ -220,7 +227,7 @@
                             data = json.loads(text)
                             output = data.get("output", "")
                             excel_name = data.get("excel_name", "")
-                            image_name = data.get("excel_name", "")
+                            image_name = data.get("image_name", "")
                             excel_url = None
                             image_url = None
                             if excel_name:

--
Gitblit v1.8.0