@ai-sdk/google 4.0.0-beta.3 → 4.0.0-beta.30
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 +201 -4
- package/README.md +2 -0
- package/dist/index.d.mts +73 -23
- package/dist/index.d.ts +73 -23
- package/dist/index.js +756 -136
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +767 -130
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +42 -15
- package/dist/internal/index.d.ts +42 -15
- package/dist/internal/index.js +499 -74
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +504 -72
- package/dist/internal/index.mjs.map +1 -1
- package/docs/15-google-generative-ai.mdx +36 -3
- package/package.json +3 -5
- package/src/convert-google-generative-ai-usage.ts +9 -2
- package/src/convert-to-google-generative-ai-messages.ts +330 -50
- package/src/google-generative-ai-embedding-model.ts +42 -13
- package/src/google-generative-ai-embedding-options.ts +24 -0
- package/src/google-generative-ai-files.ts +230 -0
- package/src/google-generative-ai-image-model.ts +14 -14
- package/src/google-generative-ai-language-model.ts +317 -44
- package/src/google-generative-ai-options.ts +5 -1
- package/src/google-generative-ai-prompt.ts +48 -4
- package/src/google-generative-ai-video-model.ts +7 -7
- package/src/google-prepare-tools.ts +64 -9
- package/src/google-provider.ts +31 -18
- package/src/index.ts +1 -0
- package/src/map-google-generative-ai-finish-reason.ts +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
2
2
|
import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
-
import {
|
|
3
|
+
import { ProviderV4, LanguageModelV4, ImageModelV4, EmbeddingModelV4, Experimental_VideoModelV4, FilesV4 } from '@ai-sdk/provider';
|
|
4
4
|
|
|
5
5
|
declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
6
6
|
error: {
|
|
@@ -11,7 +11,7 @@ declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
11
11
|
}>;
|
|
12
12
|
type GoogleErrorData = InferSchema<typeof googleErrorDataSchema>;
|
|
13
13
|
|
|
14
|
-
type GoogleGenerativeAIModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-
|
|
14
|
+
type GoogleGenerativeAIModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
15
15
|
declare const googleLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
16
16
|
responseModalities?: ("TEXT" | "IMAGE")[] | undefined;
|
|
17
17
|
thinkingConfig?: {
|
|
@@ -39,6 +39,7 @@ declare const googleLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
39
39
|
longitude: number;
|
|
40
40
|
} | undefined;
|
|
41
41
|
} | undefined;
|
|
42
|
+
serviceTier?: "standard" | "flex" | "priority" | undefined;
|
|
42
43
|
}>;
|
|
43
44
|
type GoogleLanguageModelOptions = InferSchema<typeof googleLanguageModelOptions>;
|
|
44
45
|
|
|
@@ -56,6 +57,21 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
56
57
|
mimeType: string;
|
|
57
58
|
data: string;
|
|
58
59
|
};
|
|
60
|
+
thought?: boolean | null | undefined;
|
|
61
|
+
thoughtSignature?: string | null | undefined;
|
|
62
|
+
} | {
|
|
63
|
+
toolCall: {
|
|
64
|
+
toolType: string;
|
|
65
|
+
id: string;
|
|
66
|
+
args?: unknown;
|
|
67
|
+
};
|
|
68
|
+
thoughtSignature?: string | null | undefined;
|
|
69
|
+
} | {
|
|
70
|
+
toolResponse: {
|
|
71
|
+
toolType: string;
|
|
72
|
+
id: string;
|
|
73
|
+
response?: unknown;
|
|
74
|
+
};
|
|
59
75
|
thoughtSignature?: string | null | undefined;
|
|
60
76
|
} | {
|
|
61
77
|
executableCode?: {
|
|
@@ -72,6 +88,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
72
88
|
})[] | null | undefined;
|
|
73
89
|
} | null | undefined;
|
|
74
90
|
finishReason?: string | null | undefined;
|
|
91
|
+
finishMessage?: string | null | undefined;
|
|
75
92
|
safetyRatings?: {
|
|
76
93
|
category?: string | null | undefined;
|
|
77
94
|
probability?: string | null | undefined;
|
|
@@ -141,6 +158,14 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
141
158
|
candidatesTokenCount?: number | null | undefined;
|
|
142
159
|
totalTokenCount?: number | null | undefined;
|
|
143
160
|
trafficType?: string | null | undefined;
|
|
161
|
+
promptTokensDetails?: {
|
|
162
|
+
modality: string;
|
|
163
|
+
tokenCount: number;
|
|
164
|
+
}[] | null | undefined;
|
|
165
|
+
candidatesTokensDetails?: {
|
|
166
|
+
modality: string;
|
|
167
|
+
tokenCount: number;
|
|
168
|
+
}[] | null | undefined;
|
|
144
169
|
} | null | undefined;
|
|
145
170
|
promptFeedback?: {
|
|
146
171
|
blockReason?: string | null | undefined;
|
|
@@ -153,18 +178,27 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
153
178
|
blocked?: boolean | null | undefined;
|
|
154
179
|
}[] | null | undefined;
|
|
155
180
|
} | null | undefined;
|
|
181
|
+
serviceTier?: string | null | undefined;
|
|
156
182
|
}>;
|
|
157
183
|
type GroundingMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['groundingMetadata']>;
|
|
158
184
|
type UrlContextMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['urlContextMetadata']>;
|
|
159
185
|
type SafetyRatingSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['safetyRatings']>[number];
|
|
186
|
+
type PromptFeedbackSchema = NonNullable<InferSchema<typeof responseSchema>['promptFeedback']>;
|
|
187
|
+
type UsageMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['usageMetadata']>;
|
|
160
188
|
|
|
161
189
|
type GoogleGenerativeAIGroundingMetadata = GroundingMetadataSchema;
|
|
162
190
|
type GoogleGenerativeAIUrlContextMetadata = UrlContextMetadataSchema;
|
|
163
191
|
type GoogleGenerativeAISafetyRating = SafetyRatingSchema;
|
|
192
|
+
type GoogleGenerativeAIPromptFeedback = PromptFeedbackSchema;
|
|
193
|
+
type GoogleGenerativeAIUsageMetadata = UsageMetadataSchema;
|
|
164
194
|
interface GoogleGenerativeAIProviderMetadata {
|
|
195
|
+
promptFeedback: GoogleGenerativeAIPromptFeedback | null;
|
|
165
196
|
groundingMetadata: GoogleGenerativeAIGroundingMetadata | null;
|
|
166
197
|
urlContextMetadata: GoogleGenerativeAIUrlContextMetadata | null;
|
|
167
198
|
safetyRatings: GoogleGenerativeAISafetyRating[] | null;
|
|
199
|
+
usageMetadata: GoogleGenerativeAIUsageMetadata | null;
|
|
200
|
+
finishMessage: string | null;
|
|
201
|
+
serviceTier: string | null;
|
|
168
202
|
}
|
|
169
203
|
|
|
170
204
|
type GoogleGenerativeAIImageModelId = 'imagen-4.0-generate-001' | 'imagen-4.0-ultra-generate-001' | 'imagen-4.0-fast-generate-001' | 'gemini-2.5-flash-image' | 'gemini-3-pro-image-preview' | 'gemini-3.1-flash-image-preview' | (string & {});
|
|
@@ -181,10 +215,18 @@ declare const googleImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
181
215
|
}>;
|
|
182
216
|
type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>;
|
|
183
217
|
|
|
184
|
-
type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | (string & {});
|
|
218
|
+
type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | 'gemini-embedding-2-preview' | (string & {});
|
|
185
219
|
declare const googleEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
186
220
|
outputDimensionality?: number | undefined;
|
|
187
221
|
taskType?: "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "RETRIEVAL_DOCUMENT" | "RETRIEVAL_QUERY" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY" | undefined;
|
|
222
|
+
content?: (({
|
|
223
|
+
text: string;
|
|
224
|
+
} | {
|
|
225
|
+
inlineData: {
|
|
226
|
+
mimeType: string;
|
|
227
|
+
data: string;
|
|
228
|
+
};
|
|
229
|
+
})[] | null)[] | undefined;
|
|
188
230
|
}>;
|
|
189
231
|
type GoogleEmbeddingModelOptions = InferSchema<typeof googleEmbeddingModelOptions>;
|
|
190
232
|
|
|
@@ -202,6 +244,13 @@ type GoogleVideoModelOptions = {
|
|
|
202
244
|
[key: string]: unknown;
|
|
203
245
|
};
|
|
204
246
|
|
|
247
|
+
type GoogleFilesUploadOptions = {
|
|
248
|
+
displayName?: string | null;
|
|
249
|
+
pollIntervalMs?: number | null;
|
|
250
|
+
pollTimeoutMs?: number | null;
|
|
251
|
+
[key: string]: unknown;
|
|
252
|
+
};
|
|
253
|
+
|
|
205
254
|
declare const googleTools: {
|
|
206
255
|
/**
|
|
207
256
|
* Creates a Google search tool that gives Google direct access to real-time web content.
|
|
@@ -217,7 +266,7 @@ declare const googleTools: {
|
|
|
217
266
|
startTime: string;
|
|
218
267
|
endTime: string;
|
|
219
268
|
} | undefined;
|
|
220
|
-
}>;
|
|
269
|
+
}, {}>;
|
|
221
270
|
/**
|
|
222
271
|
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
|
223
272
|
* Designed for highly-regulated industries (finance, healthcare, public sector).
|
|
@@ -228,7 +277,7 @@ declare const googleTools: {
|
|
|
228
277
|
*
|
|
229
278
|
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
|
|
230
279
|
*/
|
|
231
|
-
enterpriseWebSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
|
|
280
|
+
enterpriseWebSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}, {}>;
|
|
232
281
|
/**
|
|
233
282
|
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
234
283
|
* Must have name "google_maps".
|
|
@@ -236,12 +285,12 @@ declare const googleTools: {
|
|
|
236
285
|
* @see https://ai.google.dev/gemini-api/docs/maps-grounding
|
|
237
286
|
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
238
287
|
*/
|
|
239
|
-
googleMaps: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
|
|
288
|
+
googleMaps: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}, {}>;
|
|
240
289
|
/**
|
|
241
290
|
* Creates a URL context tool that gives Google direct access to real-time web content.
|
|
242
291
|
* Must have name "url_context".
|
|
243
292
|
*/
|
|
244
|
-
urlContext: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
|
|
293
|
+
urlContext: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}, {}>;
|
|
245
294
|
/**
|
|
246
295
|
* Enables Retrieval Augmented Generation (RAG) via the Gemini File Search tool.
|
|
247
296
|
* Must have name "file_search".
|
|
@@ -257,7 +306,7 @@ declare const googleTools: {
|
|
|
257
306
|
fileSearchStoreNames: string[];
|
|
258
307
|
topK?: number | undefined;
|
|
259
308
|
metadataFilter?: string | undefined;
|
|
260
|
-
}>;
|
|
309
|
+
}, {}>;
|
|
261
310
|
/**
|
|
262
311
|
* A tool that enables the model to generate and run Python code.
|
|
263
312
|
* Must have name "code_execution".
|
|
@@ -274,7 +323,7 @@ declare const googleTools: {
|
|
|
274
323
|
}, {
|
|
275
324
|
outcome: string;
|
|
276
325
|
output: string;
|
|
277
|
-
}, {}>;
|
|
326
|
+
}, {}, {}>;
|
|
278
327
|
/**
|
|
279
328
|
* Creates a Vertex RAG Store tool that enables the model to perform RAG searches against a Vertex RAG Store.
|
|
280
329
|
* Must have name "vertex_rag_store".
|
|
@@ -282,45 +331,46 @@ declare const googleTools: {
|
|
|
282
331
|
vertexRagStore: _ai_sdk_provider_utils.ProviderToolFactory<{}, {
|
|
283
332
|
ragCorpus: string;
|
|
284
333
|
topK?: number;
|
|
285
|
-
}>;
|
|
334
|
+
}, {}>;
|
|
286
335
|
};
|
|
287
336
|
|
|
288
|
-
interface GoogleGenerativeAIProvider extends
|
|
289
|
-
(modelId: GoogleGenerativeAIModelId):
|
|
290
|
-
languageModel(modelId: GoogleGenerativeAIModelId):
|
|
291
|
-
chat(modelId: GoogleGenerativeAIModelId):
|
|
337
|
+
interface GoogleGenerativeAIProvider extends ProviderV4 {
|
|
338
|
+
(modelId: GoogleGenerativeAIModelId): LanguageModelV4;
|
|
339
|
+
languageModel(modelId: GoogleGenerativeAIModelId): LanguageModelV4;
|
|
340
|
+
chat(modelId: GoogleGenerativeAIModelId): LanguageModelV4;
|
|
292
341
|
/**
|
|
293
342
|
* Creates a model for image generation.
|
|
294
343
|
*/
|
|
295
|
-
image(modelId: GoogleGenerativeAIImageModelId, settings?: GoogleGenerativeAIImageSettings):
|
|
344
|
+
image(modelId: GoogleGenerativeAIImageModelId, settings?: GoogleGenerativeAIImageSettings): ImageModelV4;
|
|
296
345
|
/**
|
|
297
346
|
* @deprecated Use `chat()` instead.
|
|
298
347
|
*/
|
|
299
|
-
generativeAI(modelId: GoogleGenerativeAIModelId):
|
|
348
|
+
generativeAI(modelId: GoogleGenerativeAIModelId): LanguageModelV4;
|
|
300
349
|
/**
|
|
301
350
|
* Creates a model for text embeddings.
|
|
302
351
|
*/
|
|
303
|
-
embedding(modelId: GoogleGenerativeAIEmbeddingModelId):
|
|
352
|
+
embedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV4;
|
|
304
353
|
/**
|
|
305
354
|
* Creates a model for text embeddings.
|
|
306
355
|
*/
|
|
307
|
-
embeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId):
|
|
356
|
+
embeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV4;
|
|
308
357
|
/**
|
|
309
358
|
* @deprecated Use `embedding` instead.
|
|
310
359
|
*/
|
|
311
|
-
textEmbedding(modelId: GoogleGenerativeAIEmbeddingModelId):
|
|
360
|
+
textEmbedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV4;
|
|
312
361
|
/**
|
|
313
362
|
* @deprecated Use `embeddingModel` instead.
|
|
314
363
|
*/
|
|
315
|
-
textEmbeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId):
|
|
364
|
+
textEmbeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV4;
|
|
316
365
|
/**
|
|
317
366
|
* Creates a model for video generation.
|
|
318
367
|
*/
|
|
319
|
-
video(modelId: GoogleGenerativeAIVideoModelId):
|
|
368
|
+
video(modelId: GoogleGenerativeAIVideoModelId): Experimental_VideoModelV4;
|
|
320
369
|
/**
|
|
321
370
|
* Creates a model for video generation.
|
|
322
371
|
*/
|
|
323
|
-
videoModel(modelId: GoogleGenerativeAIVideoModelId):
|
|
372
|
+
videoModel(modelId: GoogleGenerativeAIVideoModelId): Experimental_VideoModelV4;
|
|
373
|
+
files(): FilesV4;
|
|
324
374
|
tools: typeof googleTools;
|
|
325
375
|
}
|
|
326
376
|
interface GoogleGenerativeAIProviderSettings {
|
|
@@ -364,4 +414,4 @@ declare const google: GoogleGenerativeAIProvider;
|
|
|
364
414
|
|
|
365
415
|
declare const VERSION: string;
|
|
366
416
|
|
|
367
|
-
export { type GoogleEmbeddingModelOptions, type GoogleErrorData, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, type GoogleGenerativeAIVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleImageModelOptions, type GoogleLanguageModelOptions, type GoogleVideoModelOptions, VERSION, createGoogleGenerativeAI, google };
|
|
417
|
+
export { type GoogleEmbeddingModelOptions, type GoogleErrorData, type GoogleFilesUploadOptions, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, type GoogleGenerativeAIVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleImageModelOptions, type GoogleLanguageModelOptions, type GoogleVideoModelOptions, VERSION, createGoogleGenerativeAI, google };
|