Find answers from the community

Updated 3 months ago

Hi I am using ReAct agent and I put query_engine_tools. Can ReAct agent pick up more than

Hi I am using ReAct agent and I put query_engine_tools. Can ReAct agent pick up more than one tools when processing a query ? is it by default ? something like LLMMultiSelector. Fyi, I am using PandasQueryEngine for query_engine_tools
k
i
6 comments
Please stand by @ihshan :) as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
Yes, the ReAct agent in LlamaIndex can utilize multiple tools when processing a query. The agent has access to the tools you define and can use them based on the requirements of the query. However, the selection of tools is not done by default like LLMMultiSelector. The agent's tool selection is based on the query and the capabilities of the tools.

For instance, if you have defined multiple QueryEngineTool instances in your query_engine_tools list, the ReAct agent can use any of these tools. Here's an example of defining multiple tools:

Plain Text
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.",
        ),
    ),
]

Source ()

Then, you can initialize your ReAct agent with these tools:

Plain Text
outer_agent = ReActAgent.from_tools(query_engine_tools, llm=llm, verbose=True)

Source ()

In your case, if you're using PandasQueryEngine for your query_engine_tools, the ReAct agent will be able to use this tool when processing queries.
Remember, the agent's ability to use multiple tools depends on the nature of the query and the capabilities of the tools. If a query can be answered using multiple tools, the agent may use more than one tool. However, if a query can be answered using a single tool, the agent may only use that tool.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
I see @kapa.ai . So basically, I don't have to define if the agent has to use Multiple or single tool right ? the agent will do that automatically. Please advise
Let me check the knowledge base for you. One moment! :books:
----------------------
Correct, you don't have to explicitly define whether the ReAct agent should use multiple or single tools. The agent is designed to automatically determine which tools to use based on the task at hand.

When you initialize the ReAct agent with a set of tools, it has access to all of them and can use them in any sequence it deems appropriate to complete the task. This may involve breaking the task into subtasks and using different tools to complete each subtask.

Here's an example of initializing a ReAct agent with multiple tools:

Plain Text
agent = ReActAgent.from_tools(
    [multiply_tool, add_tool, subtract_tool, divide_tool],
    llm=llm,
    verbose=True,
)

Source ()

In this example, the agent has access to four tools (multiply_tool, add_tool, subtract_tool, divide_tool) and can use any of them as needed.

So, in your case, if you initialize your ReAct agent with multiple PandasQueryEngine tools, the agent will automatically decide which tools to use based on the query it's processing.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Add a reply
Sign up and join the conversation on Discord