Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@ai-sdk/google

Package Overview
Dependencies
Maintainers
3
Versions
517
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/google - npm Package Compare versions

Comparing version
3.0.78
to
3.0.79
+6
-0
CHANGELOG.md
# @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 @@

@@ -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>;

@@ -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