UNPKG

openlit

Version:

OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects

37 lines 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const base_1 = require("../base"); describe('BaseEval', () => { class DummyEval extends base_1.BaseEval { getSystemPrompt() { return 'PROMPT'; } async llmResponse() { // Simulate a model response return JSON.stringify({ verdict: 'yes', evaluation: 'Bias', score: 0.9, classification: 'age', explanation: 'reason', }); } } it('measure returns parsed result and records metrics if enabled', async () => { const evaler = new DummyEval({ collectMetrics: true }); const input = { text: 'foo' }; const result = await evaler.measure(input); expect(result.verdict).toBe('yes'); expect(result.evaluation).toBe('Bias'); expect(result.score).toBe(0.9); }); it('throws on unsupported provider', async () => { class BadEval extends base_1.BaseEval { getSystemPrompt() { return 'PROMPT'; } } // @ts-expect-error: purposely passing an invalid provider for test const evaler = new BadEval({ provider: 'unknown' }); await expect(evaler.measure({ text: 'foo' })).rejects.toThrow('Unsupported provider'); }); }); //# sourceMappingURL=base.test.js.map