| | |
| | | print(f"Received from client {chat_id}: {message}") |
| | | chat_history = message.get('chatHistory', []) |
| | | if len(chat_history) == 0: |
| | | |
| | | chat_history = await ragflow_service.set_session(token, agent_id, message["message"], chat_id, True) |
| | | chat_history = await ragflow_service.get_session_history(token, agent_id) |
| | | if len(chat_history) == 0: |
| | | chat_history = await ragflow_service.set_session(token, agent_id, |
| | | message["message"], chat_id, True) |
| | | if len(chat_history) == 0: |
| | | result = {"message": "内部错误:创建会话失败", "type": "close"} |
| | | await websocket.send_json(result) |
| | | return |
| | | async for rag_response in ragflow_service.chat(token, chat_id, chat_history): |
| | | try: |
| | | print(f"Received from ragflow: {rag_response}") |