uuidenny commited on
Commit
b57a027
·
verified ·
1 Parent(s): 2516e57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -348,22 +348,24 @@ def process_question(question: str, history: list) -> tuple:
348
 
349
  if not question.strip():
350
  error_msg = "⚠️ Please enter a question."
351
- history.append([question, error_msg])
 
352
  return history, ""
353
 
354
  try:
355
  # Add user question to history with thinking indicator
356
- history.append([question, "🤔 Thinking..."])
 
357
 
358
  # Process the question in a separate thread
359
  response = run_async_in_thread(_process_question_async(question))
360
 
361
  # Update history with the response
362
- history[-1][1] = f"🤖 {response}"
363
 
364
  except Exception as e:
365
  error_msg = f"❌ Error processing question: {str(e)}"
366
- history[-1][1] = error_msg
367
  logger.error(f"Error processing question: {str(e)}")
368
 
369
  return history, ""
@@ -454,7 +456,8 @@ def create_gradio_interface():
454
  label="Chat with MCP Agent",
455
  height=500,
456
  show_label=True,
457
- container=True
 
458
  )
459
 
460
  with gr.Row():
 
348
 
349
  if not question.strip():
350
  error_msg = "⚠️ Please enter a question."
351
+ history.append({"role": "user", "content": question})
352
+ history.append({"role": "assistant", "content": error_msg})
353
  return history, ""
354
 
355
  try:
356
  # Add user question to history with thinking indicator
357
+ history.append({"role": "user", "content": question})
358
+ history.append({"role": "assistant", "content": "🤔 Thinking..."})
359
 
360
  # Process the question in a separate thread
361
  response = run_async_in_thread(_process_question_async(question))
362
 
363
  # Update history with the response
364
+ history[-1]["content"] = f"🤖 {response}"
365
 
366
  except Exception as e:
367
  error_msg = f"❌ Error processing question: {str(e)}"
368
+ history[-1]["content"] = error_msg
369
  logger.error(f"Error processing question: {str(e)}")
370
 
371
  return history, ""
 
456
  label="Chat with MCP Agent",
457
  height=500,
458
  show_label=True,
459
+ container=True,
460
+ type='messages'
461
  )
462
 
463
  with gr.Row():