Skip to content

Commit a64f264

Browse files
committed
fix: update Gradio chat function to properly format messages - Fix chatbot message format to use list of pairs - Update return type annotation - Maintain chat history correctly
1 parent 75b195e commit a64f264

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

agentic_rag/gradio_app.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,26 @@ def process_url(url: str) -> str:
6060
except Exception as e:
6161
return f"✗ Error processing URL: {str(e)}"
6262

63-
def chat(message: str, history: List[List[str]], agent_type: str, use_cot: bool) -> str:
63+
def chat(message: str, history: List[List[str]], agent_type: str, use_cot: bool) -> List[List[str]]:
6464
"""Process chat message using selected agent"""
6565
try:
6666
# Select appropriate agent
6767
agent = local_agent if agent_type == "Local (Mistral)" else openai_agent
6868
if not agent:
69-
return "Agent not available. Please check your configuration."
69+
return history + [[message, "Agent not available. Please check your configuration."]]
7070

7171
# Set CoT option
7272
agent.use_cot = use_cot
7373

7474
# Process query
7575
response = agent.process_query(message)
76-
return response["answer"]
76+
77+
# Return updated history with new message pair
78+
history.append([message, response["answer"]])
79+
return history
7780
except Exception as e:
78-
return f"Error processing query: {str(e)}"
81+
history.append([message, f"Error processing query: {str(e)}"])
82+
return history
7983

8084
def create_interface():
8185
"""Create Gradio interface"""

0 commit comments

Comments
 (0)