@claritylabs/cl-sdk 0.13.0 → 0.13.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/dist/index.js +48 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4086,9 +4086,15 @@ var SupplementarySchema = z33.object({
|
|
|
4086
4086
|
nonrenewalNoticeDays: z33.number().optional().describe("Required notice period for nonrenewal in days"),
|
|
4087
4087
|
auxiliaryFacts: z33.array(AuxiliaryFactSchema2).optional().describe("Additional retrieval-only facts that do not fit the strict primary schema")
|
|
4088
4088
|
});
|
|
4089
|
-
function buildSupplementaryPrompt() {
|
|
4090
|
-
|
|
4089
|
+
function buildSupplementaryPrompt(alreadyExtractedSummary) {
|
|
4090
|
+
const exclusionBlock = alreadyExtractedSummary ? `
|
|
4091
4091
|
|
|
4092
|
+
IMPORTANT \u2014 The following facts have ALREADY been captured by prior extraction passes. Do NOT re-extract any of these. Your job is to find ADDITIONAL information that is missing from this list:
|
|
4093
|
+
|
|
4094
|
+
${alreadyExtractedSummary}
|
|
4095
|
+
` : "";
|
|
4096
|
+
return `You are an expert insurance document analyst. Extract supplementary, retrieval-only information from this document that is NOT already captured in the structured extraction results.
|
|
4097
|
+
${exclusionBlock}
|
|
4092
4098
|
Focus on:
|
|
4093
4099
|
- Regulatory contacts: state department of insurance, regulatory bodies, ombudsman offices \u2014 with phone, email, address
|
|
4094
4100
|
- Claims contacts: how to report claims, claims department contact info, hours of operation
|
|
@@ -4102,8 +4108,10 @@ Focus on:
|
|
|
4102
4108
|
Look for regulatory notices, complaint contact sections, claims reporting instructions, and cancellation/nonrenewal provisions throughout the document.
|
|
4103
4109
|
|
|
4104
4110
|
For auxiliaryFacts:
|
|
4111
|
+
- ONLY capture facts that are NOT already present in the structured extraction results above.
|
|
4112
|
+
- Do not duplicate information that has already been extracted \u2014 no policy numbers, insured names, addresses, coverage limits, deductibles, or any other field that appears in the already-extracted data.
|
|
4105
4113
|
- Capture concrete, policy-specific facts as structured key/value pairs.
|
|
4106
|
-
- Prioritize facts that agents may need later but that are often omitted from strict schemas: policyholder names, insured person names, driver names, ages, dates of birth, marital status, garaging information, lienholders, household members, vehicle assignments, schedule row details, and other discrete identifiers.
|
|
4114
|
+
- Prioritize facts that agents may need later but that are often omitted from strict schemas: policyholder names, insured person names, driver names, ages, dates of birth, marital status, garaging information, lienholders, household members, vehicle assignments, schedule row details, and other discrete identifiers \u2014 but ONLY if they are not already in the extracted data.
|
|
4107
4115
|
- Use short normalized keys like "policyholder_name", "policyholder_age", "insured_name", "driver_age", "driver_date_of_birth", "garaging_zip", "vehicle_principal_driver".
|
|
4108
4116
|
- Use subject when the fact belongs to a specific person, vehicle, property, or scheduled item.
|
|
4109
4117
|
- Do not invent facts.
|
|
@@ -4497,6 +4505,38 @@ function createExtractor(config) {
|
|
|
4497
4505
|
sectionCount: Array.isArray(sectionResult?.sections) ? sectionResult.sections.length : 0
|
|
4498
4506
|
}, null, 2);
|
|
4499
4507
|
}
|
|
4508
|
+
function buildAlreadyExtractedSummary(memory) {
|
|
4509
|
+
const lines = [];
|
|
4510
|
+
const declarationResult = memory.get("declarations");
|
|
4511
|
+
if (Array.isArray(declarationResult?.fields)) {
|
|
4512
|
+
for (const field of declarationResult.fields) {
|
|
4513
|
+
if (field.key && field.value) {
|
|
4514
|
+
const subject = field.subject ? ` [${field.subject}]` : "";
|
|
4515
|
+
lines.push(`- ${field.key}${subject}: ${field.value}`);
|
|
4516
|
+
}
|
|
4517
|
+
}
|
|
4518
|
+
}
|
|
4519
|
+
const coverageResult = memory.get("coverage_limits");
|
|
4520
|
+
if (Array.isArray(coverageResult?.coverages)) {
|
|
4521
|
+
for (const cov of coverageResult.coverages) {
|
|
4522
|
+
const parts = [cov.name, cov.limit && `limit=${cov.limit}`, cov.deductible && `deductible=${cov.deductible}`].filter(Boolean);
|
|
4523
|
+
if (parts.length > 0) lines.push(`- coverage: ${parts.join(", ")}`);
|
|
4524
|
+
}
|
|
4525
|
+
}
|
|
4526
|
+
const namedInsured = memory.get("named_insured");
|
|
4527
|
+
if (namedInsured) {
|
|
4528
|
+
for (const [key, value] of Object.entries(namedInsured)) {
|
|
4529
|
+
if (value && typeof value === "string") lines.push(`- ${key}: ${value}`);
|
|
4530
|
+
}
|
|
4531
|
+
}
|
|
4532
|
+
const carrierInfo = memory.get("carrier_info");
|
|
4533
|
+
if (carrierInfo) {
|
|
4534
|
+
for (const [key, value] of Object.entries(carrierInfo)) {
|
|
4535
|
+
if (value && typeof value === "string") lines.push(`- ${key}: ${value}`);
|
|
4536
|
+
}
|
|
4537
|
+
}
|
|
4538
|
+
return lines.length > 0 ? lines.join("\n") : "";
|
|
4539
|
+
}
|
|
4500
4540
|
function formatPageMapSummary(pageAssignments) {
|
|
4501
4541
|
const extractorPages = /* @__PURE__ */ new Map();
|
|
4502
4542
|
for (const assignment of pageAssignments) {
|
|
@@ -4836,20 +4876,20 @@ function createExtractor(config) {
|
|
|
4836
4876
|
mergeMemoryResult(result.name, result.data, memory);
|
|
4837
4877
|
}
|
|
4838
4878
|
}
|
|
4839
|
-
|
|
4840
|
-
if (supplementaryExtractor) {
|
|
4879
|
+
{
|
|
4841
4880
|
onProgress?.("Extracting supplementary retrieval facts...");
|
|
4842
4881
|
try {
|
|
4882
|
+
const alreadyExtractedSummary = buildAlreadyExtractedSummary(memory);
|
|
4843
4883
|
const supplementaryResult = await runExtractor({
|
|
4844
4884
|
name: "supplementary",
|
|
4845
|
-
prompt:
|
|
4846
|
-
schema:
|
|
4885
|
+
prompt: buildSupplementaryPrompt(alreadyExtractedSummary),
|
|
4886
|
+
schema: SupplementarySchema,
|
|
4847
4887
|
pdfBase64,
|
|
4848
4888
|
startPage: 1,
|
|
4849
4889
|
endPage: pageCount,
|
|
4850
4890
|
generateObject,
|
|
4851
4891
|
convertPdfToImages,
|
|
4852
|
-
maxTokens:
|
|
4892
|
+
maxTokens: 4096,
|
|
4853
4893
|
providerOptions
|
|
4854
4894
|
});
|
|
4855
4895
|
trackUsage(supplementaryResult.usage);
|