eeenn commited on
Commit
cf2fec5
·
verified ·
1 Parent(s): 5a5e47f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -15,16 +15,18 @@ agent = CodeAgent(
15
  # 定义 Gradio 接口
16
  def chat_fn(message, history):
17
  result = agent.run(message)
18
- history.append({"role": "user", "content": message})
19
- history.append({"role": "assistant", "content": result})
20
- return history, history
 
21
 
22
  demo = gr.ChatInterface(
23
  fn=chat_fn,
24
- chatbot = gr.Chatbot(type="messages"),
25
  textbox=gr.Textbox(placeholder="Ask Alfred to help plan your party..."),
26
  title="Alfred Party Planner Agent",
27
  )
28
 
 
29
  if __name__ == "__main__":
30
  demo.launch()
 
15
  # 定义 Gradio 接口
16
  def chat_fn(message, history):
17
  result = agent.run(message)
18
+ if not isinstance(result, str):
19
+ result = str(result)
20
+ return result # ✅ 只返回助手的回复
21
+
22
 
23
  demo = gr.ChatInterface(
24
  fn=chat_fn,
25
+ chatbot=gr.Chatbot(type="messages"),
26
  textbox=gr.Textbox(placeholder="Ask Alfred to help plan your party..."),
27
  title="Alfred Party Planner Agent",
28
  )
29
 
30
+
31
  if __name__ == "__main__":
32
  demo.launch()