@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
45 lines (44 loc) • 1.92 kB
TypeScript
import type { EnhancedEvaluationContext, EvaluationResult, GenerateResult } from "../types/index.js";
import type { LanguageModelV3CallOptions } from "../types/index.js";
/**
* Builds the enhanced context required for a RAGAS-style evaluation.
* This class gathers data from the generation options and results to create a
* rich snapshot of the interaction, which is then used by the evaluator.
*/
export declare class ContextBuilder {
private attemptNumber;
private previousEvaluations;
private extractTextFromContent;
/**
* Builds the full evaluation context for a single evaluation attempt.
*
* @param options The original `TextGenerationOptions` used for the request.
* @param result The `GenerateResult` from the provider.
* @returns An `EnhancedEvaluationContext` object ready for evaluation.
*/
buildContext(options: LanguageModelV3CallOptions, result: GenerateResult): EnhancedEvaluationContext;
/**
* Records the result of an evaluation and increments the internal attempt counter.
* This is used to build up the `previousEvaluations` array for subsequent retries.
*
* @param evaluation The `EvaluationResult` from the last attempt.
*/
recordEvaluation(evaluation: EvaluationResult): void;
/**
* Resets the internal state of the context builder. This should be called
* before starting a new, independent evaluation sequence.
*/
reset(): void;
/**
* Analyzes the user's query to determine intent and complexity.
* @param query The user's input query.
* @returns A QueryIntentAnalysis object.
*/
private analyzeQuery;
/**
* Maps the tool execution format from GenerateResult to the canonical ToolExecution type.
* @param result The result from the generate call.
* @returns An array of ToolExecution objects.
*/
private mapToolExecutions;
}