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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -18
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import os
2
- import gradio as gr
3
- from smolagents import CodeAgent, DuckDuckGoSearchTool, GradioUI, InferenceClientModel, ManagedAgent
4
 
5
  # 1. THE BRAIN
6
  model = InferenceClientModel(
@@ -9,34 +8,29 @@ model = InferenceClientModel(
9
  )
10
 
11
  # 2. THE RESEARCHER (Specialist)
12
- # We wrap this in a ManagedAgent so the Boss knows HOW to use it.
13
- search_agent = CodeAgent(
 
14
  tools=[DuckDuckGoSearchTool()],
15
  model=model,
16
- name="researcher",
17
- description="A specialist that searches the web and retrieves technical data."
18
- )
19
-
20
- managed_researcher = ManagedAgent(
21
- agent=search_agent,
22
- name="researcher",
23
- description="Use this agent for any task that requires searching the web or finding current information."
24
  )
25
 
26
  # 3. THE BOSS (Manager)
27
- # We use the standard constructor and pass the managed agent.
28
  manager = CodeAgent(
29
  tools=[],
30
  model=model,
31
- managed_agents=[managed_researcher],
32
  add_base_tools=True
33
  )
34
 
35
- # Set the Boss's "Mission" (Instructions)
36
- manager.system_prompt = """You are the BOSS OPERATOR.
37
- 1. For web data, delegate to the 'researcher'.
38
  2. Use Python for math ($E=mc^2$) and data analysis.
39
- 3. Provide final answers in professional Markdown."""
40
 
41
  if __name__ == "__main__":
42
  GradioUI(manager).launch()
 
1
  import os
2
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, GradioUI, InferenceClientModel
 
3
 
4
  # 1. THE BRAIN
5
  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()