Jofax commited on
Commit
7d2c8ec
·
verified ·
1 Parent(s): 9d3cb6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -15
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 define it as a standard CodeAgent.
12
- # Providing a 'name' and 'description' is what makes it "manageable."
13
- researcher = CodeAgent(
14
  tools=[DuckDuckGoSearchTool()],
15
  model=model,
16
  name="research_specialist",
17
- description="Expert at web search and retrieving technical data. Use this agent for any web-based questions."
18
  )
19
 
20
- # 3. THE BOSS (Manager)
21
- # We pass the researcher agent directly into the managed_agents list.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  manager = CodeAgent(
23
  tools=[],
24
  model=model,
25
- managed_agents=[researcher],
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()