Spaces:
Sleeping
Sleeping
Upload tool
Browse files- agent.json +7 -7
- app.py +34 -14
- requirements.txt +3 -3
- tools/visit_webpage.py +2 -2
agent.json
CHANGED
|
@@ -35,17 +35,17 @@
|
|
| 35 |
"name": null,
|
| 36 |
"description": null,
|
| 37 |
"authorized_imports": [
|
| 38 |
-
"time",
|
| 39 |
-
"datetime",
|
| 40 |
-
"pandas",
|
| 41 |
"collections",
|
| 42 |
-
"
|
|
|
|
| 43 |
"stat",
|
| 44 |
"random",
|
| 45 |
"math",
|
| 46 |
-
"
|
| 47 |
-
"
|
| 48 |
"queue",
|
| 49 |
-
"re"
|
|
|
|
|
|
|
| 50 |
]
|
| 51 |
}
|
|
|
|
| 35 |
"name": null,
|
| 36 |
"description": null,
|
| 37 |
"authorized_imports": [
|
|
|
|
|
|
|
|
|
|
| 38 |
"collections",
|
| 39 |
+
"itertools",
|
| 40 |
+
"statistics",
|
| 41 |
"stat",
|
| 42 |
"random",
|
| 43 |
"math",
|
| 44 |
+
"pandas",
|
| 45 |
+
"datetime",
|
| 46 |
"queue",
|
| 47 |
+
"re",
|
| 48 |
+
"unicodedata",
|
| 49 |
+
"time"
|
| 50 |
]
|
| 51 |
}
|
app.py
CHANGED
|
@@ -1,23 +1,43 @@
|
|
| 1 |
|
| 2 |
-
from smolagents import GradioUI,
|
| 3 |
|
| 4 |
-
{% for tool in tools.values() %}
|
| 5 |
-
from scripts.{{ tool.name }} import {{ tool.__class__.__name__ }}
|
| 6 |
-
{% endfor %}
|
| 7 |
|
| 8 |
-
|
| 9 |
|
| 10 |
-
|
| 11 |
-
{{ tool.name }} = {{ tool.__class__.__name__ }}()
|
| 12 |
-
{% endfor %}
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
model=model,
|
| 16 |
-
tools=[
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
prompts_path='./prompts.yaml'
|
| 21 |
)
|
| 22 |
|
| 23 |
-
GradioUI(agent).launch()
|
|
|
|
| 1 |
|
| 2 |
+
from smolagents import GradioUI, CodeAgent, HfApiModel
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
from scripts.web_search import DuckDuckGoSearchTool
|
| 6 |
|
| 7 |
+
from scripts.visit_webpage import VisitWebpageTool
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
from scripts.final_answer import FinalAnswerTool
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
model = HfApiModel()
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
web_search = DuckDuckGoSearchTool()
|
| 16 |
+
|
| 17 |
+
visit_webpage = VisitWebpageTool()
|
| 18 |
+
|
| 19 |
+
final_answer = FinalAnswerTool()
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
agent = CodeAgent(
|
| 23 |
model=model,
|
| 24 |
+
tools=[web_search, visit_webpage, final_answer],
|
| 25 |
+
|
| 26 |
+
max_steps=6,
|
| 27 |
+
|
| 28 |
+
verbosity_level=1,
|
| 29 |
+
|
| 30 |
+
grammar=None,
|
| 31 |
+
|
| 32 |
+
planning_interval=None,
|
| 33 |
+
|
| 34 |
+
name=None,
|
| 35 |
+
|
| 36 |
+
description=None,
|
| 37 |
+
|
| 38 |
+
authorized_imports=['collections', 'itertools', 'statistics', 'stat', 'random', 'math', 'pandas', 'datetime', 'queue', 're', 'unicodedata', 'time'],
|
| 39 |
+
|
| 40 |
prompts_path='./prompts.yaml'
|
| 41 |
)
|
| 42 |
|
| 43 |
+
GradioUI(agent).launch()
|
requirements.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
smolagents
|
| 2 |
-
duckduckgo_search
|
| 3 |
markdownify
|
| 4 |
-
pandas
|
| 5 |
requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
markdownify
|
|
|
|
| 2 |
requests
|
| 3 |
+
pandas
|
| 4 |
+
duckduckgo_search
|
| 5 |
+
smolagents
|
tools/visit_webpage.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
from typing import Any, Optional
|
| 2 |
from smolagents.tools import Tool
|
| 3 |
-
import smolagents
|
| 4 |
-
import requests
|
| 5 |
import markdownify
|
|
|
|
|
|
|
| 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"
|