Replies: 1 comment
-
Yes, it is possible to attach the query engine to an agent and call it with other agents using the Here is how you can do it:
Here is the relevant code to achieve this: from llama_index.core.tools import QueryEngineTool, ToolMetadata
from llama_index.agent.openai import OpenAIAgent
# Assuming your query engine is already defined as:
query_engine = RAGStringQueryEngine(
retriever=recursive_retriever,
response_synthesizer=response_synthesizer,
pandas_prompt=pandas_prompt,
pandas_output_parser=pandas_output_parser,
llm=llm,
qa_prompt=qa_prompt,
synthesize_response=True,
response_synthesis_prompt=response_synthesis_prompt,
)
# Create a QueryEngineTool from your query engine
query_engine_tool = QueryEngineTool.from_defaults(
query_engine=query_engine,
name="query_engine_tool",
description="Tool for querying the RAGStringQueryEngine."
)
# Define other tools if you have any
multiply_tool = FunctionTool.from_defaults(
fn=multiply,
name="multiply_tool",
description="Multiply two integers and return the result integer."
)
# Create the agent with the tools
agent = OpenAIAgent.from_tools(
tools=[query_engine_tool, multiply_tool],
verbose=True
)
# Start the agent's chat REPL or use it programmatically
agent.chat_repl() This setup allows you to channel all your input through the query engine and call it like any other agent using the
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have developed a group of agents capable of linking our databases, and retrieving and preparing data for analysis. Currently, I need to channel all my input through the 'query engine'. The main query is whether it is feasible to transform the query engine into an agent that can be called like the other agents. I have included sample agent code along with my query engine code for reference.
Beta Was this translation helpful? Give feedback.
All reactions