@ai-sdk/google
Advanced tools
+6
-0
| # @ai-sdk/google | ||
| ## 2.0.57 | ||
| ### Patch Changes | ||
| - 4dda2a3: feat(google): add support for image search, replace obsolete google_search_retrieval implementation | ||
| ## 2.0.56 | ||
@@ -4,0 +10,0 @@ |
+16
-2
@@ -84,2 +84,3 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils'; | ||
| webSearchQueries?: string[] | null | undefined; | ||
| imageSearchQueries?: string[] | null | undefined; | ||
| retrievalQueries?: string[] | null | undefined; | ||
@@ -94,2 +95,8 @@ searchEntryPoint?: { | ||
| } | null | undefined; | ||
| image?: { | ||
| sourceUri: string; | ||
| imageUri: string; | ||
| title?: string | null | undefined; | ||
| domain?: string | null | undefined; | ||
| } | null | undefined; | ||
| retrievedContext?: { | ||
@@ -191,4 +198,11 @@ uri?: string | null | undefined; | ||
| googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, { | ||
| mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED"; | ||
| dynamicThreshold?: number; | ||
| [x: string]: unknown; | ||
| searchTypes?: { | ||
| webSearch?: Record<string, never> | undefined; | ||
| imageSearch?: Record<string, never> | undefined; | ||
| } | undefined; | ||
| timeRangeFilter?: { | ||
| startTime: string; | ||
| endTime: string; | ||
| } | undefined; | ||
| }>; | ||
@@ -195,0 +209,0 @@ /** |
+16
-2
@@ -84,2 +84,3 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils'; | ||
| webSearchQueries?: string[] | null | undefined; | ||
| imageSearchQueries?: string[] | null | undefined; | ||
| retrievalQueries?: string[] | null | undefined; | ||
@@ -94,2 +95,8 @@ searchEntryPoint?: { | ||
| } | null | undefined; | ||
| image?: { | ||
| sourceUri: string; | ||
| imageUri: string; | ||
| title?: string | null | undefined; | ||
| domain?: string | null | undefined; | ||
| } | null | undefined; | ||
| retrievedContext?: { | ||
@@ -191,4 +198,11 @@ uri?: string | null | undefined; | ||
| googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, { | ||
| mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED"; | ||
| dynamicThreshold?: number; | ||
| [x: string]: unknown; | ||
| searchTypes?: { | ||
| webSearch?: Record<string, never> | undefined; | ||
| imageSearch?: Record<string, never> | undefined; | ||
| } | undefined; | ||
| timeRangeFilter?: { | ||
| startTime: string; | ||
| endTime: string; | ||
| } | undefined; | ||
| }>; | ||
@@ -195,0 +209,0 @@ /** |
@@ -33,2 +33,3 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils'; | ||
| webSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>; | ||
| imageSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>; | ||
| retrievalQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>; | ||
@@ -43,2 +44,8 @@ searchEntryPoint: z.ZodOptional<z.ZodNullable<z.ZodObject<{ | ||
| }, z.core.$strip>>>; | ||
| image: z.ZodOptional<z.ZodNullable<z.ZodObject<{ | ||
| sourceUri: z.ZodString; | ||
| imageUri: z.ZodString; | ||
| title: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
| domain: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
| }, z.core.$strip>>>; | ||
| retrievedContext: z.ZodOptional<z.ZodNullable<z.ZodObject<{ | ||
@@ -118,2 +125,3 @@ uri: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
| webSearchQueries?: string[] | null | undefined; | ||
| imageSearchQueries?: string[] | null | undefined; | ||
| retrievalQueries?: string[] | null | undefined; | ||
@@ -128,2 +136,8 @@ searchEntryPoint?: { | ||
| } | null | undefined; | ||
| image?: { | ||
| sourceUri: string; | ||
| imageUri: string; | ||
| title?: string | null | undefined; | ||
| domain?: string | null | undefined; | ||
| } | null | undefined; | ||
| retrievedContext?: { | ||
@@ -195,4 +209,11 @@ uri?: string | null | undefined; | ||
| googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, { | ||
| mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED"; | ||
| dynamicThreshold?: number; | ||
| [x: string]: unknown; | ||
| searchTypes?: { | ||
| webSearch?: Record<string, never> | undefined; | ||
| imageSearch?: Record<string, never> | undefined; | ||
| } | undefined; | ||
| timeRangeFilter?: { | ||
| startTime: string; | ||
| endTime: string; | ||
| } | undefined; | ||
| }>; | ||
@@ -199,0 +220,0 @@ /** |
@@ -33,2 +33,3 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils'; | ||
| webSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>; | ||
| imageSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>; | ||
| retrievalQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>; | ||
@@ -43,2 +44,8 @@ searchEntryPoint: z.ZodOptional<z.ZodNullable<z.ZodObject<{ | ||
| }, z.core.$strip>>>; | ||
| image: z.ZodOptional<z.ZodNullable<z.ZodObject<{ | ||
| sourceUri: z.ZodString; | ||
| imageUri: z.ZodString; | ||
| title: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
| domain: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
| }, z.core.$strip>>>; | ||
| retrievedContext: z.ZodOptional<z.ZodNullable<z.ZodObject<{ | ||
@@ -118,2 +125,3 @@ uri: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
| webSearchQueries?: string[] | null | undefined; | ||
| imageSearchQueries?: string[] | null | undefined; | ||
| retrievalQueries?: string[] | null | undefined; | ||
@@ -128,2 +136,8 @@ searchEntryPoint?: { | ||
| } | null | undefined; | ||
| image?: { | ||
| sourceUri: string; | ||
| imageUri: string; | ||
| title?: string | null | undefined; | ||
| domain?: string | null | undefined; | ||
| } | null | undefined; | ||
| retrievedContext?: { | ||
@@ -195,4 +209,11 @@ uri?: string | null | undefined; | ||
| googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, { | ||
| mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED"; | ||
| dynamicThreshold?: number; | ||
| [x: string]: unknown; | ||
| searchTypes?: { | ||
| webSearch?: Record<string, never> | undefined; | ||
| imageSearch?: Record<string, never> | undefined; | ||
| } | undefined; | ||
| timeRangeFilter?: { | ||
| startTime: string; | ||
| endTime: string; | ||
| } | undefined; | ||
| }>; | ||
@@ -199,0 +220,0 @@ /** |
+44
-27
@@ -482,5 +482,4 @@ "use strict"; | ||
| ].some((id) => id === modelId); | ||
| const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest; | ||
| const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b"); | ||
| const supportsFileSearch = modelId.includes("gemini-2.5"); | ||
| const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest; | ||
| const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3"); | ||
| if (tools == null) { | ||
@@ -510,14 +509,9 @@ return { tools: void 0, toolConfig: void 0, toolWarnings }; | ||
| if (isGemini2orNewer) { | ||
| googleTools2.push({ googleSearch: {} }); | ||
| } else if (supportsDynamicRetrieval) { | ||
| googleTools2.push({ | ||
| googleSearchRetrieval: { | ||
| dynamicRetrievalConfig: { | ||
| mode: tool.args.mode, | ||
| dynamicThreshold: tool.args.dynamicThreshold | ||
| } | ||
| } | ||
| googleTools2.push({ googleSearch: { ...tool.args } }); | ||
| } else { | ||
| toolWarnings.push({ | ||
| type: "unsupported-tool", | ||
| tool, | ||
| details: "Google Search requires Gemini 2.0 or newer." | ||
| }); | ||
| } else { | ||
| googleTools2.push({ googleSearchRetrieval: {} }); | ||
| } | ||
@@ -1195,3 +1189,3 @@ break; | ||
| }) { | ||
| var _a, _b, _c, _d, _e; | ||
| var _a, _b, _c, _d, _e, _f; | ||
| if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) { | ||
@@ -1210,2 +1204,12 @@ return void 0; | ||
| }); | ||
| } else if (chunk.image != null) { | ||
| sources.push({ | ||
| type: "source", | ||
| sourceType: "url", | ||
| id: generateId2(), | ||
| // Google requires attribution to the source URI, not the actual image URI. | ||
| // TODO: add another type in v7 to allow both the image and source URL to be included separately | ||
| url: chunk.image.sourceUri, | ||
| title: (_b = chunk.image.title) != null ? _b : void 0 | ||
| }); | ||
| } else if (chunk.retrievedContext != null) { | ||
@@ -1220,6 +1224,6 @@ const uri = chunk.retrievedContext.uri; | ||
| url: uri, | ||
| title: (_b = chunk.retrievedContext.title) != null ? _b : void 0 | ||
| title: (_c = chunk.retrievedContext.title) != null ? _c : void 0 | ||
| }); | ||
| } else if (uri) { | ||
| const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document"; | ||
| const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document"; | ||
| let mediaType = "application/octet-stream"; | ||
@@ -1254,3 +1258,3 @@ let filename = void 0; | ||
| } else if (fileSearchStore) { | ||
| const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document"; | ||
| const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document"; | ||
| sources.push({ | ||
@@ -1272,3 +1276,3 @@ type: "source", | ||
| url: chunk.maps.uri, | ||
| title: (_e = chunk.maps.title) != null ? _e : void 0 | ||
| title: (_f = chunk.maps.title) != null ? _f : void 0 | ||
| }); | ||
@@ -1282,2 +1286,3 @@ } | ||
| webSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(), | ||
| imageSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(), | ||
| retrievalQueries: import_v43.z.array(import_v43.z.string()).nullish(), | ||
@@ -1288,2 +1293,8 @@ searchEntryPoint: import_v43.z.object({ renderedContent: import_v43.z.string() }).nullish(), | ||
| web: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string().nullish() }).nullish(), | ||
| image: import_v43.z.object({ | ||
| sourceUri: import_v43.z.string(), | ||
| imageUri: import_v43.z.string(), | ||
| title: import_v43.z.string().nullish(), | ||
| domain: import_v43.z.string().nullish() | ||
| }).nullish(), | ||
| retrievedContext: import_v43.z.object({ | ||
@@ -1488,13 +1499,19 @@ uri: import_v43.z.string().nullish(), | ||
| var import_v48 = require("zod/v4"); | ||
| var googleSearchToolArgsBaseSchema = import_v48.z.object({ | ||
| searchTypes: import_v48.z.object({ | ||
| webSearch: import_v48.z.object({}).optional(), | ||
| imageSearch: import_v48.z.object({}).optional() | ||
| }).optional(), | ||
| timeRangeFilter: import_v48.z.object({ | ||
| startTime: import_v48.z.string(), | ||
| endTime: import_v48.z.string() | ||
| }).optional() | ||
| }).passthrough(); | ||
| var googleSearchToolArgsSchema = (0, import_provider_utils9.lazySchema)( | ||
| () => (0, import_provider_utils9.zodSchema)(googleSearchToolArgsBaseSchema) | ||
| ); | ||
| var googleSearch = (0, import_provider_utils9.createProviderDefinedToolFactory)({ | ||
| id: "google.google_search", | ||
| name: "google_search", | ||
| inputSchema: (0, import_provider_utils9.lazySchema)( | ||
| () => (0, import_provider_utils9.zodSchema)( | ||
| import_v48.z.object({ | ||
| mode: import_v48.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"), | ||
| dynamicThreshold: import_v48.z.number().default(1) | ||
| }) | ||
| ) | ||
| ) | ||
| inputSchema: googleSearchToolArgsSchema | ||
| }); | ||
@@ -1501,0 +1518,0 @@ |
+44
-27
@@ -474,5 +474,4 @@ // src/google-generative-ai-language-model.ts | ||
| ].some((id) => id === modelId); | ||
| const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest; | ||
| const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b"); | ||
| const supportsFileSearch = modelId.includes("gemini-2.5"); | ||
| const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest; | ||
| const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3"); | ||
| if (tools == null) { | ||
@@ -502,14 +501,9 @@ return { tools: void 0, toolConfig: void 0, toolWarnings }; | ||
| if (isGemini2orNewer) { | ||
| googleTools2.push({ googleSearch: {} }); | ||
| } else if (supportsDynamicRetrieval) { | ||
| googleTools2.push({ | ||
| googleSearchRetrieval: { | ||
| dynamicRetrievalConfig: { | ||
| mode: tool.args.mode, | ||
| dynamicThreshold: tool.args.dynamicThreshold | ||
| } | ||
| } | ||
| googleTools2.push({ googleSearch: { ...tool.args } }); | ||
| } else { | ||
| toolWarnings.push({ | ||
| type: "unsupported-tool", | ||
| tool, | ||
| details: "Google Search requires Gemini 2.0 or newer." | ||
| }); | ||
| } else { | ||
| googleTools2.push({ googleSearchRetrieval: {} }); | ||
| } | ||
@@ -1187,3 +1181,3 @@ break; | ||
| }) { | ||
| var _a, _b, _c, _d, _e; | ||
| var _a, _b, _c, _d, _e, _f; | ||
| if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) { | ||
@@ -1202,2 +1196,12 @@ return void 0; | ||
| }); | ||
| } else if (chunk.image != null) { | ||
| sources.push({ | ||
| type: "source", | ||
| sourceType: "url", | ||
| id: generateId2(), | ||
| // Google requires attribution to the source URI, not the actual image URI. | ||
| // TODO: add another type in v7 to allow both the image and source URL to be included separately | ||
| url: chunk.image.sourceUri, | ||
| title: (_b = chunk.image.title) != null ? _b : void 0 | ||
| }); | ||
| } else if (chunk.retrievedContext != null) { | ||
@@ -1212,6 +1216,6 @@ const uri = chunk.retrievedContext.uri; | ||
| url: uri, | ||
| title: (_b = chunk.retrievedContext.title) != null ? _b : void 0 | ||
| title: (_c = chunk.retrievedContext.title) != null ? _c : void 0 | ||
| }); | ||
| } else if (uri) { | ||
| const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document"; | ||
| const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document"; | ||
| let mediaType = "application/octet-stream"; | ||
@@ -1246,3 +1250,3 @@ let filename = void 0; | ||
| } else if (fileSearchStore) { | ||
| const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document"; | ||
| const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document"; | ||
| sources.push({ | ||
@@ -1264,3 +1268,3 @@ type: "source", | ||
| url: chunk.maps.uri, | ||
| title: (_e = chunk.maps.title) != null ? _e : void 0 | ||
| title: (_f = chunk.maps.title) != null ? _f : void 0 | ||
| }); | ||
@@ -1274,2 +1278,3 @@ } | ||
| webSearchQueries: z3.array(z3.string()).nullish(), | ||
| imageSearchQueries: z3.array(z3.string()).nullish(), | ||
| retrievalQueries: z3.array(z3.string()).nullish(), | ||
@@ -1280,2 +1285,8 @@ searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(), | ||
| web: z3.object({ uri: z3.string(), title: z3.string().nullish() }).nullish(), | ||
| image: z3.object({ | ||
| sourceUri: z3.string(), | ||
| imageUri: z3.string(), | ||
| title: z3.string().nullish(), | ||
| domain: z3.string().nullish() | ||
| }).nullish(), | ||
| retrievedContext: z3.object({ | ||
@@ -1496,13 +1507,19 @@ uri: z3.string().nullish(), | ||
| import { z as z8 } from "zod/v4"; | ||
| var googleSearchToolArgsBaseSchema = z8.object({ | ||
| searchTypes: z8.object({ | ||
| webSearch: z8.object({}).optional(), | ||
| imageSearch: z8.object({}).optional() | ||
| }).optional(), | ||
| timeRangeFilter: z8.object({ | ||
| startTime: z8.string(), | ||
| endTime: z8.string() | ||
| }).optional() | ||
| }).passthrough(); | ||
| var googleSearchToolArgsSchema = lazySchema7( | ||
| () => zodSchema7(googleSearchToolArgsBaseSchema) | ||
| ); | ||
| var googleSearch = createProviderDefinedToolFactory4({ | ||
| id: "google.google_search", | ||
| name: "google_search", | ||
| inputSchema: lazySchema7( | ||
| () => zodSchema7( | ||
| z8.object({ | ||
| mode: z8.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"), | ||
| dynamicThreshold: z8.number().default(1) | ||
| }) | ||
| ) | ||
| ) | ||
| inputSchema: googleSearchToolArgsSchema | ||
| }); | ||
@@ -1509,0 +1526,0 @@ |
+1
-1
| { | ||
| "name": "@ai-sdk/google", | ||
| "version": "2.0.56", | ||
| "version": "2.0.57", | ||
| "license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
812701
1.03%7632
1.37%