@judgy-ts/core
v0.1.2
Published
Portable core contracts and policies for Judgy TypeScript.
Readme
@judgy-ts/core
Core evaluation models, provider contracts, and assertion helpers for Judgy TypeScript.
@judgy-ts/core gives you the low-level building blocks for semantic testing of AI and LLM output. It includes the LlmProvider contract, the SemanticEvaluator, evaluation result models, and assertion policy helpers that higher-level packages build on top of.
Installation
npm install @judgy-ts/coreWhat This Package Contains
LlmProvider,LlmRequest, andLlmResponsefor integrating a judge modelSemanticEvaluatorfor turning an output and expectation into an evaluation resultEvaluationEvidenceandEvaluationResultmodelsevaluateSemanticAssertion,evaluateScoreAssertion, andevaluateDurationAssertionfor pass/fail decisionsformatAssertionFailureMessagefor readable failure output
Usage
import {
LlmRequest,
LlmResponse,
SemanticEvaluator,
evaluateSemanticAssertion,
type LlmProvider
} from "@judgy-ts/core";
class InlineProvider implements LlmProvider {
async complete(_request: LlmRequest): Promise<LlmResponse> {
return new LlmResponse({
text: JSON.stringify({
confidence: 0.96,
reasoning: "The answer clearly mentions the refund deadline."
})
});
}
}
const evaluator = new SemanticEvaluator(new InlineProvider());
const result = await evaluator.evaluate(
"You can request a refund within 30 days of purchase.",
"The answer should mention the refund deadline."
);
const decision = evaluateSemanticAssertion(result, { minimumScore: 0.8 });
if (!decision.succeeded) {
throw new Error("Semantic assertion failed.");
}Related Packages
@judgy-ts/expectadds higher-levelexpect(...)matchers for Jest and Vitest- provider packages such as
@judgy-ts/openai,@judgy-ts/ollama, and@judgy-ts/httpimplementLlmProviderfor common runtimes
Repository
- https://github.com/maurogioberti/judgy-ts
