@ai-sdk/google 3.0.61 → 3.0.63
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 +12 -0
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -7
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +19 -6
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +19 -6
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/google-generative-ai-language-model.ts +34 -20
- package/src/google-generative-ai-options.ts +10 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.63",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ai-sdk/provider": "
|
|
40
|
-
"@ai-sdk/provider
|
|
39
|
+
"@ai-sdk/provider-utils": "4.0.23",
|
|
40
|
+
"@ai-sdk/provider": "3.0.8"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "20.17.24",
|
|
44
44
|
"tsup": "^8",
|
|
45
45
|
"typescript": "5.8.3",
|
|
46
46
|
"zod": "3.25.76",
|
|
47
|
-
"@
|
|
48
|
-
"@ai-
|
|
47
|
+
"@ai-sdk/test-server": "1.0.3",
|
|
48
|
+
"@vercel/ai-tsconfig": "0.0.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"zod": "^3.25.76 || ^4.1.8"
|
|
@@ -38,6 +38,7 @@ import { googleFailedResponseHandler } from './google-error';
|
|
|
38
38
|
import {
|
|
39
39
|
GoogleGenerativeAIModelId,
|
|
40
40
|
googleLanguageModelOptions,
|
|
41
|
+
VertexServiceTierMap,
|
|
41
42
|
} from './google-generative-ai-options';
|
|
42
43
|
import {
|
|
43
44
|
GoogleGenerativeAIContentPart,
|
|
@@ -85,21 +86,24 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
|
|
|
85
86
|
return this.config.supportedUrls?.() ?? {};
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
private async getArgs(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
89
|
+
private async getArgs(
|
|
90
|
+
{
|
|
91
|
+
prompt,
|
|
92
|
+
maxOutputTokens,
|
|
93
|
+
temperature,
|
|
94
|
+
topP,
|
|
95
|
+
topK,
|
|
96
|
+
frequencyPenalty,
|
|
97
|
+
presencePenalty,
|
|
98
|
+
stopSequences,
|
|
99
|
+
responseFormat,
|
|
100
|
+
seed,
|
|
101
|
+
tools,
|
|
102
|
+
toolChoice,
|
|
103
|
+
providerOptions,
|
|
104
|
+
}: LanguageModelV3CallOptions,
|
|
105
|
+
{ isStreaming = false }: { isStreaming?: boolean } = {},
|
|
106
|
+
) {
|
|
103
107
|
const warnings: SharedV3Warning[] = [];
|
|
104
108
|
|
|
105
109
|
const providerOptionsName = this.config.provider.includes('vertex')
|
|
@@ -148,6 +152,12 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
|
|
|
148
152
|
});
|
|
149
153
|
}
|
|
150
154
|
|
|
155
|
+
// Vertex API requires another service tier format.
|
|
156
|
+
let sanitizedServiceTier: string | undefined = googleOptions?.serviceTier;
|
|
157
|
+
if (googleOptions?.serviceTier && isVertexProvider) {
|
|
158
|
+
sanitizedServiceTier = VertexServiceTierMap[googleOptions.serviceTier];
|
|
159
|
+
}
|
|
160
|
+
|
|
151
161
|
const isGemmaModel = this.modelId.toLowerCase().startsWith('gemma-');
|
|
152
162
|
const supportsFunctionResponseParts = this.modelId.startsWith('gemini-3');
|
|
153
163
|
|
|
@@ -170,9 +180,10 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
|
|
|
170
180
|
modelId: this.modelId,
|
|
171
181
|
});
|
|
172
182
|
|
|
173
|
-
const streamFunctionCallArguments =
|
|
174
|
-
|
|
175
|
-
|
|
183
|
+
const streamFunctionCallArguments =
|
|
184
|
+
isStreaming && isVertexProvider
|
|
185
|
+
? (googleOptions?.streamFunctionCallArguments ?? false)
|
|
186
|
+
: undefined;
|
|
176
187
|
|
|
177
188
|
const toolConfig =
|
|
178
189
|
googleToolConfig ||
|
|
@@ -238,7 +249,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
|
|
|
238
249
|
toolConfig,
|
|
239
250
|
cachedContent: googleOptions?.cachedContent,
|
|
240
251
|
labels: googleOptions?.labels,
|
|
241
|
-
serviceTier:
|
|
252
|
+
serviceTier: sanitizedServiceTier,
|
|
242
253
|
},
|
|
243
254
|
warnings: [...warnings, ...toolWarnings],
|
|
244
255
|
providerOptionsName,
|
|
@@ -468,7 +479,10 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
|
|
|
468
479
|
async doStream(
|
|
469
480
|
options: LanguageModelV3CallOptions,
|
|
470
481
|
): Promise<LanguageModelV3StreamResult> {
|
|
471
|
-
const { args, warnings, providerOptionsName } = await this.getArgs(
|
|
482
|
+
const { args, warnings, providerOptionsName } = await this.getArgs(
|
|
483
|
+
options,
|
|
484
|
+
{ isStreaming: true },
|
|
485
|
+
);
|
|
472
486
|
|
|
473
487
|
const headers = combineHeaders(
|
|
474
488
|
await resolve(this.config.headers),
|
|
@@ -192,9 +192,10 @@ export const googleLanguageModelOptions = lazySchema(() =>
|
|
|
192
192
|
/**
|
|
193
193
|
* Optional. When set to true, function call arguments will be streamed
|
|
194
194
|
* incrementally via partialArgs in streaming responses. Only supported
|
|
195
|
-
* on the Vertex AI API (not the Gemini API)
|
|
195
|
+
* on the Vertex AI API (not the Gemini API) and only for Gemini 3+
|
|
196
|
+
* models.
|
|
196
197
|
*
|
|
197
|
-
* @default
|
|
198
|
+
* @default false
|
|
198
199
|
*
|
|
199
200
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
|
|
200
201
|
*/
|
|
@@ -211,3 +212,10 @@ export const googleLanguageModelOptions = lazySchema(() =>
|
|
|
211
212
|
export type GoogleLanguageModelOptions = InferSchema<
|
|
212
213
|
typeof googleLanguageModelOptions
|
|
213
214
|
>;
|
|
215
|
+
|
|
216
|
+
// Vertex API requires another service tier format.
|
|
217
|
+
export const VertexServiceTierMap = {
|
|
218
|
+
standard: 'SERVICE_TIER_STANDARD',
|
|
219
|
+
flex: 'SERVICE_TIER_FLEX',
|
|
220
|
+
priority: 'SERVICE_TIER_PRIORITY',
|
|
221
|
+
} as const;
|