Jofax commited on
Commit
f21aa99
·
verified ·
1 Parent(s): 14f70e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -15
app.py CHANGED
@@ -1,35 +1,42 @@
1
  import os
2
- from smolagents import CodeAgent, DuckDuckGoSearchTool, GradioUI, InferenceClientModel
 
3
 
4
- # 1. INITIALIZE THE BRAIN
5
- # InferenceClientModel is the 2026 standard for HF API access.
6
  model = InferenceClientModel(
7
  model_id="deepseek-ai/DeepSeek-R1",
8
  token=os.getenv("HF_TOKEN")
9
  )
10
 
11
  # 2. THE RESEARCHER (Specialist)
12
- researcher = CodeAgent(
 
13
  tools=[DuckDuckGoSearchTool()],
14
  model=model,
15
- name="research_specialist",
16
- description="Expert at web search and data retrieval."
 
 
 
 
 
 
17
  )
18
 
19
  # 3. THE BOSS (Manager)
20
- # We use 'instructions' to pass your PhD-level logic.
21
- # We use 'managed_agents' to give the Boss control over the Specialist.
22
  manager = CodeAgent(
23
  tools=[],
24
  model=model,
25
- managed_agents=[researcher],
26
- add_base_tools=True,
27
- instructions="""You are the BOSS OPERATOR (Elite PhD Level).
28
- 1. Delegate sub-tasks to 'research_specialist' for any web-based data.
29
- 2. Use your internal Python tools for calculation, logic, and data processing.
30
- 3. Use LaTeX for all mathematical formulas ($E=mc^2$).
31
- 4. Provide clear, data-backed conclusions in Markdown tables."""
32
  )
33
 
 
 
 
 
 
 
34
  if __name__ == "__main__":
35
  GradioUI(manager).launch()
 
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(
7
  model_id="deepseek-ai/DeepSeek-R1",
8
  token=os.getenv("HF_TOKEN")
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()