zhaoqingang 1 год назад
Родитель
Сommit
0fdc313d69
3 измененных файлов с 9 добавлено и 12 удалено
  1. 1 1
      app/api/chat.py
  2. 6 10
      app/service/difyService.py
  3. 2 1
      app/task/fetch_agent.py

+ 1 - 1
app/api/chat.py

@@ -326,7 +326,7 @@ async def handle_client(websocket: WebSocket,
                             try:
                                 data = json.loads(complete_response)
                                 # data = json_data.get("data")
-                                if "answer" not in  data:  # 信息过滤
+                                if "answer" not in  data or isinstance(data["answer"], dict):  # 信息过滤
                                     continue
                                 else:  # 正常输出
                                     answer = data.get("answer", "")

+ 6 - 10
app/service/difyService.py

@@ -5,9 +5,6 @@ import httpx
 from typing import Union, Dict, List
 from fastapi import HTTPException
 from starlette import status
-from watchdog.observers.fsevents2 import message
-
-# from Log import logger
 from app.config.config import settings
 from app.utils.rsa_crypto import RagflowCrypto
 
@@ -68,17 +65,16 @@ class DifyService:
     async def chat(self, token: str, chat_id: str,  message: str, upload_file_id: str, conversation_id: str):
 
         target_url = f"{self.base_url}/v1/chat-messages"
-        files = [
+        files = []
+        if upload_file_id:
+            files = [
                 {
                     "type": "image",
-                    "transfer_method": "remote_url",
-                    "url": "https://cloud.dify.ai/logo/logo-site.png",
-                    "upload_file_id":""
+                    "transfer_method": "local_file",
+                    "url": "",
+                    "upload_file_id": upload_file_id
                 }
             ]
-        if upload_file_id:
-            files[0]["transfer_method"] = "local_file"
-            files[0]["upload_file_id"] = upload_file_id
         data = {
             "inputs": {},
             "query": message,

+ 2 - 1
app/task/fetch_agent.py

@@ -116,7 +116,8 @@ def initialize_agents():
             ('da3451da89d911efb9490242ac190006', 3, '知识问答', 'RAGFLOW', 'knowledgeQA'),
             ('e96eb7a589db11ef87d20242ac190006', 5, '智能问答', 'RAGFLOW', 'chat'),
             ('basic_excel_talk', 6, '智能数据', 'BASIC', 'excelTalk'),
-            ('basic_question_talk', 7, '文档出卷', 'BASIC', 'questionTalk')
+            ('basic_question_talk', 7, '文档出卷', 'BASIC', 'questionTalk'),
+            ('9d75142a-66eb-4e23-b7d4-03efe4584915', 8, '小数绘图', 'DIFY', 'imageTalk')
         ]
 
         for agent in initial_agents: