| | |
| | | continue |
| | | |
| | | service = BasicService(base_url=settings.basic_base_url) |
| | | complete_response = "" |
| | | async for result in service.excel_talk(question, chat_id): |
| | | try: |
| | | if result[:5] == "data:": |
| | |
| | | else: |
| | | # 否则,保持原样 |
| | | text = result |
| | | complete_response += text |
| | | try: |
| | | json_data = json.loads(complete_response) |
| | | output = json_data.get("output", "") |
| | | result = {"message": output, "type": "message"} |
| | | await websocket.send_json(result | json_data) |
| | | complete_response = "" |
| | | data = json.loads(text) |
| | | output = data.get("output", "") |
| | | excel_name = data.get("excel_name", "") |
| | | image_name = data.get("excel_name", "") |
| | | excel_url = None |
| | | image_url = None |
| | | if excel_name: |
| | | excel_url = f"/api/files/download/?agent_id=basic_excel_talk&file_id={excel_name}&file_type=excel" |
| | | if image_name: |
| | | image_url = f"/api/files/download/?agent_id=basic_excel_talk&file_id={image_name}&file_type=image" |
| | | result = {"message": output, "type": "message", "excel_url": excel_url, "image_url": image_url} |
| | | await websocket.send_json(result | data) |
| | | except json.JSONDecodeError as e: |
| | | print(f"Error decoding JSON: {e}") |
| | | print(f"Response text: {text}") |