From 6ab3410581d664dd602f6af68f5c8f78bfdb4806 Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期四, 13 二月 2025 13:53:28 +0800
Subject: [PATCH] 增加ds模型文档智能

---
 app/api/chat.py |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/app/api/chat.py b/app/api/chat.py
index 4d480bd..2d2845d 100644
--- a/app/api/chat.py
+++ b/app/api/chat.py
@@ -11,7 +11,7 @@
 from app.api import get_current_user_websocket
 from app.config.config import settings
 from app.config.const import IMAGE_TO_TEXT, DOCUMENT_TO_REPORT, DOCUMENT_TO_CLEANING, DOCUMENT_IA_QUESTIONS, \
-    DOCUMENT_TO_REPORT_TITLE, DOCUMENT_TO_TITLE, DOCUMENT_TO_PAPER
+    DOCUMENT_TO_REPORT_TITLE, DOCUMENT_TO_TITLE, DOCUMENT_TO_PAPER, DOCUMENT_IA_QUESTIONS_DS
 from app.models import MenuCapacityModel
 from app.models.agent_model import AgentModel, AgentType
 from app.models.base_model import get_db
@@ -807,8 +807,12 @@
                                         result = {"message": f"鍐呴儴閿欒锛� {e2}", "type": "close"}
                                         await websocket.send_json(result)
                                         print(f"Error process message of ragflow: {e2}")
-                elif chat_type == "documentIa":
-                    token = DfTokenDao(db).get_token_by_id(DOCUMENT_IA_QUESTIONS)
+                elif chat_type == "documentIa" or chat_type == "documentIaDs":
+                    token_dict = {
+                        "documentIa": DOCUMENT_IA_QUESTIONS,
+                        "documentIaDs": DOCUMENT_IA_QUESTIONS_DS,
+                    }
+                    token = DfTokenDao(db).get_token_by_id(token_dict[chat_type])
                     # print(token)
                     if not token:
                         await websocket.send_json({"message": "Invalid token", "type": "error"})
@@ -874,11 +878,13 @@
                                                 logger.error(data)
                                                 continue
                                             elif isinstance(answer, dict):
+                                                if answer.get("status") == "failed":
+                                                    message = answer.get("error", "")
+                                                else:
+                                                    message = answer.get("title", "")
 
-                                                message = answer.get("title", "")
-
-                                            result = {"message": message, "type": "system"}
-                                            continue
+                                                result = {"message": message, "type": "system"}
+                                            # continue
                                     elif data.get("event") == "message":  # "event": "message_end"
                                         # 姝e父杈撳嚭
                                         answer = data.get("answer", "")

--
Gitblit v1.8.0