@ai-sdk/google 4.0.0-beta.13 → 4.0.0-beta.14
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 +13 -4
- package/dist/index.js +78 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -2
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +77 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +80 -1
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -5
- package/src/google-generative-ai-language-model.ts +118 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -4,7 +4,10 @@ import {
|
|
|
4
4
|
createEventSourceResponseHandler,
|
|
5
5
|
createJsonResponseHandler,
|
|
6
6
|
generateId,
|
|
7
|
+
isCustomReasoning,
|
|
7
8
|
lazySchema as lazySchema3,
|
|
9
|
+
mapReasoningToProviderBudget,
|
|
10
|
+
mapReasoningToProviderEffort,
|
|
8
11
|
parseProviderOptions,
|
|
9
12
|
postJsonToApi,
|
|
10
13
|
resolve,
|
|
@@ -774,6 +777,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
774
777
|
seed,
|
|
775
778
|
tools,
|
|
776
779
|
toolChoice,
|
|
780
|
+
reasoning,
|
|
777
781
|
providerOptions
|
|
778
782
|
}) {
|
|
779
783
|
var _a;
|
|
@@ -813,6 +817,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
813
817
|
toolChoice,
|
|
814
818
|
modelId: this.modelId
|
|
815
819
|
});
|
|
820
|
+
const resolvedThinking = resolveThinkingConfig({
|
|
821
|
+
reasoning,
|
|
822
|
+
modelId: this.modelId,
|
|
823
|
+
warnings
|
|
824
|
+
});
|
|
825
|
+
const thinkingConfig = (googleOptions == null ? void 0 : googleOptions.thinkingConfig) || resolvedThinking ? { ...resolvedThinking, ...googleOptions == null ? void 0 : googleOptions.thinkingConfig } : void 0;
|
|
816
826
|
return {
|
|
817
827
|
args: {
|
|
818
828
|
generationConfig: {
|
|
@@ -836,7 +846,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
836
846
|
},
|
|
837
847
|
// provider options:
|
|
838
848
|
responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
|
|
839
|
-
thinkingConfig
|
|
849
|
+
thinkingConfig,
|
|
840
850
|
...(googleOptions == null ? void 0 : googleOptions.mediaResolution) && {
|
|
841
851
|
mediaResolution: googleOptions.mediaResolution
|
|
842
852
|
},
|
|
@@ -1267,6 +1277,75 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1267
1277
|
};
|
|
1268
1278
|
}
|
|
1269
1279
|
};
|
|
1280
|
+
function isGemini3Model(modelId) {
|
|
1281
|
+
return /gemini-3[\.\-]/i.test(modelId) || /gemini-3$/i.test(modelId);
|
|
1282
|
+
}
|
|
1283
|
+
function getMaxOutputTokensForGemini25Model() {
|
|
1284
|
+
return 65536;
|
|
1285
|
+
}
|
|
1286
|
+
function getMaxThinkingTokensForGemini25Model(modelId) {
|
|
1287
|
+
const id = modelId.toLowerCase();
|
|
1288
|
+
if (id.includes("2.5-pro") || id.includes("gemini-3-pro-image")) {
|
|
1289
|
+
return 32768;
|
|
1290
|
+
}
|
|
1291
|
+
return 24576;
|
|
1292
|
+
}
|
|
1293
|
+
function resolveThinkingConfig({
|
|
1294
|
+
reasoning,
|
|
1295
|
+
modelId,
|
|
1296
|
+
warnings
|
|
1297
|
+
}) {
|
|
1298
|
+
if (!isCustomReasoning(reasoning)) {
|
|
1299
|
+
return void 0;
|
|
1300
|
+
}
|
|
1301
|
+
if (isGemini3Model(modelId) && !modelId.includes("gemini-3-pro-image")) {
|
|
1302
|
+
return resolveGemini3ThinkingConfig({ reasoning, warnings });
|
|
1303
|
+
}
|
|
1304
|
+
return resolveGemini25ThinkingConfig({ reasoning, modelId, warnings });
|
|
1305
|
+
}
|
|
1306
|
+
function resolveGemini3ThinkingConfig({
|
|
1307
|
+
reasoning,
|
|
1308
|
+
warnings
|
|
1309
|
+
}) {
|
|
1310
|
+
if (reasoning === "none") {
|
|
1311
|
+
return { thinkingLevel: "minimal" };
|
|
1312
|
+
}
|
|
1313
|
+
const thinkingLevel = mapReasoningToProviderEffort({
|
|
1314
|
+
reasoning,
|
|
1315
|
+
effortMap: {
|
|
1316
|
+
minimal: "minimal",
|
|
1317
|
+
low: "low",
|
|
1318
|
+
medium: "medium",
|
|
1319
|
+
high: "high",
|
|
1320
|
+
xhigh: "high"
|
|
1321
|
+
},
|
|
1322
|
+
warnings
|
|
1323
|
+
});
|
|
1324
|
+
if (thinkingLevel == null) {
|
|
1325
|
+
return void 0;
|
|
1326
|
+
}
|
|
1327
|
+
return { thinkingLevel };
|
|
1328
|
+
}
|
|
1329
|
+
function resolveGemini25ThinkingConfig({
|
|
1330
|
+
reasoning,
|
|
1331
|
+
modelId,
|
|
1332
|
+
warnings
|
|
1333
|
+
}) {
|
|
1334
|
+
if (reasoning === "none") {
|
|
1335
|
+
return { thinkingBudget: 0 };
|
|
1336
|
+
}
|
|
1337
|
+
const thinkingBudget = mapReasoningToProviderBudget({
|
|
1338
|
+
reasoning,
|
|
1339
|
+
maxOutputTokens: getMaxOutputTokensForGemini25Model(),
|
|
1340
|
+
maxReasoningBudget: getMaxThinkingTokensForGemini25Model(modelId),
|
|
1341
|
+
minReasoningBudget: 0,
|
|
1342
|
+
warnings
|
|
1343
|
+
});
|
|
1344
|
+
if (thinkingBudget == null) {
|
|
1345
|
+
return void 0;
|
|
1346
|
+
}
|
|
1347
|
+
return { thinkingBudget };
|
|
1348
|
+
}
|
|
1270
1349
|
function getToolCallsFromParts({
|
|
1271
1350
|
parts,
|
|
1272
1351
|
generateId: generateId2,
|