import type { CompletionRequest } from '../types/messages.js'; import type { NexusResponse } from '../types/response.js'; /** The part of a client that verified completion needs. */ export interface VerificationClient { /** Runs one completion. */ complete(request: CompletionRequest): Promise; } /** One claim from an answer and whether the context supports it. */ export interface VerificationFact { /** The claim. */ text: string; /** Whether the context supports it. */ supported: boolean; /** How strongly, from 0 to 1. */ score: number; } /** How well an answer is supported by its context. */ export interface VerificationReport { /** True when the support ratio meets the minimum and no claim is unsupported. */ ok: boolean; /** Every claim checked. */ facts: VerificationFact[]; /** The claims the context does not support. */ unsupported: VerificationFact[]; /** Share of claims supported, from 0 to 1. */ supportRatio: number; } /** * A natural-language-inference model that judges whether a context entails a claim. Replaces the * lexical check. */ export interface NliVerifier { /** Judges one claim against the context. */ verify(claim: string, context: string): Promise<{ entailed: boolean; score: number; }>; } /** Options for checking an answer against its context. */ export interface VerificationOptions { /** The passages the answer must be supported by. */ context: string[]; /** Share of claims that must be supported, from 0 to 1. Defaults to 0.85. */ minSupportRatio?: number; /** Entailment model. Defaults to a lexical overlap check. */ nli?: NliVerifier; /** What the model should answer when the context is not enough. Defaults to `I don't know.` */ unknownAnswer?: string; /** Asks the model once to revise an unsupported answer. Defaults to true. */ repair?: boolean; } /** * Completes a request, checks each claim in the answer against the context, and asks for one * revision when claims are unsupported. The report is attached as `meta.verification`. */ export declare function completeVerified(client: VerificationClient, request: CompletionRequest, options: VerificationOptions): Promise; /** Checks every claim in an answer against the context. */ export declare function verifyAgainstContext(answer: string, options: VerificationOptions): Promise; /** Splits an answer into sentence-level claims, dropping "I don't know" style answers. */ export declare function extractFacts(answer: string): string[]; /** * Whether a context supports a claim by term overlap: at least 72% of its significant terms, or the * claim appearing verbatim. */ export declare function lexicalEntailment(claim: string, context: string): { entailed: boolean; score: number; };