Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,22 @@
|
|
1 |
-
# app.py
|
2 |
-
|
3 |
import gradio as gr
|
4 |
-
from smolagents import CodeAgent
|
5 |
-
from smolagents.tools import
|
6 |
|
7 |
-
# Build agent
|
8 |
agent = CodeAgent(
|
9 |
-
tools=[
|
10 |
-
model=
|
11 |
)
|
12 |
|
13 |
-
# Function
|
14 |
def ask_bot(question):
|
15 |
result = agent.run(question)
|
16 |
return result.strip()
|
17 |
|
18 |
-
# Gradio UI
|
19 |
iface = gr.Interface(
|
20 |
fn=ask_bot,
|
21 |
-
inputs=gr.Textbox(label="Ask a math
|
22 |
outputs=gr.Textbox(label="Bot Answer"),
|
23 |
-
title="
|
24 |
-
description="Ask math
|
25 |
)
|
26 |
|
27 |
if __name__ == "__main__":
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from smolagents import CodeAgent
|
3 |
+
from smolagents.tools import CalculatorTool
|
4 |
|
|
|
5 |
agent = CodeAgent(
|
6 |
+
tools=[CalculatorTool()],
|
7 |
+
model="huggingface-projects/zephyr-7b-alpha" # or HuggingFaceH4/zephyr-7b-alpha
|
8 |
)
|
9 |
|
|
|
10 |
def ask_bot(question):
|
11 |
result = agent.run(question)
|
12 |
return result.strip()
|
13 |
|
|
|
14 |
iface = gr.Interface(
|
15 |
fn=ask_bot,
|
16 |
+
inputs=gr.Textbox(label="Ask a math question"),
|
17 |
outputs=gr.Textbox(label="Bot Answer"),
|
18 |
+
title="Math Bot",
|
19 |
+
description="Ask math questions — works offline on CPU Space."
|
20 |
)
|
21 |
|
22 |
if __name__ == "__main__":
|