PredictivePreFetcherConfig
Properties
Section titled “Properties”cache: RetrievalCache;The session-level cache to populate.
conversationWindow?
Section titled “conversationWindow?”optional conversationWindow?: number;Number of recent messages to analyze for topic prediction. Default: 5.
maxKeywords?
Section titled “maxKeywords?”optional maxKeywords?: number;Maximum number of keywords to extract per prediction. Default: 3.
predictor?
Section titled “predictor?”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);}retrievalOptions?
Section titled “retrievalOptions?”optional retrievalOptions?: Partial<RetrievalOptions>;Additional retrieval options (e.g., includeEmbeddings).
retriever
Section titled “retriever”retriever: Retriever;The retriever to use for pre-fetching.
optional topK?: number;TopK results per pre-fetch query. Default: 3.