@carlonicora/nestjs-neo4jsonapi 2.14.11 → 2.15.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/dist/agents/contextualiser/contexts/contextualiser.context.d.ts +41 -0
- package/dist/agents/contextualiser/contexts/contextualiser.context.d.ts.map +1 -1
- package/dist/agents/contextualiser/contexts/contextualiser.context.js +17 -0
- package/dist/agents/contextualiser/contexts/contextualiser.context.js.map +1 -1
- package/dist/agents/contextualiser/contexts/notebook.context.d.ts +22 -0
- package/dist/agents/contextualiser/contexts/notebook.context.d.ts.map +1 -1
- package/dist/agents/contextualiser/contexts/notebook.context.js +14 -0
- package/dist/agents/contextualiser/contexts/notebook.context.js.map +1 -1
- package/dist/agents/contextualiser/factories/contextualiser.context.factory.d.ts.map +1 -1
- package/dist/agents/contextualiser/factories/contextualiser.context.factory.js +2 -0
- package/dist/agents/contextualiser/factories/contextualiser.context.factory.js.map +1 -1
- package/dist/agents/contextualiser/nodes/atomicfacts.node.service.d.ts.map +1 -1
- package/dist/agents/contextualiser/nodes/atomicfacts.node.service.js +17 -5
- package/dist/agents/contextualiser/nodes/atomicfacts.node.service.js.map +1 -1
- package/dist/agents/contextualiser/nodes/chunk.node.service.d.ts +1 -14
- package/dist/agents/contextualiser/nodes/chunk.node.service.d.ts.map +1 -1
- package/dist/agents/contextualiser/nodes/chunk.node.service.js +56 -206
- package/dist/agents/contextualiser/nodes/chunk.node.service.js.map +1 -1
- package/dist/agents/contextualiser/nodes/chunk.vector.node.service.d.ts +3 -12
- package/dist/agents/contextualiser/nodes/chunk.vector.node.service.d.ts.map +1 -1
- package/dist/agents/contextualiser/nodes/chunk.vector.node.service.js +44 -133
- package/dist/agents/contextualiser/nodes/chunk.vector.node.service.js.map +1 -1
- package/dist/agents/contextualiser/nodes/keyconcepts.node.service.d.ts +1 -2
- package/dist/agents/contextualiser/nodes/keyconcepts.node.service.d.ts.map +1 -1
- package/dist/agents/contextualiser/nodes/keyconcepts.node.service.js +60 -60
- package/dist/agents/contextualiser/nodes/keyconcepts.node.service.js.map +1 -1
- package/dist/agents/contextualiser/nodes/question.refiner.node.service.d.ts.map +1 -1
- package/dist/agents/contextualiser/nodes/question.refiner.node.service.js +7 -2
- package/dist/agents/contextualiser/nodes/question.refiner.node.service.js.map +1 -1
- package/dist/agents/contextualiser/nodes/rational.node.service.js +2 -1
- package/dist/agents/contextualiser/nodes/rational.node.service.js.map +1 -1
- package/dist/agents/contextualiser/services/contextualiser.service.d.ts.map +1 -1
- package/dist/agents/contextualiser/services/contextualiser.service.js +30 -22
- package/dist/agents/contextualiser/services/contextualiser.service.js.map +1 -1
- package/dist/agents/prompts/index.d.ts +0 -2
- package/dist/agents/prompts/index.d.ts.map +1 -1
- package/dist/agents/prompts/index.js +7 -5
- package/dist/agents/prompts/index.js.map +1 -1
- package/dist/agents/responder/contexts/responder.context.d.ts +96 -0
- package/dist/agents/responder/contexts/responder.context.d.ts.map +1 -1
- package/dist/agents/responder/interfaces/unified.trace.interface.d.ts +9 -0
- package/dist/agents/responder/interfaces/unified.trace.interface.d.ts.map +1 -1
- package/dist/agents/responder/nodes/__tests__/helpers/answer-node.harness.d.ts +38 -0
- package/dist/agents/responder/nodes/__tests__/helpers/answer-node.harness.d.ts.map +1 -0
- package/dist/agents/responder/nodes/__tests__/helpers/answer-node.harness.js +36 -0
- package/dist/agents/responder/nodes/__tests__/helpers/answer-node.harness.js.map +1 -0
- package/dist/agents/responder/nodes/graph.node.service.d.ts.map +1 -1
- package/dist/agents/responder/nodes/graph.node.service.js +18 -3
- package/dist/agents/responder/nodes/graph.node.service.js.map +1 -1
- package/dist/agents/responder/nodes/planner.node.service.d.ts.map +1 -1
- package/dist/agents/responder/nodes/planner.node.service.js +9 -0
- package/dist/agents/responder/nodes/planner.node.service.js.map +1 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.d.ts +26 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.d.ts.map +1 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.js +127 -13
- package/dist/agents/responder/nodes/responder.answer.node.service.js.map +1 -1
- package/dist/agents/responder/services/responder.service.d.ts.map +1 -1
- package/dist/agents/responder/services/responder.service.js +4 -0
- package/dist/agents/responder/services/responder.service.js.map +1 -1
- package/dist/common/utils/settled.d.ts +33 -0
- package/dist/common/utils/settled.d.ts.map +1 -0
- package/dist/common/utils/settled.js +66 -0
- package/dist/common/utils/settled.js.map +1 -0
- package/dist/config/interfaces/config.prompts.interface.d.ts +12 -0
- package/dist/config/interfaces/config.prompts.interface.d.ts.map +1 -1
- package/dist/eval/retrieval/end-to-end-sweep.service.d.ts +52 -0
- package/dist/eval/retrieval/end-to-end-sweep.service.d.ts.map +1 -0
- package/dist/eval/retrieval/end-to-end-sweep.service.js +194 -0
- package/dist/eval/retrieval/end-to-end-sweep.service.js.map +1 -0
- package/dist/eval/retrieval/evidence.matcher.d.ts +23 -0
- package/dist/eval/retrieval/evidence.matcher.d.ts.map +1 -0
- package/dist/eval/retrieval/evidence.matcher.js +38 -0
- package/dist/eval/retrieval/evidence.matcher.js.map +1 -0
- package/dist/eval/retrieval/index.d.ts +10 -0
- package/dist/eval/retrieval/index.d.ts.map +1 -0
- package/dist/eval/retrieval/index.js +35 -0
- package/dist/eval/retrieval/index.js.map +1 -0
- package/dist/eval/retrieval/question-set.loader.d.ts +16 -0
- package/dist/eval/retrieval/question-set.loader.d.ts.map +1 -0
- package/dist/eval/retrieval/question-set.loader.js +73 -0
- package/dist/eval/retrieval/question-set.loader.js.map +1 -0
- package/dist/eval/retrieval/retrieval-eval.module.d.ts +14 -0
- package/dist/eval/retrieval/retrieval-eval.module.d.ts.map +1 -0
- package/dist/eval/retrieval/retrieval-eval.module.js +48 -0
- package/dist/eval/retrieval/retrieval-eval.module.js.map +1 -0
- package/dist/eval/retrieval/retrieval-eval.types.d.ts +84 -0
- package/dist/eval/retrieval/retrieval-eval.types.d.ts.map +1 -0
- package/dist/eval/retrieval/retrieval-eval.types.js +25 -0
- package/dist/eval/retrieval/retrieval-eval.types.js.map +1 -0
- package/dist/eval/retrieval/retrieval-sweep.service.d.ts +35 -0
- package/dist/eval/retrieval/retrieval-sweep.service.d.ts.map +1 -0
- package/dist/eval/retrieval/retrieval-sweep.service.js +93 -0
- package/dist/eval/retrieval/retrieval-sweep.service.js.map +1 -0
- package/dist/eval/retrieval/rubric-judge.service.d.ts +30 -0
- package/dist/eval/retrieval/rubric-judge.service.d.ts.map +1 -0
- package/dist/eval/retrieval/rubric-judge.service.js +138 -0
- package/dist/eval/retrieval/rubric-judge.service.js.map +1 -0
- package/dist/eval/retrieval/sweep-report.d.ts +11 -0
- package/dist/eval/retrieval/sweep-report.d.ts.map +1 -0
- package/dist/eval/retrieval/sweep-report.js +79 -0
- package/dist/eval/retrieval/sweep-report.js.map +1 -0
- package/dist/eval/retrieval/token-accounting.check.d.ts +39 -0
- package/dist/eval/retrieval/token-accounting.check.d.ts.map +1 -0
- package/dist/eval/retrieval/token-accounting.check.js +75 -0
- package/dist/eval/retrieval/token-accounting.check.js.map +1 -0
- package/dist/foundations/atomicfact/repositories/atomicfact.repository.d.ts.map +1 -1
- package/dist/foundations/atomicfact/repositories/atomicfact.repository.js +7 -0
- package/dist/foundations/atomicfact/repositories/atomicfact.repository.js.map +1 -1
- package/dist/foundations/chunk/repositories/chunk.repository.d.ts +87 -1
- package/dist/foundations/chunk/repositories/chunk.repository.d.ts.map +1 -1
- package/dist/foundations/chunk/repositories/chunk.repository.js +239 -50
- package/dist/foundations/chunk/repositories/chunk.repository.js.map +1 -1
- package/dist/foundations/chunk/repositories/retrieval.constants.d.ts +69 -0
- package/dist/foundations/chunk/repositories/retrieval.constants.d.ts.map +1 -0
- package/dist/foundations/chunk/repositories/retrieval.constants.js +72 -0
- package/dist/foundations/chunk/repositories/retrieval.constants.js.map +1 -0
- package/dist/foundations/keyconcept/repositories/keyconcept.repository.d.ts +2 -0
- package/dist/foundations/keyconcept/repositories/keyconcept.repository.d.ts.map +1 -1
- package/dist/foundations/keyconcept/repositories/keyconcept.repository.js +9 -5
- package/dist/foundations/keyconcept/repositories/keyconcept.repository.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ConfigService } from "@nestjs/config";
|
|
2
|
+
import { ResponderService } from "../../agents/responder/services/responder.service";
|
|
3
|
+
import { BaseConfigInterface } from "../../config/interfaces/base.config.interface";
|
|
4
|
+
import { EvidenceMatcher } from "./evidence.matcher";
|
|
5
|
+
import { EndToEndSweepResult, EvalQuestionSet, SweepSummary } from "./retrieval-eval.types";
|
|
6
|
+
import { RubricJudgeService } from "./rubric-judge.service";
|
|
7
|
+
import { TokenAccountingChecker } from "./token-accounting.check";
|
|
8
|
+
/**
|
|
9
|
+
* The metric of record (spec §6.4): a full assistant turn per question, in the
|
|
10
|
+
* product's own voice, with its own prompts and temperature.
|
|
11
|
+
*
|
|
12
|
+
* Sequential on purpose — `answerMs` is a reported metric (spec §6.3).
|
|
13
|
+
*/
|
|
14
|
+
export declare class EndToEndSweepService {
|
|
15
|
+
private readonly responder;
|
|
16
|
+
private readonly judge;
|
|
17
|
+
private readonly evidence;
|
|
18
|
+
private readonly accounting;
|
|
19
|
+
private readonly configService;
|
|
20
|
+
private readonly logger;
|
|
21
|
+
constructor(responder: ResponderService, judge: RubricJudgeService, evidence: EvidenceMatcher, accounting: TokenAccountingChecker, configService: ConfigService<BaseConfigInterface>);
|
|
22
|
+
/**
|
|
23
|
+
* SCOPE COMES FROM CLS, NOT FROM THESE PARAMETERS.
|
|
24
|
+
*
|
|
25
|
+
* `companyId` and `userId` stay because `ResponderService.run` genuinely takes
|
|
26
|
+
* them — but they do not scope retrieval. Company scope reaches the
|
|
27
|
+
* `ChunkRepository` through `ClsService` (via `Neo4jService.initQuery`), and
|
|
28
|
+
* the run's scope root through `AGENT_SCOPE_CLS_KEY`
|
|
29
|
+
* (`common/repositories/agent-scope.filter.ts`), which fails closed. A caller
|
|
30
|
+
* that does not establish that context retrieves nothing — or, worse,
|
|
31
|
+
* retrieves unscoped. Establishing it is the entry point's job; see
|
|
32
|
+
* apps/api/src/eval/run-sweep.ts.
|
|
33
|
+
*/
|
|
34
|
+
run(params: {
|
|
35
|
+
set: EvalQuestionSet;
|
|
36
|
+
companyId: string;
|
|
37
|
+
userId: string;
|
|
38
|
+
}): Promise<SweepSummary<EndToEndSweepResult>>;
|
|
39
|
+
/**
|
|
40
|
+
* Feeds the checker the per-node figures the turn itself reported, so
|
|
41
|
+
* `check()` compares them against the accumulated ledger.
|
|
42
|
+
*
|
|
43
|
+
* Spec §6.5 asks the sweep to sum the per-call figures and cross-check the
|
|
44
|
+
* aggregate. The trace is where those per-node figures survive: each node
|
|
45
|
+
* records what its own provider calls reported, while `response.tokens` is
|
|
46
|
+
* the reducer-accumulated total — the exact pair whose disagreement IS the
|
|
47
|
+
* §1.1 double-count. Without this the checker would see zero observed tokens
|
|
48
|
+
* and declare a mismatch on every question, which is noise, not a check.
|
|
49
|
+
*/
|
|
50
|
+
private observeReportedCalls;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=end-to-end-sweep.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"end-to-end-sweep.service.d.ts","sourceRoot":"","sources":["../../../src/eval/retrieval/end-to-end-sweep.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AAErF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE;;;;;GAKG;AACH,qBACa,oBAAoB;IAI7B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAPhC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;gBAG7C,SAAS,EAAE,gBAAgB,EAC3B,KAAK,EAAE,kBAAkB,EACzB,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,sBAAsB,EAClC,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAAC;IAGpE;;;;;;;;;;;OAWG;IACG,GAAG,CAAC,MAAM,EAAE;QAChB,GAAG,EAAE,eAAe,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;IA+H9C;;;;;;;;;;OAUG;IACH,OAAO,CAAC,oBAAoB;CAW7B"}
|
|
@@ -0,0 +1,194 @@
|
|
|
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 EndToEndSweepService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.EndToEndSweepService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const config_1 = require("@nestjs/config");
|
|
16
|
+
const responder_service_1 = require("../../agents/responder/services/responder.service");
|
|
17
|
+
const agentmessage_type_1 = require("../../common/enums/agentmessage.type");
|
|
18
|
+
const evidence_matcher_1 = require("./evidence.matcher");
|
|
19
|
+
const rubric_judge_service_1 = require("./rubric-judge.service");
|
|
20
|
+
const token_accounting_check_1 = require("./token-accounting.check");
|
|
21
|
+
/**
|
|
22
|
+
* The metric of record (spec §6.4): a full assistant turn per question, in the
|
|
23
|
+
* product's own voice, with its own prompts and temperature.
|
|
24
|
+
*
|
|
25
|
+
* Sequential on purpose — `answerMs` is a reported metric (spec §6.3).
|
|
26
|
+
*/
|
|
27
|
+
let EndToEndSweepService = EndToEndSweepService_1 = class EndToEndSweepService {
|
|
28
|
+
constructor(responder, judge, evidence, accounting, configService) {
|
|
29
|
+
this.responder = responder;
|
|
30
|
+
this.judge = judge;
|
|
31
|
+
this.evidence = evidence;
|
|
32
|
+
this.accounting = accounting;
|
|
33
|
+
this.configService = configService;
|
|
34
|
+
this.logger = new common_1.Logger(EndToEndSweepService_1.name);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* SCOPE COMES FROM CLS, NOT FROM THESE PARAMETERS.
|
|
38
|
+
*
|
|
39
|
+
* `companyId` and `userId` stay because `ResponderService.run` genuinely takes
|
|
40
|
+
* them — but they do not scope retrieval. Company scope reaches the
|
|
41
|
+
* `ChunkRepository` through `ClsService` (via `Neo4jService.initQuery`), and
|
|
42
|
+
* the run's scope root through `AGENT_SCOPE_CLS_KEY`
|
|
43
|
+
* (`common/repositories/agent-scope.filter.ts`), which fails closed. A caller
|
|
44
|
+
* that does not establish that context retrieves nothing — or, worse,
|
|
45
|
+
* retrieves unscoped. Establishing it is the entry point's job; see
|
|
46
|
+
* apps/api/src/eval/run-sweep.ts.
|
|
47
|
+
*/
|
|
48
|
+
async run(params) {
|
|
49
|
+
const startedAt = new Date().toISOString();
|
|
50
|
+
const results = [];
|
|
51
|
+
for (const question of params.set.questions) {
|
|
52
|
+
const began = Date.now();
|
|
53
|
+
try {
|
|
54
|
+
const response = await this.responder.run({
|
|
55
|
+
companyId: params.companyId,
|
|
56
|
+
userId: params.userId,
|
|
57
|
+
userModuleIds: [],
|
|
58
|
+
dataLimits: {},
|
|
59
|
+
messages: [{ type: agentmessage_type_1.AgentMessageType.User, content: question.question }],
|
|
60
|
+
question: question.question,
|
|
61
|
+
scopeId: question.scopeId,
|
|
62
|
+
scopeType: question.scopeType,
|
|
63
|
+
});
|
|
64
|
+
const notebook = response.context?.notebook ?? [];
|
|
65
|
+
const retrievedText = notebook.map((entry) => entry.content ?? "").join("\n\n");
|
|
66
|
+
const retrieved = this.evidence.score({
|
|
67
|
+
snippets: question.mustRetrieve,
|
|
68
|
+
haystack: retrievedText,
|
|
69
|
+
});
|
|
70
|
+
const citedIds = new Set((response.sources ?? []).map((source) => source.chunkId));
|
|
71
|
+
const citedText = notebook
|
|
72
|
+
.filter((entry) => citedIds.has(entry.chunkId))
|
|
73
|
+
.map((entry) => entry.content ?? "")
|
|
74
|
+
.join("\n\n");
|
|
75
|
+
const cited = this.evidence.score({ snippets: question.mustRetrieve, haystack: citedText });
|
|
76
|
+
// Post-trim: only the notebook entries that survived NOTEBOOK_BUDGET_CHARS
|
|
77
|
+
// and reached the answer model (contract C1). Absent `keptChunkIds` means
|
|
78
|
+
// the answer node never reported which entries it kept — treat as "not
|
|
79
|
+
// observed", never as "nothing kept" (see the interface's own doc comment).
|
|
80
|
+
const keptChunkIds = response.trace?.answer?.keptChunkIds;
|
|
81
|
+
const readObserved = Array.isArray(keptChunkIds);
|
|
82
|
+
const keptSet = new Set(keptChunkIds ?? []);
|
|
83
|
+
// Subset of keptSet kept in core (unwidened) form (contract C2/C3): their
|
|
84
|
+
// ±1 neighbour text never reached the model, so scoring must read only
|
|
85
|
+
// `coreContent` for these — never credit the widened `content`.
|
|
86
|
+
const coreOnlyIds = new Set(response.trace?.answer?.coreOnlyChunkIds ?? []);
|
|
87
|
+
const readText = readObserved
|
|
88
|
+
? notebook
|
|
89
|
+
.filter((entry) => keptSet.has(entry.chunkId))
|
|
90
|
+
.map((entry) => (coreOnlyIds.has(entry.chunkId) ? (entry.coreContent ?? "") : (entry.content ?? "")))
|
|
91
|
+
.join("\n\n")
|
|
92
|
+
: "";
|
|
93
|
+
const read = this.evidence.score({ snippets: question.mustRetrieve, haystack: readText });
|
|
94
|
+
const answer = response.answer?.answer ?? "";
|
|
95
|
+
const verdict = await this.judge.judge({
|
|
96
|
+
question: question.question,
|
|
97
|
+
rubric: question.rubric,
|
|
98
|
+
answer,
|
|
99
|
+
evidenceCited: cited.found,
|
|
100
|
+
});
|
|
101
|
+
const ledger = response.tokens ?? { input: 0, output: 0 };
|
|
102
|
+
this.observeReportedCalls(response.trace);
|
|
103
|
+
results.push({
|
|
104
|
+
questionId: question.id,
|
|
105
|
+
evidenceRetrieved: retrieved.found,
|
|
106
|
+
missingSnippets: retrieved.missing,
|
|
107
|
+
evidenceCited: cited.found,
|
|
108
|
+
uncitedSnippets: cited.missing,
|
|
109
|
+
chunksRead: notebook.length,
|
|
110
|
+
// The turn does not report retrieval separately from the answer;
|
|
111
|
+
// `retrievalMs` is the retrieval-only mode's metric (spec §6.5).
|
|
112
|
+
retrievalMs: 0,
|
|
113
|
+
answerMs: Date.now() - began,
|
|
114
|
+
inputTokens: ledger.input ?? 0,
|
|
115
|
+
outputTokens: ledger.output ?? 0,
|
|
116
|
+
verdict,
|
|
117
|
+
tokenAccounting: this.accounting.check({ questionId: question.id, ledger }),
|
|
118
|
+
evidenceRead: readObserved ? read.found : 0,
|
|
119
|
+
chunksKept: keptSet.size,
|
|
120
|
+
chunksKeptCore: readObserved ? coreOnlyIds.size : 0,
|
|
121
|
+
readObserved,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
126
|
+
this.logger.warn(`end-to-end sweep: question ${question.id} failed: ${message}`);
|
|
127
|
+
// The turn died part-way, so `check()` never ran and never reset. Anything
|
|
128
|
+
// this question already observed must be cleared here or the next question
|
|
129
|
+
// inherits it and its own comparison is meaningless.
|
|
130
|
+
this.accounting.reset();
|
|
131
|
+
results.push({
|
|
132
|
+
questionId: question.id,
|
|
133
|
+
evidenceRetrieved: 0,
|
|
134
|
+
missingSnippets: question.mustRetrieve,
|
|
135
|
+
evidenceCited: 0,
|
|
136
|
+
uncitedSnippets: question.mustRetrieve,
|
|
137
|
+
chunksRead: 0,
|
|
138
|
+
retrievalMs: 0,
|
|
139
|
+
answerMs: Date.now() - began,
|
|
140
|
+
inputTokens: 0,
|
|
141
|
+
outputTokens: 0,
|
|
142
|
+
verdict: { passed: false, explanation: `Turn failed: ${message}` },
|
|
143
|
+
tokenAccounting: {
|
|
144
|
+
ledgerInput: 0,
|
|
145
|
+
observedInput: 0,
|
|
146
|
+
ledgerOutput: 0,
|
|
147
|
+
observedOutput: 0,
|
|
148
|
+
agrees: false,
|
|
149
|
+
checked: false,
|
|
150
|
+
},
|
|
151
|
+
evidenceRead: 0,
|
|
152
|
+
chunksKept: 0,
|
|
153
|
+
chunksKeptCore: 0,
|
|
154
|
+
readObserved: false,
|
|
155
|
+
error: message,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
product: params.set.product,
|
|
161
|
+
mode: "end-to-end",
|
|
162
|
+
model: this.configService.get("ai")?.ai?.model ?? "unknown",
|
|
163
|
+
startedAt,
|
|
164
|
+
results,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Feeds the checker the per-node figures the turn itself reported, so
|
|
169
|
+
* `check()` compares them against the accumulated ledger.
|
|
170
|
+
*
|
|
171
|
+
* Spec §6.5 asks the sweep to sum the per-call figures and cross-check the
|
|
172
|
+
* aggregate. The trace is where those per-node figures survive: each node
|
|
173
|
+
* records what its own provider calls reported, while `response.tokens` is
|
|
174
|
+
* the reducer-accumulated total — the exact pair whose disagreement IS the
|
|
175
|
+
* §1.1 double-count. Without this the checker would see zero observed tokens
|
|
176
|
+
* and declare a mismatch on every question, which is noise, not a check.
|
|
177
|
+
*/
|
|
178
|
+
observeReportedCalls(trace) {
|
|
179
|
+
for (const node of [trace?.planner, trace?.graph, trace?.contextualiser, trace?.drift, trace?.answer]) {
|
|
180
|
+
if (node?.tokens)
|
|
181
|
+
this.accounting.observe({ input: node.tokens.input, output: node.tokens.output });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
exports.EndToEndSweepService = EndToEndSweepService;
|
|
186
|
+
exports.EndToEndSweepService = EndToEndSweepService = EndToEndSweepService_1 = __decorate([
|
|
187
|
+
(0, common_1.Injectable)(),
|
|
188
|
+
__metadata("design:paramtypes", [responder_service_1.ResponderService,
|
|
189
|
+
rubric_judge_service_1.RubricJudgeService,
|
|
190
|
+
evidence_matcher_1.EvidenceMatcher,
|
|
191
|
+
token_accounting_check_1.TokenAccountingChecker,
|
|
192
|
+
config_1.ConfigService])
|
|
193
|
+
], EndToEndSweepService);
|
|
194
|
+
//# sourceMappingURL=end-to-end-sweep.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"end-to-end-sweep.service.js","sourceRoot":"","sources":["../../../src/eval/retrieval/end-to-end-sweep.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,2CAA+C;AAC/C,yFAAqF;AACrF,4EAAwE;AAGxE,yDAAqD;AAErD,iEAA4D;AAC5D,qEAAkE;AAElE;;;;;GAKG;AAEI,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAG/B,YACmB,SAA2B,EAC3B,KAAyB,EACzB,QAAyB,EACzB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F,CAAA;AAhLY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAKmB,oCAAgB;QACpB,yCAAkB;QACf,kCAAe;QACb,+CAAsB;QACnB,sBAAa;GARpC,oBAAoB,CAgLhC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decides whether a ground-truth snippet is present in retrieved text.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately forgiving on whitespace and case, and deliberately NOT fuzzy on
|
|
5
|
+
* wording: a snippet is chosen by the question's author to be distinctive, so a
|
|
6
|
+
* near-miss is a miss. Chunk ids and positions cannot anchor this — ids are
|
|
7
|
+
* regenerated on every ingest and positions shift whenever the chunker changes.
|
|
8
|
+
*/
|
|
9
|
+
export declare class EvidenceMatcher {
|
|
10
|
+
private normalise;
|
|
11
|
+
matches(params: {
|
|
12
|
+
snippet: string;
|
|
13
|
+
haystack: string;
|
|
14
|
+
}): boolean;
|
|
15
|
+
score(params: {
|
|
16
|
+
snippets: string[];
|
|
17
|
+
haystack: string;
|
|
18
|
+
}): {
|
|
19
|
+
found: number;
|
|
20
|
+
missing: string[];
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=evidence.matcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence.matcher.d.ts","sourceRoot":"","sources":["../../../src/eval/retrieval/evidence.matcher.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,qBACa,eAAe;IAC1B,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO;IAM/D,KAAK,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;CAI9F"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.EvidenceMatcher = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
/**
|
|
12
|
+
* Decides whether a ground-truth snippet is present in retrieved text.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately forgiving on whitespace and case, and deliberately NOT fuzzy on
|
|
15
|
+
* wording: a snippet is chosen by the question's author to be distinctive, so a
|
|
16
|
+
* near-miss is a miss. Chunk ids and positions cannot anchor this — ids are
|
|
17
|
+
* regenerated on every ingest and positions shift whenever the chunker changes.
|
|
18
|
+
*/
|
|
19
|
+
let EvidenceMatcher = class EvidenceMatcher {
|
|
20
|
+
normalise(value) {
|
|
21
|
+
return value.replace(/\s+/g, " ").trim().toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
matches(params) {
|
|
24
|
+
const needle = this.normalise(params.snippet);
|
|
25
|
+
if (needle === "")
|
|
26
|
+
return false;
|
|
27
|
+
return this.normalise(params.haystack).includes(needle);
|
|
28
|
+
}
|
|
29
|
+
score(params) {
|
|
30
|
+
const missing = params.snippets.filter((snippet) => !this.matches({ snippet, haystack: params.haystack }));
|
|
31
|
+
return { found: params.snippets.length - missing.length, missing };
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.EvidenceMatcher = EvidenceMatcher;
|
|
35
|
+
exports.EvidenceMatcher = EvidenceMatcher = __decorate([
|
|
36
|
+
(0, common_1.Injectable)()
|
|
37
|
+
], EvidenceMatcher);
|
|
38
|
+
//# sourceMappingURL=evidence.matcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence.matcher.js","sourceRoot":"","sources":["../../../src/eval/retrieval/evidence.matcher.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAE5C;;;;;;;GAOG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAClB,SAAS,CAAC,KAAa;QAC7B,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACzD,CAAC;IAED,OAAO,CAAC,MAA6C;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,MAAM,KAAK,EAAE;YAAE,OAAO,KAAK,CAAC;QAChC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,MAAgD;QACpD,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC3G,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IACrE,CAAC;CACF,CAAA;AAfY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;GACA,eAAe,CAe3B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./retrieval-eval.types";
|
|
2
|
+
export { QuestionSetLoader } from "./question-set.loader";
|
|
3
|
+
export { EvidenceMatcher } from "./evidence.matcher";
|
|
4
|
+
export { RetrievalSweepService } from "./retrieval-sweep.service";
|
|
5
|
+
export { EndToEndSweepService } from "./end-to-end-sweep.service";
|
|
6
|
+
export { RubricJudgeService } from "./rubric-judge.service";
|
|
7
|
+
export { TokenAccountingChecker } from "./token-accounting.check";
|
|
8
|
+
export { renderSweepReport } from "./sweep-report";
|
|
9
|
+
export { RetrievalEvalModule } from "./retrieval-eval.module";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/eval/retrieval/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.RetrievalEvalModule = exports.renderSweepReport = exports.TokenAccountingChecker = exports.RubricJudgeService = exports.EndToEndSweepService = exports.RetrievalSweepService = exports.EvidenceMatcher = exports.QuestionSetLoader = void 0;
|
|
18
|
+
__exportStar(require("./retrieval-eval.types"), exports);
|
|
19
|
+
var question_set_loader_1 = require("./question-set.loader");
|
|
20
|
+
Object.defineProperty(exports, "QuestionSetLoader", { enumerable: true, get: function () { return question_set_loader_1.QuestionSetLoader; } });
|
|
21
|
+
var evidence_matcher_1 = require("./evidence.matcher");
|
|
22
|
+
Object.defineProperty(exports, "EvidenceMatcher", { enumerable: true, get: function () { return evidence_matcher_1.EvidenceMatcher; } });
|
|
23
|
+
var retrieval_sweep_service_1 = require("./retrieval-sweep.service");
|
|
24
|
+
Object.defineProperty(exports, "RetrievalSweepService", { enumerable: true, get: function () { return retrieval_sweep_service_1.RetrievalSweepService; } });
|
|
25
|
+
var end_to_end_sweep_service_1 = require("./end-to-end-sweep.service");
|
|
26
|
+
Object.defineProperty(exports, "EndToEndSweepService", { enumerable: true, get: function () { return end_to_end_sweep_service_1.EndToEndSweepService; } });
|
|
27
|
+
var rubric_judge_service_1 = require("./rubric-judge.service");
|
|
28
|
+
Object.defineProperty(exports, "RubricJudgeService", { enumerable: true, get: function () { return rubric_judge_service_1.RubricJudgeService; } });
|
|
29
|
+
var token_accounting_check_1 = require("./token-accounting.check");
|
|
30
|
+
Object.defineProperty(exports, "TokenAccountingChecker", { enumerable: true, get: function () { return token_accounting_check_1.TokenAccountingChecker; } });
|
|
31
|
+
var sweep_report_1 = require("./sweep-report");
|
|
32
|
+
Object.defineProperty(exports, "renderSweepReport", { enumerable: true, get: function () { return sweep_report_1.renderSweepReport; } });
|
|
33
|
+
var retrieval_eval_module_1 = require("./retrieval-eval.module");
|
|
34
|
+
Object.defineProperty(exports, "RetrievalEvalModule", { enumerable: true, get: function () { return retrieval_eval_module_1.RetrievalEvalModule; } });
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/eval/retrieval/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,6DAA0D;AAAjD,wHAAA,iBAAiB,OAAA;AAC1B,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AACxB,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,uEAAkE;AAAzD,gIAAA,oBAAoB,OAAA;AAC7B,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,+CAAmD;AAA1C,iHAAA,iBAAiB,OAAA;AAC1B,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EvalQuestionSet } from "./retrieval-eval.types";
|
|
2
|
+
/**
|
|
3
|
+
* Reads a question set from YAML and validates it.
|
|
4
|
+
*
|
|
5
|
+
* Fails loudly and specifically: a malformed ground truth that loads anyway
|
|
6
|
+
* would silently weaken every later comparison, which is the opposite of what
|
|
7
|
+
* this harness exists for.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors the YAML-loading style of `core/model-manager/model-loader.ts`.
|
|
10
|
+
*/
|
|
11
|
+
export declare class QuestionSetLoader {
|
|
12
|
+
load(params: {
|
|
13
|
+
path: string;
|
|
14
|
+
}): EvalQuestionSet;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=question-set.loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question-set.loader.d.ts","sourceRoot":"","sources":["../../../src/eval/retrieval/question-set.loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAyB,MAAM,wBAAwB,CAAC;AAEhF;;;;;;;;GAQG;AACH,qBACa,iBAAiB;IAC5B,IAAI,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,eAAe;CAWhD"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.QuestionSetLoader = void 0;
|
|
43
|
+
const common_1 = require("@nestjs/common");
|
|
44
|
+
const fs_1 = require("fs");
|
|
45
|
+
const yaml = __importStar(require("js-yaml"));
|
|
46
|
+
const retrieval_eval_types_1 = require("./retrieval-eval.types");
|
|
47
|
+
/**
|
|
48
|
+
* Reads a question set from YAML and validates it.
|
|
49
|
+
*
|
|
50
|
+
* Fails loudly and specifically: a malformed ground truth that loads anyway
|
|
51
|
+
* would silently weaken every later comparison, which is the opposite of what
|
|
52
|
+
* this harness exists for.
|
|
53
|
+
*
|
|
54
|
+
* Mirrors the YAML-loading style of `core/model-manager/model-loader.ts`.
|
|
55
|
+
*/
|
|
56
|
+
let QuestionSetLoader = class QuestionSetLoader {
|
|
57
|
+
load(params) {
|
|
58
|
+
const raw = yaml.load((0, fs_1.readFileSync)(params.path, "utf8"));
|
|
59
|
+
const parsed = retrieval_eval_types_1.evalQuestionSetSchema.safeParse(raw);
|
|
60
|
+
if (!parsed.success) {
|
|
61
|
+
const issues = parsed.error.issues
|
|
62
|
+
.map((issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`)
|
|
63
|
+
.join("; ");
|
|
64
|
+
throw new Error(`Invalid question set at ${params.path} — ${issues}`);
|
|
65
|
+
}
|
|
66
|
+
return parsed.data;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.QuestionSetLoader = QuestionSetLoader;
|
|
70
|
+
exports.QuestionSetLoader = QuestionSetLoader = __decorate([
|
|
71
|
+
(0, common_1.Injectable)()
|
|
72
|
+
], QuestionSetLoader);
|
|
73
|
+
//# sourceMappingURL=question-set.loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question-set.loader.js","sourceRoot":"","sources":["../../../src/eval/retrieval/question-set.loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2BAAkC;AAClC,8CAAgC;AAChC,iEAAgF;AAEhF;;;;;;;;GAQG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,IAAI,CAAC,MAAwB;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAA,iBAAY,EAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QACzD,MAAM,MAAM,GAAG,4CAAqB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM;iBAC/B,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;iBACvE,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,IAAI,MAAM,MAAM,EAAE,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;CACF,CAAA;AAZY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAY7B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluation tooling. NOT imported by AgentsModule or by bootstrap — a product
|
|
3
|
+
* that never runs a sweep must not pay for this module's dependency graph.
|
|
4
|
+
* Import it explicitly from a sweep entrypoint.
|
|
5
|
+
*
|
|
6
|
+
* The three imports carry exactly the providers this module's services inject:
|
|
7
|
+
* `LLMModule` exports `LLMService` (RubricJudgeService), `ChunkModule` exports
|
|
8
|
+
* `ChunkRepository` (RetrievalSweepService) and `ResponderModule` exports
|
|
9
|
+
* `ResponderService` (EndToEndSweepService). `TokenAccountingChecker`,
|
|
10
|
+
* `EvidenceMatcher` and `QuestionSetLoader` have no injected dependencies.
|
|
11
|
+
*/
|
|
12
|
+
export declare class RetrievalEvalModule {
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=retrieval-eval.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval-eval.module.d.ts","sourceRoot":"","sources":["../../../src/eval/retrieval/retrieval-eval.module.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;GAUG;AACH,qBAYa,mBAAmB;CAAG"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.RetrievalEvalModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const responder_module_1 = require("../../agents/responder/responder.module");
|
|
12
|
+
const llm_module_1 = require("../../core/llm/llm.module");
|
|
13
|
+
const chunk_module_1 = require("../../foundations/chunk/chunk.module");
|
|
14
|
+
const end_to_end_sweep_service_1 = require("./end-to-end-sweep.service");
|
|
15
|
+
const evidence_matcher_1 = require("./evidence.matcher");
|
|
16
|
+
const question_set_loader_1 = require("./question-set.loader");
|
|
17
|
+
const retrieval_sweep_service_1 = require("./retrieval-sweep.service");
|
|
18
|
+
const rubric_judge_service_1 = require("./rubric-judge.service");
|
|
19
|
+
const token_accounting_check_1 = require("./token-accounting.check");
|
|
20
|
+
/**
|
|
21
|
+
* Evaluation tooling. NOT imported by AgentsModule or by bootstrap — a product
|
|
22
|
+
* that never runs a sweep must not pay for this module's dependency graph.
|
|
23
|
+
* Import it explicitly from a sweep entrypoint.
|
|
24
|
+
*
|
|
25
|
+
* The three imports carry exactly the providers this module's services inject:
|
|
26
|
+
* `LLMModule` exports `LLMService` (RubricJudgeService), `ChunkModule` exports
|
|
27
|
+
* `ChunkRepository` (RetrievalSweepService) and `ResponderModule` exports
|
|
28
|
+
* `ResponderService` (EndToEndSweepService). `TokenAccountingChecker`,
|
|
29
|
+
* `EvidenceMatcher` and `QuestionSetLoader` have no injected dependencies.
|
|
30
|
+
*/
|
|
31
|
+
let RetrievalEvalModule = class RetrievalEvalModule {
|
|
32
|
+
};
|
|
33
|
+
exports.RetrievalEvalModule = RetrievalEvalModule;
|
|
34
|
+
exports.RetrievalEvalModule = RetrievalEvalModule = __decorate([
|
|
35
|
+
(0, common_1.Module)({
|
|
36
|
+
imports: [llm_module_1.LLMModule, chunk_module_1.ChunkModule, responder_module_1.ResponderModule],
|
|
37
|
+
providers: [
|
|
38
|
+
question_set_loader_1.QuestionSetLoader,
|
|
39
|
+
evidence_matcher_1.EvidenceMatcher,
|
|
40
|
+
retrieval_sweep_service_1.RetrievalSweepService,
|
|
41
|
+
end_to_end_sweep_service_1.EndToEndSweepService,
|
|
42
|
+
rubric_judge_service_1.RubricJudgeService,
|
|
43
|
+
token_accounting_check_1.TokenAccountingChecker,
|
|
44
|
+
],
|
|
45
|
+
exports: [question_set_loader_1.QuestionSetLoader, retrieval_sweep_service_1.RetrievalSweepService, end_to_end_sweep_service_1.EndToEndSweepService],
|
|
46
|
+
})
|
|
47
|
+
], RetrievalEvalModule);
|
|
48
|
+
//# sourceMappingURL=retrieval-eval.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval-eval.module.js","sourceRoot":"","sources":["../../../src/eval/retrieval/retrieval-eval.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,8EAA0E;AAC1E,0DAAsD;AACtD,uEAAmE;AACnE,yEAAkE;AAClE,yDAAqD;AACrD,+DAA0D;AAC1D,uEAAkE;AAClE,iEAA4D;AAC5D,qEAAkE;AAElE;;;;;;;;;;GAUG;AAaI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAAG,CAAA;AAAtB,kDAAmB;8BAAnB,mBAAmB;IAZ/B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,sBAAS,EAAE,0BAAW,EAAE,kCAAe,CAAC;QAClD,SAAS,EAAE;YACT,uCAAiB;YACjB,kCAAe;YACf,+CAAqB;YACrB,+CAAoB;YACpB,yCAAkB;YAClB,+CAAsB;SACvB;QACD,OAAO,EAAE,CAAC,uCAAiB,EAAE,+CAAqB,EAAE,+CAAoB,CAAC;KAC1E,CAAC;GACW,mBAAmB,CAAG"}
|