Router Query Engine
In this tutorial, we define a custom router query engine that selects one out of several candidate query engines to execute a query.
Setup
First, we need to install import the necessary modules from llamaindex
:
pnpm i lamaindex
import {
OpenAI,
RouterQueryEngine,
SimpleDirectoryReader,
SimpleNodeParser,
SummaryIndex,
VectorStoreIndex,
Settings,
} from "llamaindex";
Loading Data
Next, we need to load some data. We will use the SimpleDirectoryReader
to load documents from a directory:
const documents = await new SimpleDirectoryReader().loadData({
directoryPath: "node_modules/llamaindex/examples",
});