----------------------
To force the OpenAIAgent to always use a query engine tool, you need to initialize the agent with the query engine tools. Here's how you can do it:
First, import the necessary modules and classes:
from llama_index.agent import OpenAIAgent
from llama_index.tools import QueryEngineTool, ToolMetadata
Next, define your query engine tools. Here's an example of how to do it:
query_engine_tools = [
QueryEngineTool(
query_engine=lyft_engine,
metadata=ToolMetadata(
name="lyft_10k",
description="Provides information about Lyft financials for year 2021. "
"Use a detailed plain text question as input to the tool.",
),
),
QueryEngineTool(
query_engine=uber_engine,
metadata=ToolMetadata(
name="uber_10k",
description="Provides information about Uber financials for year 2021. "
"Use a detailed plain text question as input to the tool.",
),
),
]
Finally, initialize the OpenAIAgent with the query engine tools:
agent = OpenAIAgent.from_tools(query_engine_tools, verbose=True)
Now, the OpenAIAgent will always use the query engine tools you've defined.
For more details, you can refer to the
documentation ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------