From 0fdc313d69ace003366ab519714158343d178acc Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期一, 25 十一月 2024 10:45:12 +0800
Subject: [PATCH] dify
---
app/api/chat.py | 2 +-
app/task/fetch_agent.py | 3 ++-
app/service/difyService.py | 16 ++++++----------
3 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/app/api/chat.py b/app/api/chat.py
index 4359eab..2932d45 100644
--- a/app/api/chat.py
+++ b/app/api/chat.py
@@ -326,7 +326,7 @@
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: # 姝e父杈撳嚭
answer = data.get("answer", "")
diff --git a/app/service/difyService.py b/app/service/difyService.py
index 6b6a59a..3e588cf 100644
--- a/app/service/difyService.py
+++ b/app/service/difyService.py
@@ -5,9 +5,6 @@
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 @@
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,
diff --git a/app/task/fetch_agent.py b/app/task/fetch_agent.py
index a39461a..80ac763 100644
--- a/app/task/fetch_agent.py
+++ b/app/task/fetch_agent.py
@@ -116,7 +116,8 @@
('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:
--
Gitblit v1.8.0