@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/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ 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.14" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -238,7 +238,10 @@ import {
|
|
|
238
238
|
createEventSourceResponseHandler,
|
|
239
239
|
createJsonResponseHandler as createJsonResponseHandler2,
|
|
240
240
|
generateId,
|
|
241
|
+
isCustomReasoning,
|
|
241
242
|
lazySchema as lazySchema5,
|
|
243
|
+
mapReasoningToProviderBudget,
|
|
244
|
+
mapReasoningToProviderEffort,
|
|
242
245
|
parseProviderOptions as parseProviderOptions2,
|
|
243
246
|
postJsonToApi as postJsonToApi2,
|
|
244
247
|
resolve as resolve2,
|
|
@@ -985,6 +988,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
985
988
|
seed,
|
|
986
989
|
tools,
|
|
987
990
|
toolChoice,
|
|
991
|
+
reasoning,
|
|
988
992
|
providerOptions
|
|
989
993
|
}) {
|
|
990
994
|
var _a;
|
|
@@ -1024,6 +1028,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1024
1028
|
toolChoice,
|
|
1025
1029
|
modelId: this.modelId
|
|
1026
1030
|
});
|
|
1031
|
+
const resolvedThinking = resolveThinkingConfig({
|
|
1032
|
+
reasoning,
|
|
1033
|
+
modelId: this.modelId,
|
|
1034
|
+
warnings
|
|
1035
|
+
});
|
|
1036
|
+
const thinkingConfig = (googleOptions == null ? void 0 : googleOptions.thinkingConfig) || resolvedThinking ? { ...resolvedThinking, ...googleOptions == null ? void 0 : googleOptions.thinkingConfig } : void 0;
|
|
1027
1037
|
return {
|
|
1028
1038
|
args: {
|
|
1029
1039
|
generationConfig: {
|
|
@@ -1047,7 +1057,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1047
1057
|
},
|
|
1048
1058
|
// provider options:
|
|
1049
1059
|
responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
|
|
1050
|
-
thinkingConfig
|
|
1060
|
+
thinkingConfig,
|
|
1051
1061
|
...(googleOptions == null ? void 0 : googleOptions.mediaResolution) && {
|
|
1052
1062
|
mediaResolution: googleOptions.mediaResolution
|
|
1053
1063
|
},
|
|
@@ -1478,6 +1488,75 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1478
1488
|
};
|
|
1479
1489
|
}
|
|
1480
1490
|
};
|
|
1491
|
+
function isGemini3Model(modelId) {
|
|
1492
|
+
return /gemini-3[\.\-]/i.test(modelId) || /gemini-3$/i.test(modelId);
|
|
1493
|
+
}
|
|
1494
|
+
function getMaxOutputTokensForGemini25Model() {
|
|
1495
|
+
return 65536;
|
|
1496
|
+
}
|
|
1497
|
+
function getMaxThinkingTokensForGemini25Model(modelId) {
|
|
1498
|
+
const id = modelId.toLowerCase();
|
|
1499
|
+
if (id.includes("2.5-pro") || id.includes("gemini-3-pro-image")) {
|
|
1500
|
+
return 32768;
|
|
1501
|
+
}
|
|
1502
|
+
return 24576;
|
|
1503
|
+
}
|
|
1504
|
+
function resolveThinkingConfig({
|
|
1505
|
+
reasoning,
|
|
1506
|
+
modelId,
|
|
1507
|
+
warnings
|
|
1508
|
+
}) {
|
|
1509
|
+
if (!isCustomReasoning(reasoning)) {
|
|
1510
|
+
return void 0;
|
|
1511
|
+
}
|
|
1512
|
+
if (isGemini3Model(modelId) && !modelId.includes("gemini-3-pro-image")) {
|
|
1513
|
+
return resolveGemini3ThinkingConfig({ reasoning, warnings });
|
|
1514
|
+
}
|
|
1515
|
+
return resolveGemini25ThinkingConfig({ reasoning, modelId, warnings });
|
|
1516
|
+
}
|
|
1517
|
+
function resolveGemini3ThinkingConfig({
|
|
1518
|
+
reasoning,
|
|
1519
|
+
warnings
|
|
1520
|
+
}) {
|
|
1521
|
+
if (reasoning === "none") {
|
|
1522
|
+
return { thinkingLevel: "minimal" };
|
|
1523
|
+
}
|
|
1524
|
+
const thinkingLevel = mapReasoningToProviderEffort({
|
|
1525
|
+
reasoning,
|
|
1526
|
+
effortMap: {
|
|
1527
|
+
minimal: "minimal",
|
|
1528
|
+
low: "low",
|
|
1529
|
+
medium: "medium",
|
|
1530
|
+
high: "high",
|
|
1531
|
+
xhigh: "high"
|
|
1532
|
+
},
|
|
1533
|
+
warnings
|
|
1534
|
+
});
|
|
1535
|
+
if (thinkingLevel == null) {
|
|
1536
|
+
return void 0;
|
|
1537
|
+
}
|
|
1538
|
+
return { thinkingLevel };
|
|
1539
|
+
}
|
|
1540
|
+
function resolveGemini25ThinkingConfig({
|
|
1541
|
+
reasoning,
|
|
1542
|
+
modelId,
|
|
1543
|
+
warnings
|
|
1544
|
+
}) {
|
|
1545
|
+
if (reasoning === "none") {
|
|
1546
|
+
return { thinkingBudget: 0 };
|
|
1547
|
+
}
|
|
1548
|
+
const thinkingBudget = mapReasoningToProviderBudget({
|
|
1549
|
+
reasoning,
|
|
1550
|
+
maxOutputTokens: getMaxOutputTokensForGemini25Model(),
|
|
1551
|
+
maxReasoningBudget: getMaxThinkingTokensForGemini25Model(modelId),
|
|
1552
|
+
minReasoningBudget: 0,
|
|
1553
|
+
warnings
|
|
1554
|
+
});
|
|
1555
|
+
if (thinkingBudget == null) {
|
|
1556
|
+
return void 0;
|
|
1557
|
+
}
|
|
1558
|
+
return { thinkingBudget };
|
|
1559
|
+
}
|
|
1481
1560
|
function getToolCallsFromParts({
|
|
1482
1561
|
parts,
|
|
1483
1562
|
generateId: generateId3,
|