Canonical TypeScript types and Zod schemas for RAG evaluation data shapes. Exports 18+ types (`EvaluationSample`, `EvalSuiteConfig`, `SampleEvalResult`, `GateConfig`, `JudgeConfig`, etc.) and two Zod schemas (`EvaluationSampleSchema`, `EvalSuiteConfigSchema`) for runtime validation, with zero runtime dependencies beyond `zod`.
Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.
Canonical TypeScript types and Zod schemas for RAG (Retrieval-Augmented Generation) evaluation. This package is the single source of truth for all evaluation shapes used throughout the @reaatech/rag-eval-* ecosystem.
18+ exported types — EvaluationSample, EvalSuiteConfig, SampleEvalResult, EvalResults, GateConfig, JudgeConfig, and more
2 Zod schemas — EvaluationSampleSchema and EvalSuiteConfigSchema for runtime validation
Full cost accounting types — CostBreakdown, TokenUsage, PricingConfig for per-evaluation cost tracking
Gate configuration types — ThresholdGateConfig, BaselineGateConfig with full operator support
Zero runtime dependencies beyond zod — lightweight and tree-shakeable
Dual ESM/CJS output — works with import and require
Quick Start
typescript
import { EvaluationSampleSchema, EvalSuiteConfigSchema, type EvaluationSample, type EvalSuiteConfig,} from "@reaatech/rag-eval-core";// Validate an evaluation sample at the boundaryconst rawSample = JSON.parse(incomingJson);const sample: EvaluationSample = EvaluationSampleSchema.parse(rawSample);// Validate a suite configurationconst rawConfig = JSON.parse(configJson);const config: EvalSuiteConfig = EvalSuiteConfigSchema.parse(rawConfig);
Exports
Core Types
Export
Description
EvaluationSample
Input sample: query, context, ground_truth, generated_answer, optional retrieved_chunk_ids and metadata
EvalSuiteConfig
Full evaluation suite configuration: metrics, judge, cost, execution, gates
SampleEvalResult
Per-sample result with heuristic and judge scores for each metric
Zod schema for validating evaluation samples (query, context, ground_truth, generated_answer)
EvalSuiteConfigSchema
Zod schema for validating suite configuration (metrics, judge, cost, gates, execution)
Usage Pattern
Every schema export has a matching type export. Use the schema for runtime validation and the type for compile-time checking:
typescript
import { EvaluationSampleSchema, type EvaluationSample } from "@reaatech/rag-eval-core";function processSample(raw: unknown): EvaluationSample { // Parse at the boundary — throws ZodError on invalid data return EvaluationSampleSchema.parse(raw);}