@ai-sdk/google 4.0.0-beta.21 → 4.0.0-beta.23
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/CHANGELOG.md +15 -0
- package/README.md +2 -0
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +250 -55
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +261 -52
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +40 -5
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +45 -6
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/convert-to-google-generative-ai-messages.ts +58 -17
- package/src/google-generative-ai-files.ts +230 -0
- package/src/google-generative-ai-prompt.ts +10 -2
- package/src/google-provider.ts +13 -0
- package/src/index.ts +1 -0
package/dist/internal/index.js
CHANGED
|
@@ -323,19 +323,36 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
323
323
|
}
|
|
324
324
|
case "file": {
|
|
325
325
|
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
if (part.data instanceof URL) {
|
|
327
|
+
parts.push({
|
|
328
328
|
fileData: {
|
|
329
329
|
mimeType: mediaType,
|
|
330
330
|
fileUri: part.data.toString()
|
|
331
331
|
}
|
|
332
|
-
}
|
|
332
|
+
});
|
|
333
|
+
} else if ((0, import_provider_utils.isProviderReference)(part.data)) {
|
|
334
|
+
if (providerOptionsName === "vertex") {
|
|
335
|
+
throw new import_provider.UnsupportedFunctionalityError({
|
|
336
|
+
functionality: "file parts with provider references"
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
parts.push({
|
|
340
|
+
fileData: {
|
|
341
|
+
mimeType: mediaType,
|
|
342
|
+
fileUri: (0, import_provider_utils.resolveProviderReference)({
|
|
343
|
+
reference: part.data,
|
|
344
|
+
provider: "google"
|
|
345
|
+
})
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
} else {
|
|
349
|
+
parts.push({
|
|
333
350
|
inlineData: {
|
|
334
351
|
mimeType: mediaType,
|
|
335
352
|
data: (0, import_provider_utils.convertToBase64)(part.data)
|
|
336
353
|
}
|
|
337
|
-
}
|
|
338
|
-
|
|
354
|
+
});
|
|
355
|
+
}
|
|
339
356
|
break;
|
|
340
357
|
}
|
|
341
358
|
}
|
|
@@ -386,6 +403,24 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
386
403
|
functionality: "File data URLs in assistant messages are not supported"
|
|
387
404
|
});
|
|
388
405
|
}
|
|
406
|
+
if ((0, import_provider_utils.isProviderReference)(part.data)) {
|
|
407
|
+
if (providerOptionsName === "vertex") {
|
|
408
|
+
throw new import_provider.UnsupportedFunctionalityError({
|
|
409
|
+
functionality: "file parts with provider references"
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
fileData: {
|
|
414
|
+
mimeType: part.mediaType,
|
|
415
|
+
fileUri: (0, import_provider_utils.resolveProviderReference)({
|
|
416
|
+
reference: part.data,
|
|
417
|
+
provider: "google"
|
|
418
|
+
})
|
|
419
|
+
},
|
|
420
|
+
...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
|
|
421
|
+
thoughtSignature
|
|
422
|
+
};
|
|
423
|
+
}
|
|
389
424
|
return {
|
|
390
425
|
inlineData: {
|
|
391
426
|
mimeType: part.mediaType,
|