Skip to content

PredictivePreFetcherConfig

cache: RetrievalCache;

The session-level cache to populate.


optional conversationWindow?: number;

Number of recent messages to analyze for topic prediction. Default: 5.


optional maxKeywords?: number;

Maximum number of keywords to extract per prediction. Default: 3.


optional predictor?: TopicPredictor;

Optional LLM-based topic predictor. When provided, this is used instead of keyword extraction for predicting follow-up queries.

The predictor receives recent conversation messages and should return an array of predicted search queries. The implementation is caller-provided so the pre-fetcher has no LLM dependency.

Example using Vercel AI SDK:

predictor: async (messages) => {
const { text } = await generateText({
model: openai('gpt-4o-mini'),
system: 'Predict 3 follow-up topics the user might ask about.',
prompt: messages.map(m => `${m.role}: ${m.content}`).join('\n'),
});
return text.split('\n').filter(Boolean);
}

optional retrievalOptions?: Partial<RetrievalOptions>;

Additional retrieval options (e.g., includeEmbeddings).


retriever: Retriever;

The retriever to use for pre-fetching.


optional topK?: number;

TopK results per pre-fetch query. Default: 3.