UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

40 lines (39 loc) 1.86 kB
/** * @file Implements the RetryManager class for handling evaluation retries. */ import type { EvaluationResult, TextGenerationOptions } from "../types/index.js"; /** * Manages the retry logic for the auto-evaluation middleware. It decides if a * retry is warranted based on the evaluation score and prepares the options * for the next generation attempt by incorporating feedback into the prompt. */ export declare class RetryManager { private maxRetries; constructor(maxRetries?: number); /** * Determines if a retry should be attempted based on the evaluation result. * * @param evaluation The `EvaluationResult` of the last attempt. * @returns `true` if the response did not pass and the maximum number of retries has not been reached. */ shouldRetry(evaluation: EvaluationResult): boolean; /** * Prepares the options for the next generation attempt by creating a new, * improved prompt that includes feedback from the failed evaluation. * * @param originalOptions The original `TextGenerationOptions` from the user request. * @param evaluation The `EvaluationResult` of the failed attempt. * @returns A new `TextGenerationOptions` object with an improved prompt. */ prepareRetryOptions(originalOptions: TextGenerationOptions, evaluation: EvaluationResult): TextGenerationOptions; /** * Builds a new prompt for a retry attempt by incorporating feedback from the * evaluation. The instructions become progressively more direct with each attempt. * * @param originalPrompt The user's original prompt. * @param feedback The constructive feedback from the evaluation. * @param attemptNumber The upcoming attempt number (e.g., 2 for the first retry). * @returns A new, enhanced prompt string. */ private buildRetryPrompt; }