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
4.0.0-canary.71
to
4.0.0-canary.72
+11
-0
dist/index.d.ts

@@ -220,2 +220,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;
}>;

@@ -222,0 +233,0 @@ type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>;

+1
-1
{
"name": "@ai-sdk/google",
"version": "4.0.0-canary.71",
"version": "4.0.0-canary.72",
"type": "module",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -7,2 +7,3 @@ import {

import { z } from 'zod/v4';
import { googleSearchToolArgsBaseSchema } from './tool/google-search';

@@ -18,2 +19,13 @@ // Note: For the initial GA launch of Imagen 3, safety filters are not configurable.

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(),
}),

@@ -20,0 +32,0 @@ ),

@@ -159,3 +159,13 @@ import type {

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);
}

@@ -287,2 +297,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

@@ -311,8 +333,19 @@ const languageModel = new GoogleLanguageModel(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,

@@ -335,2 +368,7 @@ abortSignal,

const languageModelGoogleMetadata =
(result.providerMetadata?.google as
| Record<string, unknown>
| undefined) ?? {};
return {

@@ -341,2 +379,3 @@ images,

google: {
...languageModelGoogleMetadata,
images: images.map(() => ({})),

@@ -343,0 +382,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 not supported yet