NagarajanB1990 commited on
Commit
5c17fd1
·
verified ·
1 Parent(s): 53e5ed5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -12
app.py CHANGED
@@ -1,27 +1,22 @@
1
- # app.py
2
-
3
  import gradio as gr
4
- from smolagents import CodeAgent, HfApiModel
5
- from smolagents.tools import PythonCodeInterpreter
6
 
7
- # Build agent
8
  agent = CodeAgent(
9
- tools=[PythonCodeInterpreter()],
10
- model=HfApiModel(model="HuggingFaceH4/zephyr-7b-alpha") # works on free CPU Space
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 or code question"),
22
  outputs=gr.Textbox(label="Bot Answer"),
23
- title="Python Helper Bot",
24
- description="Ask math or Python questions — runs offline on CPU Space."
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__":