Shafagh99 commited on
Commit
e636c57
·
verified ·
1 Parent(s): 56f54a6

fix Gradio error

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -5,7 +5,7 @@ import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
 
8
- from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
@@ -136,4 +136,14 @@ agent = CodeAgent(
136
  )
137
 
138
 
139
- GradioUI(agent).launch()
 
 
 
 
 
 
 
 
 
 
 
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
 
8
+ import gradio as gr
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
 
136
  )
137
 
138
 
139
+ def chat_fn(message, history):
140
+ """Simple chat wrapper around the CodeAgent for Gradio."""
141
+ # agent.run returns the final answer (already using final_answer tool)
142
+ result = agent.run(task=message)
143
+ history = history + [(message, str(result))]
144
+ return history
145
+
146
+
147
+ demo = gr.ChatInterface(fn=chat_fn, title="SmolAgents News & Tools Agent")
148
+
149
+ demo.launch()