@ai-sdk/google 4.0.16 → 4.0.17
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 +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +55 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +54 -4
- package/dist/internal/index.js.map +1 -1
- package/package.json +1 -1
- package/src/google-language-model-options.ts +40 -0
- package/src/google-language-model.ts +30 -3
package/package.json
CHANGED
|
@@ -176,6 +176,46 @@ export const googleLanguageModelOptions = lazySchema(() =>
|
|
|
176
176
|
])
|
|
177
177
|
.optional(),
|
|
178
178
|
imageSize: z.enum(['1K', '2K', '4K', '512']).optional(),
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Optional. Controls the generation of people in images.
|
|
182
|
+
* Vertex AI only.
|
|
183
|
+
*/
|
|
184
|
+
personGeneration: z
|
|
185
|
+
.enum([
|
|
186
|
+
'PERSON_GENERATION_UNSPECIFIED',
|
|
187
|
+
'ALLOW_ALL',
|
|
188
|
+
'ALLOW_ADULT',
|
|
189
|
+
'ALLOW_NONE',
|
|
190
|
+
])
|
|
191
|
+
.optional(),
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Optional. Controls whether generation of prominent people
|
|
195
|
+
* (celebrities) is allowed. When set together with
|
|
196
|
+
* `personGeneration`, `personGeneration` takes precedence.
|
|
197
|
+
* Vertex AI only.
|
|
198
|
+
*
|
|
199
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerationConfig
|
|
200
|
+
*/
|
|
201
|
+
prominentPeople: z
|
|
202
|
+
.enum([
|
|
203
|
+
'PROMINENT_PEOPLE_UNSPECIFIED',
|
|
204
|
+
'ALLOW_PROMINENT_PEOPLE',
|
|
205
|
+
'BLOCK_PROMINENT_PEOPLE',
|
|
206
|
+
])
|
|
207
|
+
.optional(),
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Optional. The image output format for generated images.
|
|
211
|
+
* Vertex AI only.
|
|
212
|
+
*/
|
|
213
|
+
imageOutputOptions: z
|
|
214
|
+
.object({
|
|
215
|
+
mimeType: z.enum(['image/jpeg', 'image/png']).optional(),
|
|
216
|
+
compressionQuality: z.number().optional(),
|
|
217
|
+
})
|
|
218
|
+
.optional(),
|
|
179
219
|
})
|
|
180
220
|
.optional(),
|
|
181
221
|
|
|
@@ -227,6 +227,35 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
227
227
|
? undefined
|
|
228
228
|
: googleOptions?.serviceTier;
|
|
229
229
|
|
|
230
|
+
// personGeneration, prominentPeople and imageOutputOptions are only
|
|
231
|
+
// supported by the Vertex AI API, the Gemini API rejects them.
|
|
232
|
+
let imageConfig = googleOptions?.imageConfig;
|
|
233
|
+
if (imageConfig != null && !isVertexProvider) {
|
|
234
|
+
const {
|
|
235
|
+
personGeneration,
|
|
236
|
+
prominentPeople,
|
|
237
|
+
imageOutputOptions,
|
|
238
|
+
...geminiApiImageConfig
|
|
239
|
+
} = imageConfig;
|
|
240
|
+
const droppedImageConfigFields = Object.entries({
|
|
241
|
+
personGeneration,
|
|
242
|
+
prominentPeople,
|
|
243
|
+
imageOutputOptions,
|
|
244
|
+
})
|
|
245
|
+
.filter(([, value]) => value != null)
|
|
246
|
+
.map(([key]) => `'imageConfig.${key}'`);
|
|
247
|
+
if (droppedImageConfigFields.length > 0) {
|
|
248
|
+
warnings.push({
|
|
249
|
+
type: 'other',
|
|
250
|
+
message:
|
|
251
|
+
`${droppedImageConfigFields.join(', ')} ` +
|
|
252
|
+
`${droppedImageConfigFields.length === 1 ? 'is a Vertex AI option and is' : 'are Vertex AI options and are'} ` +
|
|
253
|
+
`ignored with the current Google provider (${this.config.provider}).`,
|
|
254
|
+
});
|
|
255
|
+
imageConfig = geminiApiImageConfig;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
230
259
|
const isGemmaModel = this.modelId.toLowerCase().startsWith('gemma-');
|
|
231
260
|
const isGemini3Model = /^gemini-3[.-]/.test(this.modelId);
|
|
232
261
|
const supportsFunctionResponseParts = isGemini3Model;
|
|
@@ -328,9 +357,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
328
357
|
...(googleOptions?.mediaResolution && {
|
|
329
358
|
mediaResolution: googleOptions.mediaResolution,
|
|
330
359
|
}),
|
|
331
|
-
...(
|
|
332
|
-
imageConfig: googleOptions.imageConfig,
|
|
333
|
-
}),
|
|
360
|
+
...(imageConfig && { imageConfig }),
|
|
334
361
|
},
|
|
335
362
|
contents,
|
|
336
363
|
systemInstruction: isGemmaModel ? undefined : systemInstruction,
|