@ai-sdk/google 4.0.107 → 4.0.108
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 +19 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +87 -50
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +9 -0
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +86 -49
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +18 -2
- package/package.json +2 -2
- package/src/convert-to-google-messages.ts +16 -5
- package/src/google-json-accumulator.ts +26 -14
- package/src/google-language-model.ts +19 -14
- package/src/google-prompt.ts +15 -0
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.108
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9f108f8: close string values in tool-call input streamed with `streamFunctionCallArguments` on their final chunk
|
|
8
|
+
- b1bcea1: Add videoMetadata support for file parts. Pass startOffset, endOffset, and fps through per-file providerOptions to control video clipping and frame rate with the Google and Google Vertex providers.
|
|
9
|
+
- 61a315e: fix: map the top-level `reasoning` option consistently across providers
|
|
10
|
+
|
|
11
|
+
Providers now resolve reasoning the same way:
|
|
12
|
+
|
|
13
|
+
1. A provider-specific reasoning setting in `providerOptions` is sent unchanged. OpenAI no longer drops `providerOptions.openai.reasoningEffort` values that are not in its list for the model, and Fireworks no longer rewrites `providerOptions.fireworks.reasoningEffort`. Fireworks also sends top-level `reasoning` values directly instead of rounding them to `'high'` at most, except for model families known to reject `'none'` (GPT-OSS, GLM-5.3, Muse Spark) or `'minimal'` (Nemotron, Inkling).
|
|
14
|
+
2. Otherwise, `reasoning` maps to the closest level the model supports, rounding down, and rounds up only when there is no lower level. For example, `'xhigh'` now maps to `'high'` instead of `'max'` on Anthropic and Bedrock models without `xhigh` effort, and `'medium'` maps to `'low'` instead of `'high'` on DeepSeek, Kimi K3, and Mistral GLM-5.3 models.
|
|
15
|
+
3. `'none'` on a model that cannot disable reasoning maps to the model's lowest level with a compatibility warning, instead of being dropped or sending a request the API rejects. This affects GPT-6 models without `'none'`, xAI grok-4.5 and later, Groq GPT-OSS, Kimi K3, Perplexity, QuiverAI, Bedrock OpenAI `gpt-oss` models, and Gemini 2.5 Pro (minimum thinking budget). Gemini 3 and Anthropic and Bedrock `between_tools` mappings now emit the compatibility warning too.
|
|
16
|
+
|
|
17
|
+
`mapReasoningToProviderEffort` now accepts any `reasoning` value, returns an optional `providerOptionsEffort` unchanged, and rounds levels that are missing from the effort map to the closest supported level. `mapReasoningToProviderBudget` maps `'none'` to the minimum reasoning budget, always returns a budget, and uses the default percentage for levels missing from `budgetPercentages`. `OpenAICompatibleChatConfig` adds an optional `mapReasoning` function for mapping the top-level `reasoning` option.
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [61a315e]
|
|
20
|
+
- @ai-sdk/provider-utils@5.0.71
|
|
21
|
+
|
|
3
22
|
## 4.0.107
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -235,6 +235,13 @@ type PromptFeedbackSchema = NonNullable<InferSchema<typeof responseSchema>['prom
|
|
|
235
235
|
type UsageMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['usageMetadata']>;
|
|
236
236
|
//#endregion
|
|
237
237
|
//#region src/google-prompt.d.ts
|
|
238
|
+
declare const googleVideoMetadataSchema: z.ZodObject<{
|
|
239
|
+
startOffset: z.ZodOptional<z.ZodString>;
|
|
240
|
+
endOffset: z.ZodOptional<z.ZodString>;
|
|
241
|
+
fps: z.ZodOptional<z.ZodNumber>;
|
|
242
|
+
}, z.core.$strip>;
|
|
243
|
+
/** Metadata for preprocessing video file parts. */
|
|
244
|
+
type GoogleVideoMetadata = z.infer<typeof googleVideoMetadataSchema>;
|
|
238
245
|
type GoogleGroundingMetadata = GroundingMetadataSchema;
|
|
239
246
|
type GoogleUrlContextMetadata = UrlContextMetadataSchema;
|
|
240
247
|
type GoogleSafetyRating = SafetyRatingSchema;
|
|
@@ -928,5 +935,5 @@ declare class GoogleSpeechTranslationModel implements Experimental_SpeechTransla
|
|
|
928
935
|
//#region src/version.d.ts
|
|
929
936
|
export declare const VERSION: string;
|
|
930
937
|
//#endregion
|
|
931
|
-
export { GoogleRealtimeModel as Experimental_GoogleRealtimeModel, type GoogleRealtimeModelConfig as Experimental_GoogleRealtimeModelConfig, type GoogleRealtimeModelId as Experimental_GoogleRealtimeModelId, type GoogleRealtimeModelOptions as Experimental_GoogleRealtimeModelOptions, GoogleSpeechTranslationModel as Experimental_GoogleSpeechTranslationModel, GoogleSpeechTranslationModel as Experimental_GoogleTranslationModel, type GoogleSpeechTranslationModelConfig as Experimental_GoogleSpeechTranslationModelConfig, type GoogleSpeechTranslationModelConfig as Experimental_GoogleTranslationModelConfig, type GoogleSpeechTranslationModelId as Experimental_GoogleSpeechTranslationModelId, type GoogleSpeechTranslationModelId as Experimental_GoogleTranslationModelId, type GoogleSpeechTranslationModelOptions as Experimental_GoogleSpeechTranslationModelOptions, type GoogleSpeechTranslationModelOptions as Experimental_GoogleTranslationModelOptions, type GoogleEmbeddingModelOptions, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleErrorData, type GoogleFilesUploadOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleImageModelOptions, type GoogleProvider as GoogleGenerativeAIProvider, type GoogleProvider, type GoogleProviderMetadata as GoogleGenerativeAIProviderMetadata, type GoogleProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleLanguageModelOptions, type GoogleProviderSettings as GoogleGenerativeAIProviderSettings, type GoogleProviderSettings, type GoogleVideoModelId as GoogleGenerativeAIVideoModelId, type GoogleVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleVideoModelOptions, type GoogleInteractionsAgentName, type GoogleInteractionsModelId, type GoogleInteractionsProviderMetadata, type GoogleInteractionsVideoOptions, type GoogleLanguageModelInteractionsOptions, type GoogleSpeechModelId, type GoogleSpeechModelOptions, type GoogleTranscriptionModelId, type GoogleTranscriptionModelOptions, createGoogle as createGoogleGenerativeAI };
|
|
938
|
+
export { GoogleRealtimeModel as Experimental_GoogleRealtimeModel, type GoogleRealtimeModelConfig as Experimental_GoogleRealtimeModelConfig, type GoogleRealtimeModelId as Experimental_GoogleRealtimeModelId, type GoogleRealtimeModelOptions as Experimental_GoogleRealtimeModelOptions, GoogleSpeechTranslationModel as Experimental_GoogleSpeechTranslationModel, GoogleSpeechTranslationModel as Experimental_GoogleTranslationModel, type GoogleSpeechTranslationModelConfig as Experimental_GoogleSpeechTranslationModelConfig, type GoogleSpeechTranslationModelConfig as Experimental_GoogleTranslationModelConfig, type GoogleSpeechTranslationModelId as Experimental_GoogleSpeechTranslationModelId, type GoogleSpeechTranslationModelId as Experimental_GoogleTranslationModelId, type GoogleSpeechTranslationModelOptions as Experimental_GoogleSpeechTranslationModelOptions, type GoogleSpeechTranslationModelOptions as Experimental_GoogleTranslationModelOptions, type GoogleEmbeddingModelOptions, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleErrorData, type GoogleFilesUploadOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleImageModelOptions, type GoogleProvider as GoogleGenerativeAIProvider, type GoogleProvider, type GoogleProviderMetadata as GoogleGenerativeAIProviderMetadata, type GoogleProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleLanguageModelOptions, type GoogleProviderSettings as GoogleGenerativeAIProviderSettings, type GoogleProviderSettings, type GoogleVideoModelId as GoogleGenerativeAIVideoModelId, type GoogleVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleVideoModelOptions, type GoogleInteractionsAgentName, type GoogleInteractionsModelId, type GoogleInteractionsProviderMetadata, type GoogleInteractionsVideoOptions, type GoogleLanguageModelInteractionsOptions, type GoogleSpeechModelId, type GoogleSpeechModelOptions, type GoogleTranscriptionModelId, type GoogleTranscriptionModelOptions, type GoogleVideoMetadata, createGoogle as createGoogleGenerativeAI };
|
|
932
939
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["DecisionModelV4","BatchV4","SpeechTranslationModelV4","RealtimeFactoryV4","RealtimeModelV4ClientSecretOptions","RealtimeModelV4ClientSecretResult","RealtimeModelV4ServerEvent","RealtimeModelV4ClientEvent","RealtimeModelV4","RealtimeModelV4SessionConfig","TranscriptionModelV4StreamOptions","SpeechTranslationModelV4StreamOptions","SpeechTranslationModelV4"],"sources":["../src/google-error.ts","../src/google-language-model-options.ts","../src/google-language-model.ts","../src/google-prompt.ts","../src/tool/google-search.ts","../src/google-image-model-options.ts","../src/google-embedding-model-options.ts","../src/google-video-model-options.ts","../src/google-video-settings.ts","../src/google-speech-model-options.ts","../src/google-files.ts","../src/interactions/google-interactions-language-model-options.ts","../src/interactions/google-interactions-provider-metadata.ts","../src/interactions/google-interactions-agent.ts","../src/google-tools.ts","../src/google-image-settings.ts","../src/transcription/google-transcription-model-options.ts","../src/speech-translation/google-speech-translation-model-options.ts","../src/google-provider.ts","../src/realtime/google-realtime-model.ts","../src/realtime/google-realtime-model-options.ts","../src/transcription/google-transcription-model.ts","../src/speech-translation/google-speech-translation-model.ts","../src/version.ts"],"mappings":";;;;cAgBM,wDAAqB;;;;;;;;KAQf,kBAAkB,mBAAmB;;;KCjBrC;cAqDC,6DAA0B;;;;;;;;;;;;;;;WAA1B;;;;;;;;;;;;;;;;;;;;;;;;KA+OD,6BAA6B,mBAChC;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["DecisionModelV4","BatchV4","SpeechTranslationModelV4","RealtimeFactoryV4","RealtimeModelV4ClientSecretOptions","RealtimeModelV4ClientSecretResult","RealtimeModelV4ServerEvent","RealtimeModelV4ClientEvent","RealtimeModelV4","RealtimeModelV4SessionConfig","TranscriptionModelV4StreamOptions","SpeechTranslationModelV4StreamOptions","SpeechTranslationModelV4"],"sources":["../src/google-error.ts","../src/google-language-model-options.ts","../src/google-language-model.ts","../src/google-prompt.ts","../src/tool/google-search.ts","../src/google-image-model-options.ts","../src/google-embedding-model-options.ts","../src/google-video-model-options.ts","../src/google-video-settings.ts","../src/google-speech-model-options.ts","../src/google-files.ts","../src/interactions/google-interactions-language-model-options.ts","../src/interactions/google-interactions-provider-metadata.ts","../src/interactions/google-interactions-agent.ts","../src/google-tools.ts","../src/google-image-settings.ts","../src/transcription/google-transcription-model-options.ts","../src/speech-translation/google-speech-translation-model-options.ts","../src/google-provider.ts","../src/realtime/google-realtime-model.ts","../src/realtime/google-realtime-model-options.ts","../src/transcription/google-transcription-model.ts","../src/speech-translation/google-speech-translation-model.ts","../src/version.ts"],"mappings":";;;;cAgBM,wDAAqB;;;;;;;;KAQf,kBAAkB,mBAAmB;;;KCjBrC;cAqDC,6DAA0B;;;;;;;;;;;;;;;WAA1B;;;;;;;;;;;;;;;;;;;;;;;;KA+OD,6BAA6B,mBAChC;;;cCysDI,iDAAc;;;cAAd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BR,kBAAkB,YACrB,mBAAmB;KAGT,0BAA0B,YACpC;KAGU,2BAA2B,YACrC;KAGU,qBAAqB,YAC/B;KAGU,uBAAuB,YACjC,mBAAmB;KAGT,sBAAsB,YAChC,mBAAmB;;;cC/gER,2BAAyB,EAAA;;;;GAOpC,EA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F;;;;;;IAME;;;;;IAMA;;;;IAKA;;;;;;;;;;;EAYF;;;;UC6BQ;EACR;EACA;EACA,UAAU,WAAW;EACrB,QAAQ;EACR,YAAY;EACZ;IACE,oBAAoB;IACpB;;;qBAIS,oCAAoC;WAsBpC,SAAS;mBACD;WAtBV;UAED,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;MAIG;EAKO,YAAA,SAAS,4BACD,QAAQ;UAGb;EAUR,WACJ,SAAS,WAAW,yCACnB,QAAQ,QAAQ,WAAW;EAmGxB,SACJ,SAASC,iDACR,QACD,QAAQ,WAAW,YAAY;;;;KCxKvB;EACV;EACA;EACA,eAAe;EACf,YAAY;EACZ;IACE,oBAAoB;IACpB;;;cAIS,wCAAwCE;WAC1C;WACA,SAAS;mBAED;UAET,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;MAIG;EAKF,YAAA,SAAS,gCACT,QAAQ;EAMJ,SACJ,SAASD,qDACR,QAAQ,QAAQ,WAAWC;;;;qBCpHnB"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Experimental_DecisionLanguageModel } from "@ai-sdk/provider-utils/exper
|
|
|
3
3
|
import { AISDKError, InvalidArgumentError, InvalidResponseDataError, TooManyEmbeddingValuesForCallError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
5
|
//#region src/version.ts
|
|
6
|
-
const VERSION = "4.0.
|
|
6
|
+
const VERSION = "4.0.108";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/google-error.ts
|
|
9
9
|
const getGoogleErrorSchema = () => z.object({
|
|
@@ -310,6 +310,16 @@ function addTokenDetails(a, b) {
|
|
|
310
310
|
}));
|
|
311
311
|
}
|
|
312
312
|
//#endregion
|
|
313
|
+
//#region src/google-prompt.ts
|
|
314
|
+
const googleVideoMetadataSchema = z.object({
|
|
315
|
+
/** Start offset as a duration in seconds, e.g. `'3.5s'`. */
|
|
316
|
+
startOffset: z.string().optional(),
|
|
317
|
+
/** End offset as a duration in seconds, e.g. `'10s'`. */
|
|
318
|
+
endOffset: z.string().optional(),
|
|
319
|
+
/** Frames per second in the range (0, 24]. Defaults to 1. */
|
|
320
|
+
fps: z.number().gt(0).max(24).optional()
|
|
321
|
+
});
|
|
322
|
+
//#endregion
|
|
313
323
|
//#region src/tool/code-execution.ts
|
|
314
324
|
const codeExecutionInputSchema = z.object({
|
|
315
325
|
language: z.string().describe("The programming language of the code."),
|
|
@@ -470,33 +480,50 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
470
480
|
case "text":
|
|
471
481
|
parts.push({ text: part.text });
|
|
472
482
|
break;
|
|
473
|
-
case "file":
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
})
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
483
|
+
case "file": {
|
|
484
|
+
const rawVideoMetadata = readProviderOpts(part)?.videoMetadata;
|
|
485
|
+
const videoMetadata = rawVideoMetadata == null ? void 0 : googleVideoMetadataSchema.parse(rawVideoMetadata);
|
|
486
|
+
switch (part.data.type) {
|
|
487
|
+
case "url":
|
|
488
|
+
parts.push({
|
|
489
|
+
fileData: {
|
|
490
|
+
mimeType: resolveFullMediaType({ part }),
|
|
491
|
+
fileUri: part.data.url.protocol === "gs:" && part.data.originalUrl != null ? part.data.originalUrl : part.data.url.toString()
|
|
492
|
+
},
|
|
493
|
+
...videoMetadata != null ? { videoMetadata } : {}
|
|
494
|
+
});
|
|
495
|
+
break;
|
|
496
|
+
case "reference":
|
|
497
|
+
if (isVertexLike) throw new UnsupportedFunctionalityError({ functionality: "file parts with provider references" });
|
|
498
|
+
parts.push({
|
|
499
|
+
fileData: {
|
|
500
|
+
mimeType: resolveFullMediaType({ part }),
|
|
501
|
+
fileUri: resolveProviderReference({
|
|
502
|
+
reference: part.data.reference,
|
|
503
|
+
provider: "google"
|
|
504
|
+
})
|
|
505
|
+
},
|
|
506
|
+
...videoMetadata != null ? { videoMetadata } : {}
|
|
507
|
+
});
|
|
508
|
+
break;
|
|
509
|
+
case "text":
|
|
510
|
+
parts.push({
|
|
511
|
+
inlineData: {
|
|
512
|
+
mimeType: isFullMediaType(part.mediaType) ? part.mediaType : "text/plain",
|
|
513
|
+
data: convertToBase64(new TextEncoder().encode(part.data.text))
|
|
514
|
+
},
|
|
515
|
+
...videoMetadata != null ? { videoMetadata } : {}
|
|
516
|
+
});
|
|
517
|
+
break;
|
|
518
|
+
case "data": parts.push({
|
|
519
|
+
inlineData: {
|
|
520
|
+
mimeType: resolveFullMediaType({ part }),
|
|
521
|
+
data: convertToBase64(part.data.data)
|
|
522
|
+
},
|
|
523
|
+
...videoMetadata != null ? { videoMetadata } : {}
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
break;
|
|
500
527
|
}
|
|
501
528
|
}
|
|
502
529
|
contents.push({
|
|
@@ -1233,11 +1260,16 @@ var GoogleJSONAccumulator = class {
|
|
|
1233
1260
|
const escaped = JSON.stringify(arg.stringValue).slice(1, -1);
|
|
1234
1261
|
setNestedValue(this.accumulatedArgs, segments, existingValue + arg.stringValue);
|
|
1235
1262
|
delta += escaped;
|
|
1263
|
+
if (arg.willContinue !== true) delta += this.closeOpenString();
|
|
1236
1264
|
continue;
|
|
1237
1265
|
}
|
|
1238
1266
|
const resolved = resolvePartialArgValue(arg);
|
|
1239
1267
|
if (resolved == null) {
|
|
1240
|
-
if (existingValue !== void 0
|
|
1268
|
+
if (existingValue !== void 0) {
|
|
1269
|
+
if (typeof existingValue === "string" && arg.willContinue !== true) delta += this.closeOpenString();
|
|
1270
|
+
continue;
|
|
1271
|
+
}
|
|
1272
|
+
if (arg.willContinue === true) continue;
|
|
1241
1273
|
setNestedValue(this.accumulatedArgs, segments, isArrayTerminator ? [] : {});
|
|
1242
1274
|
delta += this.emitContainer(segments, isArrayTerminator);
|
|
1243
1275
|
continue;
|
|
@@ -1263,6 +1295,15 @@ var GoogleJSONAccumulator = class {
|
|
|
1263
1295
|
};
|
|
1264
1296
|
}
|
|
1265
1297
|
/**
|
|
1298
|
+
* Input: stringOpen=true
|
|
1299
|
+
* Output: '"' (and stringOpen=false), or '' when no string is open
|
|
1300
|
+
*/
|
|
1301
|
+
closeOpenString() {
|
|
1302
|
+
if (!this.stringOpen) return "";
|
|
1303
|
+
this.stringOpen = false;
|
|
1304
|
+
return "\"";
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1266
1307
|
* Input: pathStack=[] (first call) or pathStack=[root,...] (subsequent calls)
|
|
1267
1308
|
* Output: '{' (first call) or '' (subsequent calls)
|
|
1268
1309
|
*/
|
|
@@ -1285,11 +1326,7 @@ var GoogleJSONAccumulator = class {
|
|
|
1285
1326
|
* Output: '{"recipe":{"name":"Lasagna"'
|
|
1286
1327
|
*/
|
|
1287
1328
|
emitNavigationTo(targetSegments, arg, valueJson) {
|
|
1288
|
-
let fragment =
|
|
1289
|
-
if (this.stringOpen) {
|
|
1290
|
-
fragment += "\"";
|
|
1291
|
-
this.stringOpen = false;
|
|
1292
|
-
}
|
|
1329
|
+
let fragment = this.closeOpenString();
|
|
1293
1330
|
fragment += this.ensureRoot();
|
|
1294
1331
|
const targetContainerSegments = targetSegments.slice(0, -1);
|
|
1295
1332
|
const leafSegment = targetSegments[targetSegments.length - 1];
|
|
@@ -1308,11 +1345,7 @@ var GoogleJSONAccumulator = class {
|
|
|
1308
1345
|
* Output: '{"nested":{"tags":['
|
|
1309
1346
|
*/
|
|
1310
1347
|
emitContainer(targetSegments, isArray) {
|
|
1311
|
-
let fragment =
|
|
1312
|
-
if (this.stringOpen) {
|
|
1313
|
-
fragment += "\"";
|
|
1314
|
-
this.stringOpen = false;
|
|
1315
|
-
}
|
|
1348
|
+
let fragment = this.closeOpenString();
|
|
1316
1349
|
fragment += this.ensureRoot();
|
|
1317
1350
|
const commonDepth = this.findCommonStackDepth(targetSegments);
|
|
1318
1351
|
fragment += this.closeDownTo(commonDepth);
|
|
@@ -2385,6 +2418,14 @@ function getMaxThinkingTokensForGemini25Model(modelId) {
|
|
|
2385
2418
|
if (id.includes("2.5-pro") || id.includes("gemini-3-pro-image")) return 32768;
|
|
2386
2419
|
return 24576;
|
|
2387
2420
|
}
|
|
2421
|
+
/**
|
|
2422
|
+
* Gemini 2.5 Pro cannot disable thinking and requires a thinking budget of at
|
|
2423
|
+
* least 128 tokens. Other Gemini 2.5 models can disable thinking with a budget
|
|
2424
|
+
* of 0.
|
|
2425
|
+
*/
|
|
2426
|
+
function getMinThinkingTokensForGemini25Model(modelId) {
|
|
2427
|
+
return modelId.toLowerCase().includes("2.5-pro") ? 128 : 0;
|
|
2428
|
+
}
|
|
2388
2429
|
function resolveThinkingConfig({ reasoning, modelId, warnings }) {
|
|
2389
2430
|
if (!isCustomReasoning(reasoning)) return;
|
|
2390
2431
|
if (getGoogleModelCapabilities(modelId).usesGemini3Features && !modelId.includes("gemini-3-pro-image")) return resolveGemini3ThinkingConfig({
|
|
@@ -2400,16 +2441,13 @@ function resolveThinkingConfig({ reasoning, modelId, warnings }) {
|
|
|
2400
2441
|
}
|
|
2401
2442
|
function resolveGemini3ThinkingConfig({ reasoning, modelId, warnings }) {
|
|
2402
2443
|
const minimumThinkingLevel = getMinimumThinkingLevelForGemini3Model(modelId);
|
|
2403
|
-
if (reasoning === "none") return { thinkingLevel: minimumThinkingLevel };
|
|
2404
2444
|
const thinkingLevel = mapReasoningToProviderEffort({
|
|
2405
2445
|
reasoning,
|
|
2406
2446
|
effortMap: {
|
|
2407
|
-
minimal:
|
|
2447
|
+
...minimumThinkingLevel === "minimal" && { minimal: "minimal" },
|
|
2408
2448
|
low: "low",
|
|
2409
2449
|
medium: "medium",
|
|
2410
|
-
high: "high"
|
|
2411
|
-
xhigh: "high",
|
|
2412
|
-
max: "high"
|
|
2450
|
+
high: "high"
|
|
2413
2451
|
},
|
|
2414
2452
|
warnings
|
|
2415
2453
|
});
|
|
@@ -2428,16 +2466,15 @@ function getMinimumThinkingLevelForGemini3Model(modelId) {
|
|
|
2428
2466
|
return majorVersion > 3 || majorVersion === 3 && minorVersion >= 7 ? "low" : "minimal";
|
|
2429
2467
|
}
|
|
2430
2468
|
function resolveGemini25ThinkingConfig({ reasoning, modelId, warnings }) {
|
|
2431
|
-
|
|
2432
|
-
|
|
2469
|
+
const minThinkingBudget = getMinThinkingTokensForGemini25Model(modelId);
|
|
2470
|
+
if (reasoning === "none" && minThinkingBudget === 0) return { thinkingBudget: 0 };
|
|
2471
|
+
return { thinkingBudget: mapReasoningToProviderBudget({
|
|
2433
2472
|
reasoning,
|
|
2434
2473
|
maxOutputTokens: getMaxOutputTokensForGemini25Model(),
|
|
2435
2474
|
maxReasoningBudget: getMaxThinkingTokensForGemini25Model(modelId),
|
|
2436
|
-
minReasoningBudget:
|
|
2475
|
+
minReasoningBudget: minThinkingBudget,
|
|
2437
2476
|
warnings
|
|
2438
|
-
});
|
|
2439
|
-
if (thinkingBudget == null) return;
|
|
2440
|
-
return { thinkingBudget };
|
|
2477
|
+
}) };
|
|
2441
2478
|
}
|
|
2442
2479
|
function extractSources({ groundingMetadata, generateId }) {
|
|
2443
2480
|
if (!groundingMetadata?.groundingChunks) return;
|