@carlonicora/nestjs-neo4jsonapi 2.14.10 → 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/core/llm/services/model.service.d.ts.map +1 -1
- package/dist/core/llm/services/model.service.js +5 -2
- package/dist/core/llm/services/model.service.js.map +1 -1
- package/dist/core/llm/services/reasoning-content-fetch.d.ts +41 -0
- package/dist/core/llm/services/reasoning-content-fetch.d.ts.map +1 -0
- package/dist/core/llm/services/reasoning-content-fetch.js +143 -0
- package/dist/core/llm/services/reasoning-content-fetch.js.map +1 -0
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk.vector.node.service.js","sourceRoot":"","sources":["../../../../src/agents/contextualiser/nodes/chunk.vector.node.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAsE;AACtE,
|
|
1
|
+
{"version":3,"file":"chunk.vector.node.service.js","sourceRoot":"","sources":["../../../../src/agents/contextualiser/nodes/chunk.vector.node.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAsE;AACtE,kFAA8E;AAC9E,+FAA2F;AAC3F,sEAA2E;AAM3E,yFAA0G;AAE1G,MAAM,eAAe,GAAG,CAAC,CAAC;AAGnB,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAGjC,YACmB,eAAgC,EAChC,eAAgC,EAGjD,gBAAiE;QAJhD,oBAAe,GAAf,eAAe,CAAiB;QAChC,oBAAe,GAAf,eAAe,CAAiB;QAGhC,qBAAgB,GAAhB,gBAAgB,CAAgC;QAPlD,WAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;IAQ/D,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,MAAqD;QACjE,2EAA2E;QAC3E,0EAA0E;QAC1E,oDAAoD;QACpD,MAAM,cAAc,GAClB,MAAM,CAAC,KAAK,CAAC,iBAAiB;YAC9B,CAAC,MAAM,IAAI,CAAC,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C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACxC,QAAQ,EAAE,kBAAkB;YAC5B,iBAAiB,EAAE,cAAc;YACjC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;SAChC,CAAC;IACJ,CAAC;CACF,CAAA;AAzHY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,iBAAQ,GAAE,CAAA;IACV,WAAA,IAAA,eAAM,EAAC,8CAAiB,CAAC,CAAA;qCAHQ,kCAAe;QACf,kCAAe;GALxC,sBAAsB,CAyHlC"}
|
|
@@ -5,7 +5,7 @@ import { LLMService } from "../../../core/llm/services/llm.service";
|
|
|
5
5
|
import { WebSocketService } from "../../../core/websocket/services/websocket.service";
|
|
6
6
|
import { KeyConceptRepository } from "../../../foundations/keyconcept/repositories/keyconcept.repository";
|
|
7
7
|
import { ContextualiserContext, ContextualiserContextState } from "../../contextualiser/contexts/contextualiser.context";
|
|
8
|
-
export declare const defaultKeyConceptsPrompt = "\nAs an intelligent assistant, your primary objective is to score a list of key concepts in relation to the user question.\n\nYou are given the question, the rational plan, and a list of key elements
|
|
8
|
+
export declare const defaultKeyConceptsPrompt = "\nAs an intelligent assistant, your primary objective is to score a list of key concepts in relation to the user question.\n\nYou are given the question, the rational plan, and a list of key elements.\nYour must check a list of Key Concepts, with the objective of selecting the most relevant ones to efficiently answer the question.\nThese initial key concepts are crucial because they are the starting point for searching for relevant information.\n\nGiven the **question**, the **rational plan** to answer the question, and the list of **Key Concepts** you have to:\n1. for each key concept\n - Read the key concept\n - Return the key concept's **index** \u2014 the position number given to it in the input list.\n - Restate its first few words (at most five) as the **label**, so the score that follows is anchored to the concept you actually read.\n - Assess a relevance to the potential answer by assigning a score between 0 and 100. A score of 100 implies a high likelihood of relevance to the answer, whereas a score of 0 suggests minimal relevance.\n2. Provide a Status Message\n - Write a **short, friendly message** (maximum 40 characters) about your action.\n - **Avoid technical terms** such as \"nodes\", \"atomic facts\", or \"key concepts\".\n - The status message should make the user understand the action being taken\n - The status message **MUST** contain clear information contextualised to the current question and the gathered information.\n - The status message should be specific to the context and clearly convey the next steps or actions being taken.\n - The status message **MUST NOT** be something unrelated to the text, such as \"success\", \"sufficient information\", \"insufficient information\", \"chunk analysed\", \"chunk processed\" or similar generic messages.\n\n### IMPORTANT\n - You should only use Key concepts provided in the list of key elements and refrain from using any other key concepts.\n - You **MUST NOT** create new key concepts, but use ONLY the ones provided.\n\n### **Please strictly follow the above instructions and format. Let's begin.**\n";
|
|
9
9
|
export declare class KeyConceptsNodeService {
|
|
10
10
|
private readonly llmService;
|
|
11
11
|
private readonly keyConceptRepository;
|
|
@@ -18,6 +18,5 @@ export declare class KeyConceptsNodeService {
|
|
|
18
18
|
execute(params: {
|
|
19
19
|
state: typeof ContextualiserContext.State;
|
|
20
20
|
}): Promise<Partial<ContextualiserContextState>>;
|
|
21
|
-
private _transformMetadata;
|
|
22
21
|
}
|
|
23
22
|
//# sourceMappingURL=keyconcepts.node.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyconcepts.node.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/contextualiser/nodes/keyconcepts.node.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAA0B,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;
|
|
1
|
+
{"version":3,"file":"keyconcepts.node.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/contextualiser/nodes/keyconcepts.node.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAA0B,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AAGtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,oEAAoE,CAAC;AAE1G,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,sDAAsD,CAAC;AAE9D,eAAO,MAAM,wBAAwB,ikEA0BpC,CAAC;AA+CF,qBACa,sBAAsB;IAK/B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,aAAa;IARhC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAClE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAGnB,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,oBAAoB,EAC1C,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAAC;IAM9D,OAAO,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,OAAO,qBAAqB,CAAC,KAAK,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;CA+HnH"}
|
|
@@ -17,21 +17,22 @@ const nestjs_cls_1 = require("nestjs-cls");
|
|
|
17
17
|
const zod_1 = require("zod");
|
|
18
18
|
const llm_service_1 = require("../../../core/llm/services/llm.service");
|
|
19
19
|
const websocket_service_1 = require("../../../core/websocket/services/websocket.service");
|
|
20
|
+
const retrieval_constants_1 = require("../../../foundations/chunk/repositories/retrieval.constants");
|
|
20
21
|
const keyconcept_repository_1 = require("../../../foundations/keyconcept/repositories/keyconcept.repository");
|
|
21
22
|
const usage_attribution_1 = require("../../common/usage-attribution");
|
|
22
23
|
exports.defaultKeyConceptsPrompt = `
|
|
23
24
|
As an intelligent assistant, your primary objective is to score a list of key concepts in relation to the user question.
|
|
24
25
|
|
|
25
|
-
You are given the question, the rational plan, and a list of key elements
|
|
26
|
+
You are given the question, the rational plan, and a list of key elements.
|
|
26
27
|
Your must check a list of Key Concepts, with the objective of selecting the most relevant ones to efficiently answer the question.
|
|
27
28
|
These initial key concepts are crucial because they are the starting point for searching for relevant information.
|
|
28
29
|
|
|
29
30
|
Given the **question**, the **rational plan** to answer the question, and the list of **Key Concepts** you have to:
|
|
30
31
|
1. for each key concept
|
|
31
32
|
- Read the key concept
|
|
32
|
-
-
|
|
33
|
+
- Return the key concept's **index** — the position number given to it in the input list.
|
|
34
|
+
- Restate its first few words (at most five) as the **label**, so the score that follows is anchored to the concept you actually read.
|
|
33
35
|
- Assess a relevance to the potential answer by assigning a score between 0 and 100. A score of 100 implies a high likelihood of relevance to the answer, whereas a score of 0 suggests minimal relevance.
|
|
34
|
-
- If the key element contains metadata and the metadata is very relevant to the question and it will be used to answer the question, please indicate that the key element is used as a source for the answer setting isUsedAsSource to true. In any other case (there is no metadata or the metadata is not relevant to the question), set isUsedAsSource to false.
|
|
35
36
|
2. Provide a Status Message
|
|
36
37
|
- Write a **short, friendly message** (maximum 40 characters) about your action.
|
|
37
38
|
- **Avoid technical terms** such as "nodes", "atomic facts", or "key concepts".
|
|
@@ -49,26 +50,31 @@ Given the **question**, the **rational plan** to answer the question, and the li
|
|
|
49
50
|
const outputSchema = zod_1.z.object({
|
|
50
51
|
status: zod_1.z
|
|
51
52
|
.string()
|
|
52
|
-
.describe(`Write a short, friendly message (max 40 characters) about your action, avoiding technical terms such as "nodes" or "atomic facts" or "key
|
|
53
|
+
.describe(`Write a short, friendly message (max 40 characters) about your action, avoiding technical terms such as "nodes" or "atomic facts" or "key concepts". Give flavour to the message and avoid repeating the same message.`),
|
|
53
54
|
keyConcepts: zod_1.z
|
|
54
55
|
.array(zod_1.z.object({
|
|
55
|
-
|
|
56
|
+
index: zod_1.z
|
|
57
|
+
.number()
|
|
58
|
+
.int()
|
|
59
|
+
.describe("Zero-based position of the concept in the keyConcepts list you were given. This is the ONLY field used to identify the concept — copy the position exactly."),
|
|
60
|
+
label: zod_1.z
|
|
61
|
+
.string()
|
|
62
|
+
.describe("The first few words (at most five) of the concept at that position, copied from the list. Write this BEFORE the score: restating what you are judging is what keeps the score anchored to the right concept. It is not used to identify the concept — the index is."),
|
|
56
63
|
score: zod_1.z
|
|
57
64
|
.number()
|
|
58
|
-
.describe(
|
|
59
|
-
isUsedAsSource: zod_1.z.boolean().describe(`Indicate if the keyConcept is used as a source for the answer`),
|
|
65
|
+
.describe("Relevance of that concept to the question and plan, 0-100. 100 means highly likely to lead to the answer; 0 means irrelevant."),
|
|
60
66
|
}))
|
|
61
|
-
.describe(`
|
|
67
|
+
.describe(`The concepts worth following, as positions in the input list. Return ONLY those scoring above 50 — omitting a concept is how you reject it.`),
|
|
62
68
|
});
|
|
63
69
|
const inputSchema = zod_1.z.object({
|
|
64
70
|
question: zod_1.z.string().describe("The user question"),
|
|
65
71
|
rationalPlan: zod_1.z.string().describe("The rational plan to use to answer the user question"),
|
|
66
72
|
keyConcepts: zod_1.z
|
|
67
73
|
.array(zod_1.z.object({
|
|
74
|
+
index: zod_1.z.number().int().describe("This concept's position. Refer to the concept by THIS number."),
|
|
68
75
|
keyConcept: zod_1.z.string().describe("Key Concept"),
|
|
69
|
-
metadata: zod_1.z.any().optional().describe("The metadata associated with the key concept"),
|
|
70
76
|
}))
|
|
71
|
-
.describe("The key concepts to analyse"),
|
|
77
|
+
.describe("The key concepts to analyse, each with the position you must use to refer to it"),
|
|
72
78
|
});
|
|
73
79
|
let KeyConceptsNodeService = KeyConceptsNodeService_1 = class KeyConceptsNodeService {
|
|
74
80
|
constructor(llmService, keyConceptRepository, webSocketService, clsService, configService) {
|
|
@@ -82,7 +88,6 @@ let KeyConceptsNodeService = KeyConceptsNodeService_1 = class KeyConceptsNodeSer
|
|
|
82
88
|
this.systemPrompt = prompts?.contextualiser?.keyConceptExtractor ?? exports.defaultKeyConceptsPrompt;
|
|
83
89
|
}
|
|
84
90
|
async execute(params) {
|
|
85
|
-
params.state.hops += 1;
|
|
86
91
|
let keyConcepts = [];
|
|
87
92
|
if (params.state.nextStep === "key_concepts") {
|
|
88
93
|
keyConcepts = await this.keyConceptRepository.findPotentialKeyConcepts({
|
|
@@ -95,6 +100,11 @@ let KeyConceptsNodeService = KeyConceptsNodeService_1 = class KeyConceptsNodeSer
|
|
|
95
100
|
dataLimits: params.state.limits,
|
|
96
101
|
scope: params.state,
|
|
97
102
|
}),
|
|
103
|
+
// Reuses the embedding chunk_vector already computed this turn instead
|
|
104
|
+
// of embedding the same question twice. Falls back to embedding
|
|
105
|
+
// itself when undefined (e.g. a run that reaches this node without
|
|
106
|
+
// chunk_vector having executed).
|
|
107
|
+
queryEmbedding: params.state.questionEmbedding,
|
|
98
108
|
});
|
|
99
109
|
this.logger.log(`findPotentialKeyConcepts → ${keyConcepts.length} concepts ` +
|
|
100
110
|
`(question="${params.state.question}" howToMode=${!!params.state.limits.howToMode} ` +
|
|
@@ -109,29 +119,33 @@ let KeyConceptsNodeService = KeyConceptsNodeService_1 = class KeyConceptsNodeSer
|
|
|
109
119
|
this.logger.log(`findNeighboursByKeyConcepts → ${keyConcepts.length} concepts ` +
|
|
110
120
|
`(from ${params.state.processedKeyConcepts.length} processed)`);
|
|
111
121
|
}
|
|
112
|
-
const metadataList = [];
|
|
113
122
|
const usableNodes = keyConcepts
|
|
114
123
|
.filter((keyConcept) => !params.state.processedKeyConcepts.includes(keyConcept.value))
|
|
115
|
-
.map((keyConcept) => {
|
|
116
|
-
|
|
124
|
+
.map((keyConcept) => ({ keyConcept: keyConcept.value }));
|
|
125
|
+
// Safety check: nothing left to explore. The run-wide ceiling is the call
|
|
126
|
+
// budget in contextualiser.service.ts — this node no longer carries a
|
|
127
|
+
// second, disagreeing one of its own.
|
|
128
|
+
if (!usableNodes || !usableNodes.length) {
|
|
129
|
+
this.logger.warn(`key_concepts → answer (no usable concepts): usableNodes=${usableNodes?.length ?? 0} ` +
|
|
130
|
+
`processedKeyConcepts=${params.state.processedKeyConcepts.length}`);
|
|
131
|
+
// Delta only: ContextualiserContext.tokens is additive, so returning the
|
|
132
|
+
// whole state re-adds every token accumulated so far. The node consumed
|
|
133
|
+
// one graph hop and `neighbouringAlreadyExplored` is mutated on
|
|
134
|
+
// `params.state` above, so both stay in the delta. No provider call was
|
|
135
|
+
// made on this path, so it reports no `llmCalls`.
|
|
117
136
|
return {
|
|
118
|
-
|
|
119
|
-
|
|
137
|
+
nextStep: "answer",
|
|
138
|
+
hops: params.state.hops + 1,
|
|
139
|
+
neighbouringAlreadyExplored: params.state.neighbouringAlreadyExplored,
|
|
140
|
+
queuedKeyConcepts: [],
|
|
120
141
|
};
|
|
121
|
-
});
|
|
122
|
-
// Safety check: If approaching max hops or no usable nodes, stop exploration
|
|
123
|
-
const approachingMaxHops = params.state.hops >= 15;
|
|
124
|
-
if (!usableNodes || !usableNodes.length || approachingMaxHops) {
|
|
125
|
-
this.logger.warn(`key_concepts → answer (no usable concepts): usableNodes=${usableNodes?.length ?? 0} ` +
|
|
126
|
-
`processedKeyConcepts=${params.state.processedKeyConcepts.length} ` +
|
|
127
|
-
`approachingMaxHops=${approachingMaxHops}`);
|
|
128
|
-
params.state.nextStep = "answer";
|
|
129
|
-
return params.state;
|
|
130
142
|
}
|
|
131
143
|
const inputParams = {
|
|
132
144
|
rationalPlan: params.state.rationalPlan,
|
|
133
145
|
question: params.state.question,
|
|
134
|
-
|
|
146
|
+
// The model answers with positions in THIS array, so the numbering it is
|
|
147
|
+
// given and the array the answer maps back into must stay in one order.
|
|
148
|
+
keyConcepts: usableNodes.map((node, index) => ({ index, keyConcept: node.keyConcept })),
|
|
135
149
|
};
|
|
136
150
|
const llmResponse = await this.llmService.call({
|
|
137
151
|
inputSchema: inputSchema,
|
|
@@ -139,6 +153,7 @@ let KeyConceptsNodeService = KeyConceptsNodeService_1 = class KeyConceptsNodeSer
|
|
|
139
153
|
outputSchema: outputSchema,
|
|
140
154
|
systemPrompts: [this.systemPrompt],
|
|
141
155
|
temperature: 0.1,
|
|
156
|
+
metadata: { agentName: "contextualiser", nodeName: "key_concepts" },
|
|
142
157
|
// Billed to the CALLING agent: its ledger category, its entity. Spread
|
|
143
158
|
// LAST so nothing above can overwrite the attribution.
|
|
144
159
|
...(0, usage_attribution_1.buildInheritedAttribution)(params.state),
|
|
@@ -148,50 +163,35 @@ let KeyConceptsNodeService = KeyConceptsNodeService_1 = class KeyConceptsNodeSer
|
|
|
148
163
|
message: llmResponse.status,
|
|
149
164
|
conversationId: params.state.contentId,
|
|
150
165
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
168
|
-
const allowableConcepts = keyConcepts
|
|
169
|
-
.filter((keyConcept) => !params.state.processedKeyConcepts.includes(keyConcept.value))
|
|
170
|
-
.map((el) => el.value);
|
|
171
|
-
const generatedConcepts = llmResponse.keyConcepts.filter((el) => allowableConcepts.includes(el.keyConcept));
|
|
172
|
-
const keyConceptsQueue = generatedConcepts
|
|
166
|
+
// The INDEX identifies the concept; the `label` exists only so the model
|
|
167
|
+
// restates what it is judging before it scores it. Measured: dropping the
|
|
168
|
+
// restatement entirely (index + score alone) kept the same NUMBER of
|
|
169
|
+
// concepts but selected a materially worse SET — atomic-fact yield fell 25%
|
|
170
|
+
// across the eval corpus, on 13 of 20 questions. See Gate 3b in
|
|
171
|
+
// docs/superpowers/reports/2026-08-21-contextualiser-phase3-report.md.
|
|
172
|
+
const scoredConcepts = (llmResponse.keyConcepts ?? []).filter((scored) => Number.isInteger(scored.index) && scored.index >= 0 && scored.index < usableNodes.length);
|
|
173
|
+
// A label that does not match its index means the model lost position
|
|
174
|
+
// discipline — the score then belongs to a different concept than the one
|
|
175
|
+
// queued. Diagnostic only: the index still wins, because a mismatched label
|
|
176
|
+
// is no evidence about which of the two is wrong.
|
|
177
|
+
const drifted = scoredConcepts.filter((scored) => !!scored.label &&
|
|
178
|
+
!usableNodes[scored.index].keyConcept.toLowerCase().startsWith(scored.label.trim().toLowerCase().slice(0, 12))).length;
|
|
179
|
+
if (drifted > 0)
|
|
180
|
+
this.logger.warn(`key_concepts: ${drifted}/${scoredConcepts.length} labels did not match their index`);
|
|
181
|
+
const keyConceptsQueue = scoredConcepts
|
|
173
182
|
.sort((a, b) => b.score - a.score)
|
|
174
|
-
.map((
|
|
175
|
-
.slice(0,
|
|
183
|
+
.map((scored) => usableNodes[scored.index].keyConcept)
|
|
184
|
+
.slice(0, retrieval_constants_1.MAX_KEY_CONCEPTS);
|
|
176
185
|
const returnedHops = params.state.hops + 1;
|
|
177
186
|
return {
|
|
178
187
|
hops: returnedHops,
|
|
188
|
+
llmCalls: 1,
|
|
179
189
|
queuedKeyConcepts: keyConceptsQueue,
|
|
180
190
|
nextStep: "atomic_facts",
|
|
181
191
|
status: [llmResponse.status],
|
|
182
192
|
tokens: llmResponse.tokenUsage,
|
|
183
193
|
};
|
|
184
194
|
}
|
|
185
|
-
_transformMetadata(params) {
|
|
186
|
-
let response = `Metadata for ${params.node} > `;
|
|
187
|
-
response += `Type: ${params.metadata.type}`;
|
|
188
|
-
if (params.metadata.data && typeof params.metadata.data === "object") {
|
|
189
|
-
Object.entries(params.metadata.data).forEach(([key, value]) => {
|
|
190
|
-
response += `, ${key}: ${value}`;
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
return response;
|
|
194
|
-
}
|
|
195
195
|
};
|
|
196
196
|
exports.KeyConceptsNodeService = KeyConceptsNodeService;
|
|
197
197
|
exports.KeyConceptsNodeService = KeyConceptsNodeService = KeyConceptsNodeService_1 = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyconcepts.node.service.js","sourceRoot":"","sources":["../../../../src/agents/contextualiser/nodes/keyconcepts.node.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,2CAA+C;AAC/C,2CAAwC;AACxC,6BAAwB;AAExB,wEAAoE;AACpE,0FAAsF;
|
|
1
|
+
{"version":3,"file":"keyconcepts.node.service.js","sourceRoot":"","sources":["../../../../src/agents/contextualiser/nodes/keyconcepts.node.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,2CAA+C;AAC/C,2CAAwC;AACxC,6BAAwB;AAExB,wEAAoE;AACpE,0FAAsF;AACtF,qGAA+F;AAE/F,8GAA0G;AAC1G,sEAAsG;AAMzF,QAAA,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BvC,CAAC;AAEF,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,QAAQ,CACP,wNAAwN,CACzN;IACH,WAAW,EAAE,OAAC;SACX,KAAK,CACJ,OAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,OAAC;aACL,MAAM,EAAE;aACR,GAAG,EAAE;aACL,QAAQ,CACP,6JAA6J,CAC9J;QACH,KAAK,EAAE,OAAC;aACL,MAAM,EAAE;aACR,QAAQ,CACP,qQAAqQ,CACtQ;QACH,KAAK,EAAE,OAAC;aACL,MAAM,EAAE;aACR,QAAQ,CACP,+HAA+H,CAChI;KACJ,CAAC,CACH;SACA,QAAQ,CACP,6IAA6I,CAC9I;CACJ,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,QAAQ,EAAE,OAAC,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EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CACjH,CAAC,MAAM,CAAC;QACT,IAAI,OAAO,GAAG,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,OAAO,IAAI,cAAc,CAAC,MAAM,mCAAmC,CAAC,CAAC;QAEzG,MAAM,gBAAgB,GAAa,cAAc;aAC9C,IAAI,CAAC,CAAC,CAAoB,EAAE,CAAoB,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;aACvE,GAAG,CAAC,CAAC,MAAyB,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC;aACxE,KAAK,CAAC,CAAC,EAAE,sCAAgB,CAAC,CAAC;QAE9B,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;QAE3C,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE,CAAC;YACX,iBAAiB,EAAE,gBAAgB;YACnC,QAAQ,EAAE,cAAc;YACxB,MAAM,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;YAC5B,MAAM,EAAE,WAAW,CAAC,UAAU;SAC/B,CAAC;IACJ,CAAC;CACF,CAAA;AA9IY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAMoB,wBAAU;QACA,4CAAoB;QACxB,oCAAgB;QACtB,uBAAU;QACP,sBAAa;GATpC,sBAAsB,CA8IlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"question.refiner.node.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/contextualiser/nodes/question.refiner.node.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAA0B,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AACtF,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,sDAAsD,CAAC;AAG9D,eAAO,MAAM,4BAA4B,6oDAuCxC,CAAC;AA0BF,qBACa,0BAA0B;IAInC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,aAAa;IANhC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAGnB,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAAC;IAM9D,OAAO,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,OAAO,qBAAqB,CAAC,KAAK,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"question.refiner.node.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/contextualiser/nodes/question.refiner.node.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAA0B,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AACtF,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,sDAAsD,CAAC;AAG9D,eAAO,MAAM,4BAA4B,6oDAuCxC,CAAC;AA0BF,qBACa,0BAA0B;IAInC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,aAAa;IANhC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAGnB,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAAC;IAM9D,OAAO,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,OAAO,qBAAqB,CAAC,KAAK,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;CA2CnH"}
|
|
@@ -83,9 +83,12 @@ let QuestionRefinerNodeService = class QuestionRefinerNodeService {
|
|
|
83
83
|
this.systemPrompt = prompts?.contextualiser?.questionRefiner ?? exports.defaultQuestionRefinerPrompt;
|
|
84
84
|
}
|
|
85
85
|
async execute(params) {
|
|
86
|
-
|
|
86
|
+
// Nothing to refine on a fresh conversation. Return a DELTA rather than the
|
|
87
|
+
// whole state — see keyconcepts.node.service.ts for why. The node still
|
|
88
|
+
// consumed one graph hop, so the delta carries `hops`; it made no provider
|
|
89
|
+
// call, so it reports no `llmCalls`.
|
|
87
90
|
if (params.state.chatHistory.length === 0)
|
|
88
|
-
return params.state;
|
|
91
|
+
return { hops: params.state.hops + 1 };
|
|
89
92
|
const inputParams = {
|
|
90
93
|
chatHistory: [
|
|
91
94
|
...params.state.chatHistory,
|
|
@@ -101,6 +104,7 @@ let QuestionRefinerNodeService = class QuestionRefinerNodeService {
|
|
|
101
104
|
outputSchema: outputSchema,
|
|
102
105
|
systemPrompts: [this.systemPrompt],
|
|
103
106
|
temperature: 0.1,
|
|
107
|
+
metadata: { agentName: "contextualiser", nodeName: "question_refiner" },
|
|
104
108
|
// Billed to the CALLING agent: its ledger category, its entity. Spread
|
|
105
109
|
// LAST so nothing above can overwrite the attribution.
|
|
106
110
|
...(0, usage_attribution_1.buildInheritedAttribution)(params.state),
|
|
@@ -113,6 +117,7 @@ let QuestionRefinerNodeService = class QuestionRefinerNodeService {
|
|
|
113
117
|
const returnedHops = params.state.hops + 1;
|
|
114
118
|
return {
|
|
115
119
|
hops: returnedHops,
|
|
120
|
+
llmCalls: 1,
|
|
116
121
|
question: llmResponse.response,
|
|
117
122
|
tokens: llmResponse.tokenUsage,
|
|
118
123
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"question.refiner.node.service.js","sourceRoot":"","sources":["../../../../src/agents/contextualiser/nodes/question.refiner.node.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,2CAAwC;AACxC,6BAAwB;AAExB,wEAAoE;AACpE,0FAAsF;AAKtF,sEAA2E;AAE9D,QAAA,4BAA4B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuC3C,CAAC;AAEF,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,QAAQ,CACP,0NAA0N,CAC3N;IACH,QAAQ,EAAE,OAAC;SACR,MAAM,EAAE;SACR,QAAQ,CACP,+IAA+I,CAChJ;CACJ,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,OAAC;SACX,KAAK,CACJ,OAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;QACzD,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;KAChE,CAAC,CACH;SACA,QAAQ,CAAC,kBAAkB,CAAC;CAChC,CAAC,CAAC;AAGI,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAGrC,YACmB,UAAsB,EACtB,gBAAkC,EAClC,UAAsB,EACtB,aAAiD;QAHjD,eAAU,GAAV,UAAU,CAAY;QACtB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,eAAU,GAAV,UAAU,CAAY;QACtB,kBAAa,GAAb,aAAa,CAAoC;QAElE,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAyB,SAAS,CAAC,CAAC;QAC1E,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,cAAc,EAAE,eAAe,IAAI,oCAA4B,CAAC;IAC/F,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAqD;QACjE,
|
|
1
|
+
{"version":3,"file":"question.refiner.node.service.js","sourceRoot":"","sources":["../../../../src/agents/contextualiser/nodes/question.refiner.node.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,2CAAwC;AACxC,6BAAwB;AAExB,wEAAoE;AACpE,0FAAsF;AAKtF,sEAA2E;AAE9D,QAAA,4BAA4B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuC3C,CAAC;AAEF,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,QAAQ,CACP,0NAA0N,CAC3N;IACH,QAAQ,EAAE,OAAC;SACR,MAAM,EAAE;SACR,QAAQ,CACP,+IAA+I,CAChJ;CACJ,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,OAAC;SACX,KAAK,CACJ,OAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;QACzD,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;KAChE,CAAC,CACH;SACA,QAAQ,CAAC,kBAAkB,CAAC;CAChC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AK,CAAC;SAC3C,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,cAAc;YAC7C,MAAM,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,gBAAgB,EAAE;gBAC7F,OAAO,EAAE,WAAW,CAAC,MAAM;gBAC3B,cAAc,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS;aACvC,CAAC,CAAC;QAEL,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;QAC3C,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE,CAAC;YACX,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,MAAM,EAAE,WAAW,CAAC,UAAU;SAC/B,CAAC;IACJ,CAAC;CACF,CAAA;AAxDY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;qCAKoB,wBAAU;QACJ,oCAAgB;QACtB,uBAAU;QACP,sBAAa;GAPpC,0BAA0B,CAwDtC"}
|
|
@@ -67,7 +67,6 @@ let RationalNodeService = class RationalNodeService {
|
|
|
67
67
|
this.systemPrompt = prompts?.contextualiser?.rationalPlan ?? exports.defaultRationalPlanPrompt;
|
|
68
68
|
}
|
|
69
69
|
async execute(params) {
|
|
70
|
-
params.state.hops += 1;
|
|
71
70
|
const inputParams = {
|
|
72
71
|
question: params.state.question,
|
|
73
72
|
analysis: params.state.previousAnalysis,
|
|
@@ -78,6 +77,7 @@ let RationalNodeService = class RationalNodeService {
|
|
|
78
77
|
outputSchema: outputSchema,
|
|
79
78
|
systemPrompts: [this.systemPrompt],
|
|
80
79
|
temperature: 0.1,
|
|
80
|
+
metadata: { agentName: "contextualiser", nodeName: "rational_plan" },
|
|
81
81
|
// Billed to the CALLING agent: its ledger category, its entity. Spread
|
|
82
82
|
// LAST so nothing above can overwrite the attribution.
|
|
83
83
|
...(0, usage_attribution_1.buildInheritedAttribution)(params.state),
|
|
@@ -90,6 +90,7 @@ let RationalNodeService = class RationalNodeService {
|
|
|
90
90
|
const returnedHops = params.state.hops + 1;
|
|
91
91
|
return {
|
|
92
92
|
hops: returnedHops,
|
|
93
|
+
llmCalls: 1,
|
|
93
94
|
rationalPlan: llmResponse.rationalPlan,
|
|
94
95
|
nextStep: "key_concepts",
|
|
95
96
|
status: [llmResponse.status],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rational.node.service.js","sourceRoot":"","sources":["../../../../src/agents/contextualiser/nodes/rational.node.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,2CAAwC;AACxC,6BAAwB;AAExB,wEAAoE;AACpE,0FAAsF;AAKtF,sEAA2E;AAE9D,QAAA,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BxC,CAAC;AAEF,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,QAAQ,CACP,wNAAwN,CACzN;IACH,YAAY,EAAE,OAAC;SACZ,MAAM,EAAE;SACR,QAAQ,CAAC,4FAA4F,CAAC;CAC1G,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IAClD,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;CAC/E,CAAC,CAAC;AAGI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAG9B,YACmB,UAAsB,EACtB,gBAAkC,EAClC,UAAsB,EACtB,aAAiD;QAHjD,eAAU,GAAV,UAAU,CAAY;QACtB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,eAAU,GAAV,UAAU,CAAY;QACtB,kBAAa,GAAb,aAAa,CAAoC;QAElE,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAyB,SAAS,CAAC,CAAC;QAC1E,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,cAAc,EAAE,YAAY,IAAI,iCAAyB,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAqD;QACjE,MAAM,
|
|
1
|
+
{"version":3,"file":"rational.node.service.js","sourceRoot":"","sources":["../../../../src/agents/contextualiser/nodes/rational.node.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,2CAAwC;AACxC,6BAAwB;AAExB,wEAAoE;AACpE,0FAAsF;AAKtF,sEAA2E;AAE9D,QAAA,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BxC,CAAC;AAEF,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,QAAQ,CACP,wNAAwN,CACzN;IACH,YAAY,EAAE,OAAC;SACZ,MAAM,EAAE;SACR,QAAQ,CAAC,4FAA4F,CAAC;CAC1G,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IAClD,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;CAC/E,CAAC,CAAC;AAGI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAG9B,YACmB,UAAsB,EACtB,gBAAkC,EAClC,UAAsB,EACtB,aAAiD;QAHjD,eAAU,GAAV,UAAU,CAAY;QACtB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,eAAU,GAAV,UAAU,CAAY;QACtB,kBAAa,GA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AAE,cAAc;YACxB,MAAM,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;YAC5B,MAAM,EAAE,WAAW,CAAC,UAAU;SAC/B,CAAC;IACJ,CAAC;CACF,CAAA;AAhDY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAKoB,wBAAU;QACJ,oCAAgB;QACtB,uBAAU;QACP,sBAAa;GAPpC,mBAAmB,CAgD/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextualiser.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/contextualiser/services/contextualiser.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAEL,0BAA0B,EAE3B,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,mCAAmC,EAAE,MAAM,+DAA+D,CAAC;AACpH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,sDAAsD,CAAC;AAC9F,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"contextualiser.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/contextualiser/services/contextualiser.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAEL,0BAA0B,EAE3B,MAAM,sDAAsD,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BAAsB,EACvC,SAAS,EAAE,gBAAgB,EAC3B,eAAe,EAAE,sBAAsB,EACvC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,cAAc;IAGnC,GAAG,CAAC,MAAM,EAAE;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,UAAU,EAAE,UAAU,CAAC;QACvB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;QAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB;;;;WAIG;QACH,WAAW,CAAC,EAAE,sBAAsB,CAAC;KACtC,GAAG,OAAO,CAAC,0BAA0B,CAAC;CA4PxC"}
|
|
@@ -23,6 +23,7 @@ const keyconcepts_node_service_1 = require("../../contextualiser/nodes/keyconcep
|
|
|
23
23
|
const question_refiner_node_service_1 = require("../../contextualiser/nodes/question.refiner.node.service");
|
|
24
24
|
const rational_node_service_1 = require("../../contextualiser/nodes/rational.node.service");
|
|
25
25
|
const tracing_service_1 = require("../../../core/tracing/services/tracing.service");
|
|
26
|
+
const retrieval_constants_1 = require("../../../foundations/chunk/repositories/retrieval.constants");
|
|
26
27
|
const usage_attribution_1 = require("../../common/usage-attribution");
|
|
27
28
|
/**
|
|
28
29
|
* Picks the graph entry node for a turn.
|
|
@@ -47,7 +48,9 @@ let ContextualiserService = ContextualiserService_1 = class ContextualiserServic
|
|
|
47
48
|
this.logger = new common_1.Logger(ContextualiserService_1.name);
|
|
48
49
|
}
|
|
49
50
|
async run(params) {
|
|
50
|
-
|
|
51
|
+
// Supersteps, not spend. LangGraph needs an absolute ceiling so a routing
|
|
52
|
+
// bug cannot loop forever; the SPEND bound is MAX_LLM_CALLS_PER_RUN below.
|
|
53
|
+
const maxSupersteps = 20;
|
|
51
54
|
// Log proportionately. A caller that named NOTHING is opting out — MCP tool
|
|
52
55
|
// calls do this on every single request and are right to — so it gets a
|
|
53
56
|
// debug line, not a warning. A caller that named something unusable is a
|
|
@@ -77,8 +80,8 @@ let ContextualiserService = ContextualiserService_1 = class ContextualiserServic
|
|
|
77
80
|
contentType: params.contentType,
|
|
78
81
|
messagesCount: params.messages.length,
|
|
79
82
|
question: params.question ?? "none",
|
|
80
|
-
|
|
81
|
-
recursionLimit:
|
|
83
|
+
maxSupersteps: maxSupersteps,
|
|
84
|
+
recursionLimit: maxSupersteps + 2,
|
|
82
85
|
initialNode: initial,
|
|
83
86
|
},
|
|
84
87
|
});
|
|
@@ -87,88 +90,93 @@ let ContextualiserService = ContextualiserService_1 = class ContextualiserServic
|
|
|
87
90
|
this.clsService.set("ragStatus", `${params.state.status.join("\n\n")}`);
|
|
88
91
|
}
|
|
89
92
|
const nextStep = params.forceNextStep ?? params.state.nextStep;
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
// The budget is on PROVIDER CALLS. `hops` counts nodes and three of them
|
|
94
|
+
// advance it by two, so it was never a spend bound.
|
|
95
|
+
const budgetSpent = (params.state.llmCalls ?? 0) >= retrieval_constants_1.MAX_LLM_CALLS_PER_RUN;
|
|
96
|
+
if (budgetSpent) {
|
|
97
|
+
this.logger.warn(`contextualiser call budget spent (${params.state.llmCalls}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}) — routing to answer`);
|
|
98
|
+
}
|
|
99
|
+
return budgetSpent ? "answer" : nextStep;
|
|
92
100
|
};
|
|
93
101
|
const workflow = new langgraph_1.StateGraph(contextualiser_context_1.ContextualiserContext)
|
|
94
102
|
.addNode("question_refiner", async (state) => {
|
|
95
|
-
this.tracer.addSpanEvent(`Node: question_refiner - hop ${state.hops}/${
|
|
103
|
+
this.tracer.addSpanEvent(`Node: question_refiner - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
96
104
|
hopCount: state.hops,
|
|
97
105
|
});
|
|
98
106
|
const result = await this.questionRefinedNode.execute({ state: state });
|
|
99
|
-
this.tracer.addSpanEvent(`Node: question_refiner complete - hop ${state.hops}/${
|
|
107
|
+
this.tracer.addSpanEvent(`Node: question_refiner complete - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
100
108
|
nextStep: result.nextStep,
|
|
101
109
|
});
|
|
102
110
|
return result;
|
|
103
111
|
})
|
|
104
112
|
.addNode("rational_plan", async (state) => {
|
|
105
|
-
this.tracer.addSpanEvent(`Node: rational_plan - hop ${state.hops}/${
|
|
113
|
+
this.tracer.addSpanEvent(`Node: rational_plan - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
106
114
|
hopCount: state.hops,
|
|
107
115
|
});
|
|
108
116
|
const result = await this.rationalNode.execute({ state: state });
|
|
109
|
-
this.tracer.addSpanEvent(`Node: rational_plan complete - hop ${state.hops}/${
|
|
117
|
+
this.tracer.addSpanEvent(`Node: rational_plan complete - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
110
118
|
nextStep: result.nextStep,
|
|
111
119
|
});
|
|
112
120
|
return result;
|
|
113
121
|
})
|
|
114
122
|
.addNode("key_concepts", async (state) => {
|
|
115
|
-
this.tracer.addSpanEvent(`Node: key_concepts - hop ${state.hops}/${
|
|
123
|
+
this.tracer.addSpanEvent(`Node: key_concepts - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
116
124
|
hopCount: state.hops,
|
|
117
125
|
});
|
|
118
126
|
const result = await this.keyConceptsNode.execute({
|
|
119
127
|
state: state,
|
|
120
128
|
});
|
|
121
|
-
this.tracer.addSpanEvent(`Node: key_concepts complete - hop ${state.hops}/${
|
|
129
|
+
this.tracer.addSpanEvent(`Node: key_concepts complete - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
122
130
|
nextStep: result.nextStep,
|
|
123
131
|
});
|
|
124
132
|
return result;
|
|
125
133
|
})
|
|
126
134
|
.addNode("atomic_facts", async (state) => {
|
|
127
|
-
this.tracer.addSpanEvent(`Node: atomic_facts - hop ${state.hops}/${
|
|
135
|
+
this.tracer.addSpanEvent(`Node: atomic_facts - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
128
136
|
hopCount: state.hops,
|
|
129
137
|
});
|
|
130
138
|
const result = await this.atomicFactsNode.execute({
|
|
131
139
|
state: state,
|
|
132
140
|
});
|
|
133
|
-
this.tracer.addSpanEvent(`Node: atomic_facts complete - hop ${state.hops}/${
|
|
141
|
+
this.tracer.addSpanEvent(`Node: atomic_facts complete - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
134
142
|
nextStep: result.nextStep,
|
|
135
143
|
});
|
|
136
144
|
return result;
|
|
137
145
|
})
|
|
138
146
|
.addNode("chunk_vector", async (state) => {
|
|
139
|
-
this.tracer.addSpanEvent(`Node: chunk_vector - hop ${state.hops}/${
|
|
147
|
+
this.tracer.addSpanEvent(`Node: chunk_vector - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
140
148
|
hopCount: state.hops,
|
|
141
149
|
});
|
|
142
150
|
const result = await this.chunkVectorNode.execute({ state });
|
|
143
|
-
this.tracer.addSpanEvent(`Node: chunk_vector complete - hop ${state.hops}/${
|
|
151
|
+
this.tracer.addSpanEvent(`Node: chunk_vector complete - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`);
|
|
144
152
|
return result;
|
|
145
153
|
})
|
|
146
154
|
.addNode("chunks", async (state) => {
|
|
147
|
-
this.tracer.addSpanEvent(`Node: chunks - hop ${state.hops}/${
|
|
155
|
+
this.tracer.addSpanEvent(`Node: chunks - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
148
156
|
hopCount: state.hops,
|
|
149
157
|
});
|
|
150
158
|
const result = await this.chunkNode.execute({
|
|
151
159
|
state: state,
|
|
152
160
|
});
|
|
153
|
-
this.tracer.addSpanEvent(`Node: chunks complete - hop ${state.hops}/${
|
|
161
|
+
this.tracer.addSpanEvent(`Node: chunks complete - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
154
162
|
nextStep: result.nextStep,
|
|
155
163
|
});
|
|
156
164
|
return result;
|
|
157
165
|
})
|
|
158
166
|
.addNode("neighbouring_nodes", async (state) => {
|
|
159
|
-
this.tracer.addSpanEvent(`Node: neighbouring_nodes - hop ${state.hops}/${
|
|
167
|
+
this.tracer.addSpanEvent(`Node: neighbouring_nodes - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
160
168
|
hopCount: state.hops,
|
|
161
169
|
});
|
|
162
170
|
const result = await this.keyConceptsNode.execute({
|
|
163
171
|
state: state,
|
|
164
172
|
});
|
|
165
|
-
this.tracer.addSpanEvent(`Node: neighbouring_nodes complete - hop ${state.hops}/${
|
|
173
|
+
this.tracer.addSpanEvent(`Node: neighbouring_nodes complete - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN}`, {
|
|
166
174
|
nextStep: result.nextStep,
|
|
167
175
|
});
|
|
168
176
|
return result;
|
|
169
177
|
})
|
|
170
178
|
.addNode("answer", (state) => {
|
|
171
|
-
this.tracer.addSpanEvent(`Node: answer - hop ${state.hops}/${
|
|
179
|
+
this.tracer.addSpanEvent(`Node: answer - hop ${state.hops} calls ${state.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN} (final)`, {
|
|
172
180
|
hopCount: state.hops,
|
|
173
181
|
});
|
|
174
182
|
return { ...state, tokens: { input: 0, output: 0 } };
|
|
@@ -200,13 +208,13 @@ let ContextualiserService = ContextualiserService_1 = class ContextualiserServic
|
|
|
200
208
|
let finalState;
|
|
201
209
|
try {
|
|
202
210
|
finalState = await app.invoke(initialState, {
|
|
203
|
-
recursionLimit:
|
|
211
|
+
recursionLimit: maxSupersteps + 2,
|
|
204
212
|
});
|
|
205
213
|
this.tracer.addSpanEvent("Workflow Completed", {
|
|
206
214
|
finalHopCount: finalState.hops,
|
|
207
215
|
totalSteps: stepCount,
|
|
208
216
|
});
|
|
209
|
-
this.logger.log(`contextualiser END hops=${finalState.hops}/${
|
|
217
|
+
this.logger.log(`contextualiser END hops=${finalState.hops} calls=${finalState.llmCalls ?? 0}/${retrieval_constants_1.MAX_LLM_CALLS_PER_RUN} ` +
|
|
210
218
|
`processedKeyConcepts=${finalState.processedKeyConcepts?.length ?? 0} ` +
|
|
211
219
|
`processedAtomicFacts=${finalState.processedAtomicFacts?.length ?? 0} ` +
|
|
212
220
|
`processedChunks=${finalState.processedChunks?.length ?? 0} ` +
|