@launchdarkly/server-sdk-ai - v2.0.21
    Preparing search index...

    Class Judge

    Judge implementation that handles evaluation functionality and conversation management.

    According to the AIEval spec, judges are AI Configs with mode: "judge" that evaluate other AI Configs using structured output.

    Index
    • get sampleRate(): number

      The default sampling rate baked in at construction. Used by evaluate / evaluateMessages when no per-call rate is supplied.

      Returns number

    • Evaluates an AI response using the judge's configuration.

      Parameters

      • input: string

        The input prompt or question that was provided to the AI

      • output: string

        The AI-generated response to be evaluated

      • OptionalsamplingRate: number

        Sampling rate (0-1) to determine if evaluation should be processed. When omitted, the Judge's constructor-default rate is used. An explicit 0 overrides the default — only undefined falls through.

      Returns Promise<LDJudgeResult>

      Promise that resolves to evaluation results

    • Evaluates an AI response from chat messages and a runner result.

      Each message is rendered as <role>: <content> so the judge model can distinguish speakers in the message history. Messages are joined with a single newline.

      Parameters

      • messages: LDMessage[]

        Array of messages representing the conversation history

      • response: RunnerResult

        The runner result containing the AI-generated content to evaluate

      • OptionalsamplingRatio: number

        Sampling ratio (0-1). When omitted, the Judge's constructor-default rate is used.

      Returns Promise<LDJudgeResult>

      Promise that resolves to evaluation results