@ai-sdk/google
Advanced tools
+6
-0
| # @ai-sdk/google | ||
| ## 3.0.79 | ||
| ### Patch Changes | ||
| - cfa0cb2: feat(provider/google): support Google search grounding when using `generateImage` with Gemini | ||
| ## 3.0.78 | ||
@@ -4,0 +10,0 @@ |
+11
-0
@@ -228,2 +228,13 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils'; | ||
| aspectRatio?: "1:1" | "3:4" | "4:3" | "9:16" | "16:9" | null | undefined; | ||
| googleSearch?: { | ||
| [x: string]: unknown; | ||
| searchTypes?: { | ||
| webSearch?: Record<string, never> | undefined; | ||
| imageSearch?: Record<string, never> | undefined; | ||
| } | undefined; | ||
| timeRangeFilter?: { | ||
| startTime: string; | ||
| endTime: string; | ||
| } | undefined; | ||
| } | undefined; | ||
| }>; | ||
@@ -230,0 +241,0 @@ type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>; |
+11
-0
@@ -228,2 +228,13 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils'; | ||
| aspectRatio?: "1:1" | "3:4" | "4:3" | "9:16" | "16:9" | null | undefined; | ||
| googleSearch?: { | ||
| [x: string]: unknown; | ||
| searchTypes?: { | ||
| webSearch?: Record<string, never> | undefined; | ||
| imageSearch?: Record<string, never> | undefined; | ||
| } | undefined; | ||
| timeRangeFilter?: { | ||
| startTime: string; | ||
| endTime: string; | ||
| } | undefined; | ||
| } | undefined; | ||
| }>; | ||
@@ -230,0 +241,0 @@ type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>; |
+1
-1
| { | ||
| "name": "@ai-sdk/google", | ||
| "version": "3.0.78", | ||
| "version": "3.0.79", | ||
| "license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -17,4 +17,4 @@ import type { | ||
| type FetchFunction, | ||
| type InferSchema, | ||
| type Resolvable, | ||
| type InferSchema, | ||
| } from '@ai-sdk/provider-utils'; | ||
@@ -29,2 +29,3 @@ import { z } from 'zod/v4'; | ||
| import type { GoogleLanguageModelOptions } from './google-generative-ai-options'; | ||
| import { googleSearchToolArgsBaseSchema } from './tool/google-search'; | ||
@@ -144,3 +145,13 @@ interface GoogleGenerativeAIImageModelConfig { | ||
| if (googleOptions) { | ||
| Object.assign(parameters, googleOptions); | ||
| const { googleSearch: imagenGoogleSearch, ...imagenOptions } = | ||
| googleOptions; | ||
| if (imagenGoogleSearch != null) { | ||
| warnings.push({ | ||
| type: 'unsupported', | ||
| feature: 'googleSearch', | ||
| details: | ||
| 'Google Search grounding is only supported on Gemini image models.', | ||
| }); | ||
| } | ||
| Object.assign(parameters, imagenOptions); | ||
| } | ||
@@ -263,2 +274,14 @@ | ||
| // Parse image-model-specific provider options so we can map them onto | ||
| // the underlying language-model call. `googleSearch` is the dedicated | ||
| // escape hatch for grounding (generateImage has no `tools` parameter). | ||
| const googleImageOptions = await parseProviderOptions({ | ||
| provider: 'google', | ||
| providerOptions, | ||
| schema: googleImageModelOptionsSchema, | ||
| }); | ||
| const { googleSearch: _strippedGoogleSearch, ...passthroughGoogleOptions } = | ||
| providerOptions?.google ?? {}; | ||
| // Instantiate language model | ||
@@ -287,8 +310,19 @@ const languageModel = new GoogleGenerativeAILanguageModel(this.modelId, { | ||
| : undefined, | ||
| ...((providerOptions?.google as Omit< | ||
| ...(passthroughGoogleOptions as Omit< | ||
| GoogleLanguageModelOptions, | ||
| 'responseModalities' | 'imageConfig' | ||
| >) ?? {}), | ||
| >), | ||
| } satisfies GoogleLanguageModelOptions, | ||
| }, | ||
| tools: | ||
| googleImageOptions?.googleSearch != null | ||
| ? [ | ||
| { | ||
| type: 'provider', | ||
| id: 'google.google_search', | ||
| name: 'google_search', | ||
| args: googleImageOptions.googleSearch, | ||
| }, | ||
| ] | ||
| : undefined, | ||
| headers, | ||
@@ -308,2 +342,7 @@ abortSignal, | ||
| const languageModelGoogleMetadata = | ||
| (result.providerMetadata?.google as | ||
| | Record<string, unknown> | ||
| | undefined) ?? {}; | ||
| return { | ||
@@ -314,2 +353,3 @@ images, | ||
| google: { | ||
| ...languageModelGoogleMetadata, | ||
| images: images.map(() => ({})), | ||
@@ -360,2 +400,13 @@ }, | ||
| aspectRatio: z.enum(['1:1', '3:4', '4:3', '9:16', '16:9']).nullish(), | ||
| /** | ||
| * Enable Google Search grounding for Gemini image models. The value is | ||
| * forwarded as the args of the `google.tools.googleSearch` provider | ||
| * tool on the underlying language-model call. Pass `{}` for defaults. | ||
| * | ||
| * `generateImage` does not accept a `tools` parameter, so this is the | ||
| * dedicated escape hatch for grounding image generation the same way | ||
| * `generateText` does. | ||
| */ | ||
| googleSearch: googleSearchToolArgsBaseSchema.optional(), | ||
| }), | ||
@@ -362,0 +413,0 @@ ), |
@@ -12,3 +12,3 @@ import { | ||
| const googleSearchToolArgsBaseSchema = z | ||
| export const googleSearchToolArgsBaseSchema = z | ||
| .object({ | ||
@@ -15,0 +15,0 @@ searchTypes: z |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
2327203
0.47%26857
0.47%