| | |
| | | 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个字符,并去除首尾空白符 |
| | |
| | | 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", "") |