Spaces:
Sleeping
Sleeping
Deploy OmniAssistant smolagent (Hugging Face Agents Course Unit 1)
Browse files- Gradio_UI.py +0 -1
- app.py +36 -14
Gradio_UI.py
CHANGED
|
@@ -285,7 +285,6 @@ class GradioUI:
|
|
| 285 |
),
|
| 286 |
resizable=True,
|
| 287 |
scale=1,
|
| 288 |
-
type="messages",
|
| 289 |
)
|
| 290 |
# If an upload folder is provided, enable the upload feature
|
| 291 |
if self.file_upload_folder is not None:
|
|
|
|
| 285 |
),
|
| 286 |
resizable=True,
|
| 287 |
scale=1,
|
|
|
|
| 288 |
)
|
| 289 |
# If an upload folder is provided, enable the upload feature
|
| 290 |
if self.file_upload_folder is not None:
|
app.py
CHANGED
|
@@ -126,27 +126,49 @@ prompts_file = os.path.join(os.path.dirname(__file__), "prompts.yaml")
|
|
| 126 |
with open(prompts_file, "r") as stream:
|
| 127 |
prompt_templates = yaml.safe_load(stream)
|
| 128 |
|
| 129 |
-
#
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
if image_generation_tool is not None:
|
| 138 |
-
|
| 139 |
|
| 140 |
-
|
| 141 |
model=model,
|
| 142 |
-
tools=
|
| 143 |
-
|
|
|
|
| 144 |
verbosity_level=1,
|
| 145 |
planning_interval=None,
|
| 146 |
-
name="
|
| 147 |
-
description="A
|
| 148 |
prompt_templates=prompt_templates
|
| 149 |
)
|
| 150 |
|
|
|
|
|
|
|
|
|
|
| 151 |
if __name__ == "__main__":
|
| 152 |
GradioUI(agent).launch()
|
|
|
|
| 126 |
with open(prompts_file, "r") as stream:
|
| 127 |
prompt_templates = yaml.safe_load(stream)
|
| 128 |
|
| 129 |
+
# --- Specialist Agents (Unit 2: Hierarchical Multi-Agent System) ---
|
| 130 |
+
|
| 131 |
+
# Specialist 1: Web & Wikipedia Researcher
|
| 132 |
+
research_agent = CodeAgent(
|
| 133 |
+
model=model,
|
| 134 |
+
tools=[web_search, search_wikipedia],
|
| 135 |
+
max_steps=4,
|
| 136 |
+
verbosity_level=1,
|
| 137 |
+
name="web_researcher",
|
| 138 |
+
description="A specialist researcher that searches DuckDuckGo and queries Wikipedia to gather accurate facts and summaries.",
|
| 139 |
+
prompt_templates=prompt_templates
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
# Specialist 2: Weather & Timezone Specialist
|
| 143 |
+
local_info_agent = CodeAgent(
|
| 144 |
+
model=model,
|
| 145 |
+
tools=[get_current_time_in_timezone, get_weather],
|
| 146 |
+
max_steps=4,
|
| 147 |
+
verbosity_level=1,
|
| 148 |
+
name="local_info_specialist",
|
| 149 |
+
description="A specialist agent that fetches real-time live weather reports and calculates current time in timezones worldwide.",
|
| 150 |
+
prompt_templates=prompt_templates
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
# Manager Agent: Coordinates specialists and synthesizes the final response
|
| 154 |
+
manager_tools = [final_answer]
|
| 155 |
if image_generation_tool is not None:
|
| 156 |
+
manager_tools.append(image_generation_tool)
|
| 157 |
|
| 158 |
+
manager_agent = CodeAgent(
|
| 159 |
model=model,
|
| 160 |
+
tools=manager_tools,
|
| 161 |
+
managed_agents=[research_agent, local_info_agent],
|
| 162 |
+
max_steps=8,
|
| 163 |
verbosity_level=1,
|
| 164 |
planning_interval=None,
|
| 165 |
+
name="OmniAssistant_Manager",
|
| 166 |
+
description="A senior manager agent that breaks down user tasks and delegates them to specialized team members (web researcher and local info specialist).",
|
| 167 |
prompt_templates=prompt_templates
|
| 168 |
)
|
| 169 |
|
| 170 |
+
# Main agent interface for Gradio
|
| 171 |
+
agent = manager_agent
|
| 172 |
+
|
| 173 |
if __name__ == "__main__":
|
| 174 |
GradioUI(agent).launch()
|