@ai-sdk/google 3.0.120 → 3.0.122
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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -2
- package/dist/internal/index.d.ts +2 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs.map +1 -1
- package/docs/15-google-generative-ai.mdx +1 -0
- package/package.json +3 -3
- package/src/google-generative-ai-image-model.ts +23 -5
- package/src/google-generative-ai-options.ts +1 -0
- package/src/interactions/google-interactions-language-model-options.ts +1 -0
|
@@ -1082,6 +1082,7 @@ The following Zod features are known to not work with Google Generative AI:
|
|
|
1082
1082
|
|
|
1083
1083
|
| Model | Image Input | Object Generation | Tool Usage | Tool Streaming | Google Search | URL Context |
|
|
1084
1084
|
| ------------------------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
|
|
1085
|
+
| `gemini-3.8-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
1085
1086
|
| `gemini-3.7-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
1086
1087
|
| `gemini-3.6-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
1087
1088
|
| `gemini-3.5-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.122",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ai-sdk/provider": "3.0.
|
|
40
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
39
|
+
"@ai-sdk/provider": "3.0.16",
|
|
40
|
+
"@ai-sdk/provider-utils": "4.0.51"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "20.17.24",
|
|
@@ -159,7 +159,9 @@ export class GoogleGenerativeAIImageModel implements ImageModelV3 {
|
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
const { responseHeaders, value: response } = await postJsonToApi<{
|
|
162
|
-
predictions: Array<
|
|
162
|
+
predictions: Array<
|
|
163
|
+
{ bytesBase64Encoded: string } | { raiFilteredReason: string }
|
|
164
|
+
>;
|
|
163
165
|
}>({
|
|
164
166
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
165
167
|
headers: combineHeaders(await resolve(this.config.headers), headers),
|
|
@@ -171,14 +173,22 @@ export class GoogleGenerativeAIImageModel implements ImageModelV3 {
|
|
|
171
173
|
abortSignal,
|
|
172
174
|
fetch: this.config.fetch,
|
|
173
175
|
});
|
|
176
|
+
const imagePredictions = response.predictions.filter(
|
|
177
|
+
(prediction): prediction is { bytesBase64Encoded: string } =>
|
|
178
|
+
'bytesBase64Encoded' in prediction,
|
|
179
|
+
);
|
|
180
|
+
|
|
174
181
|
return {
|
|
175
|
-
images:
|
|
176
|
-
(
|
|
182
|
+
images: imagePredictions.map(
|
|
183
|
+
({ bytesBase64Encoded }) => bytesBase64Encoded,
|
|
177
184
|
),
|
|
185
|
+
...(response.predictions.some(
|
|
186
|
+
prediction => 'raiFilteredReason' in prediction,
|
|
187
|
+
) && { isRetryable: false }),
|
|
178
188
|
warnings,
|
|
179
189
|
providerMetadata: {
|
|
180
190
|
google: {
|
|
181
|
-
images:
|
|
191
|
+
images: imagePredictions.map(() => ({
|
|
182
192
|
// Add any prediction-specific metadata here
|
|
183
193
|
})),
|
|
184
194
|
},
|
|
@@ -341,6 +351,9 @@ export class GoogleGenerativeAIImageModel implements ImageModelV3 {
|
|
|
341
351
|
|
|
342
352
|
return {
|
|
343
353
|
images,
|
|
354
|
+
...(result.finishReason.unified === 'content-filter'
|
|
355
|
+
? { isRetryable: false }
|
|
356
|
+
: {}),
|
|
344
357
|
warnings,
|
|
345
358
|
providerMetadata: {
|
|
346
359
|
google: {
|
|
@@ -375,7 +388,12 @@ const googleImageResponseSchema = lazySchema(() =>
|
|
|
375
388
|
zodSchema(
|
|
376
389
|
z.object({
|
|
377
390
|
predictions: z
|
|
378
|
-
.array(
|
|
391
|
+
.array(
|
|
392
|
+
z.union([
|
|
393
|
+
z.object({ bytesBase64Encoded: z.string() }),
|
|
394
|
+
z.object({ raiFilteredReason: z.string() }),
|
|
395
|
+
]),
|
|
396
|
+
)
|
|
379
397
|
.default([]),
|
|
380
398
|
}),
|
|
381
399
|
),
|