Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import os
|
| 2 |
-
from smolagents import CodeAgent, DuckDuckGoSearchTool, GradioUI, InferenceClientModel
|
| 3 |
|
| 4 |
# 1. THE BRAIN
|
| 5 |
model = InferenceClientModel(
|
|
@@ -8,29 +8,38 @@ model = InferenceClientModel(
|
|
| 8 |
)
|
| 9 |
|
| 10 |
# 2. THE RESEARCHER (Specialist)
|
| 11 |
-
# We
|
| 12 |
-
|
| 13 |
-
researcher = CodeAgent(
|
| 14 |
tools=[DuckDuckGoSearchTool()],
|
| 15 |
model=model,
|
| 16 |
name="research_specialist",
|
| 17 |
-
description="
|
| 18 |
)
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
manager = CodeAgent(
|
| 23 |
tools=[],
|
| 24 |
model=model,
|
| 25 |
-
managed_agents=[
|
| 26 |
-
add_base_tools=True
|
|
|
|
| 27 |
)
|
| 28 |
|
| 29 |
-
# Set the Mission for the Boss
|
| 30 |
-
manager.system_prompt = """You are the BOSS OPERATOR (Elite PhD Level).
|
| 31 |
-
1. Delegate sub-tasks to 'research_specialist' for web data.
|
| 32 |
-
2. Use Python for math ($E=mc^2$) and data analysis.
|
| 33 |
-
3. Provide final answers in professional Markdown tables."""
|
| 34 |
-
|
| 35 |
if __name__ == "__main__":
|
| 36 |
GradioUI(manager).launch()
|
|
|
|
| 1 |
import os
|
| 2 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, GradioUI, InferenceClientModel, ManagedAgent
|
| 3 |
|
| 4 |
# 1. THE BRAIN
|
| 5 |
model = InferenceClientModel(
|
|
|
|
| 8 |
)
|
| 9 |
|
| 10 |
# 2. THE RESEARCHER (Specialist)
|
| 11 |
+
# We wrap the researcher in ManagedAgent so the Boss can "call" it.
|
| 12 |
+
search_agent = CodeAgent(
|
|
|
|
| 13 |
tools=[DuckDuckGoSearchTool()],
|
| 14 |
model=model,
|
| 15 |
name="research_specialist",
|
| 16 |
+
description="Finds technical data and web information. Use for all research tasks."
|
| 17 |
)
|
| 18 |
|
| 19 |
+
managed_researcher = ManagedAgent(
|
| 20 |
+
agent=search_agent,
|
| 21 |
+
name="research_specialist",
|
| 22 |
+
description="A web-search specialist. Call this agent when you need current data from the internet."
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
# 3. THE BOSS LOGIC (The Template Fix)
|
| 26 |
+
# This dictionary overrides the read-only system_prompt property.
|
| 27 |
+
custom_templates = {
|
| 28 |
+
"system_prompt": """You are the BOSS OPERATOR (Elite PhD Level).
|
| 29 |
+
1. Delegate sub-tasks to 'research_specialist' for web-based data.
|
| 30 |
+
2. Use your internal Python tools for math, simulation, and data analysis.
|
| 31 |
+
3. Always verify data before presenting a final answer.
|
| 32 |
+
4. Format all math in LaTeX ($E=mc^2$) and all data in Markdown tables."""
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
# 4. THE BOSS (Manager)
|
| 36 |
manager = CodeAgent(
|
| 37 |
tools=[],
|
| 38 |
model=model,
|
| 39 |
+
managed_agents=[managed_researcher],
|
| 40 |
+
add_base_tools=True,
|
| 41 |
+
prompt_templates=custom_templates # <--- THIS IS THE CRITICAL FIX
|
| 42 |
)
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
if __name__ == "__main__":
|
| 45 |
GradioUI(manager).launch()
|