createJudgeScorer (judge.ts)

open-multi-agent · ai

Builds LLM judge scorer: constructs prompts, parses verdicts, manages aborts/deadlines for eval.

import { z, type ZodSchema } from 'zod'
import type { AgentConfig, CostEstimateContext, TokenUsage } from '../types.js'
import {
  buildStructuredOutputInstruction,
  extractJSON,
  validateOutput,
} from '../agent/structured-output.js'
import {
  attachScoreCostInputs,
  defineScorer,
  scoreCostInputs,
  type ScoreCostInput,
  type Scorer,
  type ScorerContext,
} from './scorer.js'

export interface JudgeScorerOptions {
  readonly name: string
  readonly version?: string
  readonly judges: readonly AgentConfig[]
  readonly quorum?: number
  readonly verdictSchema?: ZodSchema
  readonly judgePrompt?: string | ((context: ScorerContext) => string)
  readonly timeoutMs?: number
}

interface JudgeVerdict {
  readonly judge: string
  readonly model: string
  readonly score: number
  readonly p

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key