Jeremy Live
commited on
Commit
·
8c64153
1
Parent(s):
a22ae4e
fix issue in the chat interface.
Browse files
app.py
CHANGED
@@ -570,12 +570,20 @@ async def stream_agent_response(question: str, chat_history: List) -> List[Dict]
|
|
570 |
assistant_message["content"] = f"## ❌ Error\n\n{error_msg}"
|
571 |
|
572 |
# Return the message in the correct format for Gradio Chatbot
|
573 |
-
# Format: [(user_message, assistant_message)]
|
574 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
575 |
|
576 |
except Exception as e:
|
577 |
error_msg = f"## ❌ Error\n\nOcurrió un error al procesar tu solicitud:\n\n```\n{str(e)}\n```"
|
578 |
logger.error(f"Error in stream_agent_response: {str(e)}", exc_info=True)
|
|
|
579 |
return [(None, error_msg)]
|
580 |
|
581 |
# Custom CSS for the app
|
|
|
570 |
assistant_message["content"] = f"## ❌ Error\n\n{error_msg}"
|
571 |
|
572 |
# Return the message in the correct format for Gradio Chatbot
|
573 |
+
# Format: [(user_message, assistant_message), ...]
|
574 |
+
# Ensure we're returning a list of tuples where each tuple is (user_msg, bot_msg)
|
575 |
+
if isinstance(assistant_message, dict) and "content" in assistant_message:
|
576 |
+
return [(None, assistant_message["content"])]
|
577 |
+
elif isinstance(assistant_message, str):
|
578 |
+
return [(None, assistant_message)]
|
579 |
+
else:
|
580 |
+
# Fallback: convert to string representation
|
581 |
+
return [(None, str(assistant_message))]
|
582 |
|
583 |
except Exception as e:
|
584 |
error_msg = f"## ❌ Error\n\nOcurrió un error al procesar tu solicitud:\n\n```\n{str(e)}\n```"
|
585 |
logger.error(f"Error in stream_agent_response: {str(e)}", exc_info=True)
|
586 |
+
# Ensure we return in the correct format: [(user_msg, bot_msg)]
|
587 |
return [(None, error_msg)]
|
588 |
|
589 |
# Custom CSS for the app
|