import type { CompletionRequest } from '../types/messages.js'; /** A passage of retrieved context. */ export interface RagChunk { /** Id the model cites it by. */ id: string; /** The passage text. */ content: string; /** Where it came from, shown to the model. */ source?: string; /** Retrieval score. */ score?: number; /** Application data, recorded in request metadata. */ metadata?: Record; } /** Options for `withRagContext()`. */ export interface RagOptions { /** The passages to answer from. */ chunks: RagChunk[]; /** Asks the model to cite chunk ids in square brackets. Defaults to true. */ requireCitations?: boolean; /** How citations are written. */ citationStyle?: 'bracket' | 'source'; /** * What the model should answer when the context is not enough. Defaults to `I don't know based on * the provided context.` */ unknownAnswer?: string; /** Most chunks included. Defaults to all of them. */ maxChunks?: number; } /** * Adds retrieved passages as a system message, telling the model to answer only from them and cite * them. Temperature and top-p default low. */ export declare function withRagContext(request: CompletionRequest, options: RagOptions): CompletionRequest; /** Every distinct bracketed citation in a text. */ export declare function extractCitations(text: string): string[]; /** Checks that every bracketed citation in a response names a known chunk. */ export declare function validateCitations(responseText: string, chunks: RagChunk[]): { ok: boolean; missing: string[]; };