From 56d8dce48022692c5a7541114ef84f4fa395ff9d Mon Sep 17 00:00:00 2001 From: zhaoqingang <zhaoqg0118@163.com> Date: 星期二, 26 十一月 2024 11:22:49 +0800 Subject: [PATCH] dify images 问题 --- app/api/chat.py | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/api/chat.py b/app/api/chat.py index 9f2ea44..97c3006 100644 --- a/app/api/chat.py +++ b/app/api/chat.py @@ -348,14 +348,20 @@ result = {"message": answer_str, "type": "message"} elif data.get("event") == "message_end": - result = {"message": answer_str, "type": "close"} + message_files = [] + res_msg = await dify_service.get_session_history(token, data.get("conversation_id"), str(current_user.id)) + if len(res_msg) > 0: + message_files = res_msg[0].get("message_files") + + result = {"message": answer_str, "type": "close", "message_files": message_files} try: SessionService(db).update_session(chat_id, - message={"role": "assistant", "content": data, "conversation_id": data.get("conversation_id")}) + message={"role": "assistant", "content": answer_str},conversation_id=data.get("conversation_id")) except Exception as e: logger.error("淇濆瓨dify鐨勪細璇濆紓甯革紒") logger.error(e) elif data.get("event") == "message_file": + url = data.get("url", "") result = {"message": url, "type": "image"} else: -- Gitblit v1.8.0