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