@claritylabs/cl-sdk 0.7.4 → 0.7.5
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 +65 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2849,29 +2849,73 @@ function getTemplate(policyType) {
|
|
|
2849
2849
|
// src/prompts/coordinator/classify.ts
|
|
2850
2850
|
var import_zod18 = require("zod");
|
|
2851
2851
|
var ClassifyResultSchema = import_zod18.z.object({
|
|
2852
|
-
documentType: import_zod18.z.enum(["policy", "quote"]),
|
|
2853
|
-
policyTypes: import_zod18.z.array(PolicyTypeSchema),
|
|
2854
|
-
confidence: import_zod18.z.number()
|
|
2852
|
+
documentType: import_zod18.z.enum(["policy", "quote"]).describe("Whether this is a bound policy or a proposed quote"),
|
|
2853
|
+
policyTypes: import_zod18.z.array(PolicyTypeSchema).min(1).describe("Lines of business covered \u2014 at least one required"),
|
|
2854
|
+
confidence: import_zod18.z.number().describe("Confidence score from 0.0 to 1.0")
|
|
2855
2855
|
});
|
|
2856
2856
|
function buildClassifyPrompt() {
|
|
2857
|
-
return `You are classifying an insurance document. Examine the
|
|
2857
|
+
return `You are classifying an insurance document. Examine the document and determine:
|
|
2858
2858
|
|
|
2859
2859
|
1. Whether this is a POLICY (bound coverage) or QUOTE (proposed coverage)
|
|
2860
|
-
2. What lines of business are covered
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2860
|
+
2. What lines of business are covered (at least one \u2014 never return an empty list)
|
|
2861
|
+
|
|
2862
|
+
POLICY indicators: policy numbers, effective/expiration dates, declarations pages, premium charges, "this policy" language.
|
|
2863
|
+
QUOTE indicators: quote numbers, proposed dates, subjectivities, "indication" or "proposal" language, "quoted premium".
|
|
2864
|
+
|
|
2865
|
+
COMMERCIAL LINES \u2014 match these values:
|
|
2866
|
+
- "general_liability" \u2014 CGL, commercial general liability, GL
|
|
2867
|
+
- "commercial_property" \u2014 commercial property, building/contents coverage
|
|
2868
|
+
- "commercial_auto" \u2014 commercial auto, business auto, CA
|
|
2869
|
+
- "non_owned_auto" \u2014 hired & non-owned auto
|
|
2870
|
+
- "workers_comp" \u2014 workers compensation, WC
|
|
2871
|
+
- "umbrella" \u2014 commercial umbrella
|
|
2872
|
+
- "excess_liability" \u2014 excess liability, follow-form excess
|
|
2873
|
+
- "professional_liability" \u2014 E&O, errors & omissions, professional liability, malpractice
|
|
2874
|
+
- "cyber" \u2014 cyber liability, data breach, network security
|
|
2875
|
+
- "epli" \u2014 employment practices liability
|
|
2876
|
+
- "directors_officers" \u2014 D&O, directors and officers
|
|
2877
|
+
- "fiduciary_liability" \u2014 fiduciary liability
|
|
2878
|
+
- "crime_fidelity" \u2014 crime, fidelity, employee dishonesty
|
|
2879
|
+
- "inland_marine" \u2014 inland marine, equipment floater, contractors equipment
|
|
2880
|
+
- "builders_risk" \u2014 builders risk, course of construction
|
|
2881
|
+
- "environmental" \u2014 environmental, pollution liability
|
|
2882
|
+
- "ocean_marine" \u2014 ocean marine, cargo, hull
|
|
2883
|
+
- "surety" \u2014 surety bond
|
|
2884
|
+
- "product_liability" \u2014 product liability, products-completed operations
|
|
2885
|
+
- "bop" \u2014 business owners policy, BOP
|
|
2886
|
+
- "management_liability_package" \u2014 management liability package
|
|
2887
|
+
- "property" \u2014 standalone property
|
|
2888
|
+
|
|
2889
|
+
PERSONAL LINES \u2014 match these values:
|
|
2890
|
+
- "homeowners_ho3" \u2014 HO-3, special form homeowners
|
|
2891
|
+
- "homeowners_ho5" \u2014 HO-5, comprehensive form homeowners
|
|
2892
|
+
- "renters_ho4" \u2014 HO-4, renters insurance
|
|
2893
|
+
- "condo_ho6" \u2014 HO-6, condo unit-owners
|
|
2894
|
+
- "dwelling_fire" \u2014 DP-1, DP-3, dwelling fire
|
|
2895
|
+
- "mobile_home" \u2014 mobile home, manufactured home
|
|
2896
|
+
- "personal_auto" \u2014 personal auto, PAP
|
|
2897
|
+
- "personal_umbrella" \u2014 personal umbrella
|
|
2898
|
+
- "flood_nfip" \u2014 NFIP flood
|
|
2899
|
+
- "flood_private" \u2014 private flood
|
|
2900
|
+
- "earthquake" \u2014 earthquake
|
|
2901
|
+
- "personal_inland_marine" \u2014 personal articles, scheduled personal property
|
|
2902
|
+
- "watercraft" \u2014 watercraft, boat
|
|
2903
|
+
- "recreational_vehicle" \u2014 RV, recreational vehicle, ATV
|
|
2904
|
+
- "farm_ranch" \u2014 farm, ranch
|
|
2905
|
+
- "pet" \u2014 pet insurance
|
|
2906
|
+
- "travel" \u2014 travel insurance
|
|
2907
|
+
- "identity_theft" \u2014 identity theft
|
|
2908
|
+
- "title" \u2014 title insurance
|
|
2909
|
+
- "other" \u2014 only if NONE of the above match
|
|
2910
|
+
|
|
2911
|
+
IMPORTANT: You must identify at least one specific policy type. Only use "other" as a last resort when the document truly does not match any known type.
|
|
2912
|
+
|
|
2913
|
+
Return JSON only:
|
|
2866
2914
|
{
|
|
2867
2915
|
"documentType": "policy" | "quote",
|
|
2868
|
-
"policyTypes": ["general_liability",
|
|
2916
|
+
"policyTypes": ["general_liability", ...],
|
|
2869
2917
|
"confidence": 0.0-1.0
|
|
2870
|
-
}
|
|
2871
|
-
|
|
2872
|
-
Use these policy type values: general_liability, commercial_property, commercial_auto, non_owned_auto, workers_comp, umbrella, excess_liability, professional_liability, cyber, epli, directors_officers, fiduciary_liability, crime_fidelity, inland_marine, builders_risk, environmental, ocean_marine, surety, product_liability, bop, management_liability_package, property, homeowners_ho3, homeowners_ho5, renters_ho4, condo_ho6, dwelling_fire, mobile_home, personal_auto, personal_umbrella, flood_nfip, flood_private, earthquake, personal_inland_marine, watercraft, recreational_vehicle, farm_ranch, pet, travel, identity_theft, title, other.
|
|
2873
|
-
|
|
2874
|
-
Respond with JSON only.`;
|
|
2918
|
+
}`;
|
|
2875
2919
|
}
|
|
2876
2920
|
|
|
2877
2921
|
// src/prompts/coordinator/plan.ts
|
|
@@ -3550,12 +3594,16 @@ function createExtractor(config) {
|
|
|
3550
3594
|
},
|
|
3551
3595
|
{
|
|
3552
3596
|
fallback: { documentType: "policy", policyTypes: ["other"], confidence: 0 },
|
|
3597
|
+
maxRetries: 3,
|
|
3553
3598
|
log,
|
|
3554
|
-
onError: (err, attempt) => log?.(`Classify attempt ${attempt + 1} failed: ${err}`)
|
|
3599
|
+
onError: (err, attempt) => log?.(`Classify attempt ${attempt + 1} failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
3555
3600
|
}
|
|
3556
3601
|
);
|
|
3557
3602
|
trackUsage(classifyResponse.usage);
|
|
3558
3603
|
classifyResult = classifyResponse.object;
|
|
3604
|
+
if (classifyResult.confidence === 0) {
|
|
3605
|
+
await log?.(`WARNING: classify returned fallback (policyTypes: ["other"]). This usually means the generateObject callback failed \u2014 check that the document content is accessible to the model.`);
|
|
3606
|
+
}
|
|
3559
3607
|
memory.set("classify", classifyResult);
|
|
3560
3608
|
await pipelineCtx.save("classify", {
|
|
3561
3609
|
id,
|