Fix managed agent example (#562)
Co-authored-by: Aymeric Roucher <69208727+aymeric-roucher@users.noreply.github.com>
This commit is contained in:
parent
3fc2d0e4e8
commit
881ce13635
|
@ -344,19 +344,18 @@ It empirically yields better performance on most benchmarks. The reason for this
|
||||||
|
|
||||||
You can easily build hierarchical multi-agent systems with `smolagents`.
|
You can easily build hierarchical multi-agent systems with `smolagents`.
|
||||||
|
|
||||||
To do so, encapsulate the agent in a [`ManagedAgent`] object. This object needs arguments `agent`, `name`, and a `description`, which will then be embedded in the manager agent's system prompt to let it know how to call this managed agent, as we also do for tools.
|
To create a managed agent, give your `CodeAgent` or `ToolCallingAgent` the attributes `name` and `description` - these are mandatory to make the agent callable by its manager agent. The manager agent will receive the managed agent via its managed_agents argument during initialization.
|
||||||
|
|
||||||
Here's an example of making an agent that managed a specific web search agent using our [`DuckDuckGoSearchTool`]:
|
Here's an example of making an agent that managed a specific web search agent using our [`DuckDuckGoSearchTool`]:
|
||||||
|
|
||||||
```py
|
```py
|
||||||
from smolagents import CodeAgent, HfApiModel, DuckDuckGoSearchTool, ManagedAgent
|
from smolagents import CodeAgent, HfApiModel, DuckDuckGoSearchTool, ToolCallingAgent
|
||||||
|
|
||||||
model = HfApiModel()
|
model = HfApiModel()
|
||||||
|
|
||||||
web_agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
|
managed_web_agent = CodeAgent(
|
||||||
|
tools=[DuckDuckGoSearchTool()],
|
||||||
managed_web_agent = ManagedAgent(
|
model=model,
|
||||||
agent=web_agent,
|
|
||||||
name="web_search",
|
name="web_search",
|
||||||
description="Runs web searches for you. Give it your query as an argument."
|
description="Runs web searches for you. Give it your query as an argument."
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue