From 9683aeeafa2f1067ef061b34124a1c362df07e5e Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期四, 03 四月 2025 14:10:13 +0800
Subject: [PATCH] rg配置修改

---
 app/api/agent.py |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/app/api/agent.py b/app/api/agent.py
index fd31c96..e3a9e31 100644
--- a/app/api/agent.py
+++ b/app/api/agent.py
@@ -18,7 +18,7 @@
 from app.service.dialog import get_session_history
 from app.service.ragflow import RagflowService
 from app.service.service_token import get_ragflow_token, get_bisheng_token
-from app.task.fetch_agent import initialize_agents
+# from app.task.fetch_agent import initialize_agents
 
 router = APIRouter()
 
@@ -45,10 +45,10 @@
     if agent_type == AgentType.RAGFLOW:
         ragflow_service = RagflowService(base_url=settings.fwr_base_url)
         try:
-            token = await get_ragflow_token(db, current_user.id)
-            result = await ragflow_service.get_chat_sessions(token, agent_id)
+            result = await get_session_history(db, current_user.id, agent_id, page, limit)
             if not result:
-                result = await get_session_history(db, current_user.id, agent_id, page, limit)
+                token = await get_ragflow_token(db, current_user.id)
+                result = await ragflow_service.get_chat_sessions(token, agent_id)
         except Exception as e:
             print(e)
             raise HTTPException(status_code=500, detail=str(e))
@@ -192,6 +192,8 @@
             for i in session.log_to_json().get("message", []):
                 if i.get("role") == "user":
                     tmp_data["question"]=i.get("content")
+                    if "upload_filenames" in i:
+                        tmp_data["upload_filenames"] = i.get("upload_filenames")
                 elif i.get("role") == "assistant":
 
                     if isinstance(i.get("content"), dict):
@@ -231,6 +233,8 @@
             for i in session.log_to_json().get("message", []):
                 if i.get("role") == "user":
                     tmp_data["question"] = i.get("content")
+                    if "upload_filenames" in i:
+                        tmp_data["upload_filenames"] = i.get("upload_filenames")
                 elif i.get("role") == "assistant":
                     if isinstance(i.get("content"), dict):
                         content = i.get("content", {})

--
Gitblit v1.8.0