Spaces:
Sleeping
Sleeping
fix Gradio error
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import pytz
|
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
|
| 8 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|