-
I am exploring the concept of a structured planning agent (as shown in link below). To initiate the agent, it appears that I need to create a tool (for example, uber_tool) and pass that tool to the worker as demonstrated in the code. However, I am currently using a query engine similar to what is shown in the code below. Is it possible to convert my query engine into the required tool? By doing so, I would be able to initiate a structured planner. Your help is appreciated. https://github.com/run-llama/llama_index/blob/main/docs/docs/examples/agent/structured_planner.ipynb Suggested code in structured Planning agent py:
My query engine that need to be ported into above tool:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Yes, it is possible to convert your existing query engine into the required tool to initiate a structured planner using LlamaIndex. Here is how you can achieve this:
By following these steps, you can convert your existing |
Beta Was this translation helpful? Give feedback.
-
Description:I'm trying to create an agent using I suspect that this error arises from the way the tools are passed to the Code:# Define the tools for querying
query_engine_tools = [
QueryEngineTool(
query_engine=sql_query_engine,
metadata=ToolMetadata(
name="SQLQueryTool",
description=(
"This tool is ideal for handling queries where the user specifies the exact name or identifier of a document. It translates natural language queries into SQL queries to search a table with columns such as file_name, text, and url. Use this tool when the request involves retrieving documents based on their name or specific identifier."
),
),
),
QueryEngineTool(
query_engine=retriever_query_engine,
metadata=ToolMetadata(
name="vectorsearch",
description=(
"This tool excels at addressing queries related to the content or subject matter of documents. It uses vector embeddings to understand the semantic meaning and context of documents. Use this tool when the request involves finding documents based on their content or topic, such as discussions about 'selling pens'."
),
),
),
]
from llama_index.core.agent import (
StructuredPlannerAgent,
FunctionCallingAgentWorker,
ReActAgentWorker,
)
# Create the function calling worker for reasoning
worker = FunctionCallingAgentWorker.from_tools(
[query_engine_tools], verbose=True
)
# Wrap the worker in the top-level planner
agent = StructuredPlannerAgent(
worker, tools=[query_engine_tools], verbose=True
)
# Execute a chat query
response = agent.chat(message="give me document which talks about selling a pen") |
Beta Was this translation helpful? Give feedback.
Yes, it is possible to convert your existing query engine into the required tool to initiate a structured planner using LlamaIndex. Here is how you can achieve this:
Convert Your Query Engine to a Tool:
Use the
QueryEngineTool.from_defaults
method to create a tool from your existingRAGStringQueryEngine
.