@gendive/chatllm 0.17.41 → 0.17.42

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.
@@ -1720,6 +1720,12 @@ var fileToBase64 = (file) => new Promise((resolve, reject) => {
1720
1720
  reader.onerror = reject;
1721
1721
  reader.readAsDataURL(file);
1722
1722
  });
1723
+ var fileToDataUri = (file) => new Promise((resolve, reject) => {
1724
+ const reader = new FileReader();
1725
+ reader.onload = () => resolve(reader.result);
1726
+ reader.onerror = reject;
1727
+ reader.readAsDataURL(file);
1728
+ });
1723
1729
  var convertAttachmentsToBase64 = async (attachments) => Promise.all(
1724
1730
  attachments.map(async (att) => ({
1725
1731
  name: att.name,
@@ -2551,8 +2557,9 @@ ${finalContent}`;
2551
2557
  userContentParts.push({ type: "text", content: finalContent });
2552
2558
  }
2553
2559
  for (const att of currentAttachments) {
2554
- if (att.type === "image" && att.previewUrl) {
2555
- userContentParts.push({ type: "image", url: att.previewUrl, alt: att.name });
2560
+ if (att.type === "image" && att.file) {
2561
+ const dataUri = await fileToDataUri(att.file);
2562
+ userContentParts.push({ type: "image", url: dataUri, alt: att.name });
2556
2563
  } else {
2557
2564
  userContentParts.push({ type: "file", name: att.name, url: att.previewUrl || "", mimeType: att.mimeType, size: att.size });
2558
2565
  }