Find answers from the community

Updated 11 months ago

React

At a glance

The community member is trying to learn the ReACt agent, which takes in a query engine as a tool. They are wondering if there is a way to feed in the DAG (Directed Acyclic Graph) for a query pipeline instead, as the query pipeline has a .run method, but the agent tool query engine expects .query. Another community member provided a solution, suggesting to wrap the query pipeline in a function tool using the FunctionTool class from the llama_index.core.tools module. They also mentioned a notebook example that goes into more detail on using a query pipeline with an agent.

Useful resources
Hey @Logan M hope you are well. I’m trying to learn the ReACt agent. It takes in a query engine as a tool. However, is there a way to feed in the DAG for a query pipeline instead? The query pipeline has a .run method, but the agent tool query engine expects .query. I cannot figure out how to connect the two. Thoughts or examples somewhere?
L
c
2 comments
You can just shove the query pipeline into a function tool

Plain Text
from llama_index.core.tools import FunctionTool

def query(inp: str) -> str:
  """Useful for answering questions about X."""
  output = pipeline.run(...)
  return str(output['response'])

tool = FunctionTool.from_defaults(fn=query)


Here the function name and docstring are used as the tool name and tool description

You can also go much more low-level, in this notebook example
https://docs.llamaindex.ai/en/stable/examples/agent/agent_runner/query_pipeline_agent/?h=query+pipeline+tool
@Logan M ohhhh thanks!
Add a reply
Sign up and join the conversation on Discord