@claritylabs/cl-sdk 3.1.21 → 3.1.23
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 +2 -2
- package/dist/application.js +2 -2
- package/dist/application.js.map +1 -1
- package/dist/application.mjs +2 -2
- package/dist/application.mjs.map +1 -1
- package/dist/index.js +21 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -243,8 +243,8 @@ function resolveModelBudget(params) {
|
|
|
243
243
|
const schemaTokens = estimateTokens(params.schemaSizeBytes) ?? 0;
|
|
244
244
|
const expectedListLength = positiveInteger(params.expectedListLength) ?? 0;
|
|
245
245
|
const warnings = [];
|
|
246
|
-
const preferredOutputTokens = constrainedPreference ?? taskCapability ?? longListCapability ??
|
|
247
|
-
let maxTokens =
|
|
246
|
+
const preferredOutputTokens = constrainedPreference ?? taskCapability ?? longListCapability ?? hintTokens ?? defaultCapability;
|
|
247
|
+
let maxTokens = preferredOutputTokens;
|
|
248
248
|
if (minOutputTokens) {
|
|
249
249
|
maxTokens = Math.max(maxTokens, minOutputTokens);
|
|
250
250
|
}
|
|
@@ -9388,9 +9388,9 @@ var ORGANIZABLE_KINDS = [
|
|
|
9388
9388
|
"schedule",
|
|
9389
9389
|
"clause"
|
|
9390
9390
|
];
|
|
9391
|
-
var ORGANIZATION_TOP_LEVEL_BATCH_SIZE =
|
|
9391
|
+
var ORGANIZATION_TOP_LEVEL_BATCH_SIZE = 1;
|
|
9392
9392
|
var ORGANIZER_MAX_TOP_LEVEL_NODES = 120;
|
|
9393
|
-
var ORGANIZER_MAX_BATCH_NODES =
|
|
9393
|
+
var ORGANIZER_MAX_BATCH_NODES = 80;
|
|
9394
9394
|
var OUTLINE_CLEANUP_MAX_TOP_LEVEL_NODES = 80;
|
|
9395
9395
|
var SourceTreeOrganizationSchema = z42.object({
|
|
9396
9396
|
labels: z42.array(z42.object({
|
|
@@ -10576,10 +10576,10 @@ function organizationCandidateText(node) {
|
|
|
10576
10576
|
}
|
|
10577
10577
|
function isHighSignalOrganizationNode(node) {
|
|
10578
10578
|
if (node.kind === "document") return false;
|
|
10579
|
-
if (["page", "page_group", "form", "endorsement", "section", "schedule", "clause", "table"
|
|
10579
|
+
if (["page", "page_group", "form", "endorsement", "section", "schedule", "clause", "table"].includes(node.kind)) {
|
|
10580
10580
|
return true;
|
|
10581
10581
|
}
|
|
10582
|
-
if (node.kind !== "text" && node.kind !== "table_cell") return false;
|
|
10582
|
+
if (node.kind !== "text" && node.kind !== "table_cell" && node.kind !== "table_row") return false;
|
|
10583
10583
|
const text = organizationCandidateText(node);
|
|
10584
10584
|
return /\b(SECTION|PART|ARTICLE|SCHEDULE)\s+[IVXLCDM0-9]+/i.test(text) || /\bItem\s+\d+[\.:]/i.test(text) || /^[A-Z]\.\s+\S/.test(cleanText(node.textExcerpt ?? node.title, "")) || /\b(forms? and endorsements?|coverage parts?|limits? of liability|extended reporting period|producer|premium|aggregate|retroactive date|endorsement no\.?)\b/i.test(text);
|
|
10585
10585
|
}
|
|
@@ -10602,7 +10602,7 @@ function organizationBatches(sourceTree) {
|
|
|
10602
10602
|
const rootId = sourceTreeRootId(sourceTree);
|
|
10603
10603
|
const topLevelNodes = (byParent.get(rootId) ?? []).filter((node) => node.kind !== "document");
|
|
10604
10604
|
if (topLevelNodes.length === 0) {
|
|
10605
|
-
const nodes = sourceTree.filter((node) => node.kind !== "document").slice(0,
|
|
10605
|
+
const nodes = sourceTree.filter((node) => node.kind !== "document").slice(0, ORGANIZER_MAX_BATCH_NODES);
|
|
10606
10606
|
return [{
|
|
10607
10607
|
label: "fallback node prefix because no document root children were found",
|
|
10608
10608
|
topLevelNodeIds: nodes.map((node) => node.id),
|
|
@@ -10620,6 +10620,17 @@ function organizationBatches(sourceTree) {
|
|
|
10620
10620
|
}
|
|
10621
10621
|
return batches;
|
|
10622
10622
|
}
|
|
10623
|
+
function pageRangeOverlaps(leftStart, leftEnd, rightStart, rightEnd) {
|
|
10624
|
+
if (leftStart === void 0 || rightStart === void 0) return true;
|
|
10625
|
+
const leftLast = leftEnd ?? leftStart;
|
|
10626
|
+
const rightLast = rightEnd ?? rightStart;
|
|
10627
|
+
return leftStart <= rightLast && rightStart <= leftLast;
|
|
10628
|
+
}
|
|
10629
|
+
function formHintsForBatch(batch, formHints) {
|
|
10630
|
+
const batchStart = batch.nodes.map((node) => node.pageStart).filter((page) => typeof page === "number").reduce((min, page) => min === void 0 ? page : Math.min(min, page), void 0);
|
|
10631
|
+
const batchEnd = batch.nodes.map((node) => node.pageEnd ?? node.pageStart).filter((page) => typeof page === "number").reduce((max, page) => max === void 0 ? page : Math.max(max, page), void 0);
|
|
10632
|
+
return formHints.filter((form) => pageRangeOverlaps(batchStart, batchEnd, form.pageStart, form.pageEnd)).slice(0, 24);
|
|
10633
|
+
}
|
|
10623
10634
|
function mergeOrganizationResults(results) {
|
|
10624
10635
|
const labels = /* @__PURE__ */ new Map();
|
|
10625
10636
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -10638,7 +10649,8 @@ function mergeOrganizationResults(results) {
|
|
|
10638
10649
|
};
|
|
10639
10650
|
}
|
|
10640
10651
|
function buildOrganizationPrompt(batch, formHints) {
|
|
10641
|
-
const nodes = batch.nodes.map((node) => compactNode2(node, node.kind === "page" ?
|
|
10652
|
+
const nodes = batch.nodes.map((node) => compactNode2(node, node.kind === "page" ? 520 : 260));
|
|
10653
|
+
const localFormHints = formHintsForBatch(batch, formHints);
|
|
10642
10654
|
return `You organize an insurance document source tree.
|
|
10643
10655
|
|
|
10644
10656
|
Scope:
|
|
@@ -10647,7 +10659,7 @@ Scope:
|
|
|
10647
10659
|
- Top-level page/form candidates in this batch: ${JSON.stringify(batch.topLevelNodeIds)}
|
|
10648
10660
|
|
|
10649
10661
|
Expected form inventory / page ranges:
|
|
10650
|
-
${formatFormHintsForPrompt(
|
|
10662
|
+
${formatFormHintsForPrompt(localFormHints)}
|
|
10651
10663
|
|
|
10652
10664
|
Rules:
|
|
10653
10665
|
- Use only node IDs from the provided list.
|