@claritylabs/cl-sdk 0.7.5 → 0.8.0
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.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +17 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1525,19 +1525,28 @@ async function runExtractor(params) {
|
|
|
1525
1525
|
maxTokens = 4096,
|
|
1526
1526
|
providerOptions
|
|
1527
1527
|
} = params;
|
|
1528
|
-
const
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1528
|
+
const extractorProviderOptions = { ...providerOptions };
|
|
1529
|
+
let fullPrompt;
|
|
1530
|
+
if (convertPdfToImages) {
|
|
1531
|
+
const images = await convertPdfToImages(pdfBase64, startPage, endPage);
|
|
1532
|
+
extractorProviderOptions.images = images;
|
|
1533
|
+
fullPrompt = `${prompt}
|
|
1534
|
+
|
|
1535
|
+
[Document pages ${startPage}-${endPage} are provided as images.]`;
|
|
1536
|
+
} else {
|
|
1537
|
+
const pagesPdf = await extractPageRange(pdfBase64, startPage, endPage);
|
|
1538
|
+
extractorProviderOptions.pdfBase64 = pagesPdf;
|
|
1539
|
+
fullPrompt = `${prompt}
|
|
1532
1540
|
|
|
1533
|
-
[Document pages ${startPage}-${endPage} are provided as a PDF file
|
|
1541
|
+
[Document pages ${startPage}-${endPage} are provided as a PDF file.]`;
|
|
1542
|
+
}
|
|
1534
1543
|
const strictSchema = toStrictSchema(schema);
|
|
1535
1544
|
const result = await withRetry(
|
|
1536
1545
|
() => generateObject({
|
|
1537
1546
|
prompt: fullPrompt,
|
|
1538
1547
|
schema: strictSchema,
|
|
1539
1548
|
maxTokens,
|
|
1540
|
-
providerOptions
|
|
1549
|
+
providerOptions: extractorProviderOptions
|
|
1541
1550
|
})
|
|
1542
1551
|
);
|
|
1543
1552
|
return {
|
|
@@ -3357,7 +3366,7 @@ function createExtractor(config) {
|
|
|
3357
3366
|
prompt: buildClassifyPrompt(),
|
|
3358
3367
|
schema: ClassifyResultSchema,
|
|
3359
3368
|
maxTokens: 512,
|
|
3360
|
-
providerOptions
|
|
3369
|
+
providerOptions: { ...providerOptions, pdfBase64 }
|
|
3361
3370
|
},
|
|
3362
3371
|
{
|
|
3363
3372
|
fallback: { documentType: "policy", policyTypes: ["other"], confidence: 0 },
|
|
@@ -3401,7 +3410,7 @@ function createExtractor(config) {
|
|
|
3401
3410
|
prompt: buildPlanPrompt(templateHints),
|
|
3402
3411
|
schema: ExtractionPlanSchema,
|
|
3403
3412
|
maxTokens: 2048,
|
|
3404
|
-
providerOptions
|
|
3413
|
+
providerOptions: { ...providerOptions, pdfBase64 }
|
|
3405
3414
|
},
|
|
3406
3415
|
{
|
|
3407
3416
|
fallback: {
|