Router with a Query Pipeline #15411
Replies: 4 comments 3 replies
-
Yes, you can use the query pipeline itself as one of the selector items in a router that decides between querying the data and querying the source document for this data. Here's an example of how to construct query pipelines for different purposes and use a router component to dynamically choose between these pipelines based on the query: from llama_index.core.query_pipeline import RouterComponent, QueryPipeline
# Define your existing query pipeline for tabular data
tabular_data_pipeline = QueryPipeline(chain=[your_tabular_data_query_engine])
# Define another query pipeline for the source document (e.g., data dictionary)
source_document_pipeline = QueryPipeline(chain=[your_source_document_query_engine])
# Define the choices for the router
choices = [
"This tool answers specific questions about the tabular data",
"This tool answers questions about the source document (data dictionary)",
]
# Create the router component
router_c = RouterComponent(
selector=your_selector_function,
choices=choices,
components=[tabular_data_pipeline, source_document_pipeline],
verbose=True,
)
# Create the top-level query pipeline with the router component
qp = QueryPipeline(chain=[router_c], verbose=True) In this setup, |
Beta Was this translation helpful? Give feedback.
-
I assume then I can also do a mix of a query pipeline and a query engine? |
Beta Was this translation helpful? Give feedback.
-
how do i incorporate a multi step query pipeline (run_multi) with this? |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have an existing query pipeline built over tabular data using llama index text to sql modules.
I want to add a router that can decide between the data and source document for this data (say a data dictionary) to answer user questions.
Current examples all user query engines but can I use query pipeline itself as one of the selector items?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions