Spaces:
Sleeping
Sleeping
Add more authorized imports for master agent
Browse files- load_data.py +0 -8
- mini_agents.py +26 -10
- prompts.yaml +2 -2
load_data.py
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
import datasets
|
2 |
-
|
3 |
-
def download_dataset(dataset_name: str, name: str):
|
4 |
-
dataset = datasets.load_dataset(dataset_name, name, trust_remote_code=True)
|
5 |
-
return dataset
|
6 |
-
|
7 |
-
dataset = download_dataset("gaia-benchmark/GAIA", "2023_all")
|
8 |
-
dataset.save_to_disk("GAIA_2023_all")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mini_agents.py
CHANGED
@@ -31,6 +31,26 @@ PROMPT_TEMPLATE = {
|
|
31 |
"pandas_agent": prompt_templates
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
audio_model = InferenceClientModel(
|
35 |
model_id=MODEL_CHOICES["audio"][0],
|
36 |
token=os.getenv("HUGGINGFACE_API_KEY")
|
@@ -40,10 +60,9 @@ 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 |
-
|
44 |
-
additional_authorized_imports=["wave", "speech_recognition", "pytube", "pytube3", "youtube_dl", "pydub", "pyAudioAnalysis", "base64", "io", "sklearn", "scipy", "numpy", "pandas", "json", "os", "logging", "yaml", "pyplot", "matplotlib", 'hmmlearn', 'pickle'],
|
45 |
name="audio_agent",
|
46 |
-
description="This agent is responsible for
|
47 |
)
|
48 |
|
49 |
vlm_model = InferenceClientModel(
|
@@ -55,8 +74,7 @@ vlm_agent = CodeAgent(
|
|
55 |
model=vlm_model,
|
56 |
tools=[image_processing, object_detection_tool, ocr_scan_tool, extract_images_from_video, get_image_from_file_path, get_video_from_file_path],
|
57 |
max_steps=6,
|
58 |
-
|
59 |
-
additional_authorized_imports=["pytube", "pytube3", "youtube_dl", "cv2", "numpy", "pytesseract", "requests", "base64", "onnxruntime", "PIL", "io", "os", "logging", "yaml", "pyplot", "matplotlib", 'hmmlearn', 'pickle', 'youtube_dl', 'bs4'],
|
60 |
name="vlm_agent",
|
61 |
description="This agent is responsible for downloading images or videos, processing images or videos, detecting objects in them and extracting text from them. It cannot process audios."
|
62 |
)
|
@@ -70,8 +88,7 @@ arithmetic_agent = CodeAgent(
|
|
70 |
model=arithmetic_model,
|
71 |
tools=[operate_two_numbers, convert_number],
|
72 |
max_steps=4,
|
73 |
-
|
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 |
)
|
@@ -85,8 +102,7 @@ pandas_agent = CodeAgent(
|
|
85 |
model=pandas_model,
|
86 |
tools=[load_dataframe_from_csv, load_dataframe_from_excel, to_dataframe, to_json, get_dataframe_data, get_dataframe_column, get_dataframe_row, get_dataframe_groupby],
|
87 |
max_steps=4,
|
88 |
-
|
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 |
)
|
@@ -127,7 +143,7 @@ master_agent = CodeAgent(
|
|
127 |
tools=[sort_list, get_youtube_transcript_from_url, *community_tools, tavily_search_tool, visit_webpage_tool],
|
128 |
add_base_tools=True,
|
129 |
max_steps=20,
|
130 |
-
additional_authorized_imports=
|
131 |
verbosity_level=logging.INFO,
|
132 |
planning_interval=4,
|
133 |
prompt_templates=PROMPT_TEMPLATE["master_agent"],
|
|
|
31 |
"pandas_agent": prompt_templates
|
32 |
}
|
33 |
|
34 |
+
# Consolidated authorized imports for all agents
|
35 |
+
AUTHORIZED_IMPORTS = [
|
36 |
+
# Audio processing
|
37 |
+
"wave", "speech_recognition", "pytube", "pytube3", "youtube_dl", "pydub", "pyAudioAnalysis",
|
38 |
+
# Image/Video processing
|
39 |
+
"cv2", "pytesseract", "onnxruntime", "PIL", "bs4",
|
40 |
+
# Data processing
|
41 |
+
"numpy", "pandas", "sklearn", "scipy", "math",
|
42 |
+
# File handling
|
43 |
+
"base64", "io", "json", "os", "pickle",
|
44 |
+
# Visualization
|
45 |
+
"pyplot", "matplotlib",
|
46 |
+
# Machine learning
|
47 |
+
"hmmlearn",
|
48 |
+
# Web
|
49 |
+
"requests",
|
50 |
+
# Utilities
|
51 |
+
"logging", "yaml", "datetime", "typing", "markdownify"
|
52 |
+
]
|
53 |
+
|
54 |
audio_model = InferenceClientModel(
|
55 |
model_id=MODEL_CHOICES["audio"][0],
|
56 |
token=os.getenv("HUGGINGFACE_API_KEY")
|
|
|
60 |
model=audio_model,
|
61 |
tools=[transcribe_audio_tool, audio_to_base64, noise_reduction, audio_segmentation, speaker_diarization],
|
62 |
max_steps=6,
|
63 |
+
additional_authorized_imports=AUTHORIZED_IMPORTS,
|
|
|
64 |
name="audio_agent",
|
65 |
+
description="This agent is responsible for processing audio, transcribing audio and extracting text from it. It cannot process videos."
|
66 |
)
|
67 |
|
68 |
vlm_model = InferenceClientModel(
|
|
|
74 |
model=vlm_model,
|
75 |
tools=[image_processing, object_detection_tool, ocr_scan_tool, extract_images_from_video, get_image_from_file_path, get_video_from_file_path],
|
76 |
max_steps=6,
|
77 |
+
additional_authorized_imports=AUTHORIZED_IMPORTS,
|
|
|
78 |
name="vlm_agent",
|
79 |
description="This agent is responsible for downloading images or videos, processing images or videos, detecting objects in them and extracting text from them. It cannot process audios."
|
80 |
)
|
|
|
88 |
model=arithmetic_model,
|
89 |
tools=[operate_two_numbers, convert_number],
|
90 |
max_steps=4,
|
91 |
+
additional_authorized_imports=AUTHORIZED_IMPORTS,
|
|
|
92 |
name="arithmetic_agent",
|
93 |
description="This agent is responsible for performing arithmetic operations on two numbers."
|
94 |
)
|
|
|
102 |
model=pandas_model,
|
103 |
tools=[load_dataframe_from_csv, load_dataframe_from_excel, to_dataframe, to_json, get_dataframe_data, get_dataframe_column, get_dataframe_row, get_dataframe_groupby],
|
104 |
max_steps=4,
|
105 |
+
additional_authorized_imports=AUTHORIZED_IMPORTS,
|
|
|
106 |
name="pandas_agent",
|
107 |
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."
|
108 |
)
|
|
|
143 |
tools=[sort_list, get_youtube_transcript_from_url, *community_tools, tavily_search_tool, visit_webpage_tool],
|
144 |
add_base_tools=True,
|
145 |
max_steps=20,
|
146 |
+
additional_authorized_imports=AUTHORIZED_IMPORTS,
|
147 |
verbosity_level=logging.INFO,
|
148 |
planning_interval=4,
|
149 |
prompt_templates=PROMPT_TEMPLATE["master_agent"],
|
prompts.yaml
CHANGED
@@ -175,8 +175,8 @@ system_prompt: |-
|
|
175 |
```
|
176 |
|
177 |
{%- if managed_agents and managed_agents.values() | list %}
|
178 |
-
You
|
179 |
-
Calling a team member works the same as for calling a tool: simply
|
180 |
Given that this team member is a real human, you should be very verbose in your task, it should be a long string providing informations as detailed as necessary.
|
181 |
Here is a list of the team members that you can call:
|
182 |
```python
|
|
|
175 |
```
|
176 |
|
177 |
{%- if managed_agents and managed_agents.values() | list %}
|
178 |
+
You should also give tasks to team members whenever possible. They are very useful to solve complex tasks especially those pertaining to multiple modalities.
|
179 |
+
Calling a team member works the same as for calling a tool: you can simply pass the task description as a string to the member without specifying any argument.
|
180 |
Given that this team member is a real human, you should be very verbose in your task, it should be a long string providing informations as detailed as necessary.
|
181 |
Here is a list of the team members that you can call:
|
182 |
```python
|