@ai-sdk/google 4.0.0-beta.44 → 4.0.0-beta.45
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 +11 -0
- package/README.md +4 -4
- package/dist/index.d.ts +33 -33
- package/dist/index.js +46 -55
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +9 -9
- package/dist/internal/index.js +22 -25
- package/dist/internal/index.js.map +1 -1
- package/docs/{15-google-generative-ai.mdx → 15-google.mdx} +36 -36
- package/package.json +4 -4
- package/src/{convert-google-generative-ai-usage.ts → convert-google-usage.ts} +6 -6
- package/src/{convert-to-google-generative-ai-messages.ts → convert-to-google-messages.ts} +14 -14
- package/src/{google-generative-ai-embedding-model.ts → google-embedding-model.ts} +10 -16
- package/src/{google-generative-ai-embedding-options.ts → google-embedding-options.ts} +1 -1
- package/src/{google-generative-ai-files.ts → google-files.ts} +3 -3
- package/src/{google-generative-ai-image-model.ts → google-image-model.ts} +16 -20
- package/src/{google-generative-ai-image-settings.ts → google-image-settings.ts} +2 -2
- package/src/{google-generative-ai-language-model.ts → google-language-model.ts} +28 -34
- package/src/{google-generative-ai-options.ts → google-options.ts} +2 -2
- package/src/google-prepare-tools.ts +3 -3
- package/src/google-prompt.ts +82 -0
- package/src/google-provider.ts +42 -46
- package/src/{google-generative-ai-video-model.ts → google-video-model.ts} +5 -5
- package/src/{google-generative-ai-video-settings.ts → google-video-settings.ts} +1 -1
- package/src/index.ts +28 -10
- package/src/internal/index.ts +2 -2
- package/src/{map-google-generative-ai-finish-reason.ts → map-google-finish-reason.ts} +1 -1
- package/src/google-generative-ai-prompt.ts +0 -82
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.45
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- a3757d7: chore(provider/google): remove useless GenerativeAI affix from types and classes for consistency
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [2e98477]
|
|
12
|
+
- @ai-sdk/provider-utils@5.0.0-beta.26
|
|
13
|
+
|
|
3
14
|
## 4.0.0-beta.44
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# AI SDK - Google
|
|
1
|
+
# AI SDK - Google Provider
|
|
2
2
|
|
|
3
|
-
The **[Google
|
|
3
|
+
The **[Google provider](https://ai-sdk.dev/providers/ai-sdk-providers/google)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the [Google Generative AI](https://ai.google/discover/generativeai/) APIs.
|
|
4
4
|
|
|
5
5
|
> **Deploying to Vercel?** With Vercel's AI Gateway you can access Google (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
|
|
6
6
|
|
|
7
7
|
## Setup
|
|
8
8
|
|
|
9
|
-
The Google
|
|
9
|
+
The Google provider is available in the `@ai-sdk/google` module. You can install it with
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
npm i @ai-sdk/google
|
|
@@ -42,4 +42,4 @@ const { text } = await generateText({
|
|
|
42
42
|
|
|
43
43
|
## Documentation
|
|
44
44
|
|
|
45
|
-
Please check out the **[Google
|
|
45
|
+
Please check out the **[Google provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/google)** for more information.
|
package/dist/index.d.ts
CHANGED
|
@@ -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
|
|
14
|
+
type GoogleModelId = '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-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-3.1-flash-tts-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?: {
|
|
@@ -196,23 +196,23 @@ type SafetyRatingSchema = NonNullable<InferSchema<typeof responseSchema>['candid
|
|
|
196
196
|
type PromptFeedbackSchema = NonNullable<InferSchema<typeof responseSchema>['promptFeedback']>;
|
|
197
197
|
type UsageMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['usageMetadata']>;
|
|
198
198
|
|
|
199
|
-
type
|
|
200
|
-
type
|
|
201
|
-
type
|
|
202
|
-
type
|
|
203
|
-
type
|
|
204
|
-
interface
|
|
205
|
-
promptFeedback:
|
|
206
|
-
groundingMetadata:
|
|
207
|
-
urlContextMetadata:
|
|
208
|
-
safetyRatings:
|
|
209
|
-
usageMetadata:
|
|
199
|
+
type GoogleGroundingMetadata = GroundingMetadataSchema;
|
|
200
|
+
type GoogleUrlContextMetadata = UrlContextMetadataSchema;
|
|
201
|
+
type GoogleSafetyRating = SafetyRatingSchema;
|
|
202
|
+
type GooglePromptFeedback = PromptFeedbackSchema;
|
|
203
|
+
type GoogleUsageMetadata = UsageMetadataSchema;
|
|
204
|
+
interface GoogleProviderMetadata {
|
|
205
|
+
promptFeedback: GooglePromptFeedback | null;
|
|
206
|
+
groundingMetadata: GoogleGroundingMetadata | null;
|
|
207
|
+
urlContextMetadata: GoogleUrlContextMetadata | null;
|
|
208
|
+
safetyRatings: GoogleSafetyRating[] | null;
|
|
209
|
+
usageMetadata: GoogleUsageMetadata | null;
|
|
210
210
|
finishMessage: string | null;
|
|
211
211
|
serviceTier: string | null;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
type
|
|
215
|
-
interface
|
|
214
|
+
type GoogleImageModelId = '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 & {});
|
|
215
|
+
interface GoogleImageSettings {
|
|
216
216
|
/**
|
|
217
217
|
* Override the maximum number of images per call (default 4)
|
|
218
218
|
*/
|
|
@@ -225,7 +225,7 @@ declare const googleImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
225
225
|
}>;
|
|
226
226
|
type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>;
|
|
227
227
|
|
|
228
|
-
type
|
|
228
|
+
type GoogleEmbeddingModelId = 'gemini-embedding-001' | 'gemini-embedding-2-preview' | (string & {});
|
|
229
229
|
declare const googleEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
230
230
|
outputDimensionality?: number | undefined;
|
|
231
231
|
taskType?: "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "RETRIEVAL_DOCUMENT" | "RETRIEVAL_QUERY" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY" | undefined;
|
|
@@ -240,7 +240,7 @@ declare const googleEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
240
240
|
}>;
|
|
241
241
|
type GoogleEmbeddingModelOptions = InferSchema<typeof googleEmbeddingModelOptions>;
|
|
242
242
|
|
|
243
|
-
type
|
|
243
|
+
type GoogleVideoModelId = 'veo-3.1-fast-generate-preview' | 'veo-3.1-generate-preview' | 'veo-3.1-generate' | 'veo-3.1-lite-generate-preview' | 'veo-3.0-generate-001' | 'veo-3.0-fast-generate-001' | 'veo-2.0-generate-001' | (string & {});
|
|
244
244
|
|
|
245
245
|
type GoogleVideoModelOptions = {
|
|
246
246
|
pollIntervalMs?: number | null;
|
|
@@ -344,46 +344,46 @@ declare const googleTools: {
|
|
|
344
344
|
}, {}>;
|
|
345
345
|
};
|
|
346
346
|
|
|
347
|
-
interface
|
|
348
|
-
(modelId:
|
|
349
|
-
languageModel(modelId:
|
|
350
|
-
chat(modelId:
|
|
347
|
+
interface GoogleProvider extends ProviderV4 {
|
|
348
|
+
(modelId: GoogleModelId): LanguageModelV4;
|
|
349
|
+
languageModel(modelId: GoogleModelId): LanguageModelV4;
|
|
350
|
+
chat(modelId: GoogleModelId): LanguageModelV4;
|
|
351
351
|
/**
|
|
352
352
|
* Creates a model for image generation.
|
|
353
353
|
*/
|
|
354
|
-
image(modelId:
|
|
354
|
+
image(modelId: GoogleImageModelId, settings?: GoogleImageSettings): ImageModelV4;
|
|
355
355
|
/**
|
|
356
356
|
* @deprecated Use `chat()` instead.
|
|
357
357
|
*/
|
|
358
|
-
generativeAI(modelId:
|
|
358
|
+
generativeAI(modelId: GoogleModelId): LanguageModelV4;
|
|
359
359
|
/**
|
|
360
360
|
* Creates a model for text embeddings.
|
|
361
361
|
*/
|
|
362
|
-
embedding(modelId:
|
|
362
|
+
embedding(modelId: GoogleEmbeddingModelId): EmbeddingModelV4;
|
|
363
363
|
/**
|
|
364
364
|
* Creates a model for text embeddings.
|
|
365
365
|
*/
|
|
366
|
-
embeddingModel(modelId:
|
|
366
|
+
embeddingModel(modelId: GoogleEmbeddingModelId): EmbeddingModelV4;
|
|
367
367
|
/**
|
|
368
368
|
* @deprecated Use `embedding` instead.
|
|
369
369
|
*/
|
|
370
|
-
textEmbedding(modelId:
|
|
370
|
+
textEmbedding(modelId: GoogleEmbeddingModelId): EmbeddingModelV4;
|
|
371
371
|
/**
|
|
372
372
|
* @deprecated Use `embeddingModel` instead.
|
|
373
373
|
*/
|
|
374
|
-
textEmbeddingModel(modelId:
|
|
374
|
+
textEmbeddingModel(modelId: GoogleEmbeddingModelId): EmbeddingModelV4;
|
|
375
375
|
/**
|
|
376
376
|
* Creates a model for video generation.
|
|
377
377
|
*/
|
|
378
|
-
video(modelId:
|
|
378
|
+
video(modelId: GoogleVideoModelId): Experimental_VideoModelV4;
|
|
379
379
|
/**
|
|
380
380
|
* Creates a model for video generation.
|
|
381
381
|
*/
|
|
382
|
-
videoModel(modelId:
|
|
382
|
+
videoModel(modelId: GoogleVideoModelId): Experimental_VideoModelV4;
|
|
383
383
|
files(): FilesV4;
|
|
384
384
|
tools: typeof googleTools;
|
|
385
385
|
}
|
|
386
|
-
interface
|
|
386
|
+
interface GoogleProviderSettings {
|
|
387
387
|
/**
|
|
388
388
|
* Use a different URL prefix for API calls, e.g. to use proxy servers.
|
|
389
389
|
* The default prefix is `https://generativelanguage.googleapis.com/v1beta`.
|
|
@@ -414,14 +414,14 @@ interface GoogleGenerativeAIProviderSettings {
|
|
|
414
414
|
name?: string;
|
|
415
415
|
}
|
|
416
416
|
/**
|
|
417
|
-
* Create a Google
|
|
417
|
+
* Create a Google provider instance.
|
|
418
418
|
*/
|
|
419
|
-
declare function
|
|
419
|
+
declare function createGoogle(options?: GoogleProviderSettings): GoogleProvider;
|
|
420
420
|
/**
|
|
421
421
|
* Default Google Generative AI provider instance.
|
|
422
422
|
*/
|
|
423
|
-
declare const google:
|
|
423
|
+
declare const google: GoogleProvider;
|
|
424
424
|
|
|
425
425
|
declare const VERSION: string;
|
|
426
426
|
|
|
427
|
-
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 };
|
|
427
|
+
export { type GoogleEmbeddingModelOptions, type GoogleErrorData, type GoogleFilesUploadOptions, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleProvider as GoogleGenerativeAIProvider, type GoogleProviderMetadata as GoogleGenerativeAIProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleProviderSettings as GoogleGenerativeAIProviderSettings, type GoogleVideoModelId as GoogleGenerativeAIVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleImageModelOptions, type GoogleLanguageModelOptions, type GoogleProvider, type GoogleProviderMetadata, type GoogleProviderSettings, type GoogleVideoModelId, type GoogleVideoModelOptions, VERSION, createGoogle, createGoogle as createGoogleGenerativeAI, google };
|
package/dist/index.js
CHANGED
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.0-beta.
|
|
10
|
+
var VERSION = true ? "4.0.0-beta.45" : "0.0.0-test";
|
|
11
11
|
|
|
12
|
-
// src/google-
|
|
12
|
+
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
14
14
|
TooManyEmbeddingValuesForCallError
|
|
15
15
|
} from "@ai-sdk/provider";
|
|
@@ -50,7 +50,7 @@ var googleFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
50
50
|
errorToMessage: (data) => data.error.message
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
// src/google-
|
|
53
|
+
// src/google-embedding-options.ts
|
|
54
54
|
import {
|
|
55
55
|
lazySchema as lazySchema2,
|
|
56
56
|
zodSchema as zodSchema2
|
|
@@ -109,8 +109,8 @@ var googleEmbeddingModelOptions = lazySchema2(
|
|
|
109
109
|
)
|
|
110
110
|
);
|
|
111
111
|
|
|
112
|
-
// src/google-
|
|
113
|
-
var
|
|
112
|
+
// src/google-embedding-model.ts
|
|
113
|
+
var GoogleEmbeddingModel = class _GoogleEmbeddingModel {
|
|
114
114
|
constructor(modelId, config) {
|
|
115
115
|
this.specificationVersion = "v4";
|
|
116
116
|
this.maxEmbeddingsPerCall = 2048;
|
|
@@ -125,10 +125,7 @@ var GoogleGenerativeAIEmbeddingModel = class _GoogleGenerativeAIEmbeddingModel {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
static [WORKFLOW_DESERIALIZE](options) {
|
|
128
|
-
return new
|
|
129
|
-
options.modelId,
|
|
130
|
-
options.config
|
|
131
|
-
);
|
|
128
|
+
return new _GoogleEmbeddingModel(options.modelId, options.config);
|
|
132
129
|
}
|
|
133
130
|
get provider() {
|
|
134
131
|
return this.config.provider;
|
|
@@ -247,7 +244,7 @@ var googleGenerativeAISingleEmbeddingResponseSchema = lazySchema3(
|
|
|
247
244
|
)
|
|
248
245
|
);
|
|
249
246
|
|
|
250
|
-
// src/google-
|
|
247
|
+
// src/google-language-model.ts
|
|
251
248
|
import {
|
|
252
249
|
combineHeaders as combineHeaders2,
|
|
253
250
|
createEventSourceResponseHandler,
|
|
@@ -267,8 +264,8 @@ import {
|
|
|
267
264
|
} from "@ai-sdk/provider-utils";
|
|
268
265
|
import { z as z5 } from "zod/v4";
|
|
269
266
|
|
|
270
|
-
// src/convert-google-
|
|
271
|
-
function
|
|
267
|
+
// src/convert-google-usage.ts
|
|
268
|
+
function convertGoogleUsage(usage) {
|
|
272
269
|
var _a, _b, _c, _d;
|
|
273
270
|
if (usage == null) {
|
|
274
271
|
return {
|
|
@@ -422,7 +419,7 @@ function isEmptyObjectSchema(jsonSchema) {
|
|
|
422
419
|
return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
|
|
423
420
|
}
|
|
424
421
|
|
|
425
|
-
// src/convert-to-google-
|
|
422
|
+
// src/convert-to-google-messages.ts
|
|
426
423
|
import {
|
|
427
424
|
UnsupportedFunctionalityError
|
|
428
425
|
} from "@ai-sdk/provider";
|
|
@@ -537,7 +534,7 @@ function appendLegacyToolResultParts(parts, toolName, outputValue) {
|
|
|
537
534
|
}
|
|
538
535
|
}
|
|
539
536
|
}
|
|
540
|
-
function
|
|
537
|
+
function convertToGoogleMessages(prompt, options) {
|
|
541
538
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
542
539
|
const systemInstructionParts = [];
|
|
543
540
|
const contents = [];
|
|
@@ -784,7 +781,7 @@ function getModelPath(modelId) {
|
|
|
784
781
|
return modelId.includes("/") ? modelId : `models/${modelId}`;
|
|
785
782
|
}
|
|
786
783
|
|
|
787
|
-
// src/google-
|
|
784
|
+
// src/google-options.ts
|
|
788
785
|
import { lazySchema as lazySchema4, zodSchema as zodSchema4 } from "@ai-sdk/provider-utils";
|
|
789
786
|
import { z as z4 } from "zod/v4";
|
|
790
787
|
var googleLanguageModelOptions = lazySchema4(
|
|
@@ -808,7 +805,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
808
805
|
*
|
|
809
806
|
* This is useful when the JSON Schema contains elements that are
|
|
810
807
|
* not supported by the OpenAPI schema version that
|
|
811
|
-
* Google
|
|
808
|
+
* Google uses. You can use this to disable
|
|
812
809
|
* structured outputs if you need to.
|
|
813
810
|
*/
|
|
814
811
|
structuredOutputs: z4.boolean().optional(),
|
|
@@ -1401,8 +1398,8 @@ function resolvePartialArgValue(arg) {
|
|
|
1401
1398
|
return void 0;
|
|
1402
1399
|
}
|
|
1403
1400
|
|
|
1404
|
-
// src/map-google-
|
|
1405
|
-
function
|
|
1401
|
+
// src/map-google-finish-reason.ts
|
|
1402
|
+
function mapGoogleFinishReason({
|
|
1406
1403
|
finishReason,
|
|
1407
1404
|
hasToolCalls
|
|
1408
1405
|
}) {
|
|
@@ -1427,8 +1424,8 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
1427
1424
|
}
|
|
1428
1425
|
}
|
|
1429
1426
|
|
|
1430
|
-
// src/google-
|
|
1431
|
-
var
|
|
1427
|
+
// src/google-language-model.ts
|
|
1428
|
+
var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
1432
1429
|
constructor(modelId, config) {
|
|
1433
1430
|
this.specificationVersion = "v4";
|
|
1434
1431
|
var _a;
|
|
@@ -1443,7 +1440,7 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
1443
1440
|
});
|
|
1444
1441
|
}
|
|
1445
1442
|
static [WORKFLOW_DESERIALIZE2](options) {
|
|
1446
|
-
return new
|
|
1443
|
+
return new _GoogleLanguageModel(options.modelId, options.config);
|
|
1447
1444
|
}
|
|
1448
1445
|
get provider() {
|
|
1449
1446
|
return this.config.provider;
|
|
@@ -1504,14 +1501,11 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
1504
1501
|
}
|
|
1505
1502
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1506
1503
|
const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
|
|
1507
|
-
const { contents, systemInstruction } =
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
supportsFunctionResponseParts
|
|
1513
|
-
}
|
|
1514
|
-
);
|
|
1504
|
+
const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
|
|
1505
|
+
isGemmaModel,
|
|
1506
|
+
providerOptionsName,
|
|
1507
|
+
supportsFunctionResponseParts
|
|
1508
|
+
});
|
|
1515
1509
|
const {
|
|
1516
1510
|
tools: googleTools2,
|
|
1517
1511
|
toolConfig: googleToolConfig,
|
|
@@ -1734,7 +1728,7 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
1734
1728
|
return {
|
|
1735
1729
|
content,
|
|
1736
1730
|
finishReason: {
|
|
1737
|
-
unified:
|
|
1731
|
+
unified: mapGoogleFinishReason({
|
|
1738
1732
|
finishReason: candidate.finishReason,
|
|
1739
1733
|
// Only count client-executed tool calls for finish reason determination.
|
|
1740
1734
|
hasToolCalls: content.some(
|
|
@@ -1743,7 +1737,7 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
1743
1737
|
}),
|
|
1744
1738
|
raw: (_j = candidate.finishReason) != null ? _j : void 0
|
|
1745
1739
|
},
|
|
1746
|
-
usage:
|
|
1740
|
+
usage: convertGoogleUsage(usageMetadata),
|
|
1747
1741
|
warnings,
|
|
1748
1742
|
providerMetadata: {
|
|
1749
1743
|
[providerOptionsName]: {
|
|
@@ -2112,7 +2106,7 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
2112
2106
|
}
|
|
2113
2107
|
if (candidate.finishReason != null) {
|
|
2114
2108
|
finishReason = {
|
|
2115
|
-
unified:
|
|
2109
|
+
unified: mapGoogleFinishReason({
|
|
2116
2110
|
finishReason: candidate.finishReason,
|
|
2117
2111
|
hasToolCalls
|
|
2118
2112
|
}),
|
|
@@ -2147,7 +2141,7 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
2147
2141
|
controller.enqueue({
|
|
2148
2142
|
type: "finish",
|
|
2149
2143
|
finishReason,
|
|
2150
|
-
usage:
|
|
2144
|
+
usage: convertGoogleUsage(usage),
|
|
2151
2145
|
providerMetadata
|
|
2152
2146
|
});
|
|
2153
2147
|
}
|
|
@@ -2690,7 +2684,7 @@ var googleTools = {
|
|
|
2690
2684
|
vertexRagStore
|
|
2691
2685
|
};
|
|
2692
2686
|
|
|
2693
|
-
// src/google-
|
|
2687
|
+
// src/google-image-model.ts
|
|
2694
2688
|
import {
|
|
2695
2689
|
combineHeaders as combineHeaders3,
|
|
2696
2690
|
convertToBase64 as convertToBase642,
|
|
@@ -2706,7 +2700,7 @@ import {
|
|
|
2706
2700
|
zodSchema as zodSchema11
|
|
2707
2701
|
} from "@ai-sdk/provider-utils";
|
|
2708
2702
|
import { z as z13 } from "zod/v4";
|
|
2709
|
-
var
|
|
2703
|
+
var GoogleImageModel = class _GoogleImageModel {
|
|
2710
2704
|
constructor(modelId, settings, config) {
|
|
2711
2705
|
this.modelId = modelId;
|
|
2712
2706
|
this.settings = settings;
|
|
@@ -2720,11 +2714,7 @@ var GoogleGenerativeAIImageModel = class _GoogleGenerativeAIImageModel {
|
|
|
2720
2714
|
});
|
|
2721
2715
|
}
|
|
2722
2716
|
static [WORKFLOW_DESERIALIZE3](options) {
|
|
2723
|
-
return new
|
|
2724
|
-
options.modelId,
|
|
2725
|
-
{},
|
|
2726
|
-
options.config
|
|
2727
|
-
);
|
|
2717
|
+
return new _GoogleImageModel(options.modelId, {}, options.config);
|
|
2728
2718
|
}
|
|
2729
2719
|
get maxImagesPerCall() {
|
|
2730
2720
|
if (this.settings.maxImagesPerCall != null) {
|
|
@@ -2761,12 +2751,12 @@ var GoogleGenerativeAIImageModel = class _GoogleGenerativeAIImageModel {
|
|
|
2761
2751
|
const warnings = [];
|
|
2762
2752
|
if (files != null && files.length > 0) {
|
|
2763
2753
|
throw new Error(
|
|
2764
|
-
"Google
|
|
2754
|
+
"Google Gemini API does not support image editing with Imagen models. Use Google Vertex AI (@ai-sdk/google-vertex) for image editing capabilities."
|
|
2765
2755
|
);
|
|
2766
2756
|
}
|
|
2767
2757
|
if (mask != null) {
|
|
2768
2758
|
throw new Error(
|
|
2769
|
-
"Google
|
|
2759
|
+
"Google Gemini API does not support image editing with masks. Use Google Vertex AI (@ai-sdk/google-vertex) for image editing capabilities."
|
|
2770
2760
|
);
|
|
2771
2761
|
}
|
|
2772
2762
|
if (size != null) {
|
|
@@ -2891,7 +2881,7 @@ var GoogleGenerativeAIImageModel = class _GoogleGenerativeAIImageModel {
|
|
|
2891
2881
|
const languageModelPrompt = [
|
|
2892
2882
|
{ role: "user", content: userContent }
|
|
2893
2883
|
];
|
|
2894
|
-
const languageModel = new
|
|
2884
|
+
const languageModel = new GoogleLanguageModel(this.modelId, {
|
|
2895
2885
|
provider: this.config.provider,
|
|
2896
2886
|
baseURL: this.config.baseURL,
|
|
2897
2887
|
headers: (_a = this.config.headers) != null ? _a : {},
|
|
@@ -2960,7 +2950,7 @@ var googleImageModelOptionsSchema = lazySchema11(
|
|
|
2960
2950
|
)
|
|
2961
2951
|
);
|
|
2962
2952
|
|
|
2963
|
-
// src/google-
|
|
2953
|
+
// src/google-files.ts
|
|
2964
2954
|
import {
|
|
2965
2955
|
AISDKError
|
|
2966
2956
|
} from "@ai-sdk/provider";
|
|
@@ -2974,7 +2964,7 @@ import {
|
|
|
2974
2964
|
getFromApi
|
|
2975
2965
|
} from "@ai-sdk/provider-utils";
|
|
2976
2966
|
import { z as z14 } from "zod/v4";
|
|
2977
|
-
var
|
|
2967
|
+
var GoogleFiles = class {
|
|
2978
2968
|
constructor(config) {
|
|
2979
2969
|
this.config = config;
|
|
2980
2970
|
this.specificationVersion = "v4";
|
|
@@ -3123,7 +3113,7 @@ var googleFilesUploadOptionsSchema = lazySchema12(
|
|
|
3123
3113
|
)
|
|
3124
3114
|
);
|
|
3125
3115
|
|
|
3126
|
-
// src/google-
|
|
3116
|
+
// src/google-video-model.ts
|
|
3127
3117
|
import {
|
|
3128
3118
|
AISDKError as AISDKError2
|
|
3129
3119
|
} from "@ai-sdk/provider";
|
|
@@ -3140,7 +3130,7 @@ import {
|
|
|
3140
3130
|
zodSchema as zodSchema13
|
|
3141
3131
|
} from "@ai-sdk/provider-utils";
|
|
3142
3132
|
import { z as z15 } from "zod/v4";
|
|
3143
|
-
var
|
|
3133
|
+
var GoogleVideoModel = class {
|
|
3144
3134
|
constructor(modelId, config) {
|
|
3145
3135
|
this.modelId = modelId;
|
|
3146
3136
|
this.config = config;
|
|
@@ -3389,7 +3379,7 @@ var googleVideoModelOptionsSchema = lazySchema13(
|
|
|
3389
3379
|
);
|
|
3390
3380
|
|
|
3391
3381
|
// src/google-provider.ts
|
|
3392
|
-
function
|
|
3382
|
+
function createGoogle(options = {}) {
|
|
3393
3383
|
var _a, _b;
|
|
3394
3384
|
const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
3395
3385
|
const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
|
|
@@ -3406,7 +3396,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
3406
3396
|
);
|
|
3407
3397
|
const createChatModel = (modelId) => {
|
|
3408
3398
|
var _a2;
|
|
3409
|
-
return new
|
|
3399
|
+
return new GoogleLanguageModel(modelId, {
|
|
3410
3400
|
provider: providerName,
|
|
3411
3401
|
baseURL,
|
|
3412
3402
|
headers: getHeaders,
|
|
@@ -3426,19 +3416,19 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
3426
3416
|
fetch: options.fetch
|
|
3427
3417
|
});
|
|
3428
3418
|
};
|
|
3429
|
-
const createEmbeddingModel = (modelId) => new
|
|
3419
|
+
const createEmbeddingModel = (modelId) => new GoogleEmbeddingModel(modelId, {
|
|
3430
3420
|
provider: providerName,
|
|
3431
3421
|
baseURL,
|
|
3432
3422
|
headers: getHeaders,
|
|
3433
3423
|
fetch: options.fetch
|
|
3434
3424
|
});
|
|
3435
|
-
const createImageModel = (modelId, settings = {}) => new
|
|
3425
|
+
const createImageModel = (modelId, settings = {}) => new GoogleImageModel(modelId, settings, {
|
|
3436
3426
|
provider: providerName,
|
|
3437
3427
|
baseURL,
|
|
3438
3428
|
headers: getHeaders,
|
|
3439
3429
|
fetch: options.fetch
|
|
3440
3430
|
});
|
|
3441
|
-
const createFiles = () => new
|
|
3431
|
+
const createFiles = () => new GoogleFiles({
|
|
3442
3432
|
provider: providerName,
|
|
3443
3433
|
baseURL,
|
|
3444
3434
|
headers: getHeaders,
|
|
@@ -3446,7 +3436,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
3446
3436
|
});
|
|
3447
3437
|
const createVideoModel = (modelId) => {
|
|
3448
3438
|
var _a2;
|
|
3449
|
-
return new
|
|
3439
|
+
return new GoogleVideoModel(modelId, {
|
|
3450
3440
|
provider: providerName,
|
|
3451
3441
|
baseURL,
|
|
3452
3442
|
headers: getHeaders,
|
|
@@ -3478,10 +3468,11 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
3478
3468
|
provider.tools = googleTools;
|
|
3479
3469
|
return provider;
|
|
3480
3470
|
}
|
|
3481
|
-
var google =
|
|
3471
|
+
var google = createGoogle();
|
|
3482
3472
|
export {
|
|
3483
3473
|
VERSION,
|
|
3484
|
-
|
|
3474
|
+
createGoogle,
|
|
3475
|
+
createGoogle as createGoogleGenerativeAI,
|
|
3485
3476
|
google
|
|
3486
3477
|
};
|
|
3487
3478
|
//# sourceMappingURL=index.js.map
|