@chanl/scorecards-core 0.4.0
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.
- package/LICENSE +21 -0
- package/dist/dto/create-scorecard-category.dto.d.ts +7 -0
- package/dist/dto/create-scorecard-category.dto.d.ts.map +1 -0
- package/dist/dto/create-scorecard-category.dto.js +38 -0
- package/dist/dto/create-scorecard-category.dto.js.map +1 -0
- package/dist/dto/create-scorecard-criteria.dto.d.ts +11 -0
- package/dist/dto/create-scorecard-criteria.dto.d.ts.map +1 -0
- package/dist/dto/create-scorecard-criteria.dto.js +63 -0
- package/dist/dto/create-scorecard-criteria.dto.js.map +1 -0
- package/dist/dto/create-scorecard-result.dto.d.ts +8 -0
- package/dist/dto/create-scorecard-result.dto.d.ts.map +1 -0
- package/dist/dto/create-scorecard-result.dto.js +41 -0
- package/dist/dto/create-scorecard-result.dto.js.map +1 -0
- package/dist/dto/create-scorecard.dto.d.ts +9 -0
- package/dist/dto/create-scorecard.dto.d.ts.map +1 -0
- package/dist/dto/create-scorecard.dto.js +54 -0
- package/dist/dto/create-scorecard.dto.js.map +1 -0
- package/dist/dto/index.d.ts +8 -0
- package/dist/dto/index.d.ts.map +1 -0
- package/dist/dto/index.js +18 -0
- package/dist/dto/index.js.map +1 -0
- package/dist/dto/update-scorecard-category.dto.d.ts +6 -0
- package/dist/dto/update-scorecard-category.dto.d.ts.map +1 -0
- package/dist/dto/update-scorecard-category.dto.js +9 -0
- package/dist/dto/update-scorecard-category.dto.js.map +1 -0
- package/dist/dto/update-scorecard-criteria.dto.d.ts +6 -0
- package/dist/dto/update-scorecard-criteria.dto.d.ts.map +1 -0
- package/dist/dto/update-scorecard-criteria.dto.js +9 -0
- package/dist/dto/update-scorecard-criteria.dto.js.map +1 -0
- package/dist/dto/update-scorecard.dto.d.ts +6 -0
- package/dist/dto/update-scorecard.dto.d.ts.map +1 -0
- package/dist/dto/update-scorecard.dto.js +9 -0
- package/dist/dto/update-scorecard.dto.js.map +1 -0
- package/dist/evaluation/evaluation.service.d.ts +35 -0
- package/dist/evaluation/evaluation.service.d.ts.map +1 -0
- package/dist/evaluation/evaluation.service.js +225 -0
- package/dist/evaluation/evaluation.service.js.map +1 -0
- package/dist/evaluation/index.d.ts +2 -0
- package/dist/evaluation/index.d.ts.map +1 -0
- package/dist/evaluation/index.js +6 -0
- package/dist/evaluation/index.js.map +1 -0
- package/dist/handlers/conversation-completeness.handler.d.ts +7 -0
- package/dist/handlers/conversation-completeness.handler.d.ts.map +1 -0
- package/dist/handlers/conversation-completeness.handler.js +74 -0
- package/dist/handlers/conversation-completeness.handler.js.map +1 -0
- package/dist/handlers/criteria-handler-registry.d.ts +12 -0
- package/dist/handlers/criteria-handler-registry.d.ts.map +1 -0
- package/dist/handlers/criteria-handler-registry.js +45 -0
- package/dist/handlers/criteria-handler-registry.js.map +1 -0
- package/dist/handlers/criteria-handler.interface.d.ts +81 -0
- package/dist/handlers/criteria-handler.interface.d.ts.map +1 -0
- package/dist/handlers/criteria-handler.interface.js +3 -0
- package/dist/handlers/criteria-handler.interface.js.map +1 -0
- package/dist/handlers/hallucination.handler.d.ts +7 -0
- package/dist/handlers/hallucination.handler.d.ts.map +1 -0
- package/dist/handlers/hallucination.handler.js +86 -0
- package/dist/handlers/hallucination.handler.js.map +1 -0
- package/dist/handlers/index.d.ts +13 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +29 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/keyword.handler.d.ts +7 -0
- package/dist/handlers/keyword.handler.d.ts.map +1 -0
- package/dist/handlers/keyword.handler.js +64 -0
- package/dist/handlers/keyword.handler.js.map +1 -0
- package/dist/handlers/knowledge-retention.handler.d.ts +7 -0
- package/dist/handlers/knowledge-retention.handler.d.ts.map +1 -0
- package/dist/handlers/knowledge-retention.handler.js +74 -0
- package/dist/handlers/knowledge-retention.handler.js.map +1 -0
- package/dist/handlers/prompt.handler.d.ts +7 -0
- package/dist/handlers/prompt.handler.d.ts.map +1 -0
- package/dist/handlers/prompt.handler.js +77 -0
- package/dist/handlers/prompt.handler.js.map +1 -0
- package/dist/handlers/rag-faithfulness.handler.d.ts +7 -0
- package/dist/handlers/rag-faithfulness.handler.d.ts.map +1 -0
- package/dist/handlers/rag-faithfulness.handler.js +110 -0
- package/dist/handlers/rag-faithfulness.handler.js.map +1 -0
- package/dist/handlers/response-time.handler.d.ts +7 -0
- package/dist/handlers/response-time.handler.d.ts.map +1 -0
- package/dist/handlers/response-time.handler.js +56 -0
- package/dist/handlers/response-time.handler.js.map +1 -0
- package/dist/handlers/role-adherence.handler.d.ts +7 -0
- package/dist/handlers/role-adherence.handler.d.ts.map +1 -0
- package/dist/handlers/role-adherence.handler.js +74 -0
- package/dist/handlers/role-adherence.handler.js.map +1 -0
- package/dist/handlers/scoring-utils.d.ts +10 -0
- package/dist/handlers/scoring-utils.d.ts.map +1 -0
- package/dist/handlers/scoring-utils.js +88 -0
- package/dist/handlers/scoring-utils.js.map +1 -0
- package/dist/handlers/tool-call.handler.d.ts +7 -0
- package/dist/handlers/tool-call.handler.d.ts.map +1 -0
- package/dist/handlers/tool-call.handler.js +43 -0
- package/dist/handlers/tool-call.handler.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +23 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/scorecard-category.schema.d.ts +20 -0
- package/dist/schemas/scorecard-category.schema.d.ts.map +1 -0
- package/dist/schemas/scorecard-category.schema.js +83 -0
- package/dist/schemas/scorecard-category.schema.js.map +1 -0
- package/dist/schemas/scorecard-criteria.schema.d.ts +92 -0
- package/dist/schemas/scorecard-criteria.schema.d.ts.map +1 -0
- package/dist/schemas/scorecard-criteria.schema.js +153 -0
- package/dist/schemas/scorecard-criteria.schema.js.map +1 -0
- package/dist/schemas/scorecard-result.schema.d.ts +47 -0
- package/dist/schemas/scorecard-result.schema.d.ts.map +1 -0
- package/dist/schemas/scorecard-result.schema.js +96 -0
- package/dist/schemas/scorecard-result.schema.js.map +1 -0
- package/dist/schemas/scorecard.schema.d.ts +21 -0
- package/dist/schemas/scorecard.schema.d.ts.map +1 -0
- package/dist/schemas/scorecard.schema.js +90 -0
- package/dist/schemas/scorecard.schema.js.map +1 -0
- package/dist/scorecards.controller.d.ts +104 -0
- package/dist/scorecards.controller.d.ts.map +1 -0
- package/dist/scorecards.controller.js +366 -0
- package/dist/scorecards.controller.js.map +1 -0
- package/dist/scorecards.module.d.ts +3 -0
- package/dist/scorecards.module.d.ts.map +1 -0
- package/dist/scorecards.module.js +59 -0
- package/dist/scorecards.module.js.map +1 -0
- package/dist/scorecards.service.d.ts +89 -0
- package/dist/scorecards.service.d.ts.map +1 -0
- package/dist/scorecards.service.js +587 -0
- package/dist/scorecards.service.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var EvaluationService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.EvaluationService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
19
|
+
const mongoose_2 = require("mongoose");
|
|
20
|
+
const schemas_1 = require("../schemas");
|
|
21
|
+
const handlers_1 = require("../handlers");
|
|
22
|
+
let EvaluationService = EvaluationService_1 = class EvaluationService {
|
|
23
|
+
constructor(scorecardModel, categoryModel, criteriaModel, resultModel, handlerRegistry) {
|
|
24
|
+
this.scorecardModel = scorecardModel;
|
|
25
|
+
this.categoryModel = categoryModel;
|
|
26
|
+
this.criteriaModel = criteriaModel;
|
|
27
|
+
this.resultModel = resultModel;
|
|
28
|
+
this.handlerRegistry = handlerRegistry;
|
|
29
|
+
this.logger = new common_1.Logger(EvaluationService_1.name);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Evaluate a transcript against a scorecard.
|
|
33
|
+
*/
|
|
34
|
+
async evaluate(scorecardId, context, options = {}) {
|
|
35
|
+
const startTime = Date.now();
|
|
36
|
+
// 1. Load scorecard
|
|
37
|
+
const scorecard = await this.scorecardModel.findById(scorecardId);
|
|
38
|
+
if (!scorecard) {
|
|
39
|
+
throw new Error(`Scorecard ${scorecardId} not found`);
|
|
40
|
+
}
|
|
41
|
+
// 2. Load categories and active criteria
|
|
42
|
+
const objectId = new mongoose_2.Types.ObjectId(scorecardId);
|
|
43
|
+
const categories = await this.categoryModel
|
|
44
|
+
.find({ scorecardId: objectId })
|
|
45
|
+
.sort({ order: 1 });
|
|
46
|
+
const allCriteria = await this.criteriaModel
|
|
47
|
+
.find({ scorecardId: objectId, isActive: true });
|
|
48
|
+
if (allCriteria.length === 0) {
|
|
49
|
+
throw new Error(`Scorecard ${scorecardId} has no active criteria`);
|
|
50
|
+
}
|
|
51
|
+
// 3. Create result record with status='processing'
|
|
52
|
+
const result = await this.resultModel.create({
|
|
53
|
+
scorecardId,
|
|
54
|
+
callId: options.callId,
|
|
55
|
+
agentId: options.agentId,
|
|
56
|
+
scenarioExecutionId: options.scenarioExecutionId,
|
|
57
|
+
status: 'processing',
|
|
58
|
+
criteriaResults: [],
|
|
59
|
+
categoryScores: {},
|
|
60
|
+
});
|
|
61
|
+
try {
|
|
62
|
+
// 4. Evaluate each criterion
|
|
63
|
+
const criteriaResults = [];
|
|
64
|
+
for (const criterion of allCriteria) {
|
|
65
|
+
const handler = this.handlerRegistry.get(criterion.type);
|
|
66
|
+
if (!handler) {
|
|
67
|
+
this.logger.warn(`No handler for criteria type: ${criterion.type}, skipping ${criterion.key}`);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const category = categories.find((c) => c._id?.toString() === criterion.categoryId?.toString());
|
|
71
|
+
try {
|
|
72
|
+
const handlerResult = await handler.evaluate(criterion, context);
|
|
73
|
+
criteriaResults.push({
|
|
74
|
+
criteriaId: criterion._id?.toString() || '',
|
|
75
|
+
criteriaKey: criterion.key,
|
|
76
|
+
criteriaVersion: criterion.version,
|
|
77
|
+
categoryId: criterion.categoryId?.toString() || '',
|
|
78
|
+
categoryVersion: category?.version || 1,
|
|
79
|
+
categoryName: category?.name,
|
|
80
|
+
criteriaName: criterion.name,
|
|
81
|
+
result: handlerResult.result,
|
|
82
|
+
passed: handlerResult.passed,
|
|
83
|
+
reasoning: handlerResult.reasoning,
|
|
84
|
+
evidence: handlerResult.evidence,
|
|
85
|
+
...(handlerResult.notApplicable ? { notApplicable: true } : {}),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
this.logger.error(`Error evaluating ${criterion.key}: ${error.message}`);
|
|
90
|
+
criteriaResults.push({
|
|
91
|
+
criteriaId: criterion._id?.toString() || '',
|
|
92
|
+
criteriaKey: criterion.key,
|
|
93
|
+
criteriaVersion: criterion.version,
|
|
94
|
+
categoryId: criterion.categoryId?.toString() || '',
|
|
95
|
+
categoryVersion: category?.version || 1,
|
|
96
|
+
categoryName: category?.name,
|
|
97
|
+
criteriaName: criterion.name,
|
|
98
|
+
result: null,
|
|
99
|
+
passed: false,
|
|
100
|
+
reasoning: `Evaluation error: ${error.message}`,
|
|
101
|
+
evidence: [],
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// 5. Calculate category scores (average of normalized criteria scores in each category)
|
|
106
|
+
const categoryScores = {};
|
|
107
|
+
for (const category of categories) {
|
|
108
|
+
const categoryId = category._id?.toString() || '';
|
|
109
|
+
const categoryCriteria = criteriaResults.filter((cr) => cr.categoryId === categoryId);
|
|
110
|
+
if (categoryCriteria.length === 0)
|
|
111
|
+
continue;
|
|
112
|
+
const normalizedScores = categoryCriteria.map((cr) => {
|
|
113
|
+
const criterion = allCriteria.find((c) => c._id?.toString() === cr.criteriaId);
|
|
114
|
+
if (!criterion)
|
|
115
|
+
return 0;
|
|
116
|
+
return (0, handlers_1.normalizeScore)(cr.result, criterion, cr.passed);
|
|
117
|
+
});
|
|
118
|
+
const avgScore = normalizedScores.reduce((sum, s) => sum + s, 0) /
|
|
119
|
+
normalizedScores.length;
|
|
120
|
+
categoryScores[category.name] = Math.round(avgScore * 100) / 100;
|
|
121
|
+
}
|
|
122
|
+
// 6. Calculate overall score based on scoring algorithm
|
|
123
|
+
const overallScore = this.calculateOverallScore(scorecard.scoringAlgorithm, categoryScores, categories, criteriaResults);
|
|
124
|
+
// 7. Determine pass/fail
|
|
125
|
+
const passed = overallScore >= (scorecard.passingThreshold / 100) * 10;
|
|
126
|
+
// 8. Update result
|
|
127
|
+
const processingTime = Date.now() - startTime;
|
|
128
|
+
await this.resultModel.findByIdAndUpdate(result._id, {
|
|
129
|
+
status: 'completed',
|
|
130
|
+
overallScore,
|
|
131
|
+
categoryScores,
|
|
132
|
+
criteriaResults,
|
|
133
|
+
analysisMetadata: {
|
|
134
|
+
analysisType: 'automatic',
|
|
135
|
+
triggeredBy: options.scenarioExecutionId ? 'scenario' : 'endpoint',
|
|
136
|
+
processingTime,
|
|
137
|
+
transcriptLength: context.transcriptText.length,
|
|
138
|
+
criteriaCount: allCriteria.length,
|
|
139
|
+
autoScored: true,
|
|
140
|
+
scorecardVersion: String(scorecard.__v || 1),
|
|
141
|
+
analysisTimestamp: new Date(),
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
resultId: result._id?.toString() || '',
|
|
146
|
+
scorecardId,
|
|
147
|
+
overallScore,
|
|
148
|
+
categoryScores,
|
|
149
|
+
criteriaResults,
|
|
150
|
+
status: 'completed',
|
|
151
|
+
passed,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
this.logger.error(`Evaluation failed: ${error.message}`, error.stack);
|
|
156
|
+
await this.resultModel.findByIdAndUpdate(result._id, {
|
|
157
|
+
status: 'failed',
|
|
158
|
+
errorMessage: error.message,
|
|
159
|
+
});
|
|
160
|
+
return {
|
|
161
|
+
resultId: result._id?.toString() || '',
|
|
162
|
+
scorecardId,
|
|
163
|
+
overallScore: 0,
|
|
164
|
+
categoryScores: {},
|
|
165
|
+
criteriaResults: [],
|
|
166
|
+
status: 'failed',
|
|
167
|
+
passed: false,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Calculate overall score based on the scorecard's scoring algorithm.
|
|
173
|
+
*/
|
|
174
|
+
calculateOverallScore(algorithm, categoryScores, categories, criteriaResults) {
|
|
175
|
+
const categoryNames = Object.keys(categoryScores);
|
|
176
|
+
if (categoryNames.length === 0)
|
|
177
|
+
return 0;
|
|
178
|
+
switch (algorithm) {
|
|
179
|
+
case 'weighted_average': {
|
|
180
|
+
let totalWeight = 0;
|
|
181
|
+
let weightedSum = 0;
|
|
182
|
+
for (const category of categories) {
|
|
183
|
+
const score = categoryScores[category.name];
|
|
184
|
+
if (score !== undefined) {
|
|
185
|
+
weightedSum += score * category.weight;
|
|
186
|
+
totalWeight += category.weight;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return totalWeight > 0
|
|
190
|
+
? Math.round((weightedSum / totalWeight) * 100) / 100
|
|
191
|
+
: 0;
|
|
192
|
+
}
|
|
193
|
+
case 'simple_average': {
|
|
194
|
+
const scores = Object.values(categoryScores);
|
|
195
|
+
const sum = scores.reduce((a, b) => a + b, 0);
|
|
196
|
+
return Math.round((sum / scores.length) * 100) / 100;
|
|
197
|
+
}
|
|
198
|
+
case 'minimum_all': {
|
|
199
|
+
const allPassed = criteriaResults.every((cr) => cr.passed);
|
|
200
|
+
return allPassed ? 10 : 0;
|
|
201
|
+
}
|
|
202
|
+
case 'pass_fail': {
|
|
203
|
+
const scores = Object.values(categoryScores);
|
|
204
|
+
const avg = scores.reduce((a, b) => a + b, 0) / scores.length;
|
|
205
|
+
return Math.round(avg * 100) / 100;
|
|
206
|
+
}
|
|
207
|
+
default:
|
|
208
|
+
return 0;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
exports.EvaluationService = EvaluationService;
|
|
213
|
+
exports.EvaluationService = EvaluationService = EvaluationService_1 = __decorate([
|
|
214
|
+
(0, common_1.Injectable)(),
|
|
215
|
+
__param(0, (0, mongoose_1.InjectModel)(schemas_1.Scorecard.name)),
|
|
216
|
+
__param(1, (0, mongoose_1.InjectModel)(schemas_1.ScorecardCategory.name)),
|
|
217
|
+
__param(2, (0, mongoose_1.InjectModel)(schemas_1.ScorecardCriteria.name)),
|
|
218
|
+
__param(3, (0, mongoose_1.InjectModel)(schemas_1.ScorecardResult.name)),
|
|
219
|
+
__metadata("design:paramtypes", [mongoose_2.Model,
|
|
220
|
+
mongoose_2.Model,
|
|
221
|
+
mongoose_2.Model,
|
|
222
|
+
mongoose_2.Model,
|
|
223
|
+
handlers_1.CriteriaHandlerRegistry])
|
|
224
|
+
], EvaluationService);
|
|
225
|
+
//# sourceMappingURL=evaluation.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluation.service.js","sourceRoot":"","sources":["../../src/evaluation/evaluation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,+CAA+C;AAC/C,uCAAwC;AACxC,wCAWoB;AACpB,0CAIqB;AAmBd,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAG5B,YAEE,cAAyD,EAEzD,aAAgE,EAEhE,aAAgE,EAEhE,WAA4D,EAC3C,eAAwC;QAPxC,mBAAc,GAAd,cAAc,CAA0B;QAExC,kBAAa,GAAb,aAAa,CAAkC;QAE/C,kBAAa,GAAb,aAAa,CAAkC;QAE/C,gBAAW,GAAX,WAAW,CAAgC;QAC3C,oBAAe,GAAf,eAAe,CAAyB;QAX1C,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAY1D,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,QAAQ,CACZ,WAAmB,EACnB,OAA0B,EAC1B,UAA2B,EAAE;QAE7B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,oBAAoB;QACpB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAClE,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,aAAa,WAAW,YAAY,CAAC,CAAC;QACxD,CAAC;QAED,yCAAyC;QACzC,MAAM,QAAQ,GAAG,IAAI,gBAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACjD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa;aACxC,IAAI,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;aAC/B,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAEtB,MAAM,WAAW,GAAG,MAA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BAAK;QAEN,gBAAK;QAEL,gBAAK;QAEP,gBAAK;QACD,kCAAuB;GAZhD,iBAAiB,CAqP7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evaluation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,gBAAgB,GACjB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EvaluationService = void 0;
|
|
4
|
+
var evaluation_service_1 = require("./evaluation.service");
|
|
5
|
+
Object.defineProperty(exports, "EvaluationService", { enumerable: true, get: function () { return evaluation_service_1.EvaluationService; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/evaluation/index.ts"],"names":[],"mappings":";;;AAAA,2DAI8B;AAH5B,uHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ScorecardCriteria } from '../schemas';
|
|
2
|
+
import { CriteriaHandler, CriteriaHandlerResult, EvaluationContext } from './criteria-handler.interface';
|
|
3
|
+
export declare class ConversationCompletenessHandler implements CriteriaHandler {
|
|
4
|
+
readonly type = "conversation_completeness";
|
|
5
|
+
evaluate(criteria: ScorecardCriteria, context: EvaluationContext): Promise<CriteriaHandlerResult>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=conversation-completeness.handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-completeness.handler.d.ts","sourceRoot":"","sources":["../../src/handlers/conversation-completeness.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAIlB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,8BAA8B,CAAC;AAGtC,qBAAa,+BAAgC,YAAW,eAAe;IACrE,QAAQ,CAAC,IAAI,+BAA+B;IAEtC,QAAQ,CACZ,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,qBAAqB,CAAC;CAwElC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConversationCompletenessHandler = void 0;
|
|
4
|
+
const schemas_1 = require("../schemas");
|
|
5
|
+
const scoring_utils_1 = require("./scoring-utils");
|
|
6
|
+
class ConversationCompletenessHandler {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.type = 'conversation_completeness';
|
|
9
|
+
}
|
|
10
|
+
async evaluate(criteria, context) {
|
|
11
|
+
const settings = criteria.settings;
|
|
12
|
+
const evaluationType = settings?.evaluationType || 'score';
|
|
13
|
+
// No LLM available — return fallback
|
|
14
|
+
if (!context.llmEvaluate) {
|
|
15
|
+
return {
|
|
16
|
+
result: 5,
|
|
17
|
+
passed: false,
|
|
18
|
+
reasoning: 'LLM evaluator not available',
|
|
19
|
+
evidence: [],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// Empty transcript — nothing to evaluate
|
|
23
|
+
if (!context.transcriptText || context.transcriptText.trim() === '') {
|
|
24
|
+
return {
|
|
25
|
+
result: 5,
|
|
26
|
+
passed: false,
|
|
27
|
+
reasoning: 'Empty transcript',
|
|
28
|
+
evidence: [],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// Build threshold info for LLM (same pattern as prompt.handler)
|
|
32
|
+
let thresholdInfo;
|
|
33
|
+
if (criteria.threshold) {
|
|
34
|
+
if ((0, schemas_1.isBooleanThreshold)(criteria.threshold)) {
|
|
35
|
+
thresholdInfo = {
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
expectedValue: criteria.threshold.expectedValue,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else if ((0, schemas_1.isNumericalThreshold)(criteria.threshold)) {
|
|
41
|
+
thresholdInfo = {
|
|
42
|
+
type: 'numerical',
|
|
43
|
+
min: criteria.threshold.min,
|
|
44
|
+
max: criteria.threshold.max,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const llmResult = await context.llmEvaluate({
|
|
50
|
+
criterionName: criteria.name,
|
|
51
|
+
description: 'Identify every distinct concern, question, or request the customer raised during this conversation. For each one, determine whether the agent fully addressed it, partially addressed it, or ignored it. Score 1-10 where 10 means every customer concern was fully resolved or acknowledged with a clear next step.',
|
|
52
|
+
evaluationType,
|
|
53
|
+
transcript: context.transcriptText,
|
|
54
|
+
threshold: thresholdInfo,
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
result: llmResult.result,
|
|
58
|
+
passed: llmResult.passed ?? (0, scoring_utils_1.checkThreshold)(criteria, llmResult.result),
|
|
59
|
+
reasoning: llmResult.reasoning || 'Conversation completeness evaluation completed.',
|
|
60
|
+
evidence: llmResult.evidence || [],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
return {
|
|
65
|
+
result: 5,
|
|
66
|
+
passed: false,
|
|
67
|
+
reasoning: `Conversation completeness evaluation failed: ${error.message}. Using fallback.`,
|
|
68
|
+
evidence: [],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.ConversationCompletenessHandler = ConversationCompletenessHandler;
|
|
74
|
+
//# sourceMappingURL=conversation-completeness.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-completeness.handler.js","sourceRoot":"","sources":["../../src/handlers/conversation-completeness.handler.ts"],"names":[],"mappings":";;;AAAA,wCAKoB;AAMpB,mDAAiD;AAEjD,MAAa,+BAA+B;IAA5C;QACW,SAAI,GAA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C,WAAW,CAAC;gBAC1C,aAAa,EAAE,QAAQ,CAAC,IAAI;gBAC5B,WAAW,EACT,sTAAsT;gBACxT,cAAc;gBACd,UAAU,EAAE,OAAO,CAAC,cAAc;gBAClC,SAAS,EAAE,aAAa;aACzB,CAAC,CAAC;YAEH,OAAO;gBACL,MAAM,EAAE,SAAS,CAAC,MAAM;gBACxB,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI,IAAA,8BAAc,EAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC;gBACtE,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,iDAAiD;gBACnF,QAAQ,EAAE,SAAS,CAAC,QAAQ,IAAI,EAAE;aACnC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO;gBACL,MAAM,EAAE,CAAC;gBACT,MAAM,EAAE,KAAK;gBACb,SAAS,EAAE,gDAAgD,KAAK,CAAC,OAAO,mBAAmB;gBAC3F,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA9ED,0EA8EC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CriteriaHandler } from './criteria-handler.interface';
|
|
2
|
+
export declare class CriteriaHandlerRegistry {
|
|
3
|
+
private readonly logger;
|
|
4
|
+
private readonly handlers;
|
|
5
|
+
register(handler: CriteriaHandler): void;
|
|
6
|
+
get(type: string): CriteriaHandler | undefined;
|
|
7
|
+
getOrThrow(type: string): CriteriaHandler;
|
|
8
|
+
has(type: string): boolean;
|
|
9
|
+
list(): CriteriaHandler[];
|
|
10
|
+
listTypes(): string[];
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=criteria-handler-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"criteria-handler-registry.d.ts","sourceRoot":"","sources":["../../src/handlers/criteria-handler-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,qBACa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4C;IACnE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsC;IAE/D,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAKxC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAI9C,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAUzC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,IAAI,IAAI,eAAe,EAAE;IAIzB,SAAS,IAAI,MAAM,EAAE;CAGtB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var CriteriaHandlerRegistry_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.CriteriaHandlerRegistry = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
let CriteriaHandlerRegistry = CriteriaHandlerRegistry_1 = class CriteriaHandlerRegistry {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.logger = new common_1.Logger(CriteriaHandlerRegistry_1.name);
|
|
15
|
+
this.handlers = new Map();
|
|
16
|
+
}
|
|
17
|
+
register(handler) {
|
|
18
|
+
this.handlers.set(handler.type, handler);
|
|
19
|
+
this.logger.log(`Registered criteria handler: ${handler.type}`);
|
|
20
|
+
}
|
|
21
|
+
get(type) {
|
|
22
|
+
return this.handlers.get(type);
|
|
23
|
+
}
|
|
24
|
+
getOrThrow(type) {
|
|
25
|
+
const handler = this.handlers.get(type);
|
|
26
|
+
if (!handler) {
|
|
27
|
+
throw new Error(`No criteria handler registered for type: ${type}. Available: ${this.listTypes().join(', ')}`);
|
|
28
|
+
}
|
|
29
|
+
return handler;
|
|
30
|
+
}
|
|
31
|
+
has(type) {
|
|
32
|
+
return this.handlers.has(type);
|
|
33
|
+
}
|
|
34
|
+
list() {
|
|
35
|
+
return Array.from(this.handlers.values());
|
|
36
|
+
}
|
|
37
|
+
listTypes() {
|
|
38
|
+
return Array.from(this.handlers.keys());
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.CriteriaHandlerRegistry = CriteriaHandlerRegistry;
|
|
42
|
+
exports.CriteriaHandlerRegistry = CriteriaHandlerRegistry = CriteriaHandlerRegistry_1 = __decorate([
|
|
43
|
+
(0, common_1.Injectable)()
|
|
44
|
+
], CriteriaHandlerRegistry);
|
|
45
|
+
//# sourceMappingURL=criteria-handler-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"criteria-handler-registry.js","sourceRoot":"","sources":["../../src/handlers/criteria-handler-registry.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAI7C,IAAM,uBAAuB,+BAA7B,MAAM,uBAAuB;IAA7B;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;QAClD,aAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;IAgCjE,CAAC;IA9BC,QAAQ,CAAC,OAAwB;QAC/B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gCAAgC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,4CAA4C,IAAI,gBAAgB,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC9F,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS;QACP,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF,CAAA;AAlCY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;GACA,uBAAuB,CAkCnC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ScorecardCriteria } from '../schemas';
|
|
2
|
+
/**
|
|
3
|
+
* Context provided to criteria handlers for evaluation.
|
|
4
|
+
* Handlers extract what they need from this context.
|
|
5
|
+
*/
|
|
6
|
+
export interface EvaluationContext {
|
|
7
|
+
/** Full transcript text (all segments joined) */
|
|
8
|
+
transcriptText: string;
|
|
9
|
+
/** Individual transcript segments with metadata */
|
|
10
|
+
segments?: Array<{
|
|
11
|
+
speaker: string;
|
|
12
|
+
text: string;
|
|
13
|
+
startTime?: number;
|
|
14
|
+
endTime?: number;
|
|
15
|
+
duration?: number;
|
|
16
|
+
}>;
|
|
17
|
+
/** Interaction-level metrics */
|
|
18
|
+
metrics?: {
|
|
19
|
+
duration?: number;
|
|
20
|
+
firstResponseLatency?: number;
|
|
21
|
+
avgSegmentLength?: Record<string, number>;
|
|
22
|
+
};
|
|
23
|
+
/** Tool calls made during the interaction */
|
|
24
|
+
toolCalls?: Array<{
|
|
25
|
+
name: string;
|
|
26
|
+
arguments?: Record<string, any>;
|
|
27
|
+
result?: any;
|
|
28
|
+
timestamp?: Date;
|
|
29
|
+
function?: {
|
|
30
|
+
name: string;
|
|
31
|
+
};
|
|
32
|
+
}>;
|
|
33
|
+
/** Ground truth facts for hallucination detection */
|
|
34
|
+
groundTruth?: string;
|
|
35
|
+
/** Optional LLM evaluation function for prompt-type criteria */
|
|
36
|
+
llmEvaluate?: (params: {
|
|
37
|
+
criterionName: string;
|
|
38
|
+
description: string;
|
|
39
|
+
evaluationType: 'boolean' | 'score';
|
|
40
|
+
transcript: string;
|
|
41
|
+
threshold?: {
|
|
42
|
+
type: 'boolean' | 'numerical';
|
|
43
|
+
expectedValue?: boolean;
|
|
44
|
+
min?: number;
|
|
45
|
+
max?: number;
|
|
46
|
+
};
|
|
47
|
+
}) => Promise<{
|
|
48
|
+
result: boolean | number;
|
|
49
|
+
passed: boolean;
|
|
50
|
+
reasoning: string;
|
|
51
|
+
evidence: string[];
|
|
52
|
+
confidence?: number;
|
|
53
|
+
}>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Interface for criteria type handlers.
|
|
57
|
+
* Each handler evaluates a specific type of criterion.
|
|
58
|
+
*/
|
|
59
|
+
export interface CriteriaHandler {
|
|
60
|
+
/** The criteria type this handler supports (matches CriteriaType enum) */
|
|
61
|
+
readonly type: string;
|
|
62
|
+
/**
|
|
63
|
+
* Evaluate a criterion against the provided context.
|
|
64
|
+
* @param criteria - The criterion definition (settings, threshold, etc.)
|
|
65
|
+
* @param context - The evaluation context (transcript, metrics, etc.)
|
|
66
|
+
* @returns A partial CriteriaResult with result, passed, reasoning, evidence
|
|
67
|
+
*/
|
|
68
|
+
evaluate(criteria: ScorecardCriteria, context: EvaluationContext): Promise<CriteriaHandlerResult>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Result from a criteria handler evaluation.
|
|
72
|
+
*/
|
|
73
|
+
export interface CriteriaHandlerResult {
|
|
74
|
+
result: any;
|
|
75
|
+
passed: boolean;
|
|
76
|
+
reasoning: string;
|
|
77
|
+
evidence: string[];
|
|
78
|
+
/** When true, this criterion was skipped (no ground truth, no tools, etc.) — should display as N/A, not pass/fail */
|
|
79
|
+
notApplicable?: boolean;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=criteria-handler.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"criteria-handler.interface.d.ts","sourceRoot":"","sources":["../../src/handlers/criteria-handler.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAElB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,cAAc,EAAE,MAAM,CAAC;IAEvB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,KAAK,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IAEH,gCAAgC;IAChC,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC3C,CAAC;IAEF,6CAA6C;IAC7C,SAAS,CAAC,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,C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M,EAAE,CAAC;IACnB,qHAAqH;IACrH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"criteria-handler.interface.js","sourceRoot":"","sources":["../../src/handlers/criteria-handler.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ScorecardCriteria } from '../schemas';
|
|
2
|
+
import { CriteriaHandler, CriteriaHandlerResult, EvaluationContext } from './criteria-handler.interface';
|
|
3
|
+
export declare class HallucinationHandler implements CriteriaHandler {
|
|
4
|
+
readonly type = "hallucination";
|
|
5
|
+
evaluate(criteria: ScorecardCriteria, context: EvaluationContext): Promise<CriteriaHandlerResult>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=hallucination.handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hallucination.handler.d.ts","sourceRoot":"","sources":["../../src/handlers/hallucination.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAIlB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,8BAA8B,CAAC;AAGtC,qBAAa,oBAAqB,YAAW,eAAe;IAC1D,QAAQ,CAAC,IAAI,mBAAmB;IAE1B,QAAQ,CACZ,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,qBAAqB,CAAC;CAsFlC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HallucinationHandler = void 0;
|
|
4
|
+
const schemas_1 = require("../schemas");
|
|
5
|
+
const scoring_utils_1 = require("./scoring-utils");
|
|
6
|
+
class HallucinationHandler {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.type = 'hallucination';
|
|
9
|
+
}
|
|
10
|
+
async evaluate(criteria, context) {
|
|
11
|
+
const settings = criteria.settings;
|
|
12
|
+
const evaluationType = settings?.evaluationType || 'boolean';
|
|
13
|
+
// No ground truth — nothing to check against
|
|
14
|
+
if (!context.groundTruth) {
|
|
15
|
+
return {
|
|
16
|
+
result: true,
|
|
17
|
+
passed: true,
|
|
18
|
+
reasoning: 'No ground truth provided',
|
|
19
|
+
evidence: [],
|
|
20
|
+
notApplicable: true,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// No LLM available — cannot evaluate
|
|
24
|
+
if (!context.llmEvaluate) {
|
|
25
|
+
return {
|
|
26
|
+
result: false,
|
|
27
|
+
passed: false,
|
|
28
|
+
reasoning: 'LLM evaluator not available',
|
|
29
|
+
evidence: [],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// Empty transcript — nothing to evaluate
|
|
33
|
+
if (!context.transcriptText || context.transcriptText.trim() === '') {
|
|
34
|
+
return {
|
|
35
|
+
result: true,
|
|
36
|
+
passed: true,
|
|
37
|
+
reasoning: 'Empty transcript — skipped',
|
|
38
|
+
evidence: [],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// Build enhanced transcript with ground truth prepended
|
|
42
|
+
const enhancedTranscript = `## Ground Truth Facts\n${context.groundTruth}\n\n## Conversation Transcript\n${context.transcriptText}`;
|
|
43
|
+
// Build threshold info for LLM (same pattern as prompt.handler)
|
|
44
|
+
let thresholdInfo;
|
|
45
|
+
if (criteria.threshold) {
|
|
46
|
+
if ((0, schemas_1.isBooleanThreshold)(criteria.threshold)) {
|
|
47
|
+
thresholdInfo = {
|
|
48
|
+
type: 'boolean',
|
|
49
|
+
expectedValue: criteria.threshold.expectedValue,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
else if ((0, schemas_1.isNumericalThreshold)(criteria.threshold)) {
|
|
53
|
+
thresholdInfo = {
|
|
54
|
+
type: 'numerical',
|
|
55
|
+
min: criteria.threshold.min,
|
|
56
|
+
max: criteria.threshold.max,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const llmResult = await context.llmEvaluate({
|
|
62
|
+
criterionName: criteria.name,
|
|
63
|
+
description: 'Evaluate whether the agent\'s responses contradict, fabricate, or go beyond the provided ground truth facts. A hallucination is any claim not supported by the ground truth. Check each agent response against the ground truth and identify any fabricated information.',
|
|
64
|
+
evaluationType,
|
|
65
|
+
transcript: enhancedTranscript,
|
|
66
|
+
threshold: thresholdInfo,
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
result: llmResult.result,
|
|
70
|
+
passed: llmResult.passed ?? (0, scoring_utils_1.checkThreshold)(criteria, llmResult.result),
|
|
71
|
+
reasoning: llmResult.reasoning || 'Hallucination evaluation completed.',
|
|
72
|
+
evidence: llmResult.evidence || [],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return {
|
|
77
|
+
result: false,
|
|
78
|
+
passed: false,
|
|
79
|
+
reasoning: `Hallucination evaluation failed: ${error.message}`,
|
|
80
|
+
evidence: [],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.HallucinationHandler = HallucinationHandler;
|
|
86
|
+
//# sourceMappingURL=hallucination.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hallucination.handler.js","sourceRoot":"","sources":["../../src/handlers/hallucination.handler.ts"],"names":[],"mappings":";;;AAAA,wCAKoB;AAMpB,mDAAiD;AAEjD,MAAa,oBAAoB;IAAjC;QACW,SAAI,GAAG,eAAe,CAAC;IA2FlC,CAAC;IAzFC,KAAK,CAAC,QAAQ,CACZ,QAA2B,EAC3B,OAA0B;QAE1B,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAyC,CAAC;QACpE,MAAM,cAAc,GAAG,QAAQ,EAAE,cAAc,IAAI,SAAS,CAAC;QAE7D,6CAA6C;QAC7C,IAAI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S,CAAC,GAAG;iBAC5B,CAAC;YACJ,CAAC;QACH,CAAC;QAED,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC;gBAC1C,aAAa,EAAE,QAAQ,CAAC,IAAI;gBAC5B,WAAW,EACT,0QAA0Q;gBAC5Q,cAAc;gBACd,UAAU,EAAE,kBAAkB;gBAC9B,SAAS,EAAE,aAAa;aACzB,CAAC,CAAC;YAEH,OAAO;gBACL,MAAM,EAAE,SAAS,CAAC,MAAM;gBACxB,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI,IAAA,8BAAc,EAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC;gBACtE,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,qCAAqC;gBACvE,QAAQ,EAAE,SAAS,CAAC,QAAQ,IAAI,EAAE;aACnC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO;gBACL,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,KAAK;gBACb,SAAS,EAAE,oCAAoC,KAAK,CAAC,OAAO,EAAE;gBAC9D,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA5FD,oDA4FC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { CriteriaHandler, CriteriaHandlerResult, EvaluationContext, } from './criteria-handler.interface';
|
|
2
|
+
export { CriteriaHandlerRegistry } from './criteria-handler-registry';
|
|
3
|
+
export { checkThreshold, normalizeScore } from './scoring-utils';
|
|
4
|
+
export { HallucinationHandler } from './hallucination.handler';
|
|
5
|
+
export { KeywordHandler } from './keyword.handler';
|
|
6
|
+
export { PromptHandler } from './prompt.handler';
|
|
7
|
+
export { RagFaithfulnessHandler } from './rag-faithfulness.handler';
|
|
8
|
+
export { ResponseTimeHandler } from './response-time.handler';
|
|
9
|
+
export { ToolCallHandler } from './tool-call.handler';
|
|
10
|
+
export { KnowledgeRetentionHandler } from './knowledge-retention.handler';
|
|
11
|
+
export { ConversationCompletenessHandler } from './conversation-completeness.handler';
|
|
12
|
+
export { RoleAdherenceHandler } from './role-adherence.handler';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC"}
|