UNPKG

@plust/datasleuth

Version:

Build LLM-powered research pipelines and output structured data.

61 lines (60 loc) 2.24 kB
/** * Flow control utilities for the research pipeline * Implements conditional iteration and evaluation steps */ import { createStep } from '../utils/steps.js'; import { ResearchState, ResearchStep } from '../types/pipeline.js'; /** * Options for the evaluate step */ export interface EvaluateOptions { /** Criteria function that determines if evaluation passes */ criteriaFn: (state: ResearchState) => boolean | Promise<boolean>; /** Name for this evaluation criteria (used in logs) */ criteriaName?: string; /** Confidence threshold (0.0 to 1.0) */ confidenceThreshold?: number; /** Whether to store evaluation result in state metadata */ storeResult?: boolean; /** Retry configuration */ retry?: { /** Maximum number of retries */ maxRetries?: number; /** Base delay between retries in ms */ baseDelay?: number; }; } /** * Creates an evaluation step for the research pipeline * * @param options Configuration options for evaluation * @returns An evaluation step for the research pipeline */ export declare function evaluate(options: EvaluateOptions): ReturnType<typeof createStep>; /** * Options for the repeatUntil step */ export interface RepeatUntilOptions { /** Maximum number of iterations */ maxIterations?: number; /** Whether to throw an error if max iterations is reached */ throwOnMaxIterations?: boolean; /** Whether to continue if a step fails during iteration */ continueOnError?: boolean; /** Retry configuration */ retry?: { /** Maximum number of retries for the whole RepeatUntil step */ maxRetries?: number; /** Base delay between retries in ms */ baseDelay?: number; }; } /** * Creates a composite step that repeats the given steps until a condition is met * * @param conditionStep Step that evaluates whether to continue repeating * @param stepsToRepeat Array of steps to repeat until condition is met * @param options Configuration options * @returns A composite step that handles the iteration */ export declare function repeatUntil(conditionStep: ResearchStep, stepsToRepeat: ResearchStep[], options?: RepeatUntilOptions): ReturnType<typeof createStep>;