zhaoqingang
2024-11-25 1ab90de913405b45050e0f732a03004087134fda
app/api/chat.py
@@ -314,7 +314,7 @@
                    except Exception as e:
                        logger.error(e)
                    complete_response = ""
                    async for rag_response in dify_service.chat(token, chat_id, question, upload_file_id, conversation_id):
                    async for rag_response in dify_service.chat(token, current_user.id, question, upload_file_id, conversation_id):
                        try:
                            if rag_response[:5] == "data:":
                                # 如果是,则截取掉前5个字符,并去除首尾空白符
@@ -326,7 +326,7 @@
                            try:
                                data = json.loads(complete_response)
                                # data = json_data.get("data")
                                if "answer" not in  data or isinstance(data["answer"], dict):  # 信息过滤
                                if "answer" not in  data or not isinstance(data["answer"], dict):  # 信息过滤
                                    continue
                                else:  # 正常输出
                                    answer = data.get("answer", "")