Provides a set of TypeScript classes implementing a `JudgmentTemplate` interface to generate LLM evaluation prompts and parse their structured JSON responses. Each template includes built-in logic for cleaning markdown, handling malformed output, and normalizing scores for criteria like faithfulness, relevance, and safety.
Input validation — 500K character length limit and required field checks enforced per template
Score normalization — safeScore clamps and validates scores to 0–1, defaults to 0.5
Quick Start
typescript
import { FaithfulnessTemplate } from "@reaatech/llm-judge-templates";const template = new FaithfulnessTemplate();const prompt = template.buildPrompt({ query: "What is the capital of France?", response: "The capital of France is Paris.", context: "Paris is the capital and most populous city of France.",});// prompt = { system: "...", user: "..." }const parsed = template.parseResponse(`{ "score": 1.0, "reasoning": "All claims are supported by the source material.", "confidence": 0.95}`);console.log(parsed.score, parsed.confidence);// 1.0, 0.95