judgeval 0.1.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/LICENSE.md +202 -0
  2. package/README.md +340 -0
  3. package/dist/clients.d.ts +7 -0
  4. package/dist/clients.js +78 -0
  5. package/dist/clients.js.map +1 -0
  6. package/dist/common/integrations/langgraph.d.ts +40 -0
  7. package/dist/common/integrations/langgraph.js +444 -0
  8. package/dist/common/integrations/langgraph.js.map +1 -0
  9. package/dist/common/logger-instance.d.ts +3 -0
  10. package/dist/common/logger-instance.js +64 -0
  11. package/dist/common/logger-instance.js.map +1 -0
  12. package/dist/common/logger.d.ts +54 -0
  13. package/dist/common/logger.js +221 -0
  14. package/dist/common/logger.js.map +1 -0
  15. package/dist/common/tracer.d.ts +205 -0
  16. package/dist/common/tracer.js +1035 -0
  17. package/dist/common/tracer.js.map +1 -0
  18. package/dist/constants.d.ts +51 -0
  19. package/dist/constants.js +344 -0
  20. package/dist/constants.js.map +1 -0
  21. package/dist/data/example.d.ts +70 -0
  22. package/dist/data/example.js +125 -0
  23. package/dist/data/example.js.map +1 -0
  24. package/dist/data/result.d.ts +51 -0
  25. package/dist/data/result.js +83 -0
  26. package/dist/data/result.js.map +1 -0
  27. package/dist/evaluation-run.d.ts +44 -0
  28. package/dist/evaluation-run.js +136 -0
  29. package/dist/evaluation-run.js.map +1 -0
  30. package/dist/index.d.ts +10 -0
  31. package/dist/index.js +73 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/judgment-client.d.ts +179 -0
  34. package/dist/judgment-client.js +1038 -0
  35. package/dist/judgment-client.js.map +1 -0
  36. package/dist/rules.d.ts +120 -0
  37. package/dist/rules.js +322 -0
  38. package/dist/rules.js.map +1 -0
  39. package/dist/run-evaluation.d.ts +78 -0
  40. package/dist/run-evaluation.js +618 -0
  41. package/dist/run-evaluation.js.map +1 -0
  42. package/dist/scorers/api-scorer.d.ts +79 -0
  43. package/dist/scorers/api-scorer.js +291 -0
  44. package/dist/scorers/api-scorer.js.map +1 -0
  45. package/dist/scorers/base-scorer.d.ts +100 -0
  46. package/dist/scorers/base-scorer.js +190 -0
  47. package/dist/scorers/base-scorer.js.map +1 -0
  48. package/dist/scorers/exact-match-scorer.d.ts +10 -0
  49. package/dist/scorers/exact-match-scorer.js +84 -0
  50. package/dist/scorers/exact-match-scorer.js.map +1 -0
  51. package/package.json +88 -0
@@ -0,0 +1,618 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.assertTest = exports.runEval = exports.checkExamples = exports.checkMissingScorerData = exports.mergeResults = exports.logEvaluationResults = exports.hasLoggedUrl = exports.checkEvalRunNameExists = exports.executeApiEval = exports.pollEvaluationStatus = exports.checkEvaluationStatus = exports.sendToRabbitMQ = exports.validateApiResponse = exports.JudgmentAPIError = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const result_1 = require("./data/result");
18
+ const base_scorer_1 = require("./scorers/base-scorer");
19
+ const constants_1 = require("./constants");
20
+ const logger_1 = require("./common/logger");
21
+ /**
22
+ * Custom error for Judgment API errors
23
+ */
24
+ class JudgmentAPIError extends Error {
25
+ constructor(message) {
26
+ super(message);
27
+ this.name = 'JudgmentAPIError';
28
+ }
29
+ }
30
+ exports.JudgmentAPIError = JudgmentAPIError;
31
+ /**
32
+ * Validates an API response to ensure it has the expected format
33
+ * Throws a JudgmentAPIError if the response is invalid
34
+ */
35
+ function validateApiResponse(response) {
36
+ if (!response || typeof response !== 'object') {
37
+ throw new JudgmentAPIError('Invalid API response format: response is not an object');
38
+ }
39
+ if (response.error) {
40
+ throw new JudgmentAPIError(`API error: ${response.error}`);
41
+ }
42
+ }
43
+ exports.validateApiResponse = validateApiResponse;
44
+ /**
45
+ * Sends an evaluation run to the RabbitMQ evaluation queue
46
+ */
47
+ function sendToRabbitMQ(evaluationRun) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const payload = evaluationRun.toJSON();
50
+ try {
51
+ const response = yield axios_1.default.post(constants_1.JUDGMENT_ADD_TO_RUN_EVAL_QUEUE_API_URL, payload, {
52
+ headers: {
53
+ 'Content-Type': 'application/json',
54
+ 'Authorization': `Bearer ${evaluationRun.judgmentApiKey}`,
55
+ 'X-Organization-Id': evaluationRun.organizationId
56
+ }
57
+ });
58
+ return response.data;
59
+ }
60
+ catch (error) {
61
+ if (axios_1.default.isAxiosError(error) && error.response) {
62
+ throw new JudgmentAPIError(`Error sending to RabbitMQ: ${error.response.data.detail || error.message}`);
63
+ }
64
+ else {
65
+ throw new JudgmentAPIError(`Error sending to RabbitMQ: ${(error === null || error === void 0 ? void 0 : error.message) || String(error)}`);
66
+ }
67
+ }
68
+ });
69
+ }
70
+ exports.sendToRabbitMQ = sendToRabbitMQ;
71
+ /**
72
+ * Checks the status of an async evaluation
73
+ * @param evaluationRun The evaluation run to check
74
+ * @returns The status of the evaluation
75
+ */
76
+ function checkEvaluationStatus(evaluationRun) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ try {
79
+ const response = yield axios_1.default.post(`${constants_1.ROOT_API}/check-eval-status/`, {
80
+ eval_name: evaluationRun.evalName,
81
+ project_name: evaluationRun.projectName,
82
+ judgment_api_key: evaluationRun.judgmentApiKey,
83
+ }, {
84
+ headers: {
85
+ 'Content-Type': 'application/json',
86
+ 'Authorization': `Bearer ${evaluationRun.judgmentApiKey}`,
87
+ 'X-Organization-Id': evaluationRun.organizationId
88
+ }
89
+ });
90
+ return response.data;
91
+ }
92
+ catch (error) {
93
+ if (axios_1.default.isAxiosError(error) && error.response) {
94
+ throw new JudgmentAPIError(`Error checking evaluation status: ${error.response.data.detail || error.message}`);
95
+ }
96
+ else {
97
+ throw new JudgmentAPIError(`Error checking evaluation status: ${(error === null || error === void 0 ? void 0 : error.message) || String(error)}`);
98
+ }
99
+ }
100
+ });
101
+ }
102
+ exports.checkEvaluationStatus = checkEvaluationStatus;
103
+ /**
104
+ * Polls the status of an async evaluation until it's complete
105
+ * @param evaluationRun The evaluation run to poll
106
+ * @param intervalMs The interval between polls in milliseconds
107
+ * @param maxAttempts The maximum number of polling attempts
108
+ * @param onProgress Optional callback for progress updates
109
+ * @returns The evaluation results
110
+ */
111
+ function pollEvaluationStatus(evaluationRun_1) {
112
+ return __awaiter(this, arguments, void 0, function* (evaluationRun, intervalMs = 2000, maxAttempts = 300, onProgress) {
113
+ let attempts = 0;
114
+ while (attempts < maxAttempts) {
115
+ try {
116
+ const status = yield checkEvaluationStatus(evaluationRun);
117
+ // Call progress callback if provided
118
+ if (onProgress) {
119
+ onProgress(status);
120
+ }
121
+ // Check if evaluation is complete
122
+ if (status.status === 'complete') {
123
+ (0, logger_1.log)('Async evaluation complete, fetching results');
124
+ // Fetch the results
125
+ const response = yield axios_1.default.post(constants_1.JUDGMENT_EVAL_FETCH_API_URL, {
126
+ eval_name: evaluationRun.evalName,
127
+ project_name: evaluationRun.projectName,
128
+ judgment_api_key: evaluationRun.judgmentApiKey,
129
+ }, {
130
+ headers: {
131
+ 'Content-Type': 'application/json',
132
+ 'Authorization': `Bearer ${evaluationRun.judgmentApiKey}`,
133
+ 'X-Organization-Id': evaluationRun.organizationId
134
+ }
135
+ });
136
+ // Convert API results to ScoringResult objects
137
+ const results = response.data.map((result) => {
138
+ return new result_1.ScoringResult({
139
+ dataObject: result.data_object,
140
+ scorersData: result.scorers_data || [],
141
+ error: result.error
142
+ });
143
+ });
144
+ return results;
145
+ }
146
+ else if (status.status === 'failed') {
147
+ throw new JudgmentAPIError(`Async evaluation failed: ${status.error || 'Unknown error'}`);
148
+ }
149
+ // Log progress
150
+ (0, logger_1.log)(`Evaluation status: ${status.status}, progress: ${status.progress || 'unknown'}`);
151
+ // Wait before next poll
152
+ yield new Promise(resolve => setTimeout(resolve, intervalMs));
153
+ attempts++;
154
+ }
155
+ catch (error) {
156
+ (0, logger_1.error)(`Error polling evaluation status: ${(error === null || error === void 0 ? void 0 : error.message) || String(error)}`);
157
+ throw new JudgmentAPIError(`Error polling evaluation status: ${(error === null || error === void 0 ? void 0 : error.message) || String(error)}`);
158
+ }
159
+ }
160
+ throw new JudgmentAPIError(`Evaluation polling timed out after ${maxAttempts} attempts`);
161
+ });
162
+ }
163
+ exports.pollEvaluationStatus = pollEvaluationStatus;
164
+ /**
165
+ * Executes an evaluation of a list of Examples using one or more JudgmentScorers via the Judgment API
166
+ * @param evaluationRun The evaluation run object containing the examples, scorers, and metadata
167
+ * @returns The results of the evaluation
168
+ */
169
+ function executeApiEval(evaluationRun) {
170
+ return __awaiter(this, void 0, void 0, function* () {
171
+ var _a;
172
+ try {
173
+ // Submit API request to execute evals
174
+ const payload = evaluationRun.toJSON();
175
+ const response = yield axios_1.default.post(constants_1.JUDGMENT_EVAL_API_URL, payload, {
176
+ headers: {
177
+ 'Content-Type': 'application/json',
178
+ 'Authorization': `Bearer ${evaluationRun.judgmentApiKey}`,
179
+ 'X-Organization-Id': evaluationRun.organizationId
180
+ }
181
+ });
182
+ return response.data;
183
+ }
184
+ catch (error) {
185
+ if (axios_1.default.isAxiosError(error) && error.response) {
186
+ const errorMessage = ((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.detail) || JSON.stringify(error.response.data) || 'An unknown error occurred.';
187
+ (0, logger_1.error)(`Error: ${errorMessage}`);
188
+ throw new JudgmentAPIError(errorMessage);
189
+ }
190
+ else {
191
+ (0, logger_1.error)(`Error: ${error}`);
192
+ throw new JudgmentAPIError(`An error occurred while executing the Judgment API request: ${error}`);
193
+ }
194
+ }
195
+ });
196
+ }
197
+ exports.executeApiEval = executeApiEval;
198
+ /**
199
+ * Checks if an evaluation run name already exists for a given project
200
+ */
201
+ function checkEvalRunNameExists(evalName, projectName, judgmentApiKey, organizationId) {
202
+ return __awaiter(this, void 0, void 0, function* () {
203
+ try {
204
+ const response = yield axios_1.default.post(`${constants_1.ROOT_API}/eval-run-name-exists/`, {
205
+ eval_name: evalName,
206
+ project_name: projectName,
207
+ judgment_api_key: judgmentApiKey,
208
+ }, {
209
+ headers: {
210
+ 'Content-Type': 'application/json',
211
+ 'Authorization': `Bearer ${judgmentApiKey}`,
212
+ 'X-Organization-Id': organizationId
213
+ }
214
+ });
215
+ // Check if the evaluation run name already exists
216
+ if (response.status === 409) {
217
+ throw new JudgmentAPIError(`Evaluation run name '${evalName}' already exists for project '${projectName}'.`);
218
+ }
219
+ // Check if the response status code is not 2XX
220
+ if (!response.status.toString().startsWith('2')) {
221
+ const responseData = response.data;
222
+ const errorMessage = responseData.detail || 'An unknown error occurred.';
223
+ (0, logger_1.error)(`Error checking eval run name: ${errorMessage}`);
224
+ throw new JudgmentAPIError(errorMessage);
225
+ }
226
+ }
227
+ catch (error) {
228
+ if (axios_1.default.isAxiosError(error) && error.response) {
229
+ if (error.response.status === 409) {
230
+ throw new JudgmentAPIError(`Evaluation run name '${evalName}' already exists for project '${projectName}'.`);
231
+ }
232
+ }
233
+ // For connection errors or other issues, log but continue
234
+ (0, logger_1.error)(`Failed to check if eval run name exists: ${(error === null || error === void 0 ? void 0 : error.message) || String(error)}`);
235
+ // Don't throw an error here, just log it and continue
236
+ }
237
+ });
238
+ }
239
+ exports.checkEvalRunNameExists = checkEvalRunNameExists;
240
+ // Track whether a URL has been printed
241
+ exports.hasLoggedUrl = false;
242
+ /**
243
+ * Logs evaluation results to the Judgment API database.
244
+ * @param results The results to log
245
+ * @param projectName The project name
246
+ * @param evalName The evaluation run name
247
+ * @param apiKey The API key for the Judgment API
248
+ * @param organizationId The organization ID
249
+ * @returns A URL to view the results in the Judgment UI
250
+ */
251
+ function logEvaluationResults(results_1, projectName_1, evalName_1) {
252
+ return __awaiter(this, arguments, void 0, function* (results, projectName, evalName, apiKey = '', organizationId) {
253
+ var _a;
254
+ try {
255
+ const response = yield axios_1.default.post(constants_1.JUDGMENT_EVAL_LOG_API_URL, {
256
+ results: results.map(result => result.toJSON()),
257
+ project_name: projectName,
258
+ eval_name: evalName,
259
+ }, {
260
+ headers: {
261
+ 'Content-Type': 'application/json',
262
+ 'Authorization': `Bearer ${apiKey}`,
263
+ 'X-Organization-Id': organizationId
264
+ }
265
+ });
266
+ if (response.status < 200 || response.status >= 300) {
267
+ const responseData = response.data;
268
+ const errorMessage = (responseData === null || responseData === void 0 ? void 0 : responseData.detail) || 'An unknown error occurred.';
269
+ (0, logger_1.error)(`Error ${response.status}: ${errorMessage}`);
270
+ throw new JudgmentAPIError(errorMessage);
271
+ }
272
+ if (response.data && response.data.ui_results_url) {
273
+ const url = response.data.ui_results_url;
274
+ const prettyStr = `\n \n🔍 You can view your evaluation results here: ${url}\n`;
275
+ console.log(prettyStr);
276
+ exports.hasLoggedUrl = true;
277
+ return url;
278
+ }
279
+ return '';
280
+ }
281
+ catch (error) {
282
+ if (axios_1.default.isAxiosError(error) && error.response) {
283
+ const errorMessage = ((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.detail) || JSON.stringify(error.response.data) || 'An unknown error occurred.';
284
+ (0, logger_1.error)(`Error: ${errorMessage}`);
285
+ throw new JudgmentAPIError(errorMessage);
286
+ }
287
+ else {
288
+ (0, logger_1.error)(`Error: ${error}`);
289
+ throw new JudgmentAPIError(`An error occurred while logging evaluation results: ${error}`);
290
+ }
291
+ }
292
+ });
293
+ }
294
+ exports.logEvaluationResults = logEvaluationResults;
295
+ /**
296
+ * When executing scorers that come from both the Judgment API and local scorers, we're left with
297
+ * results for each type of scorer. This function merges the results from the API and local evaluations,
298
+ * grouped by example.
299
+ */
300
+ function mergeResults(apiResults, localResults) {
301
+ // No merge required
302
+ if (!localResults.length && apiResults.length) {
303
+ return apiResults;
304
+ }
305
+ if (!apiResults.length && localResults.length) {
306
+ return localResults;
307
+ }
308
+ if (apiResults.length !== localResults.length) {
309
+ // Results should be of same length because each ScoringResult is a 1-1 mapping to an Example
310
+ throw new Error(`The number of API and local results do not match: ${apiResults.length} vs ${localResults.length}`);
311
+ }
312
+ // Each ScoringResult in api and local have all the same fields besides `scorersData`
313
+ for (let i = 0; i < apiResults.length; i++) {
314
+ const apiResult = apiResults[i];
315
+ const localResult = localResults[i];
316
+ if (!apiResult.dataObject || !localResult.dataObject) {
317
+ throw new Error('Data object is null in one of the results.');
318
+ }
319
+ // Verify the results are aligned
320
+ if (apiResult.dataObject.input !== localResult.dataObject.input ||
321
+ apiResult.dataObject.actualOutput !== localResult.dataObject.actualOutput ||
322
+ apiResult.dataObject.expectedOutput !== localResult.dataObject.expectedOutput) {
323
+ throw new Error('The API and local results are not aligned.');
324
+ }
325
+ // Merge ScorerData from the API and local scorers together
326
+ const apiScorerData = apiResult.scorersData;
327
+ const localScorerData = localResult.scorersData;
328
+ if (!apiScorerData && localScorerData) {
329
+ apiResult.scorersData = localScorerData;
330
+ }
331
+ else if (apiScorerData && localScorerData) {
332
+ apiResult.scorersData = [...apiScorerData, ...localScorerData];
333
+ }
334
+ }
335
+ return apiResults;
336
+ }
337
+ exports.mergeResults = mergeResults;
338
+ /**
339
+ * Checks if any ScoringResult objects are missing scorersData
340
+ */
341
+ function checkMissingScorerData(results) {
342
+ var _a;
343
+ for (let i = 0; i < results.length; i++) {
344
+ if (!results[i].scorersData || ((_a = results[i].scorersData) === null || _a === void 0 ? void 0 : _a.length) === 0) {
345
+ (0, logger_1.error)(`Scorer data is missing for example ${i}. ` +
346
+ 'This is usually caused when the example does not contain ' +
347
+ 'the fields required by the scorer. ' +
348
+ 'Check that your example contains the fields required by the scorers.');
349
+ }
350
+ }
351
+ return results;
352
+ }
353
+ exports.checkMissingScorerData = checkMissingScorerData;
354
+ /**
355
+ * Checks if the example contains the necessary parameters for the scorer
356
+ */
357
+ function checkExamples(examples, scorers) {
358
+ for (const scorer of scorers) {
359
+ for (const example of examples) {
360
+ // Check for required fields based on scorer type
361
+ switch (scorer.scoreType) {
362
+ case 'answer_correctness':
363
+ case 'answer_relevancy':
364
+ if (!example.expectedOutput) {
365
+ (0, logger_1.warn)(`Scorer ${scorer.scoreType} requires expectedOutput field`);
366
+ }
367
+ break;
368
+ case 'contextual_precision':
369
+ case 'contextual_recall':
370
+ case 'contextual_relevancy':
371
+ if (!example.context || example.context.length === 0) {
372
+ (0, logger_1.warn)(`Scorer ${scorer.scoreType} requires context field`);
373
+ }
374
+ break;
375
+ case 'execution_order':
376
+ if (!example.expectedTools || example.expectedTools.length === 0) {
377
+ (0, logger_1.warn)(`Scorer ${scorer.scoreType} requires expectedTools field`);
378
+ }
379
+ break;
380
+ // Add more checks for other scorer types as needed
381
+ }
382
+ }
383
+ }
384
+ }
385
+ exports.checkExamples = checkExamples;
386
+ /**
387
+ * Executes an evaluation of Examples using one or more Scorers
388
+ */
389
+ function runEval(evaluationRun_1) {
390
+ return __awaiter(this, arguments, void 0, function* (evaluationRun, override = false, ignoreErrors = true, asyncExecution = false) {
391
+ // Check if the evaluation run name already exists
392
+ // This prevents accidentally overwriting existing evaluation results
393
+ if (!override && evaluationRun.logResults) {
394
+ yield checkEvalRunNameExists(evaluationRun.evalName || '', evaluationRun.projectName || '', evaluationRun.judgmentApiKey || '', evaluationRun.organizationId || '');
395
+ }
396
+ // --- Set example IDs and timestamps if not already set ---
397
+ // This is important for tracking and debugging purposes
398
+ (0, logger_1.log)("Initializing examples with IDs and timestamps");
399
+ evaluationRun.examples.forEach((example, idx) => {
400
+ example.exampleIndex = idx; // Set numeric index
401
+ example.timestamp = new Date().toISOString().replace(/[-:]/g, '').split('.')[0];
402
+ (0, logger_1.log)(`Initialized example ${example.exampleId} (index: ${example.exampleIndex})`);
403
+ (0, logger_1.log)(`Input: ${example.input}`);
404
+ (0, logger_1.log)(`Actual output: ${example.actualOutput || ''}`);
405
+ if (example.expectedOutput) {
406
+ (0, logger_1.log)(`Expected output: ${example.expectedOutput}`);
407
+ }
408
+ if (example.context) {
409
+ (0, logger_1.log)(`Context: ${example.context}`);
410
+ }
411
+ });
412
+ (0, logger_1.log)(`Starting evaluation run with ${evaluationRun.examples.length} examples`);
413
+ // --- Split scorers into API and local ---
414
+ // API scorers run on the Judgment API server
415
+ // Local scorers run in this process
416
+ (0, logger_1.log)("Grouping scorers by type");
417
+ const apiScorers = [];
418
+ const localScorers = [];
419
+ evaluationRun.scorers.forEach(scorer => {
420
+ if (scorer instanceof base_scorer_1.APIJudgmentScorer) {
421
+ apiScorers.push(scorer);
422
+ (0, logger_1.log)(`Added judgment scorer: ${scorer.constructor.name}`);
423
+ }
424
+ else {
425
+ localScorers.push(scorer);
426
+ (0, logger_1.log)(`Added local scorer: ${scorer.constructor.name}`);
427
+ }
428
+ });
429
+ (0, logger_1.log)(`Found ${apiScorers.length} judgment scorers and ${localScorers.length} local scorers`);
430
+ let apiResults = [];
431
+ let localResults = [];
432
+ // --- Handle async execution ---
433
+ // This allows evaluations to run in the background without blocking
434
+ // Useful for large-scale evaluations that might take a long time
435
+ if (asyncExecution) {
436
+ checkExamples(evaluationRun.examples, evaluationRun.scorers);
437
+ (0, logger_1.log)("Starting async evaluation");
438
+ // Add the evaluation to the RabbitMQ queue for async processing
439
+ // The server will pick it up and process it in the background
440
+ try {
441
+ yield axios_1.default.post(constants_1.JUDGMENT_ADD_TO_RUN_EVAL_QUEUE_API_URL, evaluationRun.toJSON(), {
442
+ headers: {
443
+ 'Content-Type': 'application/json',
444
+ 'Authorization': `Bearer ${evaluationRun.judgmentApiKey}`,
445
+ 'X-Organization-Id': evaluationRun.organizationId
446
+ }
447
+ });
448
+ (0, logger_1.info)("Successfully added evaluation to queue");
449
+ }
450
+ catch (error) {
451
+ // Log the error but don't throw it - this matches Python SDK behavior
452
+ // Combine error message into the first argument
453
+ (0, logger_1.error)(`Error adding evaluation to queue: ${error instanceof Error ? error.message : String(error)}`);
454
+ // Always print success message to match Python SDK behavior
455
+ // This is important because the Python SDK always prints this message
456
+ // even when there's an error connecting to RabbitMQ
457
+ (0, logger_1.info)("Successfully added evaluation to queue (Note: Previous error occurred)");
458
+ }
459
+ // Return empty results for async execution
460
+ // The results will be available later via the UI or API
461
+ return [];
462
+ }
463
+ else {
464
+ // --- Execute API scorers ---
465
+ // These run on the Judgment API server
466
+ if (apiScorers.length > 0) {
467
+ try {
468
+ (0, logger_1.log)('Executing API evaluation...');
469
+ const apiResponseData = yield executeApiEval(evaluationRun);
470
+ // Create ScoringResult objects from API response
471
+ // Check if the response has a results field (matching Python SDK format)
472
+ const resultsData = apiResponseData && typeof apiResponseData === 'object' && 'results' in apiResponseData
473
+ ? apiResponseData.results
474
+ : apiResponseData;
475
+ apiResults = resultsData.map((result) => {
476
+ // If the result is already a ScoringResult, return it directly
477
+ if (result instanceof result_1.ScoringResult) {
478
+ return result;
479
+ }
480
+ // Otherwise, create a new ScoringResult from the result data
481
+ return new result_1.ScoringResult({
482
+ dataObject: result.data_object,
483
+ scorersData: result.scorers_data,
484
+ error: result.error
485
+ });
486
+ });
487
+ (0, logger_1.log)(`API evaluation complete with ${apiResults.length} results`);
488
+ }
489
+ catch (error) {
490
+ (0, logger_1.error)(`Error executing API evaluation: ${error}`);
491
+ if (!ignoreErrors) {
492
+ throw error;
493
+ }
494
+ }
495
+ }
496
+ // --- Execute local scorers ---
497
+ // These run in this process
498
+ if (localScorers.length > 0) {
499
+ (0, logger_1.log)('Starting local evaluation');
500
+ try {
501
+ // Process each example with each local scorer
502
+ localResults = yield Promise.all(evaluationRun.examples.map((example) => __awaiter(this, void 0, void 0, function* () {
503
+ const scorersData = [];
504
+ // Run each local scorer on the example
505
+ for (const scorer of localScorers) {
506
+ try {
507
+ (0, logger_1.log)(`Running local scorer ${scorer.type} on example ${example.exampleId}`);
508
+ const scorerData = yield scorer.scoreExample(example);
509
+ scorersData.push(scorerData);
510
+ (0, logger_1.log)(`Scorer ${scorer.type} result: score=${scorerData.score}, success=${scorerData.success}`);
511
+ }
512
+ catch (scorerError) {
513
+ (0, logger_1.error)(`Error running scorer ${scorer.type} on example ${example.exampleId}: ${(scorerError === null || scorerError === void 0 ? void 0 : scorerError.message) || String(scorerError)}`);
514
+ // Add failed scorer data
515
+ scorersData.push({
516
+ name: scorer.type,
517
+ threshold: scorer.threshold,
518
+ success: false,
519
+ score: 0,
520
+ reason: null,
521
+ strict_mode: null,
522
+ evaluation_model: null,
523
+ error: (scorerError === null || scorerError === void 0 ? void 0 : scorerError.message) || String(scorerError),
524
+ evaluation_cost: null,
525
+ verbose_logs: null,
526
+ additional_metadata: scorer.additional_metadata || {}
527
+ });
528
+ }
529
+ }
530
+ // Create a ScoringResult with all scorer data for this example
531
+ return new result_1.ScoringResult({
532
+ dataObject: example,
533
+ scorersData: scorersData,
534
+ error: undefined
535
+ });
536
+ })));
537
+ (0, logger_1.log)(`Local evaluation complete with ${localResults.length} results`);
538
+ }
539
+ catch (error) {
540
+ (0, logger_1.error)(`Error executing local evaluation: ${(error === null || error === void 0 ? void 0 : error.message) || String(error)}`);
541
+ if (!ignoreErrors) {
542
+ throw error;
543
+ }
544
+ // Create empty results with errors if ignoring errors
545
+ localResults = evaluationRun.examples.map(example => {
546
+ return new result_1.ScoringResult({
547
+ dataObject: example,
548
+ scorersData: [],
549
+ error: error === null || error === void 0 ? void 0 : error.message
550
+ });
551
+ });
552
+ }
553
+ }
554
+ // --- Merge results from API and local scorers ---
555
+ // This combines the results from both types of scorers
556
+ // Align with Python - only record content and usage base
557
+ (0, logger_1.log)('Merging API and local results');
558
+ const mergedResults = mergeResults(apiResults, localResults);
559
+ // Check for missing scorer data
560
+ // This helps identify examples that couldn't be evaluated
561
+ const checkedResults = checkMissingScorerData(mergedResults);
562
+ (0, logger_1.log)(`Successfully merged ${checkedResults.length} results`);
563
+ // --- Log results to Judgment API if requested ---
564
+ // This saves the results to the database for later viewing
565
+ if (evaluationRun.logResults) {
566
+ try {
567
+ const url = yield logEvaluationResults(checkedResults, evaluationRun.projectName || '', evaluationRun.evalName || '', evaluationRun.judgmentApiKey || '', evaluationRun.organizationId || '');
568
+ (0, logger_1.log)(`Results logged to Judgment API: ${url}`);
569
+ }
570
+ catch (error) {
571
+ (0, logger_1.error)(`Error logging evaluation results: ${(error === null || error === void 0 ? void 0 : error.message) || String(error)}`);
572
+ if (!ignoreErrors) {
573
+ throw error;
574
+ }
575
+ }
576
+ }
577
+ // --- Check for examples with no scorer data ---
578
+ // This helps identify examples that couldn't be evaluated
579
+ for (let i = 0; i < checkedResults.length; i++) {
580
+ const result = checkedResults[i];
581
+ if (!result.scorersData || result.scorersData.length === 0) {
582
+ (0, logger_1.log)(`None of the scorers could be executed on example ${i}. This is usually because the Example is missing the fields needed by the scorers. Try checking that the Example has the necessary fields for your scorers.`);
583
+ }
584
+ }
585
+ return checkedResults;
586
+ }
587
+ });
588
+ }
589
+ exports.runEval = runEval;
590
+ /**
591
+ * Collects all failed scorers from the scoring results
592
+ * Raises exceptions for any failed test cases
593
+ */
594
+ function assertTest(scoringResults) {
595
+ var _a;
596
+ const failedTests = [];
597
+ for (const result of scoringResults) {
598
+ if (result.error) {
599
+ failedTests.push(`Error in result: ${result.error}`);
600
+ continue;
601
+ }
602
+ if (!result.scorersData || ((_a = result.scorersData) === null || _a === void 0 ? void 0 : _a.length) === 0) {
603
+ failedTests.push('No scorer data found in result');
604
+ continue;
605
+ }
606
+ for (const scorerData of result.scorersData) {
607
+ if (!scorerData.success) {
608
+ failedTests.push(`Test failed: ${scorerData.name} with score ${scorerData.score} ` +
609
+ `(threshold: ${scorerData.threshold})`);
610
+ }
611
+ }
612
+ }
613
+ if (failedTests.length > 0) {
614
+ throw new Error(`Test assertion failed:\n${failedTests.join('\n')}`);
615
+ }
616
+ }
617
+ exports.assertTest = assertTest;
618
+ //# sourceMappingURL=run-evaluation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-evaluation.js","sourceRoot":"","sources":["../src/run-evaluation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kDAA0B;AAG1B,0CAA0D;AAC1D,uDAA0E;AAC1E,2CAOqB;AACrB,4CAAiH;AAEjH;;GAEG;AACH,MAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AALD,4CAKC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,QAAa;IAC/C,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC9C,MAAM,IAAI,gBAAgB,CAAC,wDAAwD,CAAC,CAAC;IACvF,CAAC;IAED,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,MAAM,IAAI,gBAAgB,CAAC,cAAc,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC;AARD,kDAQC;AAED;;GAEG;AACH,SAAsB,cAAc,CAAC,aAA4B;;QAC/D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC;QACvC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,kDAAsC,EACtC,OAAO,EACP;gBACE,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,eAAe,EAAE,UAAU,aAAa,CAAC,cAAc,EAAE;oBACzD,mBAAmB,EAAE,aAAa,CAAC,cAAc;iBAClD;aACF,CACF,CAAC;YACF,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,eAAK,CAAC,YAAY,CAAC,KA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