UNPKG

@plust/datasleuth

Version:

Build LLM-powered research pipelines and output structured data.

71 lines (70 loc) 2.48 kB
import { createStep } from '../utils/steps.js'; import { StepOptions } from '../types/pipeline.js'; import { z } from 'zod'; import { LanguageModel } from 'ai'; /** * Schema for fact check results */ declare const factCheckResultSchema: z.ZodObject<{ statement: z.ZodString; isValid: z.ZodBoolean; confidence: z.ZodNumber; evidence: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; sources: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; corrections: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { statement: string; isValid: boolean; confidence: number; evidence?: string[] | undefined; sources?: string[] | undefined; corrections?: string | undefined; }, { statement: string; isValid: boolean; confidence: number; evidence?: string[] | undefined; sources?: string[] | undefined; corrections?: string | undefined; }>; export type FactCheckResult = z.infer<typeof factCheckResultSchema>; /** * Options for the fact checking step */ export interface FactCheckOptions extends StepOptions { /** Minimum confidence threshold for validation (0.0 to 1.0) */ threshold?: number; /** Model to use for fact checking (from the AI SDK) */ llm?: LanguageModel; /** Whether to include evidence in the output */ includeEvidence?: boolean; /** Whether to include fact check results in the final results */ includeInResults?: boolean; /** Specific statements to check (if empty, will extract from content) */ statements?: string[]; /** Maximum number of statements to check */ maxStatements?: number; /** Custom prompt for the fact-checking LLM */ customPrompt?: string; /** Temperature for the LLM (0.0 to 1.0) */ temperature?: number; /** Retry configuration for LLM calls */ retry?: { /** Maximum number of retries */ maxRetries?: number; /** Base delay between retries in ms */ baseDelay?: number; }; /** Whether to continue if some statements fail to check */ continueOnError?: boolean; /** Whether to continue even if zero extracted content is available */ allowEmptyContent?: boolean; } /** * Creates a fact checking step for the research pipeline * * @param options Configuration options for fact checking * @returns A fact checking step for the research pipeline */ export declare function factCheck(options?: FactCheckOptions): ReturnType<typeof createStep>; export {};