@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.d.cts CHANGED
@@ -412,7 +412,8 @@ interface VisionLLMComponentOptions extends BaseLLMComponentOptions {
412
412
  */
413
413
  interface ImageContent {
414
414
  type: 'image';
415
- image: string;
415
+ image: Uint8Array;
416
+ mediaType: string;
416
417
  }
417
418
  /**
418
419
  * Abstract base class for vision-based LLM components
@@ -441,13 +442,6 @@ declare abstract class VisionLLMComponent extends BaseLLMComponent {
441
442
  output: z.infer<TSchema>;
442
443
  usage: ExtendedTokenUsage;
443
444
  }>;
444
- /**
445
- * Load an image file and encode it as base64
446
- *
447
- * @param imagePath - Absolute path to the image file
448
- * @returns Base64 encoded image string
449
- */
450
- protected loadImageAsBase64(imagePath: string): string;
451
445
  /**
452
446
  * Build image content object for vision LLM messages
453
447
  *
package/dist/index.d.ts CHANGED
@@ -412,7 +412,8 @@ interface VisionLLMComponentOptions extends BaseLLMComponentOptions {
412
412
  */
413
413
  interface ImageContent {
414
414
  type: 'image';
415
- image: string;
415
+ image: Uint8Array;
416
+ mediaType: string;
416
417
  }
417
418
  /**
418
419
  * Abstract base class for vision-based LLM components
@@ -441,13 +442,6 @@ declare abstract class VisionLLMComponent extends BaseLLMComponent {
441
442
  output: z.infer<TSchema>;
442
443
  usage: ExtendedTokenUsage;
443
444
  }>;
444
- /**
445
- * Load an image file and encode it as base64
446
- *
447
- * @param imagePath - Absolute path to the image file
448
- * @returns Base64 encoded image string
449
- */
450
- protected loadImageAsBase64(imagePath: string): string;
451
445
  /**
452
446
  * Build image content object for vision LLM messages
453
447
  *
package/dist/index.js CHANGED
@@ -2354,16 +2354,6 @@ var VisionLLMComponent = class extends BaseLLMComponent {
2354
2354
  usage: result.usage
2355
2355
  };
2356
2356
  }
2357
- /**
2358
- * Load an image file and encode it as base64
2359
- *
2360
- * @param imagePath - Absolute path to the image file
2361
- * @returns Base64 encoded image string
2362
- */
2363
- loadImageAsBase64(imagePath) {
2364
- const imageBuffer = fs.readFileSync(imagePath);
2365
- return imageBuffer.toString("base64");
2366
- }
2367
2357
  /**
2368
2358
  * Build image content object for vision LLM messages
2369
2359
  *
@@ -2373,10 +2363,11 @@ var VisionLLMComponent = class extends BaseLLMComponent {
2373
2363
  */
2374
2364
  buildImageContent(imagePath, mimeType = "image/png") {
2375
2365
  const absolutePath = path.isAbsolute(imagePath) ? imagePath : path.resolve(this.outputPath, imagePath);
2376
- const base64Image = this.loadImageAsBase64(absolutePath);
2366
+ const imageData = new Uint8Array(fs.readFileSync(absolutePath));
2377
2367
  return {
2378
2368
  type: "image",
2379
- image: `data:${mimeType};base64,${base64Image}`
2369
+ image: imageData,
2370
+ mediaType: mimeType
2380
2371
  };
2381
2372
  }
2382
2373
  };
@@ -2531,11 +2522,11 @@ var VisionTocExtractor = class extends VisionLLMComponent {
2531
2522
  this.outputPath,
2532
2523
  `pages/page_${pageNo - 1}.png`
2533
2524
  );
2534
- const imageBuffer = fs2.readFileSync(imagePath);
2535
- const base64Image = imageBuffer.toString("base64");
2525
+ const imageData = new Uint8Array(fs2.readFileSync(imagePath));
2536
2526
  imageContents.push({
2537
2527
  type: "image",
2538
- image: `data:image/png;base64,${base64Image}`
2528
+ image: imageData,
2529
+ mediaType: "image/png"
2539
2530
  });
2540
2531
  }
2541
2532
  return imageContents;
@@ -3113,12 +3104,12 @@ var PageRangeParser = class extends VisionLLMComponent {
3113
3104
  this.outputPath,
3114
3105
  `pages/page_${pageNo - 1}.png`
3115
3106
  );
3116
- const imageBuffer = fs3.readFileSync(imagePath);
3117
- const base64Image = imageBuffer.toString("base64");
3107
+ const imageData = new Uint8Array(fs3.readFileSync(imagePath));
3118
3108
  const mimeType = page.image.mimetype || "image/png";
3119
3109
  imageContents.push({
3120
3110
  type: "image",
3121
- image: `data:${mimeType};base64,${base64Image}`
3111
+ image: imageData,
3112
+ mediaType: mimeType
3122
3113
  });
3123
3114
  }
3124
3115
  const schema = z4.object({