Ubik80 commited on
Commit
7760191
·
verified ·
1 Parent(s): 018ff1c
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -1,10 +1,10 @@
1
- app.py
2
  import os
3
  import gradio as gr
4
  import requests
5
  import pandas as pd
6
  from pathlib import Path
7
  import tempfile
 
8
  from smolagents import CodeAgent, OpenAIServerModel
9
  from smolagents import DuckDuckGoSearchTool, WikipediaSearchTool
10
  from tools import AnswerTool, SpeechToTextTool, ExcelToTextTool
@@ -32,7 +32,7 @@ def download_file_if_any(base_api_url: str, task_id: str) -> str | None:
32
  filename = task_id
33
  if "filename=" in cdisp:
34
  import re
35
- m = re.search(r'filename="([^\"]+)"', cdisp)
36
  if m:
37
  filename = m.group(1)
38
 
@@ -43,22 +43,23 @@ def download_file_if_any(base_api_url: str, task_id: str) -> str | None:
43
  f.write(resp.content)
44
  return str(file_path)
45
 
 
46
  class BasicAgent:
47
  def __init__(self):
48
  model = OpenAIServerModel(model_id="gpt-4o")
 
49
  tools = [
 
 
50
  SpeechToTextTool(),
51
  ExcelToTextTool(),
52
- DuckDuckGoSearchTool(),
53
- WikipediaSearchTool(),
54
  AnswerTool(),
55
  ]
56
  self.agent = CodeAgent(
57
  model=model,
58
  tools=tools,
59
- add_base_tools=False,
60
- additional_authorized_imports=["pandas", "openpyxl"],
61
- max_steps=4,
62
  verbosity_level=0,
63
  planning_interval=1,
64
  )
@@ -135,6 +136,8 @@ def test_random_question(username):
135
  except Exception as e:
136
  return f"Error during test: {e}", ""
137
 
 
 
138
  with gr.Blocks() as demo:
139
  gr.Markdown("# Basic Agent Evaluation Runner")
140
  gr.Markdown(
 
 
1
  import os
2
  import gradio as gr
3
  import requests
4
  import pandas as pd
5
  from pathlib import Path
6
  import tempfile
7
+
8
  from smolagents import CodeAgent, OpenAIServerModel
9
  from smolagents import DuckDuckGoSearchTool, WikipediaSearchTool
10
  from tools import AnswerTool, SpeechToTextTool, ExcelToTextTool
 
32
  filename = task_id
33
  if "filename=" in cdisp:
34
  import re
35
+ m = re.search(r'filename="([^"]+)"', cdisp)
36
  if m:
37
  filename = m.group(1)
38
 
 
43
  f.write(resp.content)
44
  return str(file_path)
45
 
46
+
47
  class BasicAgent:
48
  def __init__(self):
49
  model = OpenAIServerModel(model_id="gpt-4o")
50
+ # Tool priority: Wiki → Web → Python REPL (via base tools) → Audio → Excel → Fallback
51
  tools = [
52
+ WikipediaSearchTool(),
53
+ DuckDuckGoSearchTool(),
54
  SpeechToTextTool(),
55
  ExcelToTextTool(),
 
 
56
  AnswerTool(),
57
  ]
58
  self.agent = CodeAgent(
59
  model=model,
60
  tools=tools,
61
+ add_base_tools=True, # enable python REPL, calculator, etc.
62
+ max_steps=6, # allow up to 6 planning/execution steps
 
63
  verbosity_level=0,
64
  planning_interval=1,
65
  )
 
136
  except Exception as e:
137
  return f"Error during test: {e}", ""
138
 
139
+
140
+ # --- Gradio UI ---
141
  with gr.Blocks() as demo:
142
  gr.Markdown("# Basic Agent Evaluation Runner")
143
  gr.Markdown(