Added new tools to the smolagent
Browse files
agent.py
CHANGED
|
@@ -10,13 +10,52 @@ from models import select_model
|
|
| 10 |
|
| 11 |
from typing import Optional
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
save_and_read_file,
|
| 15 |
-
analyze_excel_file,
|
| 16 |
-
analyze_csv_file,
|
| 17 |
download_file_from_url,
|
| 18 |
extract_text_from_image,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
class BasicAgent:
|
|
@@ -27,15 +66,46 @@ class BasicAgent:
|
|
| 27 |
name_model=None,
|
| 28 |
):
|
| 29 |
self.verbose = verbose
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
tools = [
|
| 31 |
GoogleSearchTool(provider="serper"),
|
| 32 |
PythonInterpreterTool(),
|
| 33 |
-
VisitWebpageTool(),
|
| 34 |
save_and_read_file,
|
| 35 |
analyze_excel_file,
|
| 36 |
analyze_csv_file,
|
| 37 |
download_file_from_url,
|
| 38 |
extract_text_from_image,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
]
|
| 40 |
self.agent = CodeAgent(
|
| 41 |
tools=tools,
|
|
|
|
| 10 |
|
| 11 |
from typing import Optional
|
| 12 |
|
| 13 |
+
|
| 14 |
+
from tools_smolagent_audio import transcribe_audio
|
| 15 |
+
from tools_smolagent_browser import (
|
| 16 |
+
wiki_search,
|
| 17 |
+
web_search,
|
| 18 |
+
arxiv_search,
|
| 19 |
+
website_scrape,
|
| 20 |
+
)
|
| 21 |
+
from tools_smolagent_doc import (
|
| 22 |
save_and_read_file,
|
|
|
|
|
|
|
| 23 |
download_file_from_url,
|
| 24 |
extract_text_from_image,
|
| 25 |
+
analyze_csv_file,
|
| 26 |
+
analyze_excel_file,
|
| 27 |
+
read_file,
|
| 28 |
+
)
|
| 29 |
+
from tools_smolagent_img import (
|
| 30 |
+
analyze_image,
|
| 31 |
+
transform_image,
|
| 32 |
+
draw_on_image,
|
| 33 |
+
generate_simple_image,
|
| 34 |
+
combine_images,
|
| 35 |
+
)
|
| 36 |
+
from tools_smolagent_maths import (
|
| 37 |
+
multiply,
|
| 38 |
+
add,
|
| 39 |
+
subtract,
|
| 40 |
+
divide,
|
| 41 |
+
modulus,
|
| 42 |
+
power,
|
| 43 |
+
# square_root,
|
| 44 |
)
|
| 45 |
+
from tools_smolagent_video import (
|
| 46 |
+
review_youtube_video,
|
| 47 |
+
use_vision_model,
|
| 48 |
+
video_frames_to_images,
|
| 49 |
+
transcribe_youtube,
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
# from tools import (
|
| 53 |
+
# save_and_read_file,
|
| 54 |
+
# analyze_excel_file,
|
| 55 |
+
# analyze_csv_file,
|
| 56 |
+
# download_file_from_url,
|
| 57 |
+
# extract_text_from_image,
|
| 58 |
+
# )
|
| 59 |
|
| 60 |
|
| 61 |
class BasicAgent:
|
|
|
|
| 66 |
name_model=None,
|
| 67 |
):
|
| 68 |
self.verbose = verbose
|
| 69 |
+
# tools = [
|
| 70 |
+
# GoogleSearchTool(provider="serper"),
|
| 71 |
+
# PythonInterpreterTool(),
|
| 72 |
+
# VisitWebpageTool(),
|
| 73 |
+
# save_and_read_file,
|
| 74 |
+
# analyze_excel_file,
|
| 75 |
+
# analyze_csv_file,
|
| 76 |
+
# download_file_from_url,
|
| 77 |
+
# extract_text_from_image,
|
| 78 |
+
# ]
|
| 79 |
tools = [
|
| 80 |
GoogleSearchTool(provider="serper"),
|
| 81 |
PythonInterpreterTool(),
|
|
|
|
| 82 |
save_and_read_file,
|
| 83 |
analyze_excel_file,
|
| 84 |
analyze_csv_file,
|
| 85 |
download_file_from_url,
|
| 86 |
extract_text_from_image,
|
| 87 |
+
read_file,
|
| 88 |
+
transcribe_audio,
|
| 89 |
+
wiki_search,
|
| 90 |
+
# web_search,
|
| 91 |
+
arxiv_search,
|
| 92 |
+
website_scrape,
|
| 93 |
+
analyze_image,
|
| 94 |
+
transform_image,
|
| 95 |
+
draw_on_image,
|
| 96 |
+
generate_simple_image,
|
| 97 |
+
combine_images,
|
| 98 |
+
multiply,
|
| 99 |
+
add,
|
| 100 |
+
subtract,
|
| 101 |
+
divide,
|
| 102 |
+
modulus,
|
| 103 |
+
power,
|
| 104 |
+
# square_root,
|
| 105 |
+
review_youtube_video,
|
| 106 |
+
use_vision_model,
|
| 107 |
+
video_frames_to_images,
|
| 108 |
+
transcribe_youtube,
|
| 109 |
]
|
| 110 |
self.agent = CodeAgent(
|
| 111 |
tools=tools,
|