Spaces:
Sleeping
Sleeping
Fix agents
Browse files- mini_agents.py +17 -16
mini_agents.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
from smolagents import CodeAgent, InferenceClientModel
|
2 |
from tools import sort_list, operate_two_numbers, convert_number, load_dataframe_from_csv
|
|
|
3 |
from tools import to_dataframe, to_json, get_dataframe_data, get_dataframe_column, get_dataframe_row, get_dataframe_groupby
|
4 |
from vlm_tools import download_image, image_processing, object_detection_tool, ocr_scan_tool, extract_frames_from_video
|
5 |
-
from audio_tools import audio_to_base64, noise_reduction, audio_segmentation, speaker_diarization
|
6 |
from community_tools import community_tools
|
7 |
import os
|
8 |
import logging
|
@@ -11,12 +12,12 @@ import yaml
|
|
11 |
logging.basicConfig(level=logging.DEBUG)
|
12 |
|
13 |
MODEL_CHOICES = {
|
14 |
-
"audio": ["
|
15 |
-
"vlm": ["Qwen/Qwen2.5-
|
16 |
"code": ["Qwen/Qwen2.5-Coder-32B-Instruct"],
|
17 |
"arithmetic": ["Qwen/Qwen2.5-Coder-7B-Instruct"],
|
18 |
"pandas": ["Qwen/Qwen2.5-Coder-7B-Instruct"],
|
19 |
-
"master": ["Qwen/Qwen2.5-Coder-32B-Instruct"
|
20 |
}
|
21 |
|
22 |
with open("prompts.yaml", 'r') as stream:
|
@@ -37,8 +38,8 @@ audio_model = InferenceClientModel(
|
|
37 |
|
38 |
audio_agent = CodeAgent(
|
39 |
model=audio_model,
|
40 |
-
tools=[audio_to_base64, noise_reduction, audio_segmentation, speaker_diarization],
|
41 |
-
max_steps=
|
42 |
# prompt_templates=PROMPT_TEMPLATE["audio_agent"],
|
43 |
additional_authorized_imports=["pydub", "pyAudioAnalysis", "base64", "io", "sklearn", "scipy", "numpy", "pandas", "json", "os", "logging", "yaml", "pyplot", "matplotlib", 'hmmlearn', 'pickle'],
|
44 |
name="audio_agent",
|
@@ -53,7 +54,7 @@ vlm_model = InferenceClientModel(
|
|
53 |
vlm_agent = CodeAgent(
|
54 |
model=vlm_model,
|
55 |
tools=[download_image, image_processing, object_detection_tool, ocr_scan_tool, extract_frames_from_video],
|
56 |
-
max_steps=
|
57 |
# prompt_templates=PROMPT_TEMPLATE["vlm_agent"],
|
58 |
additional_authorized_imports=["cv2", "numpy", "pytesseract", "requests", "base64", "onnxruntime", "PIL", "io"],
|
59 |
name="vlm_agent",
|
@@ -68,9 +69,9 @@ arithmetic_model = InferenceClientModel(
|
|
68 |
arithmetic_agent = CodeAgent(
|
69 |
model=arithmetic_model,
|
70 |
tools=[operate_two_numbers, convert_number],
|
71 |
-
max_steps=
|
72 |
# prompt_templates=PROMPT_TEMPLATE["arithmetic_agent"],
|
73 |
-
additional_authorized_imports=["math", "
|
74 |
name="arithmetic_agent",
|
75 |
description="This agent is responsible for performing arithmetic operations on two numbers."
|
76 |
)
|
@@ -83,9 +84,9 @@ pandas_model = InferenceClientModel(
|
|
83 |
pandas_agent = CodeAgent(
|
84 |
model=pandas_model,
|
85 |
tools=[load_dataframe_from_csv, to_dataframe, to_json, get_dataframe_data, get_dataframe_column, get_dataframe_row, get_dataframe_groupby],
|
86 |
-
max_steps=
|
87 |
# prompt_templates=PROMPT_TEMPLATE["pandas_agent"],
|
88 |
-
additional_authorized_imports=["math","pandas", "json", "numpy", "io", "os", "logging", "yaml", "pyplot", "matplotlib", 'hmmlearn', 'pickle'],
|
89 |
name="pandas_agent",
|
90 |
description="This agent is responsible for converting data to a dataframe, performing pandas operations on such dataframe and converting the dataframe back to a json or a csv file."
|
91 |
)
|
@@ -123,13 +124,13 @@ master_model = InferenceClientModel(
|
|
123 |
master_agent = CodeAgent(
|
124 |
model=master_model,
|
125 |
managed_agents=[audio_agent, vlm_agent, arithmetic_agent, pandas_agent],
|
126 |
-
tools=[sort_list, *community_tools],
|
127 |
add_base_tools=True,
|
128 |
-
max_steps=
|
129 |
-
additional_authorized_imports=["math","pandas", "
|
130 |
-
verbosity_level=logging.
|
131 |
planning_interval=4,
|
132 |
-
|
133 |
name="master_agent",
|
134 |
description="This agent is responsible for managing audio, vlm, arithmetic and pandas agents."
|
135 |
)
|
|
|
1 |
from smolagents import CodeAgent, InferenceClientModel
|
2 |
from tools import sort_list, operate_two_numbers, convert_number, load_dataframe_from_csv
|
3 |
+
from tools import tavily_search_tool, visit_webpage_tool
|
4 |
from tools import to_dataframe, to_json, get_dataframe_data, get_dataframe_column, get_dataframe_row, get_dataframe_groupby
|
5 |
from vlm_tools import download_image, image_processing, object_detection_tool, ocr_scan_tool, extract_frames_from_video
|
6 |
+
from audio_tools import transcribe_audio_tool, audio_to_base64, noise_reduction, audio_segmentation, speaker_diarization
|
7 |
from community_tools import community_tools
|
8 |
import os
|
9 |
import logging
|
|
|
12 |
logging.basicConfig(level=logging.DEBUG)
|
13 |
|
14 |
MODEL_CHOICES = {
|
15 |
+
"audio": ["Qwen/Qwen2.5-Coder-32B-Instruct"],
|
16 |
+
"vlm": ["Qwen/Qwen2.5-Coder-32B-Instruct"],
|
17 |
"code": ["Qwen/Qwen2.5-Coder-32B-Instruct"],
|
18 |
"arithmetic": ["Qwen/Qwen2.5-Coder-7B-Instruct"],
|
19 |
"pandas": ["Qwen/Qwen2.5-Coder-7B-Instruct"],
|
20 |
+
"master": ["Qwen/Qwen2.5-Coder-32B-Instruct"]
|
21 |
}
|
22 |
|
23 |
with open("prompts.yaml", 'r') as stream:
|
|
|
38 |
|
39 |
audio_agent = CodeAgent(
|
40 |
model=audio_model,
|
41 |
+
tools=[transcribe_audio_tool, audio_to_base64, noise_reduction, audio_segmentation, speaker_diarization],
|
42 |
+
max_steps=6,
|
43 |
# prompt_templates=PROMPT_TEMPLATE["audio_agent"],
|
44 |
additional_authorized_imports=["pydub", "pyAudioAnalysis", "base64", "io", "sklearn", "scipy", "numpy", "pandas", "json", "os", "logging", "yaml", "pyplot", "matplotlib", 'hmmlearn', 'pickle'],
|
45 |
name="audio_agent",
|
|
|
54 |
vlm_agent = CodeAgent(
|
55 |
model=vlm_model,
|
56 |
tools=[download_image, image_processing, object_detection_tool, ocr_scan_tool, extract_frames_from_video],
|
57 |
+
max_steps=6,
|
58 |
# prompt_templates=PROMPT_TEMPLATE["vlm_agent"],
|
59 |
additional_authorized_imports=["cv2", "numpy", "pytesseract", "requests", "base64", "onnxruntime", "PIL", "io"],
|
60 |
name="vlm_agent",
|
|
|
69 |
arithmetic_agent = CodeAgent(
|
70 |
model=arithmetic_model,
|
71 |
tools=[operate_two_numbers, convert_number],
|
72 |
+
max_steps=4,
|
73 |
# prompt_templates=PROMPT_TEMPLATE["arithmetic_agent"],
|
74 |
+
additional_authorized_imports=["math", "pandas", "json", "numpy", "io", "os", "logging", "yaml", "pyplot", "matplotlib", 'hmmlearn', 'pickle', 'sklearn', 'scipy'],
|
75 |
name="arithmetic_agent",
|
76 |
description="This agent is responsible for performing arithmetic operations on two numbers."
|
77 |
)
|
|
|
84 |
pandas_agent = CodeAgent(
|
85 |
model=pandas_model,
|
86 |
tools=[load_dataframe_from_csv, to_dataframe, to_json, get_dataframe_data, get_dataframe_column, get_dataframe_row, get_dataframe_groupby],
|
87 |
+
max_steps=4,
|
88 |
# prompt_templates=PROMPT_TEMPLATE["pandas_agent"],
|
89 |
+
additional_authorized_imports=["math", "pandas", "json", "numpy", "io", "os", "logging", "yaml", "pyplot", "matplotlib", 'hmmlearn', 'pickle', 'sklearn', 'scipy'],
|
90 |
name="pandas_agent",
|
91 |
description="This agent is responsible for converting data to a dataframe, performing pandas operations on such dataframe and converting the dataframe back to a json or a csv file."
|
92 |
)
|
|
|
124 |
master_agent = CodeAgent(
|
125 |
model=master_model,
|
126 |
managed_agents=[audio_agent, vlm_agent, arithmetic_agent, pandas_agent],
|
127 |
+
tools=[sort_list, *community_tools, tavily_search_tool, visit_webpage_tool],
|
128 |
add_base_tools=True,
|
129 |
+
max_steps=20,
|
130 |
+
additional_authorized_imports=["math", "pandas", "json", "numpy", "io", "os", "logging", "yaml", "pyplot", "matplotlib", 'hmmlearn', 'pickle', 'sklearn', 'scipy', 'datetime', 'typing'],
|
131 |
+
verbosity_level=logging.INFO,
|
132 |
planning_interval=4,
|
133 |
+
prompt_templates=PROMPT_TEMPLATE["master_agent"],
|
134 |
name="master_agent",
|
135 |
description="This agent is responsible for managing audio, vlm, arithmetic and pandas agents."
|
136 |
)
|