@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.js
CHANGED
|
@@ -785,6 +785,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
785
785
|
seed,
|
|
786
786
|
tools,
|
|
787
787
|
toolChoice,
|
|
788
|
+
reasoning,
|
|
788
789
|
providerOptions
|
|
789
790
|
}) {
|
|
790
791
|
var _a;
|
|
@@ -824,6 +825,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
824
825
|
toolChoice,
|
|
825
826
|
modelId: this.modelId
|
|
826
827
|
});
|
|
828
|
+
const resolvedThinking = resolveThinkingConfig({
|
|
829
|
+
reasoning,
|
|
830
|
+
modelId: this.modelId,
|
|
831
|
+
warnings
|
|
832
|
+
});
|
|
833
|
+
const thinkingConfig = (googleOptions == null ? void 0 : googleOptions.thinkingConfig) || resolvedThinking ? { ...resolvedThinking, ...googleOptions == null ? void 0 : googleOptions.thinkingConfig } : void 0;
|
|
827
834
|
return {
|
|
828
835
|
args: {
|
|
829
836
|
generationConfig: {
|
|
@@ -847,7 +854,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
847
854
|
},
|
|
848
855
|
// provider options:
|
|
849
856
|
responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
|
|
850
|
-
thinkingConfig
|
|
857
|
+
thinkingConfig,
|
|
851
858
|
...(googleOptions == null ? void 0 : googleOptions.mediaResolution) && {
|
|
852
859
|
mediaResolution: googleOptions.mediaResolution
|
|
853
860
|
},
|
|
@@ -1278,6 +1285,75 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1278
1285
|
};
|
|
1279
1286
|
}
|
|
1280
1287
|
};
|
|
1288
|
+
function isGemini3Model(modelId) {
|
|
1289
|
+
return /gemini-3[\.\-]/i.test(modelId) || /gemini-3$/i.test(modelId);
|
|
1290
|
+
}
|
|
1291
|
+
function getMaxOutputTokensForGemini25Model() {
|
|
1292
|
+
return 65536;
|
|
1293
|
+
}
|
|
1294
|
+
function getMaxThinkingTokensForGemini25Model(modelId) {
|
|
1295
|
+
const id = modelId.toLowerCase();
|
|
1296
|
+
if (id.includes("2.5-pro") || id.includes("gemini-3-pro-image")) {
|
|
1297
|
+
return 32768;
|
|
1298
|
+
}
|
|
1299
|
+
return 24576;
|
|
1300
|
+
}
|
|
1301
|
+
function resolveThinkingConfig({
|
|
1302
|
+
reasoning,
|
|
1303
|
+
modelId,
|
|
1304
|
+
warnings
|
|
1305
|
+
}) {
|
|
1306
|
+
if (!(0, import_provider_utils4.isCustomReasoning)(reasoning)) {
|
|
1307
|
+
return void 0;
|
|
1308
|
+
}
|
|
1309
|
+
if (isGemini3Model(modelId) && !modelId.includes("gemini-3-pro-image")) {
|
|
1310
|
+
return resolveGemini3ThinkingConfig({ reasoning, warnings });
|
|
1311
|
+
}
|
|
1312
|
+
return resolveGemini25ThinkingConfig({ reasoning, modelId, warnings });
|
|
1313
|
+
}
|
|
1314
|
+
function resolveGemini3ThinkingConfig({
|
|
1315
|
+
reasoning,
|
|
1316
|
+
warnings
|
|
1317
|
+
}) {
|
|
1318
|
+
if (reasoning === "none") {
|
|
1319
|
+
return { thinkingLevel: "minimal" };
|
|
1320
|
+
}
|
|
1321
|
+
const thinkingLevel = (0, import_provider_utils4.mapReasoningToProviderEffort)({
|
|
1322
|
+
reasoning,
|
|
1323
|
+
effortMap: {
|
|
1324
|
+
minimal: "minimal",
|
|
1325
|
+
low: "low",
|
|
1326
|
+
medium: "medium",
|
|
1327
|
+
high: "high",
|
|
1328
|
+
xhigh: "high"
|
|
1329
|
+
},
|
|
1330
|
+
warnings
|
|
1331
|
+
});
|
|
1332
|
+
if (thinkingLevel == null) {
|
|
1333
|
+
return void 0;
|
|
1334
|
+
}
|
|
1335
|
+
return { thinkingLevel };
|
|
1336
|
+
}
|
|
1337
|
+
function resolveGemini25ThinkingConfig({
|
|
1338
|
+
reasoning,
|
|
1339
|
+
modelId,
|
|
1340
|
+
warnings
|
|
1341
|
+
}) {
|
|
1342
|
+
if (reasoning === "none") {
|
|
1343
|
+
return { thinkingBudget: 0 };
|
|
1344
|
+
}
|
|
1345
|
+
const thinkingBudget = (0, import_provider_utils4.mapReasoningToProviderBudget)({
|
|
1346
|
+
reasoning,
|
|
1347
|
+
maxOutputTokens: getMaxOutputTokensForGemini25Model(),
|
|
1348
|
+
maxReasoningBudget: getMaxThinkingTokensForGemini25Model(modelId),
|
|
1349
|
+
minReasoningBudget: 0,
|
|
1350
|
+
warnings
|
|
1351
|
+
});
|
|
1352
|
+
if (thinkingBudget == null) {
|
|
1353
|
+
return void 0;
|
|
1354
|
+
}
|
|
1355
|
+
return { thinkingBudget };
|
|
1356
|
+
}
|
|
1281
1357
|
function getToolCallsFromParts({
|
|
1282
1358
|
parts,
|
|
1283
1359
|
generateId: generateId2,
|