@heripo/document-processor 0.1.11 → 0.1.13
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.cjs +9 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -8
- package/dist/index.d.ts +2 -8
- package/dist/index.js +9 -18
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -2410,16 +2410,6 @@ var VisionLLMComponent = class extends BaseLLMComponent {
|
|
|
2410
2410
|
usage: result.usage
|
|
2411
2411
|
};
|
|
2412
2412
|
}
|
|
2413
|
-
/**
|
|
2414
|
-
* Load an image file and encode it as base64
|
|
2415
|
-
*
|
|
2416
|
-
* @param imagePath - Absolute path to the image file
|
|
2417
|
-
* @returns Base64 encoded image string
|
|
2418
|
-
*/
|
|
2419
|
-
loadImageAsBase64(imagePath) {
|
|
2420
|
-
const imageBuffer = fs.readFileSync(imagePath);
|
|
2421
|
-
return imageBuffer.toString("base64");
|
|
2422
|
-
}
|
|
2423
2413
|
/**
|
|
2424
2414
|
* Build image content object for vision LLM messages
|
|
2425
2415
|
*
|
|
@@ -2429,10 +2419,11 @@ var VisionLLMComponent = class extends BaseLLMComponent {
|
|
|
2429
2419
|
*/
|
|
2430
2420
|
buildImageContent(imagePath, mimeType = "image/png") {
|
|
2431
2421
|
const absolutePath = path.isAbsolute(imagePath) ? imagePath : path.resolve(this.outputPath, imagePath);
|
|
2432
|
-
const
|
|
2422
|
+
const imageData = new Uint8Array(fs.readFileSync(absolutePath));
|
|
2433
2423
|
return {
|
|
2434
2424
|
type: "image",
|
|
2435
|
-
image:
|
|
2425
|
+
image: imageData,
|
|
2426
|
+
mediaType: mimeType
|
|
2436
2427
|
};
|
|
2437
2428
|
}
|
|
2438
2429
|
};
|
|
@@ -2587,11 +2578,11 @@ var VisionTocExtractor = class extends VisionLLMComponent {
|
|
|
2587
2578
|
this.outputPath,
|
|
2588
2579
|
`pages/page_${pageNo - 1}.png`
|
|
2589
2580
|
);
|
|
2590
|
-
const
|
|
2591
|
-
const base64Image = imageBuffer.toString("base64");
|
|
2581
|
+
const imageData = new Uint8Array(fs2.readFileSync(imagePath));
|
|
2592
2582
|
imageContents.push({
|
|
2593
2583
|
type: "image",
|
|
2594
|
-
image:
|
|
2584
|
+
image: imageData,
|
|
2585
|
+
mediaType: "image/png"
|
|
2595
2586
|
});
|
|
2596
2587
|
}
|
|
2597
2588
|
return imageContents;
|
|
@@ -3169,12 +3160,12 @@ var PageRangeParser = class extends VisionLLMComponent {
|
|
|
3169
3160
|
this.outputPath,
|
|
3170
3161
|
`pages/page_${pageNo - 1}.png`
|
|
3171
3162
|
);
|
|
3172
|
-
const
|
|
3173
|
-
const base64Image = imageBuffer.toString("base64");
|
|
3163
|
+
const imageData = new Uint8Array(fs3.readFileSync(imagePath));
|
|
3174
3164
|
const mimeType = page.image.mimetype || "image/png";
|
|
3175
3165
|
imageContents.push({
|
|
3176
3166
|
type: "image",
|
|
3177
|
-
image:
|
|
3167
|
+
image: imageData,
|
|
3168
|
+
mediaType: mimeType
|
|
3178
3169
|
});
|
|
3179
3170
|
}
|
|
3180
3171
|
const schema = import_zod4.z.object({
|