To build a simple router (with only two query engines) over one single document, we do the following:
- We index the document into two vector indexes:
- Vector Index → upon receiving a query, it returns the most similar results.
- Summary Index → upon receiving a query, it return everything.
- Define query engines and set metadata (this is LlamaIndex specific syntax, using other libraries would require adopting their syntax)
- Define router query engine
- There are several selectors in LlamaIndex that we could use here:
- The LLM selectors use the LLM to output a JSON that is parsed, and the corresponding indexes are queried.
- The Pydantic selectors use the OpenAI Function Calling API to produce Pydantic selection objects, rather than parsing raw JSON.