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 +++++++++++++------- app/config/const.py | 1 + app/api/files.py | 5 +++-- app/config/env_conf/menu_conf.json | 17 +++++++++++++++++ 4 files changed, 34 insertions(+), 9 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", "") diff --git a/app/api/files.py b/app/api/files.py index db8936b..3a8491d 100644 --- a/app/api/files.py +++ b/app/api/files.py @@ -11,7 +11,7 @@ from app.api import Response, get_current_user, ResponseList from app.config.config import settings from app.config.const import DOCUMENT_TO_REPORT, IMAGE_TO_TEXT, DOCUMENT_TO_REPORT_TITLE, DOCUMENT_IA_QUESTIONS, \ - DOCUMENT_TO_PAPER + DOCUMENT_TO_PAPER, DOCUMENT_IA_QUESTIONS_DS from app.models import MenuCapacityModel from app.models.agent_model import AgentType, AgentModel from app.models.base_model import get_db @@ -116,11 +116,12 @@ data = await dify_service.upload(token, file.filename, file_content, current_user.id) except Exception as e: raise HTTPException(status_code=500, detail=str(e)) - elif agent.chat_type == "reportWorkflow" or agent.chat_type == "documentIa" or agent.chat_type == "paperTalk": + elif agent.chat_type == "reportWorkflow" or agent.chat_type == "documentIa" or agent.chat_type == "paperTalk" or agent.chat_type == "documentIaDs": token_dict = { "reportWorkflow": DOCUMENT_TO_REPORT_TITLE, "documentIa": DOCUMENT_IA_QUESTIONS, "paperTalk": DOCUMENT_TO_PAPER, + "documentIaDs": DOCUMENT_IA_QUESTIONS_DS, } token = DfTokenDao(db).get_token_by_id(token_dict[agent.chat_type]) if not token: diff --git a/app/config/const.py b/app/config/const.py index fcc1e5f..2237794 100644 --- a/app/config/const.py +++ b/app/config/const.py @@ -4,6 +4,7 @@ DOCUMENT_TO_REPORT = "document_to_report" IMAGE_TO_TEXT = "image_and_text_conversion" DOCUMENT_IA_QUESTIONS = "document_ia_questions" +DOCUMENT_IA_QUESTIONS_DS = "document_ia_questions_ds" DOCUMENT_TO_REPORT_TITLE = "document_to_report_title" DOCUMENT_TO_TITLE = "document_to_title" DOCUMENT_TO_PAPER = "document_to_paper" diff --git a/app/config/env_conf/menu_conf.json b/app/config/env_conf/menu_conf.json index b35dbfc..1e52f8b 100644 --- a/app/config/env_conf/menu_conf.json +++ b/app/config/env_conf/menu_conf.json @@ -164,6 +164,23 @@ "agentType": 4 } ] + }, + { + "id": 10, + "title": "鏂囨。鏅鸿兘锛圖S锛�", + "icon": "7", + "img": "/src/assets/index/7.png", + "desc": "涓汉鐭ヨ瘑搴撶殑闂瓟鍔╂墜锛屽熀浜庢偍涓婁紶鐨勬枃妗h繘琛岄棶绛旓紝鏀寔澶氭枃妗�", + "describe": "涓汉鐭ヨ瘑搴撶殑闂瓟鍔╂墜锛屽熀浜庢偍涓婁紶鐨勬枃妗h繘琛岄棶绛旓紝鏀寔澶氭枃妗o紝澶у皬鍦�30M浠ュ唴銆�", + "rank": 90, + "dialog": [ + { + "id": "e138dd77-34d9-40f8-88f8-4d0ba7842b0b", + "chat_id": "e138dd77-34d9-40f8-88f8-4d0ba7842b0b", + "chat_type": "documentIaDs", + "agentType": 4 + } + ] } ] } \ No newline at end of file -- Gitblit v1.8.0