@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.js
CHANGED
|
@@ -4330,9 +4330,15 @@ var SupplementarySchema = import_zod33.z.object({
|
|
|
4330
4330
|
nonrenewalNoticeDays: import_zod33.z.number().optional().describe("Required notice period for nonrenewal in days"),
|
|
4331
4331
|
auxiliaryFacts: import_zod33.z.array(AuxiliaryFactSchema2).optional().describe("Additional retrieval-only facts that do not fit the strict primary schema")
|
|
4332
4332
|
});
|
|
4333
|
-
function buildSupplementaryPrompt() {
|
|
4334
|
-
|
|
4333
|
+
function buildSupplementaryPrompt(alreadyExtractedSummary) {
|
|
4334
|
+
const exclusionBlock = alreadyExtractedSummary ? `
|
|
4335
4335
|
|
|
4336
|
+
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:
|
|
4337
|
+
|
|
4338
|
+
${alreadyExtractedSummary}
|
|
4339
|
+
` : "";
|
|
4340
|
+
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.
|
|
4341
|
+
${exclusionBlock}
|
|
4336
4342
|
Focus on:
|
|
4337
4343
|
- Regulatory contacts: state department of insurance, regulatory bodies, ombudsman offices \u2014 with phone, email, address
|
|
4338
4344
|
- Claims contacts: how to report claims, claims department contact info, hours of operation
|
|
@@ -4346,8 +4352,10 @@ Focus on:
|
|
|
4346
4352
|
Look for regulatory notices, complaint contact sections, claims reporting instructions, and cancellation/nonrenewal provisions throughout the document.
|
|
4347
4353
|
|
|
4348
4354
|
For auxiliaryFacts:
|
|
4355
|
+
- ONLY capture facts that are NOT already present in the structured extraction results above.
|
|
4356
|
+
- 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.
|
|
4349
4357
|
- Capture concrete, policy-specific facts as structured key/value pairs.
|
|
4350
|
-
- 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.
|
|
4358
|
+
- 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.
|
|
4351
4359
|
- Use short normalized keys like "policyholder_name", "policyholder_age", "insured_name", "driver_age", "driver_date_of_birth", "garaging_zip", "vehicle_principal_driver".
|
|
4352
4360
|
- Use subject when the fact belongs to a specific person, vehicle, property, or scheduled item.
|
|
4353
4361
|
- Do not invent facts.
|
|
@@ -4741,6 +4749,38 @@ function createExtractor(config) {
|
|
|
4741
4749
|
sectionCount: Array.isArray(sectionResult?.sections) ? sectionResult.sections.length : 0
|
|
4742
4750
|
}, null, 2);
|
|
4743
4751
|
}
|
|
4752
|
+
function buildAlreadyExtractedSummary(memory) {
|
|
4753
|
+
const lines = [];
|
|
4754
|
+
const declarationResult = memory.get("declarations");
|
|
4755
|
+
if (Array.isArray(declarationResult?.fields)) {
|
|
4756
|
+
for (const field of declarationResult.fields) {
|
|
4757
|
+
if (field.key && field.value) {
|
|
4758
|
+
const subject = field.subject ? ` [${field.subject}]` : "";
|
|
4759
|
+
lines.push(`- ${field.key}${subject}: ${field.value}`);
|
|
4760
|
+
}
|
|
4761
|
+
}
|
|
4762
|
+
}
|
|
4763
|
+
const coverageResult = memory.get("coverage_limits");
|
|
4764
|
+
if (Array.isArray(coverageResult?.coverages)) {
|
|
4765
|
+
for (const cov of coverageResult.coverages) {
|
|
4766
|
+
const parts = [cov.name, cov.limit && `limit=${cov.limit}`, cov.deductible && `deductible=${cov.deductible}`].filter(Boolean);
|
|
4767
|
+
if (parts.length > 0) lines.push(`- coverage: ${parts.join(", ")}`);
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
const namedInsured = memory.get("named_insured");
|
|
4771
|
+
if (namedInsured) {
|
|
4772
|
+
for (const [key, value] of Object.entries(namedInsured)) {
|
|
4773
|
+
if (value && typeof value === "string") lines.push(`- ${key}: ${value}`);
|
|
4774
|
+
}
|
|
4775
|
+
}
|
|
4776
|
+
const carrierInfo = memory.get("carrier_info");
|
|
4777
|
+
if (carrierInfo) {
|
|
4778
|
+
for (const [key, value] of Object.entries(carrierInfo)) {
|
|
4779
|
+
if (value && typeof value === "string") lines.push(`- ${key}: ${value}`);
|
|
4780
|
+
}
|
|
4781
|
+
}
|
|
4782
|
+
return lines.length > 0 ? lines.join("\n") : "";
|
|
4783
|
+
}
|
|
4744
4784
|
function formatPageMapSummary(pageAssignments) {
|
|
4745
4785
|
const extractorPages = /* @__PURE__ */ new Map();
|
|
4746
4786
|
for (const assignment of pageAssignments) {
|
|
@@ -5080,20 +5120,20 @@ function createExtractor(config) {
|
|
|
5080
5120
|
mergeMemoryResult(result.name, result.data, memory);
|
|
5081
5121
|
}
|
|
5082
5122
|
}
|
|
5083
|
-
|
|
5084
|
-
if (supplementaryExtractor) {
|
|
5123
|
+
{
|
|
5085
5124
|
onProgress?.("Extracting supplementary retrieval facts...");
|
|
5086
5125
|
try {
|
|
5126
|
+
const alreadyExtractedSummary = buildAlreadyExtractedSummary(memory);
|
|
5087
5127
|
const supplementaryResult = await runExtractor({
|
|
5088
5128
|
name: "supplementary",
|
|
5089
|
-
prompt:
|
|
5090
|
-
schema:
|
|
5129
|
+
prompt: buildSupplementaryPrompt(alreadyExtractedSummary),
|
|
5130
|
+
schema: SupplementarySchema,
|
|
5091
5131
|
pdfBase64,
|
|
5092
5132
|
startPage: 1,
|
|
5093
5133
|
endPage: pageCount,
|
|
5094
5134
|
generateObject,
|
|
5095
5135
|
convertPdfToImages,
|
|
5096
|
-
maxTokens:
|
|
5136
|
+
maxTokens: 4096,
|
|
5097
5137
|
providerOptions
|
|
5098
5138
|
});
|
|
5099
5139
|
trackUsage(supplementaryResult.usage);
|