File size: 973 Bytes
17f0b1c
 
b0dea19
 
17f0b1c
 
 
 
 
b0dea19
 
17f0b1c
b0dea19
 
17f0b1c
 
 
 
b0dea19
 
 
17f0b1c
b0dea19
 
17f0b1c
b0dea19
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Secure multi-agent with E2B sandboxed code execution
import os
from smolagents import CodeAgent, DuckDuckGoSearchTool, GradioUI, InferenceClientModel

model = InferenceClientModel(
    model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
    max_tokens=8192,
)

web_agent = CodeAgent(
    tools=[DuckDuckGoSearchTool()],
    model=model,
    name="web_search_agent",
    description="A web search agent that can search the internet using DuckDuckGo to find current information, news, and answers to questions.",
    executor_type="e2b",
    executor_kwargs={"api_key": os.getenv("E2B_API_KEY")},
    additional_authorized_imports=["json", "re", "math", "datetime"],
    max_steps=10,
)

manager_agent = CodeAgent(
    model=model,
    tools=[],
    managed_agents=[web_agent],
    additional_authorized_imports=["json", "re", "math", "datetime"],
    planning_interval=5,
    verbosity_level=2,
    max_steps=15,
)

if __name__ == "__main__":
    GradioUI(manager_agent).launch()