Find answers from the community

Updated 11 months ago

I'm interested in using

At a glance

The community member is interested in using AutoMergingRetriever as a chat engine with streaming chat responses. They have existing chat engine code, but are unsure how to integrate AutoMergingRetriever with the chat functionality. The documentation suggests using RetrieverQueryEngine, but the community member is unsure how to get a chat engine from that.

In the comments, another community member suggests putting the retriever into a RetrieverQueryEngine and then giving that as a tool to an agent. When asked for code examples, a third community member provides some sample code showing how to create a QueryEngineTool from a RetrieverQueryEngine and then use it with an OpenAIAgent.

There is no explicitly marked answer in the comments, but the community members provide suggestions on how to integrate AutoMergingRetriever with chat functionality using a RetrieverQueryEngine and an agent.

Useful resources
I'm interested in using AutoMergingRetriever but I need it to function as a chat engine and to stream chat responses. My existing chat engine code is as follows:

Plain Text
chat_engine = index.as_chat_engine(
        similarity_top_k=similarity_top_k,
        node_postprocessors=node_postprocessors,
        vector_store_kwargs={"qdrant_filters": filters})


I'm unsure how to integrate AutoMergingRetriever with the chat functionality. The documentation (https://docs.llamaindex.ai/en/latest/examples/retrievers/auto_merging_retriever.html) suggests using RetrieverQueryEngine, but that would only provide me with a query engine. How can I get a chat engine?
L
S
4 comments
You can put the retriever into a RetrieverQueryEngine, and then give that as a tool to an agent
Thanks @Logan M , do you have any code examples to show how to do this?
Plain Text
from llama_index.core.query_engine import RetrieverQueryEngine
from llama_index.core.tools import QueryEngineTool, ToolMetadata
from llama_index.agent.openai import OpenAIAgent

tool = QuerEngineTool.from_defaults(
  RetrieverQueryEngine.from_args(retriever, ...),
  metadata=ToolMetadata(name="name", description="Useful for finding information about X.")
)

agent = OpenAIAgent.from_tools([tool], llm=llm)
Add a reply
Sign up and join the conversation on Discord