From 383c21560fcb7012cd2e5b15d559e46d038c87b0 Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期二, 25 二月 2025 09:54:43 +0800
Subject: [PATCH] 增加设备分析

---
 app/api/chat.py                    |    7 +++++--
 app/config/const.py                |    1 +
 app/api/v2/public_api.py           |    5 +++--
 app/models/public_api_model.py     |    4 ++++
 app/service/session.py             |    1 +
 app/api/files.py                   |    5 +++--
 app/config/env_conf/menu_conf.json |   17 +++++++++++++++++
 7 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/app/api/chat.py b/app/api/chat.py
index 5ca3277..f6153df 100644
--- a/app/api/chat.py
+++ b/app/api/chat.py
@@ -11,7 +11,8 @@
 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_IA_QUESTIONS_DS
+    DOCUMENT_TO_REPORT_TITLE, DOCUMENT_TO_TITLE, DOCUMENT_TO_PAPER, DOCUMENT_IA_QUESTIONS_DS, \
+    DOCUMENT_IA_QUESTIONS_EQUIPMENT
 from app.models import MenuCapacityModel
 from app.models.agent_model import AgentModel, AgentType
 from app.models.base_model import get_db
@@ -39,6 +40,7 @@
     print(f"Client {agent_id} connected")
     agent = db.query(MenuCapacityModel).filter(MenuCapacityModel.chat_id == agent_id).first()
     if not agent:
+        print("Agent not found")
         agent = db.query(AgentModel).filter(AgentModel.id == agent_id).first()
         agent_type = agent.agent_type
         chat_type = agent.type
@@ -808,10 +810,11 @@
                                         result = {"message": f"鍐呴儴閿欒锛� {e2}", "type": "close"}
                                         await websocket.send_json(result)
                                         print(f"Error process message of ragflow: {e2}")
-                elif chat_type == "documentIa" or chat_type == "documentIaDs":
+                elif chat_type == "documentIa" or chat_type == "documentIaDs" or chat_type == "documentIaEq":
                     token_dict = {
                         "documentIa": DOCUMENT_IA_QUESTIONS,
                         "documentIaDs": DOCUMENT_IA_QUESTIONS_DS,
+                        "documentIaEq": DOCUMENT_IA_QUESTIONS_EQUIPMENT,
                     }
                     token = DfTokenDao(db).get_token_by_id(token_dict[chat_type])
                     # print(token)
diff --git a/app/api/files.py b/app/api/files.py
index e00c43b..0592b4b 100644
--- a/app/api/files.py
+++ b/app/api/files.py
@@ -12,7 +12,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_IA_QUESTIONS_DS
+    DOCUMENT_TO_PAPER, DOCUMENT_IA_QUESTIONS_DS, DOCUMENT_IA_QUESTIONS_EQUIPMENT
 from app.models import MenuCapacityModel
 from app.models.agent_model import AgentType, AgentModel
 from app.models.base_model import get_db
@@ -118,12 +118,13 @@
                 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" or agent.chat_type == "documentIaDs":
+        elif agent.chat_type == "reportWorkflow" or agent.chat_type == "documentIa" or agent.chat_type == "paperTalk" or agent.chat_type == "documentIaDs" or agent.chat_type == "documentIaEq":
             token_dict = {
                 "reportWorkflow": DOCUMENT_TO_REPORT_TITLE,
                 "documentIa": DOCUMENT_IA_QUESTIONS,
                 "paperTalk": DOCUMENT_TO_PAPER,
                 "documentIaDs": DOCUMENT_IA_QUESTIONS_DS,
+                "documentIaEq": DOCUMENT_IA_QUESTIONS_EQUIPMENT,
             }
             token = DfTokenDao(db).get_token_by_id(token_dict[agent.chat_type])
             if not token:
diff --git a/app/api/v2/public_api.py b/app/api/v2/public_api.py
index e320aeb..990a55a 100644
--- a/app/api/v2/public_api.py
+++ b/app/api/v2/public_api.py
@@ -6,7 +6,8 @@
 from app.api import Response
 from app.api.auth import login
 from app.config.const import IMAGE_TO_TEXT, DOCUMENT_TO_CLEANING, DOCUMENT_TO_REPORT, DIFY, BISHENG, RAGFLOW, \
-    DOCUMENT_IA_QUESTIONS, DOCUMENT_TO_REPORT_TITLE, DOCUMENT_TO_TITLE, DOCUMENT_TO_PAPER
+    DOCUMENT_IA_QUESTIONS, DOCUMENT_TO_REPORT_TITLE, DOCUMENT_TO_TITLE, DOCUMENT_TO_PAPER, \
+    DOCUMENT_IA_QUESTIONS_EQUIPMENT
 from app.models.base_model import get_db
 from app.models.public_api_model import DfToken, AppRegister
 from app.service.v2.api_token import DfTokenDao
@@ -19,7 +20,7 @@
 
 @public_api.post("/sync/df_token", response_model=Response)
 async def sync_df_token(df: DfToken, db=Depends(get_db)):
-    token_dict = {IMAGE_TO_TEXT: df.image, DOCUMENT_TO_CLEANING: df.clean,
+    token_dict = {IMAGE_TO_TEXT: df.image, DOCUMENT_TO_CLEANING: df.clean,DOCUMENT_IA_QUESTIONS_EQUIPMENT: df.equipment,
                   DOCUMENT_IA_QUESTIONS: df.doc, DOCUMENT_TO_REPORT_TITLE: df.report,DOCUMENT_TO_TITLE: df.title,DOCUMENT_TO_PAPER: df.paper}
 
     try:
diff --git a/app/config/const.py b/app/config/const.py
index 2237794..5093f40 100644
--- a/app/config/const.py
+++ b/app/config/const.py
@@ -5,6 +5,7 @@
 IMAGE_TO_TEXT = "image_and_text_conversion"
 DOCUMENT_IA_QUESTIONS = "document_ia_questions"
 DOCUMENT_IA_QUESTIONS_DS = "document_ia_questions_ds"
+DOCUMENT_IA_QUESTIONS_EQUIPMENT = "document_ia_questions_equipment"
 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 9fecd0f..bdca3f7 100644
--- a/app/config/env_conf/menu_conf.json
+++ b/app/config/env_conf/menu_conf.json
@@ -181,6 +181,23 @@
           "agentType": 4
         }
       ]
+    },
+    {
+      "id": 11,
+      "title": "璁惧鍒嗘瀽",
+      "icon": "7",
+      "img": "/src/assets/index/7.png",
+      "desc": "璁惧鍒嗘瀽鍔╂墜锛屽熀浜庢偍涓婁紶鐨勮澶囨暟鎹繘琛岄棶绛旓紝鏀寔澶氳澶�",
+      "describe": "璁惧鍒嗘瀽鍔╂墜锛屽熀浜庢偍涓婁紶鐨勬枃妗h繘琛岄棶绛旓紝鏀寔澶氭枃妗o紝澶у皬鍦�30M浠ュ唴銆�",
+      "rank": 89,
+      "dialog": [
+        {
+          "id": "a6c01e15-378e-4f56-bd8c-cde5155d37f1",
+          "chat_id": "a6c01e15-378e-4f56-bd8c-cde5155d37f1",
+          "chat_type": "documentIaEq",
+          "agentType": 4
+        }
+      ]
     }
   ]
 }
\ No newline at end of file
diff --git a/app/models/public_api_model.py b/app/models/public_api_model.py
index 8edffde..bfb05b3 100644
--- a/app/models/public_api_model.py
+++ b/app/models/public_api_model.py
@@ -53,6 +53,10 @@
     image: Optional[str] = ""
     clean: Optional[str] = ""
     report: Optional[str] = ""
+    doc: Optional[str] = ""
+    title: Optional[str] = ""
+    paper: Optional[str] = ""
+    equipment: Optional[str] = ""
 
 
 class AppRegister(BaseModel):
diff --git a/app/service/session.py b/app/service/session.py
index dca20a1..33fff72 100644
--- a/app/service/session.py
+++ b/app/service/session.py
@@ -28,6 +28,7 @@
         """
         existing_session = self.get_session_by_id(session_id)
         if existing_session:
+            print("update success")
             # existing_session.add_message({"role": "user", "content": name})
             existing_session.add_message(message)
             existing_session.update_date = current_time()

--
Gitblit v1.8.0