NagarajanB1990 commited on
Commit
4fb0dcc
·
verified ·
1 Parent(s): 0f92ec2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -17
app.py CHANGED
@@ -1,29 +1,26 @@
1
- import os
2
  import gradio as gr
3
- from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
 
 
4
 
5
- # Optional: if you add HF_TOKEN in secrets, it can use it
6
- os.environ["HF_TOKEN"] = os.getenv("HF_TOKEN")
7
-
8
- # Build the agent
9
  agent = CodeAgent(
10
- tools=[DuckDuckGoSearchTool()],
11
- model=HfApiModel(model="HuggingFaceH4/zephyr-7b-beta")
12
  )
13
 
14
- # Simple app function
15
- def who_is_bot(person_name):
16
- prompt = f"Who is {person_name}? Give a short 1-2 sentence summary."
17
- result = agent.run(prompt)
18
  return result.strip()
19
 
20
  # Gradio UI
21
  iface = gr.Interface(
22
- fn=who_is_bot,
23
- inputs=gr.Textbox(label="Person Name"),
24
- outputs=gr.Textbox(label="Summary"),
25
- title="Who Is Bot",
26
- description="Enter a nameget a 1-2 sentence summary."
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__":