@proposit/proposit-core 1.2.0 → 1.3.1
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/README.md +9 -0
- package/dist/extensions/argument-ingestion/index.d.ts +8 -2
- package/dist/extensions/argument-ingestion/index.d.ts.map +1 -1
- package/dist/extensions/argument-ingestion/index.js +11 -5
- package/dist/extensions/argument-ingestion/index.js.map +1 -1
- package/dist/extensions/argument-ingestion/shared/finalize-response-v2.d.ts +17 -0
- package/dist/extensions/argument-ingestion/shared/finalize-response-v2.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/shared/finalize-response-v2.js +185 -0
- package/dist/extensions/argument-ingestion/shared/finalize-response-v2.js.map +1 -0
- package/dist/extensions/argument-ingestion/shared/resolve-llm-stage-options.d.ts +19 -0
- package/dist/extensions/argument-ingestion/shared/resolve-llm-stage-options.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/shared/resolve-llm-stage-options.js +44 -0
- package/dist/extensions/argument-ingestion/shared/resolve-llm-stage-options.js.map +1 -0
- package/dist/extensions/argument-ingestion/shared/types.d.ts +39 -0
- package/dist/extensions/argument-ingestion/shared/types.d.ts.map +1 -1
- package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.d.ts +12 -0
- package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.js +51 -0
- package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/citation-source-detection.d.ts +12 -0
- package/dist/extensions/argument-ingestion/stages/citation-source-detection.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/citation-source-detection.js +51 -0
- package/dist/extensions/argument-ingestion/stages/citation-source-detection.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-canonicalization.d.ts +21 -0
- package/dist/extensions/argument-ingestion/stages/claim-canonicalization.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-canonicalization.js +157 -0
- package/dist/extensions/argument-ingestion/stages/claim-canonicalization.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.d.ts +12 -0
- package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.js +47 -0
- package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-reference-validation.d.ts +37 -0
- package/dist/extensions/argument-ingestion/stages/claim-reference-validation.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-reference-validation.js +108 -0
- package/dist/extensions/argument-ingestion/stages/claim-reference-validation.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-type-classification.d.ts +12 -0
- package/dist/extensions/argument-ingestion/stages/claim-type-classification.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-type-classification.js +76 -0
- package/dist/extensions/argument-ingestion/stages/claim-type-classification.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/conclusion-selection.d.ts +27 -0
- package/dist/extensions/argument-ingestion/stages/conclusion-selection.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/conclusion-selection.js +104 -0
- package/dist/extensions/argument-ingestion/stages/conclusion-selection.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/formula-compilation.d.ts +27 -0
- package/dist/extensions/argument-ingestion/stages/formula-compilation.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/formula-compilation.js +175 -0
- package/dist/extensions/argument-ingestion/stages/formula-compilation.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/formula-validation.d.ts +19 -0
- package/dist/extensions/argument-ingestion/stages/formula-validation.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/formula-validation.js +101 -0
- package/dist/extensions/argument-ingestion/stages/formula-validation.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/index.d.ts +15 -0
- package/dist/extensions/argument-ingestion/stages/index.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/index.js +16 -0
- package/dist/extensions/argument-ingestion/stages/index.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/relation-extraction.d.ts +13 -0
- package/dist/extensions/argument-ingestion/stages/relation-extraction.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/relation-extraction.js +87 -0
- package/dist/extensions/argument-ingestion/stages/relation-extraction.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/schemas.d.ts +161 -0
- package/dist/extensions/argument-ingestion/stages/schemas.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/schemas.js +218 -0
- package/dist/extensions/argument-ingestion/stages/schemas.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/segmentation.d.ts +26 -0
- package/dist/extensions/argument-ingestion/stages/segmentation.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/segmentation.js +81 -0
- package/dist/extensions/argument-ingestion/stages/segmentation.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/variable-assignment.d.ts +15 -0
- package/dist/extensions/argument-ingestion/stages/variable-assignment.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/variable-assignment.js +84 -0
- package/dist/extensions/argument-ingestion/stages/variable-assignment.js.map +1 -0
- package/dist/extensions/argument-ingestion/v1-single-shot.d.ts +9 -1
- package/dist/extensions/argument-ingestion/v1-single-shot.d.ts.map +1 -1
- package/dist/extensions/argument-ingestion/v1-single-shot.js +13 -6
- package/dist/extensions/argument-ingestion/v1-single-shot.js.map +1 -1
- package/dist/extensions/argument-ingestion/v2-multi-stage.d.ts +38 -0
- package/dist/extensions/argument-ingestion/v2-multi-stage.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/v2-multi-stage.js +100 -0
- package/dist/extensions/argument-ingestion/v2-multi-stage.js.map +1 -0
- package/dist/extensions/openai/provider.d.ts.map +1 -1
- package/dist/extensions/openai/provider.js +136 -1
- package/dist/extensions/openai/provider.js.map +1 -1
- package/dist/extensions/openai/types.d.ts +19 -0
- package/dist/extensions/openai/types.d.ts.map +1 -1
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/pipelines/debug-log.d.ts +96 -0
- package/dist/lib/pipelines/debug-log.d.ts.map +1 -0
- package/dist/lib/pipelines/debug-log.js +144 -0
- package/dist/lib/pipelines/debug-log.js.map +1 -0
- package/dist/lib/pipelines/execute.d.ts.map +1 -1
- package/dist/lib/pipelines/execute.js +84 -54
- package/dist/lib/pipelines/execute.js.map +1 -1
- package/dist/lib/pipelines/index.d.ts +1 -0
- package/dist/lib/pipelines/index.d.ts.map +1 -1
- package/dist/lib/pipelines/index.js +1 -0
- package/dist/lib/pipelines/index.js.map +1 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -1196,4 +1196,13 @@ A CLI smoke test exercises every command against an isolated temp directory:
|
|
|
1196
1196
|
pnpm run build && bash scripts/smoke-test.sh
|
|
1197
1197
|
```
|
|
1198
1198
|
|
|
1199
|
+
### Git hooks
|
|
1200
|
+
|
|
1201
|
+
`pnpm install` runs a `prepare` script that points `core.hooksPath` at the
|
|
1202
|
+
tracked `.githooks/` directory, so the **pre-push** hook activates
|
|
1203
|
+
automatically. Before each push it runs Prettier (`--check`) on the files your
|
|
1204
|
+
branch changed relative to its remote counterpart, falling back to the whole
|
|
1205
|
+
repo when that comparison can't be made. Fix any reported files with
|
|
1206
|
+
`pnpm prettify`, or bypass the check once with `git push --no-verify`.
|
|
1207
|
+
|
|
1199
1208
|
See [CLI_EXAMPLES.md](CLI_EXAMPLES.md) for a full walkthrough.
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
export { createIngestionV1Pipeline } from "./v1-single-shot.js";
|
|
1
|
+
export { createIngestionV1Pipeline, V1_PARSE_STAGE_ID, } from "./v1-single-shot.js";
|
|
2
2
|
export type { TCreateIngestionV1PipelineOptions } from "./v1-single-shot.js";
|
|
3
|
+
export { createIngestionV2Pipeline } from "./v2-multi-stage.js";
|
|
4
|
+
export type { TCreateIngestionV2PipelineOptions } from "./v2-multi-stage.js";
|
|
5
|
+
export { resolveLlmStageOptions } from "./shared/resolve-llm-stage-options.js";
|
|
3
6
|
export { basicsExtension } from "./shared/basics-extension.js";
|
|
4
|
-
export type { TIngestionExtension, TIngestionInput } from "./shared/types.js";
|
|
7
|
+
export type { TIngestionExtension, TIngestionInput, TIngestionLlmOptions, TLlmStageOptionsOverride, } from "./shared/types.js";
|
|
5
8
|
export { finalizeResponse } from "./shared/finalize-response.js";
|
|
6
9
|
export type { TFinalizeResponseInput } from "./shared/finalize-response.js";
|
|
10
|
+
export { finalizeResponseV2, FINALIZE_V2_FAILURE_TEXTS, } from "./shared/finalize-response-v2.js";
|
|
11
|
+
export type { TFinalizeResponseV2Input } from "./shared/finalize-response-v2.js";
|
|
7
12
|
export { deriveRoles } from "./shared/role-derivation.js";
|
|
8
13
|
export type { TClaimRole, TDeriveRolesInput } from "./shared/role-derivation.js";
|
|
14
|
+
export * from "./stages/index.js";
|
|
9
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/argument-ingestion/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,YAAY,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/argument-ingestion/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACH,yBAAyB,EACzB,iBAAiB,GACpB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,YAAY,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,YAAY,EACR,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,wBAAwB,GAC3B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAChE,YAAY,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAC3E,OAAO,EACH,kBAAkB,EAClB,yBAAyB,GAC5B,MAAM,kCAAkC,CAAA;AACzC,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAGhF,cAAc,mBAAmB,CAAA"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
// Barrel for the argument-ingestion extension.
|
|
2
2
|
//
|
|
3
|
-
// Exposes the v1 single-shot pipeline factory + the
|
|
4
|
-
//
|
|
5
|
-
// `
|
|
6
|
-
//
|
|
7
|
-
export { createIngestionV1Pipeline } from "./v1-single-shot.js";
|
|
3
|
+
// Exposes the v1 single-shot pipeline factory + the v2 multi-stage
|
|
4
|
+
// pipeline factory + the default `basicsExtension`. The shared
|
|
5
|
+
// `TIngestionExtension` descriptor is forward-compatible across both
|
|
6
|
+
// pipelines.
|
|
7
|
+
export { createIngestionV1Pipeline, V1_PARSE_STAGE_ID, } from "./v1-single-shot.js";
|
|
8
|
+
export { createIngestionV2Pipeline } from "./v2-multi-stage.js";
|
|
9
|
+
export { resolveLlmStageOptions } from "./shared/resolve-llm-stage-options.js";
|
|
8
10
|
export { basicsExtension } from "./shared/basics-extension.js";
|
|
9
11
|
export { finalizeResponse } from "./shared/finalize-response.js";
|
|
12
|
+
export { finalizeResponseV2, FINALIZE_V2_FAILURE_TEXTS, } from "./shared/finalize-response-v2.js";
|
|
10
13
|
export { deriveRoles } from "./shared/role-derivation.js";
|
|
14
|
+
// Per-stage exports — surfaced for consumers (e.g. observability
|
|
15
|
+
// bridges) that want to key on stage ids without re-stringifying.
|
|
16
|
+
export * from "./stages/index.js";
|
|
11
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/argument-ingestion/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/argument-ingestion/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,EAAE;AACF,mEAAmE;AACnE,+DAA+D;AAC/D,qEAAqE;AACrE,aAAa;AAEb,OAAO,EACH,yBAAyB,EACzB,iBAAiB,GACpB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAE/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAO9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAEhE,OAAO,EACH,kBAAkB,EAClB,yBAAyB,GAC5B,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,iEAAiE;AACjE,kEAAkE;AAClE,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TParsedArgumentResponse } from "../../../lib/parsing/index.js";
|
|
2
|
+
import type { TStageContext } from "../../../lib/pipelines/index.js";
|
|
3
|
+
import type { TIngestionExtension } from "./types.js";
|
|
4
|
+
export declare const FINALIZE_V2_FAILURE_TEXTS: {
|
|
5
|
+
readonly noClaims: "No claims could be extracted from the input.";
|
|
6
|
+
readonly noConclusion: "No single conclusion could be selected.";
|
|
7
|
+
};
|
|
8
|
+
export type TFinalizeResponseV2Input = {
|
|
9
|
+
ctx: TStageContext;
|
|
10
|
+
extension: TIngestionExtension;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Assembles the v2 pipeline's final response from the
|
|
14
|
+
* `TStageContext`'s accumulated upstream outputs.
|
|
15
|
+
*/
|
|
16
|
+
export declare function finalizeResponseV2(input: TFinalizeResponseV2Input): TParsedArgumentResponse;
|
|
17
|
+
//# sourceMappingURL=finalize-response-v2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalize-response-v2.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/shared/finalize-response-v2.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAWpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,eAAO,MAAM,yBAAyB;;;CAG5B,CAAA;AAyGV,MAAM,MAAM,wBAAwB,GAAG;IACnC,GAAG,EAAE,aAAa,CAAA;IAClB,SAAS,EAAE,mBAAmB,CAAA;CACjC,CAAA;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAC9B,KAAK,EAAE,wBAAwB,GAChC,uBAAuB,CA2GzB"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// `finalize-response-v2` — assembles the v2 multi-stage pipeline's
|
|
2
|
+
// final `TParsedArgumentResponse`-shaped output from accumulated
|
|
3
|
+
// per-stage outputs.
|
|
4
|
+
//
|
|
5
|
+
// Behavior per spec §7.2 finalize row + §7.4 (role derivation) +
|
|
6
|
+
// §7.5 (failure model):
|
|
7
|
+
//
|
|
8
|
+
// - When `claim-canonicalization.canonicalClaims` is empty:
|
|
9
|
+
// `{ argument: null, failureText: "No claims could be extracted
|
|
10
|
+
// from the input.", uncategorizedText: null,
|
|
11
|
+
// selectionRationale: null, processingFailures: [] }`.
|
|
12
|
+
//
|
|
13
|
+
// - When `formula-compilation.conclusionPremiseMiniId` is null
|
|
14
|
+
// (conclusion-selection returned null, or the conclusion claim
|
|
15
|
+
// wasn't resolvable to a symbol): `{ argument: null,
|
|
16
|
+
// failureText: "No single conclusion could be selected.", ... }`.
|
|
17
|
+
//
|
|
18
|
+
// - Otherwise: assemble the full argument from the canonical claims
|
|
19
|
+
// (with per-claim role derived from `relation-extraction` +
|
|
20
|
+
// `conclusion-selection`), the variables from `variable-assignment`,
|
|
21
|
+
// and the premises from `formula-compilation`. The `selectionRationale`
|
|
22
|
+
// field is `conclusion-selection.rationale` (or null when the
|
|
23
|
+
// stage is missing).
|
|
24
|
+
//
|
|
25
|
+
// **`processingFailures` slot.** Mirroring v1's convention, finalize
|
|
26
|
+
// always emits an empty `processingFailures: []` array on the output.
|
|
27
|
+
// The full list of per-stage failures lives on `PipelineResult.failures`
|
|
28
|
+
// — consumers that want them read that field. The slot on the response
|
|
29
|
+
// object is a forward-compat hook; the framework doesn't have a clean
|
|
30
|
+
// way for `finalize.run` to consult the executor's accumulated failure
|
|
31
|
+
// list (which would require widening `TStageContext` — out of scope
|
|
32
|
+
// for slice 2A.late).
|
|
33
|
+
import { STAGE_IDS, } from "../stages/schemas.js";
|
|
34
|
+
export const FINALIZE_V2_FAILURE_TEXTS = {
|
|
35
|
+
noClaims: "No claims could be extracted from the input.",
|
|
36
|
+
noConclusion: "No single conclusion could be selected.",
|
|
37
|
+
};
|
|
38
|
+
function buildClaimToRole(args) {
|
|
39
|
+
const out = {};
|
|
40
|
+
// Claims that participate in any relation (source or target) are
|
|
41
|
+
// "premise" by default; claims that don't appear in any relation
|
|
42
|
+
// are "intermediate" (per spec §7.4). The conclusion overrides.
|
|
43
|
+
const claimsInRelations = new Set();
|
|
44
|
+
for (const rel of args.relations) {
|
|
45
|
+
for (const s of rel.sources)
|
|
46
|
+
claimsInRelations.add(s);
|
|
47
|
+
claimsInRelations.add(rel.target);
|
|
48
|
+
}
|
|
49
|
+
for (const claim of args.canonicalClaims) {
|
|
50
|
+
if (claim.miniId === args.conclusionMiniId) {
|
|
51
|
+
out[claim.miniId] = "conclusion";
|
|
52
|
+
}
|
|
53
|
+
else if (claimsInRelations.has(claim.miniId)) {
|
|
54
|
+
out[claim.miniId] = "premise";
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
out[claim.miniId] = "intermediate";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
function stripCanonicalizerOnlyFields(claim) {
|
|
63
|
+
// The canonicalizer's per-claim record carries `mentionIds` and
|
|
64
|
+
// `suggestedSymbol` which are not part of the public response
|
|
65
|
+
// schema. Strip them from the finalize output (the variable's
|
|
66
|
+
// `symbol` carries the assigned identifier; mentionIds are an
|
|
67
|
+
// internal trace).
|
|
68
|
+
const stripped = {};
|
|
69
|
+
for (const [key, value] of Object.entries(claim)) {
|
|
70
|
+
if (key === "mentionIds" || key === "suggestedSymbol")
|
|
71
|
+
continue;
|
|
72
|
+
stripped[key] = value;
|
|
73
|
+
}
|
|
74
|
+
return stripped;
|
|
75
|
+
}
|
|
76
|
+
function buildPremiseTitle(formula, roleHint) {
|
|
77
|
+
const cap = 50;
|
|
78
|
+
const truncate = (s) => s.length <= cap ? s : s.slice(0, cap - 1) + "…";
|
|
79
|
+
switch (roleHint) {
|
|
80
|
+
case "conclusion":
|
|
81
|
+
return truncate(`Conclusion: ${formula}`);
|
|
82
|
+
case "joint-support":
|
|
83
|
+
return truncate(`Joint support → ${formula}`);
|
|
84
|
+
case "derivation":
|
|
85
|
+
return truncate(`Derivation: ${formula}`);
|
|
86
|
+
case "support":
|
|
87
|
+
return truncate(`Support: ${formula}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function buildArgumentTitle(canonicalClaims, conclusionMiniId) {
|
|
91
|
+
const cap = 50;
|
|
92
|
+
const conclusionClaim = canonicalClaims.find((c) => c.miniId === conclusionMiniId);
|
|
93
|
+
const candidateTitle = conclusionClaim?.title ??
|
|
94
|
+
conclusionClaim?.axiom ??
|
|
95
|
+
"Argument";
|
|
96
|
+
return candidateTitle.length <= cap
|
|
97
|
+
? candidateTitle
|
|
98
|
+
: candidateTitle.slice(0, cap - 1) + "…";
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Assembles the v2 pipeline's final response from the
|
|
102
|
+
* `TStageContext`'s accumulated upstream outputs.
|
|
103
|
+
*/
|
|
104
|
+
export function finalizeResponseV2(input) {
|
|
105
|
+
void input.extension; // forward-compat (extension-specific assembly hooks)
|
|
106
|
+
const { ctx } = input;
|
|
107
|
+
const canon = ctx.get(STAGE_IDS.claimCanonicalization);
|
|
108
|
+
const variables = ctx.get(STAGE_IDS.variableAssignment) ?? [];
|
|
109
|
+
const compilation = ctx.get(STAGE_IDS.formulaCompilation);
|
|
110
|
+
const conclusion = ctx.get(STAGE_IDS.conclusionSelection);
|
|
111
|
+
const relationEnvelope = ctx.get(STAGE_IDS.relationExtraction);
|
|
112
|
+
const relations = relationEnvelope?.relations ?? [];
|
|
113
|
+
const typeEnvelope = ctx.get(STAGE_IDS.claimTypeClassification);
|
|
114
|
+
const typeByMiniId = new Map();
|
|
115
|
+
for (const entry of typeEnvelope?.classifications ?? []) {
|
|
116
|
+
typeByMiniId.set(entry.miniId, entry);
|
|
117
|
+
}
|
|
118
|
+
const processingFailures = [];
|
|
119
|
+
const baseResponse = {
|
|
120
|
+
uncategorizedText: null,
|
|
121
|
+
selectionRationale: conclusion?.rationale ?? null,
|
|
122
|
+
};
|
|
123
|
+
// Failure path 1: no canonical claims at all.
|
|
124
|
+
if (!canon || canon.canonicalClaims.length === 0) {
|
|
125
|
+
return {
|
|
126
|
+
argument: null,
|
|
127
|
+
failureText: FINALIZE_V2_FAILURE_TEXTS.noClaims,
|
|
128
|
+
...baseResponse,
|
|
129
|
+
// `processingFailures` is a side-channel slot the v1
|
|
130
|
+
// finalize also attaches; the response schema permits
|
|
131
|
+
// additional properties.
|
|
132
|
+
processingFailures,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// Failure path 2: no single conclusion could be selected (or the
|
|
136
|
+
// conclusion claim has no resolvable variable, in which case
|
|
137
|
+
// formula-compilation already emitted an unresolved-conclusion
|
|
138
|
+
// failure and left conclusionPremiseMiniId null).
|
|
139
|
+
if (compilation?.conclusionPremiseMiniId === null || !compilation) {
|
|
140
|
+
return {
|
|
141
|
+
argument: null,
|
|
142
|
+
failureText: FINALIZE_V2_FAILURE_TEXTS.noConclusion,
|
|
143
|
+
...baseResponse,
|
|
144
|
+
processingFailures,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
// Happy path: assemble the argument.
|
|
148
|
+
const conclusionMiniId = conclusion?.conclusionMiniId ?? null;
|
|
149
|
+
const roles = buildClaimToRole({
|
|
150
|
+
canonicalClaims: canon.canonicalClaims,
|
|
151
|
+
relations,
|
|
152
|
+
conclusionMiniId,
|
|
153
|
+
});
|
|
154
|
+
const claims = canon.canonicalClaims.map((c) => {
|
|
155
|
+
const refinedType = typeByMiniId.get(c.miniId)?.type ?? c.type;
|
|
156
|
+
const stripped = stripCanonicalizerOnlyFields(c);
|
|
157
|
+
return {
|
|
158
|
+
...stripped,
|
|
159
|
+
type: refinedType,
|
|
160
|
+
role: roles[c.miniId],
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
const finalVariables = variables.map((v) => ({
|
|
164
|
+
...v,
|
|
165
|
+
}));
|
|
166
|
+
const finalPremises = compilation.premises.map((p) => ({
|
|
167
|
+
miniId: p.premiseMiniId,
|
|
168
|
+
formula: p.formula,
|
|
169
|
+
title: buildPremiseTitle(p.formula, p.roleHint),
|
|
170
|
+
}));
|
|
171
|
+
const argument = {
|
|
172
|
+
claims,
|
|
173
|
+
variables: finalVariables,
|
|
174
|
+
premises: finalPremises,
|
|
175
|
+
conclusionPremiseMiniId: compilation.conclusionPremiseMiniId,
|
|
176
|
+
title: buildArgumentTitle(canon.canonicalClaims, conclusionMiniId),
|
|
177
|
+
};
|
|
178
|
+
return {
|
|
179
|
+
argument: argument,
|
|
180
|
+
failureText: null,
|
|
181
|
+
...baseResponse,
|
|
182
|
+
processingFailures,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=finalize-response-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalize-response-v2.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/shared/finalize-response-v2.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,iEAAiE;AACjE,qBAAqB;AACrB,EAAE;AACF,iEAAiE;AACjE,wBAAwB;AACxB,EAAE;AACF,8DAA8D;AAC9D,oEAAoE;AACpE,iDAAiD;AACjD,2DAA2D;AAC3D,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,yDAAyD;AACzD,sEAAsE;AACtE,EAAE;AACF,sEAAsE;AACtE,gEAAgE;AAChE,yEAAyE;AACzE,4EAA4E;AAC5E,kEAAkE;AAClE,yBAAyB;AACzB,EAAE;AACF,qEAAqE;AACrE,sEAAsE;AACtE,yEAAyE;AACzE,uEAAuE;AACvE,sEAAsE;AACtE,uEAAuE;AACvE,oEAAoE;AACpE,sBAAsB;AAItB,OAAO,EACH,SAAS,GAQZ,MAAM,sBAAsB,CAAA;AAG7B,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACrC,QAAQ,EAAE,8CAA8C;IACxD,YAAY,EAAE,yCAAyC;CACjD,CAAA;AA0BV,SAAS,gBAAgB,CAAC,IAKzB;IACG,MAAM,GAAG,GAA8D,EAAE,CAAA;IACzE,iEAAiE;IACjE,iEAAi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AAQ,GAAuB;QACjC,MAAM;QACN,SAAS,EAAE,cAAc;QACzB,QAAQ,EAAE,aAAa;QACvB,uBAAuB,EAAE,WAAW,CAAC,uBAAuB;QAC5D,KAAK,EAAE,kBAAkB,CAAC,KAAK,CAAC,eAAe,EAAE,gBAAgB,CAAC;KACrE,CAAA;IAED,OAAO;QACH,QAAQ,EAAE,QAA0D;QACpE,WAAW,EAAE,IAAI;QACjB,GAAG,YAAY;QAEf,kBAAkB;KACM,CAAA;AAChC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TIngestionLlmOptions, TLlmStageOptionsOverride } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the final per-stage LLM knobs.
|
|
4
|
+
*
|
|
5
|
+
* @param stageId — the stage's id (e.g. `"segmentation"`). Used to
|
|
6
|
+
* pick the right entry from `options.overrides`.
|
|
7
|
+
* @param internalDefault — the stage's built-in defaults; takes
|
|
8
|
+
* effect for any knob not set by `options.defaults`
|
|
9
|
+
* or `options.overrides[stageId]`.
|
|
10
|
+
* @param options — the caller's pipeline-level options surface.
|
|
11
|
+
* May be `undefined`, in which case the resolver
|
|
12
|
+
* returns `internalDefault` verbatim.
|
|
13
|
+
*
|
|
14
|
+
* The merge is shallow per-field. A missing field at higher
|
|
15
|
+
* precedence does not blank out a lower-precedence value — it
|
|
16
|
+
* simply doesn't override.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveLlmStageOptions(stageId: string, internalDefault: TLlmStageOptionsOverride, options?: TIngestionLlmOptions): TLlmStageOptionsOverride;
|
|
19
|
+
//# sourceMappingURL=resolve-llm-stage-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-llm-stage-options.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/shared/resolve-llm-stage-options.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAEhF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,wBAAwB,EACzC,OAAO,CAAC,EAAE,oBAAoB,GAC/B,wBAAwB,CAiB1B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Shared resolver for per-stage LLM-knob options.
|
|
2
|
+
//
|
|
3
|
+
// The ingestion pipelines (`createIngestionV1Pipeline`,
|
|
4
|
+
// `createIngestionV2Pipeline`) expose a `TIngestionLlmOptions`
|
|
5
|
+
// surface with pipeline-level `defaults` + per-stage `overrides`.
|
|
6
|
+
// Each LLM stage in turn carries its own *internal default* — the
|
|
7
|
+
// model + effort + token cap the stage author picked for typical
|
|
8
|
+
// inputs. The two surfaces compose via this resolver: stage-level
|
|
9
|
+
// override > pipeline-default > internal stage default.
|
|
10
|
+
/**
|
|
11
|
+
* Resolve the final per-stage LLM knobs.
|
|
12
|
+
*
|
|
13
|
+
* @param stageId — the stage's id (e.g. `"segmentation"`). Used to
|
|
14
|
+
* pick the right entry from `options.overrides`.
|
|
15
|
+
* @param internalDefault — the stage's built-in defaults; takes
|
|
16
|
+
* effect for any knob not set by `options.defaults`
|
|
17
|
+
* or `options.overrides[stageId]`.
|
|
18
|
+
* @param options — the caller's pipeline-level options surface.
|
|
19
|
+
* May be `undefined`, in which case the resolver
|
|
20
|
+
* returns `internalDefault` verbatim.
|
|
21
|
+
*
|
|
22
|
+
* The merge is shallow per-field. A missing field at higher
|
|
23
|
+
* precedence does not blank out a lower-precedence value — it
|
|
24
|
+
* simply doesn't override.
|
|
25
|
+
*/
|
|
26
|
+
export function resolveLlmStageOptions(stageId, internalDefault, options) {
|
|
27
|
+
const pipelineDefault = options?.defaults ?? {};
|
|
28
|
+
const perStage = options?.overrides?.[stageId] ?? {};
|
|
29
|
+
const resolved = { ...internalDefault };
|
|
30
|
+
if (pipelineDefault.maxOutputTokens !== undefined) {
|
|
31
|
+
resolved.maxOutputTokens = pipelineDefault.maxOutputTokens;
|
|
32
|
+
}
|
|
33
|
+
if (pipelineDefault.reasoningEffort !== undefined) {
|
|
34
|
+
resolved.reasoningEffort = pipelineDefault.reasoningEffort;
|
|
35
|
+
}
|
|
36
|
+
if (perStage.maxOutputTokens !== undefined) {
|
|
37
|
+
resolved.maxOutputTokens = perStage.maxOutputTokens;
|
|
38
|
+
}
|
|
39
|
+
if (perStage.reasoningEffort !== undefined) {
|
|
40
|
+
resolved.reasoningEffort = perStage.reasoningEffort;
|
|
41
|
+
}
|
|
42
|
+
return resolved;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=resolve-llm-stage-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-llm-stage-options.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/shared/resolve-llm-stage-options.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,EAAE;AACF,wDAAwD;AACxD,+DAA+D;AAC/D,kEAAkE;AAClE,kEAAkE;AAClE,iEAAiE;AACjE,kEAAkE;AAClE,wDAAwD;AAIxD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,sBAAsB,CAClC,OAAe,EACf,eAAyC,EACzC,OAA8B;IAE9B,MAAM,eAAe,GAAG,OAAO,EAAE,QAAQ,IAAI,EAAE,CAAA;IAC/C,MAAM,QAAQ,GAAG,OAAO,EAAE,SAAS,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;IACpD,MAAM,QAAQ,GAA6B,EAAE,GAAG,eAAe,EAAE,CAAA;IACjE,IAAI,eAAe,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QAChD,QAAQ,CAAC,eAAe,GAAG,eAAe,CAAC,eAAe,CAAA;IAC9D,CAAC;IACD,IAAI,eAAe,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QAChD,QAAQ,CAAC,eAAe,GAAG,eAAe,CAAC,eAAe,CAAA;IAC9D,CAAC;IACD,IAAI,QAAQ,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QACzC,QAAQ,CAAC,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAA;IACvD,CAAC;IACD,IAAI,QAAQ,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QACzC,QAAQ,CAAC,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAA;IACvD,CAAC;IACD,OAAO,QAAQ,CAAA;AACnB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TSchema } from "typebox";
|
|
2
|
+
import type { TReasoningEffort } from "../../../lib/llm/types.js";
|
|
2
3
|
/**
|
|
3
4
|
* Bundle of TypeBox schemas a caller hands to an ingestion pipeline
|
|
4
5
|
* factory. Only `responseSchema` is consumed by v1; the per-entity
|
|
@@ -31,4 +32,42 @@ export type TIngestionExtension = {
|
|
|
31
32
|
export type TIngestionInput = {
|
|
32
33
|
text: string;
|
|
33
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Per-stage LLM knob overrides for an ingestion pipeline factory.
|
|
37
|
+
*
|
|
38
|
+
* Every field is optional and merges over the stage's internal
|
|
39
|
+
* default (which is in turn merged over the pipeline-level default).
|
|
40
|
+
* The merge order is: stage-override > pipeline-default > internal
|
|
41
|
+
* stage default. A missing field at every layer means the stage
|
|
42
|
+
* keeps its built-in behavior.
|
|
43
|
+
*
|
|
44
|
+
* Currently exposes the two knobs that have proven load-bearing for
|
|
45
|
+
* the v2 pipeline: `maxOutputTokens` (the output-budget cap; not
|
|
46
|
+
* setting one means the model's default applies, which is what
|
|
47
|
+
* caused the v1.3.0 segmentation truncation against the Singer
|
|
48
|
+
* fixture) and `reasoningEffort` (effort budget for reasoning
|
|
49
|
+
* models). The struct is forward-compatible — new knobs (e.g.
|
|
50
|
+
* `model` overrides) can land additively without breaking callers.
|
|
51
|
+
*/
|
|
52
|
+
export type TLlmStageOptionsOverride = {
|
|
53
|
+
maxOutputTokens?: number;
|
|
54
|
+
reasoningEffort?: TReasoningEffort;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Pipeline-level LLM-options surface threaded through every LLM
|
|
58
|
+
* stage by the ingestion-pipeline factories.
|
|
59
|
+
*
|
|
60
|
+
* `defaults` applies to all LLM stages in the pipeline that don't
|
|
61
|
+
* have a per-stage entry under `overrides`. A stage's internal
|
|
62
|
+
* default still takes effect for any knob neither `defaults` nor
|
|
63
|
+
* `overrides` sets.
|
|
64
|
+
*
|
|
65
|
+
* `overrides` is keyed by stage id (`STAGE_IDS.segmentation`,
|
|
66
|
+
* `STAGE_IDS.claimMentionExtraction`, etc.). v1 has only one LLM
|
|
67
|
+
* stage and uses the id `"parse-argument"`.
|
|
68
|
+
*/
|
|
69
|
+
export type TIngestionLlmOptions = {
|
|
70
|
+
defaults?: TLlmStageOptionsOverride;
|
|
71
|
+
overrides?: Record<string, TLlmStageOptionsOverride>;
|
|
72
|
+
};
|
|
34
73
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/shared/types.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/shared/types.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAC9B,8EAA8E;IAC9E,cAAc,EAAE,OAAO,CAAA;IACvB,uGAAuG;IACvG,WAAW,EAAE,OAAO,CAAA;IACpB,gDAAgD;IAChD,cAAc,EAAE,OAAO,CAAA;IACvB,+CAA+C;IAC/C,aAAa,EAAE,OAAO,CAAA;IACtB,yDAAyD;IACzD,cAAc,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACnC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,gBAAgB,CAAA;CACrC,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAC/B,QAAQ,CAAC,EAAE,wBAAwB,CAAA;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAA;CACvD,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type TAxiomIndicatorDetectionOutput } from "./schemas.js";
|
|
2
|
+
import type { TStage } from "../../../lib/pipelines/types.js";
|
|
3
|
+
import type { TLlmStageOptionsOverride } from "../shared/types.js";
|
|
4
|
+
export declare const AXIOM_INDICATOR_DETECTION_MODEL = "gpt-5.4-mini";
|
|
5
|
+
export declare const AXIOM_INDICATOR_DETECTION_SYSTEM_PROMPT = "You scan the segments of an argument for axiom indicators \u2014 explicit signals that the author is invoking a self-evident truth as bottom-level support.\n\nRecognized indicator patterns include (non-exhaustive):\n- \"by definition\"\n- \"tautologically\", \"necessarily true\"\n- \"by convention\"\n- \"is true a priori\"\n- \"as a matter of (logic | mathematics | definition)\"\n- \"trivially\"\n\nReturn an object with a single key `axioms` whose value is the array of detected indicators. For each detected indicator emit:\n- a fresh \"axiomId\" (ax1, ax2, ...)\n- the list of \"segmentIds\" the indicator occurs in (usually one; sometimes two when the indicator straddles a clause)\n- the \"indicator\" \u2014 the verbatim trigger phrase\n- the character \"spans\" \u2014 one span object (\"start\" inclusive, \"end\" exclusive) per occurrence, relative to the SEGMENT'S TEXT\n\nHedging phrases (\"clearly\", \"obviously\", \"of course\") are NOT axiom indicators on their own \u2014 they are stylistic emphasis. Return `{ \"axioms\": [] }` when no indicators are present.";
|
|
6
|
+
/** Internal default knobs for the axiom-indicator-detection stage. */
|
|
7
|
+
export declare const AXIOM_INDICATOR_DETECTION_STAGE_DEFAULTS: TLlmStageOptionsOverride;
|
|
8
|
+
/** Build the axiom-indicator-detection stage with optional caller overrides. */
|
|
9
|
+
export declare function createAxiomIndicatorDetectionStage(options?: TLlmStageOptionsOverride): TStage<TAxiomIndicatorDetectionOutput>;
|
|
10
|
+
/** Backward-compatible default-options stage. */
|
|
11
|
+
export declare const axiomIndicatorDetectionStage: TStage<TAxiomIndicatorDetectionOutput>;
|
|
12
|
+
//# sourceMappingURL=axiom-indicator-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axiom-indicator-detection.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/axiom-indicator-detection.ts"],"names":[],"mappings":"AAKA,OAAO,EAGH,KAAK,8BAA8B,EAEtC,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,iCAAiC,CAAA;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAElE,eAAO,MAAM,+BAA+B,iBAAiB,CAAA;AAE7D,eAAO,MAAM,uCAAuC,4jCAgBmI,CAAA;AAavL,sEAAsE;AACtE,eAAO,MAAM,wCAAwC,EAAE,wBACjD,CAAA;AAEN,gFAAgF;AAChF,wBAAgB,kCAAkC,CAC9C,OAAO,CAAC,EAAE,wBAAwB,GACnC,MAAM,CAAC,8BAA8B,CAAC,CAUxC;AAED,iDAAiD;AACjD,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,8BAA8B,CACxC,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// `axiom-indicator-detection` — detects places where the author
|
|
2
|
+
// invokes a self-evident truth (axiom) as the bottom-level support of
|
|
3
|
+
// some claim. Phrases like "by definition", "by convention",
|
|
4
|
+
// "as a matter of logic", "is necessarily true" mark the spots.
|
|
5
|
+
import { STAGE_IDS, AxiomIndicatorDetectionOutputSchema, } from "./schemas.js";
|
|
6
|
+
import { llmStage } from "../../../lib/pipelines/stage-helpers.js";
|
|
7
|
+
export const AXIOM_INDICATOR_DETECTION_MODEL = "gpt-5.4-mini";
|
|
8
|
+
export const AXIOM_INDICATOR_DETECTION_SYSTEM_PROMPT = `You scan the segments of an argument for axiom indicators — explicit signals that the author is invoking a self-evident truth as bottom-level support.
|
|
9
|
+
|
|
10
|
+
Recognized indicator patterns include (non-exhaustive):
|
|
11
|
+
- "by definition"
|
|
12
|
+
- "tautologically", "necessarily true"
|
|
13
|
+
- "by convention"
|
|
14
|
+
- "is true a priori"
|
|
15
|
+
- "as a matter of (logic | mathematics | definition)"
|
|
16
|
+
- "trivially"
|
|
17
|
+
|
|
18
|
+
Return an object with a single key \`axioms\` whose value is the array of detected indicators. For each detected indicator emit:
|
|
19
|
+
- a fresh "axiomId" (ax1, ax2, ...)
|
|
20
|
+
- the list of "segmentIds" the indicator occurs in (usually one; sometimes two when the indicator straddles a clause)
|
|
21
|
+
- the "indicator" — the verbatim trigger phrase
|
|
22
|
+
- the character "spans" — one span object ("start" inclusive, "end" exclusive) per occurrence, relative to the SEGMENT'S TEXT
|
|
23
|
+
|
|
24
|
+
Hedging phrases ("clearly", "obviously", "of course") are NOT axiom indicators on their own — they are stylistic emphasis. Return \`{ "axioms": [] }\` when no indicators are present.`;
|
|
25
|
+
function buildPrompt(ctx) {
|
|
26
|
+
const segmentation = ctx.get(STAGE_IDS.segmentation);
|
|
27
|
+
const segments = segmentation?.segments ?? [];
|
|
28
|
+
const renderedSegments = segments
|
|
29
|
+
.map((s) => `[${s.segmentId}] ${JSON.stringify(s.text)}`)
|
|
30
|
+
.join("\n");
|
|
31
|
+
const markedSystem = `<!-- stage-id: ${STAGE_IDS.axiomIndicatorDetection} -->\n${AXIOM_INDICATOR_DETECTION_SYSTEM_PROMPT}`;
|
|
32
|
+
const user = `Segments:\n\n${renderedSegments}\n\nDetect every axiom indicator.`;
|
|
33
|
+
return { system: markedSystem, user };
|
|
34
|
+
}
|
|
35
|
+
/** Internal default knobs for the axiom-indicator-detection stage. */
|
|
36
|
+
export const AXIOM_INDICATOR_DETECTION_STAGE_DEFAULTS = {};
|
|
37
|
+
/** Build the axiom-indicator-detection stage with optional caller overrides. */
|
|
38
|
+
export function createAxiomIndicatorDetectionStage(options) {
|
|
39
|
+
return llmStage({
|
|
40
|
+
id: STAGE_IDS.axiomIndicatorDetection,
|
|
41
|
+
dependsOn: [STAGE_IDS.segmentation],
|
|
42
|
+
outputSchema: AxiomIndicatorDetectionOutputSchema,
|
|
43
|
+
model: AXIOM_INDICATOR_DETECTION_MODEL,
|
|
44
|
+
maxOutputTokens: options?.maxOutputTokens,
|
|
45
|
+
reasoningEffort: options?.reasoningEffort,
|
|
46
|
+
buildPrompt,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** Backward-compatible default-options stage. */
|
|
50
|
+
export const axiomIndicatorDetectionStage = createAxiomIndicatorDetectionStage();
|
|
51
|
+
//# sourceMappingURL=axiom-indicator-detection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axiom-indicator-detection.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/axiom-indicator-detection.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,sEAAsE;AACtE,6DAA6D;AAC7D,gEAAgE;AAEhE,OAAO,EACH,SAAS,EACT,mCAAmC,GAGtC,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAA;AAIlE,MAAM,CAAC,MAAM,+BAA+B,GAAG,cAAc,CAAA;AAE7D,MAAM,CAAC,MAAM,uCAAuC,GAAG;;;;;;;;;;;;;;;;uLAgBgI,CAAA;AAEvL,SAAS,WAAW,CAAC,GAAkB;IACnC,MAAM,YAAY,GAAG,GAAG,CAAC,GAAG,CAAsB,SAAS,CAAC,YAAY,CAAC,CAAA;IACzE,MAAM,QAAQ,GAAG,YAAY,EAAE,QAAQ,IAAI,EAAE,CAAA;IAC7C,MAAM,gBAAgB,GAAG,QAAQ;SAC5B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;SACxD,IAAI,CAAC,IAAI,CAAC,CAAA;IACf,MAAM,YAAY,GAAG,kBAAkB,SAAS,CAAC,uBAAuB,SAAS,uCAAuC,EAAE,CAAA;IAC1H,MAAM,IAAI,GAAG,gBAAgB,gBAAgB,mCAAmC,CAAA;IAChF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,CAAA;AACzC,CAAC;AAED,sEAAsE;AACtE,MAAM,CAAC,MAAM,wCAAwC,GACjD,EAAE,CAAA;AAEN,gFAAgF;AAChF,MAAM,UAAU,kCAAkC,CAC9C,OAAkC;IAElC,OAAO,QAAQ,CAAiC;QAC5C,EAAE,EAAE,SAAS,CAAC,uBAAuB;QACrC,SAAS,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC;QACnC,YAAY,EAAE,mCAAmC;QACjD,KAAK,EAAE,+BAA+B;QACtC,eAAe,EAAE,OAAO,EAAE,eAAe;QACzC,eAAe,EAAE,OAAO,EAAE,eAAe;QACzC,WAAW;KACd,CAAC,CAAA;AACN,CAAC;AAED,iDAAiD;AACjD,MAAM,CAAC,MAAM,4BAA4B,GACrC,kCAAkC,EAAE,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type TCitationSourceDetectionOutput } from "./schemas.js";
|
|
2
|
+
import type { TStage } from "../../../lib/pipelines/types.js";
|
|
3
|
+
import type { TLlmStageOptionsOverride } from "../shared/types.js";
|
|
4
|
+
export declare const CITATION_SOURCE_DETECTION_MODEL = "gpt-5.4-mini";
|
|
5
|
+
export declare const CITATION_SOURCE_DETECTION_SYSTEM_PROMPT = "You scan the segments of an argument for explicit references to external sources of evidence.\n\nA source reference is any of:\n- a Markdown link: `[label](url)`\n- a named source: \"according to X\", \"as reported in Y\", \"the X report\"\n- a bracketed citation marker: `[1]`, `[Smith 2024]`\n- a fully-qualified URL\n\nReturn an object with a single key `sources` whose value is the array of detected source references. For each detected source emit:\n- a fresh \"sourceId\" (src1, src2, ...)\n- the list of \"segmentIds\" the source occurs in (almost always one; multi-segment when one citation spans a clause boundary)\n- a short \"sourceString\" \u2014 the human-readable label (e.g. \"NASA climate report\", \"Smith 2024\")\n- the \"url\" field \u2014 the URL when one is present, otherwise null\n- the character \"spans\" \u2014 one span object (\"start\" inclusive, \"end\" exclusive) per occurrence, relative to the SEGMENT'S TEXT\n\nDo not detect mere mentions of people, organizations, or studies that are not invoked as supporting evidence. Quote attribution alone (\"Bob said X\") is not a citation unless Bob's saying is being used to support a claim. Return `{ \"sources\": [] }` when no sources are present.";
|
|
6
|
+
/** Internal default knobs for the citation-source-detection stage. */
|
|
7
|
+
export declare const CITATION_SOURCE_DETECTION_STAGE_DEFAULTS: TLlmStageOptionsOverride;
|
|
8
|
+
/** Build the citation-source-detection stage with optional caller overrides. */
|
|
9
|
+
export declare function createCitationSourceDetectionStage(options?: TLlmStageOptionsOverride): TStage<TCitationSourceDetectionOutput>;
|
|
10
|
+
/** Backward-compatible default-options stage. */
|
|
11
|
+
export declare const citationSourceDetectionStage: TStage<TCitationSourceDetectionOutput>;
|
|
12
|
+
//# sourceMappingURL=citation-source-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citation-source-detection.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/citation-source-detection.ts"],"names":[],"mappings":"AAMA,OAAO,EAGH,KAAK,8BAA8B,EAEtC,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,iCAAiC,CAAA;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAElE,eAAO,MAAM,+BAA+B,iBAAiB,CAAA;AAE7D,eAAO,MAAM,uCAAuC,6sCAemO,CAAA;AAavR,sEAAsE;AACtE,eAAO,MAAM,wCAAwC,EAAE,wBACjD,CAAA;AAEN,gFAAgF;AAChF,wBAAgB,kCAAkC,CAC9C,OAAO,CAAC,EAAE,wBAAwB,GACnC,MAAM,CAAC,8BAA8B,CAAC,CAUxC;AAED,iDAAiD;AACjD,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,8BAA8B,CACxC,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// `citation-source-detection` — detects explicit source references in
|
|
2
|
+
// the segmented input. Markdown links, "according to X", named
|
|
3
|
+
// reports/papers, bracketed citation markers, etc. The downstream
|
|
4
|
+
// `claim-canonicalization` stage uses this to route the right claims
|
|
5
|
+
// to citation-typed records with their `url` / `title` populated.
|
|
6
|
+
import { STAGE_IDS, CitationSourceDetectionOutputSchema, } from "./schemas.js";
|
|
7
|
+
import { llmStage } from "../../../lib/pipelines/stage-helpers.js";
|
|
8
|
+
export const CITATION_SOURCE_DETECTION_MODEL = "gpt-5.4-mini";
|
|
9
|
+
export const CITATION_SOURCE_DETECTION_SYSTEM_PROMPT = `You scan the segments of an argument for explicit references to external sources of evidence.
|
|
10
|
+
|
|
11
|
+
A source reference is any of:
|
|
12
|
+
- a Markdown link: \`[label](url)\`
|
|
13
|
+
- a named source: "according to X", "as reported in Y", "the X report"
|
|
14
|
+
- a bracketed citation marker: \`[1]\`, \`[Smith 2024]\`
|
|
15
|
+
- a fully-qualified URL
|
|
16
|
+
|
|
17
|
+
Return an object with a single key \`sources\` whose value is the array of detected source references. For each detected source emit:
|
|
18
|
+
- a fresh "sourceId" (src1, src2, ...)
|
|
19
|
+
- the list of "segmentIds" the source occurs in (almost always one; multi-segment when one citation spans a clause boundary)
|
|
20
|
+
- a short "sourceString" — the human-readable label (e.g. "NASA climate report", "Smith 2024")
|
|
21
|
+
- the "url" field — the URL when one is present, otherwise null
|
|
22
|
+
- the character "spans" — one span object ("start" inclusive, "end" exclusive) per occurrence, relative to the SEGMENT'S TEXT
|
|
23
|
+
|
|
24
|
+
Do not detect mere mentions of people, organizations, or studies that are not invoked as supporting evidence. Quote attribution alone ("Bob said X") is not a citation unless Bob's saying is being used to support a claim. Return \`{ "sources": [] }\` when no sources are present.`;
|
|
25
|
+
function buildPrompt(ctx) {
|
|
26
|
+
const segmentation = ctx.get(STAGE_IDS.segmentation);
|
|
27
|
+
const segments = segmentation?.segments ?? [];
|
|
28
|
+
const renderedSegments = segments
|
|
29
|
+
.map((s) => `[${s.segmentId}] ${JSON.stringify(s.text)}`)
|
|
30
|
+
.join("\n");
|
|
31
|
+
const markedSystem = `<!-- stage-id: ${STAGE_IDS.citationSourceDetection} -->\n${CITATION_SOURCE_DETECTION_SYSTEM_PROMPT}`;
|
|
32
|
+
const user = `Segments:\n\n${renderedSegments}\n\nDetect every citation/source reference.`;
|
|
33
|
+
return { system: markedSystem, user };
|
|
34
|
+
}
|
|
35
|
+
/** Internal default knobs for the citation-source-detection stage. */
|
|
36
|
+
export const CITATION_SOURCE_DETECTION_STAGE_DEFAULTS = {};
|
|
37
|
+
/** Build the citation-source-detection stage with optional caller overrides. */
|
|
38
|
+
export function createCitationSourceDetectionStage(options) {
|
|
39
|
+
return llmStage({
|
|
40
|
+
id: STAGE_IDS.citationSourceDetection,
|
|
41
|
+
dependsOn: [STAGE_IDS.segmentation],
|
|
42
|
+
outputSchema: CitationSourceDetectionOutputSchema,
|
|
43
|
+
model: CITATION_SOURCE_DETECTION_MODEL,
|
|
44
|
+
maxOutputTokens: options?.maxOutputTokens,
|
|
45
|
+
reasoningEffort: options?.reasoningEffort,
|
|
46
|
+
buildPrompt,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** Backward-compatible default-options stage. */
|
|
50
|
+
export const citationSourceDetectionStage = createCitationSourceDetectionStage();
|
|
51
|
+
//# sourceMappingURL=citation-source-detection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citation-source-detection.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/citation-source-detection.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,+DAA+D;AAC/D,kEAAkE;AAClE,qEAAqE;AACrE,kEAAkE;AAElE,OAAO,EACH,SAAS,EACT,mCAAmC,GAGtC,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAA;AAIlE,MAAM,CAAC,MAAM,+BAA+B,GAAG,cAAc,CAAA;AAE7D,MAAM,CAAC,MAAM,uCAAuC,GAAG;;;;;;;;;;;;;;;uRAegO,CAAA;AAEvR,SAAS,WAAW,CAAC,GAAkB;IACnC,MAAM,YAAY,GAAG,GAAG,CAAC,GAAG,CAAsB,SAAS,CAAC,YAAY,CAAC,CAAA;IACzE,MAAM,QAAQ,GAAG,YAAY,EAAE,QAAQ,IAAI,EAAE,CAAA;IAC7C,MAAM,gBAAgB,GAAG,QAAQ;SAC5B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;SACxD,IAAI,CAAC,IAAI,CAAC,CAAA;IACf,MAAM,YAAY,GAAG,kBAAkB,SAAS,CAAC,uBAAuB,SAAS,uCAAuC,EAAE,CAAA;IAC1H,MAAM,IAAI,GAAG,gBAAgB,gBAAgB,6CAA6C,CAAA;IAC1F,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,CAAA;AACzC,CAAC;AAED,sEAAsE;AACtE,MAAM,CAAC,MAAM,wCAAwC,GACjD,EAAE,CAAA;AAEN,gFAAgF;AAChF,MAAM,UAAU,kCAAkC,CAC9C,OAAkC;IAElC,OAAO,QAAQ,CAAiC;QAC5C,EAAE,EAAE,SAAS,CAAC,uBAAuB;QACrC,SAAS,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC;QACnC,YAAY,EAAE,mCAAmC;QACjD,KAAK,EAAE,+BAA+B;QACtC,eAAe,EAAE,OAAO,EAAE,eAAe;QACzC,eAAe,EAAE,OAAO,EAAE,eAAe;QACzC,WAAW;KACd,CAAC,CAAA;AACN,CAAC;AAED,iDAAiD;AACjD,MAAM,CAAC,MAAM,4BAA4B,GACrC,kCAAkC,EAAE,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type TClaimCanonicalizationOutput } from "./schemas.js";
|
|
2
|
+
import type { TStage } from "../../../lib/pipelines/types.js";
|
|
3
|
+
import type { TIngestionExtension, TLlmStageOptionsOverride } from "../shared/types.js";
|
|
4
|
+
export declare const CLAIM_CANONICALIZATION_MODEL = "gpt-5.5";
|
|
5
|
+
export declare const CLAIM_CANONICALIZATION_REASONING: "minimal" | "low" | "medium" | "high";
|
|
6
|
+
export declare const CLAIM_CANONICALIZATION_SYSTEM_PROMPT = "You merge raw claim mentions into a single canonical set of claims for an argument-ingestion pipeline.\n\nYou are given:\n- the raw input text (for full context)\n- the segmented breakdown of the text\n- the list of every claim mention extracted from those segments\n- optionally, the detected citation sources + axiom indicators\n\nYour output has two parts:\n\n1. `canonicalClaims` \u2014 an array of canonical claims, one entry per distinct proposition the author makes. Two mentions that assert the same proposition (even when phrased differently across the text) merge into a single canonical claim. Each canonical claim carries:\n - `miniId` \u2014 assign in canonicalization order: c1, c2, c3, ...\n - `mentionIds` \u2014 list of the mention ids that resolved to this claim\n - `type` \u2014 one of \"normal\", \"citation\", or \"axiomatic\" (see below)\n - `suggestedSymbol` \u2014 a short PascalCase-or-snake_case identifier summarizing the claim (e.g. \"Rain_Wets_Ground\", \"NASA_Temp_Rise\", \"Socrates_Mortal\"). Use letters, digits, and underscores only; start with a letter or underscore; keep under 32 characters; aim for under 20. AVOID single letters and generic names like \"Claim1\".\n - the extension fields described in your output schema (title, body, url, axiom \u2014 whichever apply to the claim's `type`)\n\n2. `mentionToClaim` \u2014 an array of `{ \"mentionId\": \"...\", \"claimMiniId\": \"...\" }` entries, one per input mention. Every input mentionId must appear in exactly one entry; the mapping is total. (We surface this as a list rather than a map because the response schema does not allow arbitrary string keys.)\n\n## Claim types\n\n- `\"normal\"` \u2014 a primary proposition the argument argues for or from.\n- `\"citation\"` \u2014 a claim whose content is \"the cited source asserts X\". Use this type when one of the citation sources covers the same span(s) as the mention. Populate `url` (the URL if present) and `title` (a short human-readable label).\n- `\"axiomatic\"` \u2014 a claim invoked as self-evident truth. Use this type when an axiom indicator (e.g. \"by definition\") covers or precedes the mention. Populate `axiom` with the gist of the self-evident proposition.\n\nWhen a mention is the antecedent of \"according to X, P\", split it into two claims: a citation-typed claim for the source itself + a normal-typed claim for the proposition. The two are connected via a relation in a later stage, not here.\n\n## Style\n\n- Claim titles + bodies are written in third-person, present-tense, active voice.\n- Titles are short (\u2264 50 characters); bodies fill in the detail.\n- For citation claims, the title summarizes what the source asserts (e.g. \"NASA reports temperature rise\"); the URL goes in `url`.\n- For axiomatic claims, the `axiom` field captures the self-evident proposition (e.g. \"A bachelor is an unmarried man by definition.\").\n\nOutput ONLY the schema-shaped object. No prose.";
|
|
7
|
+
/** Internal default knobs for the claim-canonicalization stage. */
|
|
8
|
+
export declare const CLAIM_CANONICALIZATION_STAGE_DEFAULTS: TLlmStageOptionsOverride;
|
|
9
|
+
/**
|
|
10
|
+
* Builds the `claim-canonicalization` stage for the supplied
|
|
11
|
+
* extension. The stage's `outputSchema` carries the extension's
|
|
12
|
+
* per-claim fields, so the LLM's structured-output schema matches the
|
|
13
|
+
* extension's claim shape (e.g. for `basics`: a discriminated union
|
|
14
|
+
* over `type`).
|
|
15
|
+
*
|
|
16
|
+
* `options` overrides the stage's internal defaults
|
|
17
|
+
* (`CLAIM_CANONICALIZATION_STAGE_DEFAULTS`). Threaded through by
|
|
18
|
+
* `createIngestionV2Pipeline` per its `TIngestionLlmOptions` surface.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createClaimCanonicalizationStage(extension: TIngestionExtension, options?: TLlmStageOptionsOverride): TStage<TClaimCanonicalizationOutput>;
|
|
21
|
+
//# sourceMappingURL=claim-canonicalization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim-canonicalization.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/claim-canonicalization.ts"],"names":[],"mappings":"AAiBA,OAAO,EAMH,KAAK,4BAA4B,EACpC,MAAM,cAAc,CAAA;AAGrB,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,iCAAiC,CAAA;AAC5E,OAAO,KAAK,EACR,mBAAmB,EAEnB,wBAAwB,EAC3B,MAAM,oBAAoB,CAAA;AAE3B,eAAO,MAAM,4BAA4B,YAAY,CAAA;AACrD,eAAO,MAAM,gCAAgC,EACvC,SAAS,GACT,KAAK,GACL,QAAQ,GACR,MAAiB,CAAA;AAEvB,eAAO,MAAM,oCAAoC,05FAkCD,CAAA;AA8GhD,mEAAmE;AACnE,eAAO,MAAM,qCAAqC,EAAE,wBAEnD,CAAA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gCAAgC,CAC5C,SAAS,EAAE,mBAAmB,EAC9B,OAAO,CAAC,EAAE,wBAAwB,GACnC,MAAM,CAAC,4BAA4B,CAAC,CAetC"}
|