m-ric HF staff commited on
Commit
cc003cf
·
verified ·
1 Parent(s): e0cc0af

Upload tool

Browse files
Files changed (4) hide show
  1. agent.json +6 -6
  2. app.py +16 -17
  3. requirements.txt +3 -3
  4. tools/visit_webpage.py +1 -1
agent.json CHANGED
@@ -35,17 +35,17 @@
35
  "name": null,
36
  "description": null,
37
  "authorized_imports": [
 
38
  "datetime",
39
  "queue",
40
- "stat",
41
  "itertools",
 
 
42
  "pandas",
 
43
  "random",
44
- "collections",
45
- "math",
46
  "statistics",
47
- "unicodedata",
48
- "re",
49
- "time"
50
  ]
51
  }
 
35
  "name": null,
36
  "description": null,
37
  "authorized_imports": [
38
+ "unicodedata",
39
  "datetime",
40
  "queue",
 
41
  "itertools",
42
+ "stat",
43
+ "time",
44
  "pandas",
45
+ "re",
46
  "random",
 
 
47
  "statistics",
48
+ "collections",
49
+ "math"
 
50
  ]
51
  }
app.py CHANGED
@@ -1,23 +1,22 @@
1
- from smolagents import GradioUI, CodeAgent, HfApiModel
2
- from scripts.web_search import DuckDuckGoSearchTool
3
- from scripts.visit_webpage import VisitWebpageTool
4
- from scripts.final_answer import FinalAnswerTool
5
 
6
- model = HfApiModel()
7
- web_search = DuckDuckGoSearchTool()
8
- visit_webpage = VisitWebpageTool()
9
- final_answer = FinalAnswerTool()
10
 
11
- agent = CodeAgent(
 
 
 
 
 
 
 
 
 
 
12
  model=model,
13
- tools= [web_search, visit_webpage, final_answer],
14
- max_steps=6,
15
- verbosity_level=1,
16
- grammar=None,
17
- planning_interval=None,
18
- name=None,
19
- description=None,
20
- authorized_imports=['datetime', 'queue', 'stat', 'itertools', 'pandas', 'random', 'collections', 'math', 'statistics', 'unicodedata', 're', 'time'],
21
  prompts_path='./prompts.yaml'
22
  )
23
 
 
 
 
 
 
1
 
2
+ from smolagents import GradioUI, {{ class_name }}, {{ agent_dict['model']['class'] }}
 
 
 
3
 
4
+ {% for tool in tools.values() %}
5
+ from scripts.{{ tool.name }} import {{ tool.__class__.__name__ }}
6
+ {% endfor %}
7
+
8
+ model = {{ agent_dict['model']['class'] }}()
9
+
10
+ {% for tool in tools.values() %}
11
+ {{ tool.name }} = {{ tool.__class__.__name__ }}()
12
+ {% endfor %}
13
+
14
+ agent = {{ class_name }}(
15
  model=model,
16
+ tools=[{% for tool in tools.keys() %}{{ tool }}{% if not loop.last %}, {% endif %}{% endfor %}],
17
+ {% for attribute_name, value in agent_dict.items() if attribute_name not in ["model", "tools", "prompt_templates"] %}
18
+ {{ attribute_name }}={{ value }},
19
+ {% endfor %}
 
 
 
 
20
  prompts_path='./prompts.yaml'
21
  )
22
 
requirements.txt CHANGED
@@ -1,5 +1,5 @@
1
- smolagents
2
  requests
3
- duckduckgo_search
4
- pandas
5
  markdownify
 
 
 
 
 
1
  requests
 
 
2
  markdownify
3
+ pandas
4
+ smolagents
5
+ duckduckgo_search
tools/visit_webpage.py CHANGED
@@ -1,8 +1,8 @@
1
  from typing import Any, Optional
2
  from smolagents.tools import Tool
3
  import markdownify
4
- import smolagents
5
  import requests
 
6
 
7
  class VisitWebpageTool(Tool):
8
  name = "visit_webpage"
 
1
  from typing import Any, Optional
2
  from smolagents.tools import Tool
3
  import markdownify
 
4
  import requests
5
+ import smolagents
6
 
7
  class VisitWebpageTool(Tool):
8
  name = "visit_webpage"