Skip to content
reaatech

@reaatech/llm-judge-types

npm v0.1.1

Shared TypeScript types, Zod schemas, and error classes for the LLM Judge Toolkit ecosystem, providing 70+ exported types and 6 typed error classes with zero runtime dependencies beyond Zod.

@reaatech/llm-judge-types

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

Canonical TypeScript types, Zod schemas, and error classes for LLM Judge Toolkit. This package is the single source of truth for all type definitions used throughout the ecosystem.

Installation

terminal
npm install @reaatech/llm-judge-types
# or
pnpm add @reaatech/llm-judge-types

Feature Overview

  • 70+ exported types/schemas
  • 11 type files covering judgment/cost/provider/cache/events/types
  • 6 typed error classes
  • Zero runtime deps beyond zod
  • Dual ESM/CJS

Quick Start

typescript
import {
  Judgment,
  EvaluationCriteriaSchema,
  JudgeError,
  LLMProvider,
} from '@reaatech/llm-judge-types';
 
const criteria = EvaluationCriteriaSchema.enum.faithfulness;
 
function validateScore(score: unknown): number {
  if (typeof score !== 'number' || score < 0 || score > 1) {
    throw new JudgeError('Score must be 0–1', 'VALIDATION_ERROR');
  }
  return score;
}

API Reference

Core Types

ExportDescription
JudgmentFull judgment result (id, score, reasoning, confidence, cost, metadata)
JudgmentMetadataPer-judgment metadata (provider, model, duration, retries)
ConsensusJudgmentConsensus aggregate across multiple judges
ConsensusMethodUnion of consensus methods (majority, mean, weighted, etc.)
CostBreakdownToken-level cost breakdown (input/output/total, currency)
BudgetBudget configuration for cost tracking

Provider System

ExportDescription
LLMProviderInterface for provider implementations
CompletionRequestLLM completion request shape
CompletionResponseLLM completion response shape
TokenUsageToken usage counts for a completion
ModelInfoModel metadata (name, version, capabilities)
HealthStatusProvider health check result

Configuration

ExportDescription
ProviderConfigProvider configuration shape
EngineConfigEngine configuration (model, temperature, maxTokens, retries)
JudgeConfigJudge configuration shape
CacheConfigCache configuration shape
CriteriaConfigEvaluation criteria configuration

Interfaces

ExportDescription
ConsensusStrategyInterface for consensus aggregation strategies
CacheBackendInterface for cache backend implementations
EventBusInterface for typed event emission and subscription

Infrastructure Types

ExportDescription
ConfusionMatrixBinary classification confusion matrix
CalibrationReportCalibration metrics output
PositionBiasScorePer-position bias scoring result
PositionBiasReportFull position-bias analysis result
JudgmentEventDiscriminated union of judgment lifecycle events

Error Classes

ExportDescription
JudgeErrorBase error class for all judge-related errors
ProviderErrorProvider-specific errors (auth, rate limit, timeout, server)
ValidationErrorZod validation failures
BudgetExceededErrorBudget threshold exceeded
TemplateErrorPrompt template build/failure errors
CacheErrorCache read/write failures

License

MIT