Jeremy Live commited on
Commit
28f7cda
·
1 Parent(s): 95c55e1
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -581,11 +581,9 @@ async def stream_agent_response(question: str, chat_history: List) -> List[Dict]
581
  else:
582
  message_content = str(assistant_message)
583
 
584
- # Ensure we return a list of tuples in the format Gradio expects
585
- # Each message should be a tuple of (user_msg, bot_msg)
586
- # For the current response, we need to include both the user's question and the assistant's response
587
- chat_history.append((question, message_content))
588
- return chat_history
589
 
590
  except Exception as e:
591
  error_msg = f"## ❌ Error\n\nOcurrió un error al procesar tu solicitud:\n\n```\n{str(e)}\n```"
@@ -833,14 +831,10 @@ def create_application():
833
  logger.info(f"Processing question: {question}")
834
 
835
  # Call the agent and get the response
836
- response = await stream_agent_response(question, chat_history[:-2])
837
 
838
- # Convert the response to the correct format for the chat history
839
- if isinstance(response, list) and response:
840
- # The response is already in the format [(None, assistant_message)]
841
- # Extract the assistant message and update the chat history
842
- assistant_message = response[0][1] if isinstance(response[0], (list, tuple)) and len(response[0]) > 1 else str(response[0])
843
- chat_history[-1]["content"] = assistant_message
844
 
845
  logger.info("Response generation complete")
846
  return chat_history
 
581
  else:
582
  message_content = str(assistant_message)
583
 
584
+ # Return the assistant's response in the format expected by the bot_response function
585
+ # The bot_response function will handle updating the chat history
586
+ return message_content
 
 
587
 
588
  except Exception as e:
589
  error_msg = f"## ❌ Error\n\nOcurrió un error al procesar tu solicitud:\n\n```\n{str(e)}\n```"
 
831
  logger.info(f"Processing question: {question}")
832
 
833
  # Call the agent and get the response
834
+ assistant_message = await stream_agent_response(question, chat_history[:-2])
835
 
836
+ # Update the assistant's message in the chat history
837
+ chat_history[-1]["content"] = assistant_message
 
 
 
 
838
 
839
  logger.info("Response generation complete")
840
  return chat_history