----------------------
Yes, LlamaIndex provides a feature where agents can be used as tools. Since the agents inherit from
BaseQueryEngine
, you can easily define other agents as tools through the
QueryEngineTool
. Here is an example of how you can do this:
from llama_index.core.tools import QueryEngineTool
query_engine_tools = [
QueryEngineTool(
query_engine=sql_agent,
metadata=ToolMetadata(
name="sql_agent", description="Agent that can execute SQL queries."
),
),
QueryEngineTool(
query_engine=gmail_agent,
metadata=ToolMetadata(
name="gmail_agent",
description="Tool that can send emails on Gmail.",
),
),
]
outer_agent = ReActAgent.from_tools(query_engine_tools, llm=llm, verbose=True)
In this example,
sql_agent
and
gmail_agent
are agents that are being used as tools. They are wrapped in the
QueryEngineTool
class and then used to create a new agent
outer_agent
.
You can find more details in the
source documentation ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------