QueryEngine
A query engine wraps a Retriever
and a ResponseSynthesizer
into a pipeline, that will use the query string to fetech nodes and then send them to the LLM to generate a response.
const queryEngine = index.asQueryEngine();
const response = await queryEngine.query({ query: "query string" });
The query
function also supports streaming, just add stream: true
as an option:
const stream = await queryEngine.query({ query: "query string", stream: true });
for await (const chunk of stream) {
process.stdout.write(chunk.response);
}