@ai-sdk/google 2.0.0-beta.7 → 2.0.0-beta.9

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 2.0.0-beta.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 8af9e03: Added Image Models to the Google Provider for Imagen 3 Support
8
+
9
+ ## 2.0.0-beta.8
10
+
11
+ ### Patch Changes
12
+
13
+ - 2e06f14: feat (provider/google): Change to provider defined tools
14
+
15
+ - Change the google search tool to be a provider defined tool
16
+ - Added new URL context tool as a provider defined tool
17
+
3
18
  ## 2.0.0-beta.7
4
19
 
5
20
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod/v4';
2
- import { ProviderV2, LanguageModelV2, EmbeddingModelV2 } from '@ai-sdk/provider';
2
+ import { ProviderV2, LanguageModelV2, ImageModelV2, EmbeddingModelV2 } from '@ai-sdk/provider';
3
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
4
5
 
5
6
  declare const googleErrorDataSchema: z.ZodObject<{
@@ -50,14 +51,6 @@ declare const googleGenerativeAIProviderOptions: z.ZodObject<{
50
51
  OFF: "OFF";
51
52
  }>>;
52
53
  audioTimestamp: z.ZodOptional<z.ZodBoolean>;
53
- useSearchGrounding: z.ZodOptional<z.ZodBoolean>;
54
- dynamicRetrievalConfig: z.ZodOptional<z.ZodObject<{
55
- mode: z.ZodOptional<z.ZodEnum<{
56
- MODE_UNSPECIFIED: "MODE_UNSPECIFIED";
57
- MODE_DYNAMIC: "MODE_DYNAMIC";
58
- }>>;
59
- dynamicThreshold: z.ZodOptional<z.ZodNumber>;
60
- }, z.core.$strip>>;
61
54
  }, z.core.$strip>;
62
55
  type GoogleGenerativeAIProviderOptions = z.infer<typeof googleGenerativeAIProviderOptions>;
63
56
 
@@ -93,6 +86,14 @@ declare const groundingMetadataSchema: z.ZodObject<{
93
86
  webDynamicRetrievalScore: z.ZodNumber;
94
87
  }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>]>>>;
95
88
  }, z.core.$strip>;
89
+
90
+ declare const urlContextMetadataSchema: z.ZodObject<{
91
+ urlMetadata: z.ZodArray<z.ZodObject<{
92
+ retrievedUrl: z.ZodString;
93
+ urlRetrievalStatus: z.ZodString;
94
+ }, z.core.$strip>>;
95
+ }, z.core.$strip>;
96
+
96
97
  declare const safetyRatingSchema: z.ZodObject<{
97
98
  category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
98
99
  probability: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -103,19 +104,65 @@ declare const safetyRatingSchema: z.ZodObject<{
103
104
  }, z.core.$strip>;
104
105
 
105
106
  type GoogleGenerativeAIGroundingMetadata = z.infer<typeof groundingMetadataSchema>;
107
+ type GoogleGenerativeAIUrlContextMetadata = z.infer<typeof urlContextMetadataSchema>;
106
108
  type GoogleGenerativeAISafetyRating = z.infer<typeof safetyRatingSchema>;
107
109
  interface GoogleGenerativeAIProviderMetadata {
108
110
  groundingMetadata: GoogleGenerativeAIGroundingMetadata | null;
111
+ urlContextMetadata: GoogleGenerativeAIUrlContextMetadata | null;
109
112
  safetyRatings: GoogleGenerativeAISafetyRating[] | null;
110
113
  }
111
114
 
115
+ type GoogleGenerativeAIImageModelId = 'imagen-3.0-generate-002' | (string & {});
116
+ interface GoogleGenerativeAIImageSettings {
117
+ /**
118
+ Override the maximum number of images per call (default 4)
119
+ */
120
+ maxImagesPerCall?: number;
121
+ }
122
+
123
+ declare const googleImageProviderOptionsSchema: z.ZodObject<{
124
+ personGeneration: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
125
+ dont_allow: "dont_allow";
126
+ allow_adult: "allow_adult";
127
+ allow_all: "allow_all";
128
+ }>>>;
129
+ aspectRatio: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
130
+ "1:1": "1:1";
131
+ "3:4": "3:4";
132
+ "4:3": "4:3";
133
+ "9:16": "9:16";
134
+ "16:9": "16:9";
135
+ }>>>;
136
+ }, z.core.$strip>;
137
+ type GoogleGenerativeAIImageProviderOptions = z.infer<typeof googleImageProviderOptionsSchema>;
138
+
112
139
  type GoogleGenerativeAIEmbeddingModelId = 'text-embedding-004' | (string & {});
113
140
 
141
+ declare const googleTools: {
142
+ /**
143
+ * Creates a Google search tool that gives Google direct access to real-time web content.
144
+ * Must have name "google_search".
145
+ */
146
+ googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
147
+ mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
148
+ dynamicThreshold?: number;
149
+ }>;
150
+ /**
151
+ * Creates a URL context tool that gives Google direct access to real-time web content.
152
+ * Must have name "url_context".
153
+ */
154
+ urlContext: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
155
+ };
156
+
114
157
  interface GoogleGenerativeAIProvider extends ProviderV2 {
115
158
  (modelId: GoogleGenerativeAIModelId): LanguageModelV2;
116
159
  languageModel(modelId: GoogleGenerativeAIModelId): LanguageModelV2;
117
160
  chat(modelId: GoogleGenerativeAIModelId): LanguageModelV2;
118
161
  /**
162
+ Creates a model for image generation.
163
+ */
164
+ image(modelId: GoogleGenerativeAIImageModelId, settings?: GoogleGenerativeAIImageSettings): ImageModelV2;
165
+ /**
119
166
  * @deprecated Use `chat()` instead.
120
167
  */
121
168
  generativeAI(modelId: GoogleGenerativeAIModelId): LanguageModelV2;
@@ -128,6 +175,7 @@ interface GoogleGenerativeAIProvider extends ProviderV2 {
128
175
  */
129
176
  textEmbedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV2<string>;
130
177
  textEmbeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV2<string>;
178
+ tools: typeof googleTools;
131
179
  }
132
180
  interface GoogleGenerativeAIProviderSettings {
133
181
  /**
@@ -163,4 +211,4 @@ Default Google Generative AI provider instance.
163
211
  */
164
212
  declare const google: GoogleGenerativeAIProvider;
165
213
 
166
- export { type GoogleErrorData, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, createGoogleGenerativeAI, google };
214
+ export { type GoogleErrorData, type GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, createGoogleGenerativeAI, google };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod/v4';
2
- import { ProviderV2, LanguageModelV2, EmbeddingModelV2 } from '@ai-sdk/provider';
2
+ import { ProviderV2, LanguageModelV2, ImageModelV2, EmbeddingModelV2 } from '@ai-sdk/provider';
3
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
4
5
 
5
6
  declare const googleErrorDataSchema: z.ZodObject<{
@@ -50,14 +51,6 @@ declare const googleGenerativeAIProviderOptions: z.ZodObject<{
50
51
  OFF: "OFF";
51
52
  }>>;
52
53
  audioTimestamp: z.ZodOptional<z.ZodBoolean>;
53
- useSearchGrounding: z.ZodOptional<z.ZodBoolean>;
54
- dynamicRetrievalConfig: z.ZodOptional<z.ZodObject<{
55
- mode: z.ZodOptional<z.ZodEnum<{
56
- MODE_UNSPECIFIED: "MODE_UNSPECIFIED";
57
- MODE_DYNAMIC: "MODE_DYNAMIC";
58
- }>>;
59
- dynamicThreshold: z.ZodOptional<z.ZodNumber>;
60
- }, z.core.$strip>>;
61
54
  }, z.core.$strip>;
62
55
  type GoogleGenerativeAIProviderOptions = z.infer<typeof googleGenerativeAIProviderOptions>;
63
56
 
@@ -93,6 +86,14 @@ declare const groundingMetadataSchema: z.ZodObject<{
93
86
  webDynamicRetrievalScore: z.ZodNumber;
94
87
  }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>]>>>;
95
88
  }, z.core.$strip>;
89
+
90
+ declare const urlContextMetadataSchema: z.ZodObject<{
91
+ urlMetadata: z.ZodArray<z.ZodObject<{
92
+ retrievedUrl: z.ZodString;
93
+ urlRetrievalStatus: z.ZodString;
94
+ }, z.core.$strip>>;
95
+ }, z.core.$strip>;
96
+
96
97
  declare const safetyRatingSchema: z.ZodObject<{
97
98
  category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
98
99
  probability: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -103,19 +104,65 @@ declare const safetyRatingSchema: z.ZodObject<{
103
104
  }, z.core.$strip>;
104
105
 
105
106
  type GoogleGenerativeAIGroundingMetadata = z.infer<typeof groundingMetadataSchema>;
107
+ type GoogleGenerativeAIUrlContextMetadata = z.infer<typeof urlContextMetadataSchema>;
106
108
  type GoogleGenerativeAISafetyRating = z.infer<typeof safetyRatingSchema>;
107
109
  interface GoogleGenerativeAIProviderMetadata {
108
110
  groundingMetadata: GoogleGenerativeAIGroundingMetadata | null;
111
+ urlContextMetadata: GoogleGenerativeAIUrlContextMetadata | null;
109
112
  safetyRatings: GoogleGenerativeAISafetyRating[] | null;
110
113
  }
111
114
 
115
+ type GoogleGenerativeAIImageModelId = 'imagen-3.0-generate-002' | (string & {});
116
+ interface GoogleGenerativeAIImageSettings {
117
+ /**
118
+ Override the maximum number of images per call (default 4)
119
+ */
120
+ maxImagesPerCall?: number;
121
+ }
122
+
123
+ declare const googleImageProviderOptionsSchema: z.ZodObject<{
124
+ personGeneration: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
125
+ dont_allow: "dont_allow";
126
+ allow_adult: "allow_adult";
127
+ allow_all: "allow_all";
128
+ }>>>;
129
+ aspectRatio: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
130
+ "1:1": "1:1";
131
+ "3:4": "3:4";
132
+ "4:3": "4:3";
133
+ "9:16": "9:16";
134
+ "16:9": "16:9";
135
+ }>>>;
136
+ }, z.core.$strip>;
137
+ type GoogleGenerativeAIImageProviderOptions = z.infer<typeof googleImageProviderOptionsSchema>;
138
+
112
139
  type GoogleGenerativeAIEmbeddingModelId = 'text-embedding-004' | (string & {});
113
140
 
141
+ declare const googleTools: {
142
+ /**
143
+ * Creates a Google search tool that gives Google direct access to real-time web content.
144
+ * Must have name "google_search".
145
+ */
146
+ googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
147
+ mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
148
+ dynamicThreshold?: number;
149
+ }>;
150
+ /**
151
+ * Creates a URL context tool that gives Google direct access to real-time web content.
152
+ * Must have name "url_context".
153
+ */
154
+ urlContext: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
155
+ };
156
+
114
157
  interface GoogleGenerativeAIProvider extends ProviderV2 {
115
158
  (modelId: GoogleGenerativeAIModelId): LanguageModelV2;
116
159
  languageModel(modelId: GoogleGenerativeAIModelId): LanguageModelV2;
117
160
  chat(modelId: GoogleGenerativeAIModelId): LanguageModelV2;
118
161
  /**
162
+ Creates a model for image generation.
163
+ */
164
+ image(modelId: GoogleGenerativeAIImageModelId, settings?: GoogleGenerativeAIImageSettings): ImageModelV2;
165
+ /**
119
166
  * @deprecated Use `chat()` instead.
120
167
  */
121
168
  generativeAI(modelId: GoogleGenerativeAIModelId): LanguageModelV2;
@@ -128,6 +175,7 @@ interface GoogleGenerativeAIProvider extends ProviderV2 {
128
175
  */
129
176
  textEmbedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV2<string>;
130
177
  textEmbeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV2<string>;
178
+ tools: typeof googleTools;
131
179
  }
132
180
  interface GoogleGenerativeAIProviderSettings {
133
181
  /**
@@ -163,4 +211,4 @@ Default Google Generative AI provider instance.
163
211
  */
164
212
  declare const google: GoogleGenerativeAIProvider;
165
213
 
166
- export { type GoogleErrorData, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, createGoogleGenerativeAI, google };
214
+ export { type GoogleErrorData, type GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, createGoogleGenerativeAI, google };