@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.mjs CHANGED
@@ -2616,29 +2616,73 @@ function getTemplate(policyType) {
2616
2616
  // src/prompts/coordinator/classify.ts
2617
2617
  import { z as z18 } from "zod";
2618
2618
  var ClassifyResultSchema = z18.object({
2619
- documentType: z18.enum(["policy", "quote"]),
2620
- policyTypes: z18.array(PolicyTypeSchema),
2621
- confidence: z18.number()
2619
+ documentType: z18.enum(["policy", "quote"]).describe("Whether this is a bound policy or a proposed quote"),
2620
+ policyTypes: z18.array(PolicyTypeSchema).min(1).describe("Lines of business covered \u2014 at least one required"),
2621
+ confidence: z18.number().describe("Confidence score from 0.0 to 1.0")
2622
2622
  });
2623
2623
  function buildClassifyPrompt() {
2624
- return `You are classifying an insurance document. Examine the first few pages and determine:
2624
+ return `You are classifying an insurance document. Examine the document and determine:
2625
2625
 
2626
2626
  1. Whether this is a POLICY (bound coverage) or QUOTE (proposed coverage)
2627
- 2. What lines of business are covered
2628
-
2629
- Policies typically have: policy numbers, effective/expiration dates, declarations pages, premium charges.
2630
- Quotes typically have: quote numbers, proposed dates, subjectivities, "indication" or "proposal" language.
2631
-
2632
- Return JSON matching this structure:
2627
+ 2. What lines of business are covered (at least one \u2014 never return an empty list)
2628
+
2629
+ POLICY indicators: policy numbers, effective/expiration dates, declarations pages, premium charges, "this policy" language.
2630
+ QUOTE indicators: quote numbers, proposed dates, subjectivities, "indication" or "proposal" language, "quoted premium".
2631
+
2632
+ COMMERCIAL LINES \u2014 match these values:
2633
+ - "general_liability" \u2014 CGL, commercial general liability, GL
2634
+ - "commercial_property" \u2014 commercial property, building/contents coverage
2635
+ - "commercial_auto" \u2014 commercial auto, business auto, CA
2636
+ - "non_owned_auto" \u2014 hired & non-owned auto
2637
+ - "workers_comp" \u2014 workers compensation, WC
2638
+ - "umbrella" \u2014 commercial umbrella
2639
+ - "excess_liability" \u2014 excess liability, follow-form excess
2640
+ - "professional_liability" \u2014 E&O, errors & omissions, professional liability, malpractice
2641
+ - "cyber" \u2014 cyber liability, data breach, network security
2642
+ - "epli" \u2014 employment practices liability
2643
+ - "directors_officers" \u2014 D&O, directors and officers
2644
+ - "fiduciary_liability" \u2014 fiduciary liability
2645
+ - "crime_fidelity" \u2014 crime, fidelity, employee dishonesty
2646
+ - "inland_marine" \u2014 inland marine, equipment floater, contractors equipment
2647
+ - "builders_risk" \u2014 builders risk, course of construction
2648
+ - "environmental" \u2014 environmental, pollution liability
2649
+ - "ocean_marine" \u2014 ocean marine, cargo, hull
2650
+ - "surety" \u2014 surety bond
2651
+ - "product_liability" \u2014 product liability, products-completed operations
2652
+ - "bop" \u2014 business owners policy, BOP
2653
+ - "management_liability_package" \u2014 management liability package
2654
+ - "property" \u2014 standalone property
2655
+
2656
+ PERSONAL LINES \u2014 match these values:
2657
+ - "homeowners_ho3" \u2014 HO-3, special form homeowners
2658
+ - "homeowners_ho5" \u2014 HO-5, comprehensive form homeowners
2659
+ - "renters_ho4" \u2014 HO-4, renters insurance
2660
+ - "condo_ho6" \u2014 HO-6, condo unit-owners
2661
+ - "dwelling_fire" \u2014 DP-1, DP-3, dwelling fire
2662
+ - "mobile_home" \u2014 mobile home, manufactured home
2663
+ - "personal_auto" \u2014 personal auto, PAP
2664
+ - "personal_umbrella" \u2014 personal umbrella
2665
+ - "flood_nfip" \u2014 NFIP flood
2666
+ - "flood_private" \u2014 private flood
2667
+ - "earthquake" \u2014 earthquake
2668
+ - "personal_inland_marine" \u2014 personal articles, scheduled personal property
2669
+ - "watercraft" \u2014 watercraft, boat
2670
+ - "recreational_vehicle" \u2014 RV, recreational vehicle, ATV
2671
+ - "farm_ranch" \u2014 farm, ranch
2672
+ - "pet" \u2014 pet insurance
2673
+ - "travel" \u2014 travel insurance
2674
+ - "identity_theft" \u2014 identity theft
2675
+ - "title" \u2014 title insurance
2676
+ - "other" \u2014 only if NONE of the above match
2677
+
2678
+ 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.
2679
+
2680
+ Return JSON only:
2633
2681
  {
2634
2682
  "documentType": "policy" | "quote",
2635
- "policyTypes": ["general_liability", "commercial_property", ...],
2683
+ "policyTypes": ["general_liability", ...],
2636
2684
  "confidence": 0.0-1.0
2637
- }
2638
-
2639
- 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.
2640
-
2641
- Respond with JSON only.`;
2685
+ }`;
2642
2686
  }
2643
2687
 
2644
2688
  // src/prompts/coordinator/plan.ts
@@ -3317,12 +3361,16 @@ function createExtractor(config) {
3317
3361
  },
3318
3362
  {
3319
3363
  fallback: { documentType: "policy", policyTypes: ["other"], confidence: 0 },
3364
+ maxRetries: 3,
3320
3365
  log,
3321
- onError: (err, attempt) => log?.(`Classify attempt ${attempt + 1} failed: ${err}`)
3366
+ onError: (err, attempt) => log?.(`Classify attempt ${attempt + 1} failed: ${err instanceof Error ? err.message : String(err)}`)
3322
3367
  }
3323
3368
  );
3324
3369
  trackUsage(classifyResponse.usage);
3325
3370
  classifyResult = classifyResponse.object;
3371
+ if (classifyResult.confidence === 0) {
3372
+ 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.`);
3373
+ }
3326
3374
  memory.set("classify", classifyResult);
3327
3375
  await pipelineCtx.save("classify", {
3328
3376
  id,