modelmix 3.5.4 → 3.5.6

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.
Files changed (2) hide show
  1. package/index.js +14 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -202,15 +202,8 @@ class ModelMix {
202
202
  return this;
203
203
  }
204
204
 
205
- addImage(filePath, { role = "user" } = {}) {
206
- const imageBuffer = this.readFile(filePath, { encoding: null });
207
- const mimeType = mime.lookup(filePath);
208
-
209
- if (!mimeType || !mimeType.startsWith('image/')) {
210
- throw new Error('Invalid image file type');
211
- }
212
-
213
- const data = imageBuffer.toString('base64');
205
+ addImageFromBuffer(buffer, { role = "user" } = {}) {
206
+ const data = buffer.toString('base64');
214
207
 
215
208
  const imageMessage = {
216
209
  ...{ role },
@@ -230,6 +223,18 @@ class ModelMix {
230
223
  return this;
231
224
  }
232
225
 
226
+ addImage(filePath, { role = "user" } = {}) {
227
+ const imageBuffer = this.readFile(filePath, { encoding: null });
228
+ const mimeType = mime.lookup(filePath);
229
+
230
+ if (!mimeType || !mimeType.startsWith('image/')) {
231
+ throw new Error('Invalid image file type');
232
+ }
233
+
234
+ this.addImageFromBuffer(imageBuffer, { role });
235
+ return this;
236
+ }
237
+
233
238
  addImageFromUrl(url, config = { role: "user" }) {
234
239
  if (!this.imagesToProcess) {
235
240
  this.imagesToProcess = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modelmix",
3
- "version": "3.5.4",
3
+ "version": "3.5.6",
4
4
  "description": "🧬 ModelMix - Unified API for Diverse AI LLM.",
5
5
  "main": "index.js",
6
6
  "repository": {