@ai-sdk/google 3.0.99 → 3.0.100
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 +6 -0
- package/dist/index.js +34 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -21
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +33 -20
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +33 -20
- package/dist/internal/index.mjs.map +1 -1
- package/docs/15-google-generative-ai.mdx +16 -6
- package/package.json +1 -1
- package/src/google-generative-ai-language-model.ts +4 -4
- package/src/google-model-capabilities.ts +44 -0
- package/src/google-prepare-tools.ts +11 -23
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.100" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -963,6 +963,27 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
963
963
|
)
|
|
964
964
|
);
|
|
965
965
|
|
|
966
|
+
// src/google-model-capabilities.ts
|
|
967
|
+
var gemini1ModelPattern = /(^|\/)gemini-1(?:[.-]|$)/i;
|
|
968
|
+
var gemini2ModelPattern = /(^|\/)gemini-2(?:[.-]|$)/i;
|
|
969
|
+
var gemini25ModelPattern = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
|
|
970
|
+
var geminiModelPattern = /(^|\/)gemini-/i;
|
|
971
|
+
function isKnownPreGemini2Model(modelId) {
|
|
972
|
+
return gemini1ModelPattern.test(modelId) || /(^|\/)gemini-pro(?:-vision)?$/i.test(modelId) || /(^|\/)gemini-robotics-er-1\.5(?:[.-]|$)/i.test(modelId);
|
|
973
|
+
}
|
|
974
|
+
function getGoogleModelCapabilities(modelId) {
|
|
975
|
+
const isGeminiModel2 = geminiModelPattern.test(modelId);
|
|
976
|
+
const isGemini2Model = gemini2ModelPattern.test(modelId);
|
|
977
|
+
const isKnownPreGemini2 = isKnownPreGemini2Model(modelId);
|
|
978
|
+
const isKnownOlderModel = isKnownPreGemini2 || isGemini2Model;
|
|
979
|
+
const usesGemini3Features = isGeminiModel2 && !isKnownOlderModel;
|
|
980
|
+
return {
|
|
981
|
+
supportsGemini2Tools: isGeminiModel2 && !isKnownPreGemini2 || modelId.toLowerCase().includes("nano-banana"),
|
|
982
|
+
supportsFileSearch: gemini25ModelPattern.test(modelId) || usesGemini3Features,
|
|
983
|
+
usesGemini3Features
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
|
|
966
987
|
// src/google-prepare-tools.ts
|
|
967
988
|
var import_provider3 = require("@ai-sdk/provider");
|
|
968
989
|
function prepareTools({
|
|
@@ -974,20 +995,13 @@ function prepareTools({
|
|
|
974
995
|
var _a, _b;
|
|
975
996
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
976
997
|
const toolWarnings = [];
|
|
977
|
-
const
|
|
978
|
-
"gemini-flash-latest",
|
|
979
|
-
"gemini-flash-lite-latest",
|
|
980
|
-
"gemini-pro-latest"
|
|
981
|
-
].some((id) => id === modelId);
|
|
982
|
-
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
|
|
983
|
-
const isGemini3orNewer = modelId.includes("gemini-3");
|
|
984
|
-
const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
|
|
998
|
+
const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
985
999
|
if (tools == null) {
|
|
986
1000
|
return { tools: void 0, toolConfig: void 0, toolWarnings };
|
|
987
1001
|
}
|
|
988
1002
|
const hasFunctionTools = tools.some((tool) => tool.type === "function");
|
|
989
1003
|
const hasProviderTools = tools.some((tool) => tool.type === "provider");
|
|
990
|
-
if (hasFunctionTools && hasProviderTools && !
|
|
1004
|
+
if (hasFunctionTools && hasProviderTools && !usesGemini3Features) {
|
|
991
1005
|
toolWarnings.push({
|
|
992
1006
|
type: "unsupported",
|
|
993
1007
|
feature: `combination of function and provider-defined tools`
|
|
@@ -999,7 +1013,7 @@ function prepareTools({
|
|
|
999
1013
|
ProviderTools.forEach((tool) => {
|
|
1000
1014
|
switch (tool.id) {
|
|
1001
1015
|
case "google.google_search":
|
|
1002
|
-
if (
|
|
1016
|
+
if (supportsGemini2Tools) {
|
|
1003
1017
|
googleTools2.push({ googleSearch: { ...tool.args } });
|
|
1004
1018
|
} else {
|
|
1005
1019
|
toolWarnings.push({
|
|
@@ -1010,7 +1024,7 @@ function prepareTools({
|
|
|
1010
1024
|
}
|
|
1011
1025
|
break;
|
|
1012
1026
|
case "google.enterprise_web_search":
|
|
1013
|
-
if (
|
|
1027
|
+
if (supportsGemini2Tools) {
|
|
1014
1028
|
googleTools2.push({ enterpriseWebSearch: {} });
|
|
1015
1029
|
} else {
|
|
1016
1030
|
toolWarnings.push({
|
|
@@ -1021,7 +1035,7 @@ function prepareTools({
|
|
|
1021
1035
|
}
|
|
1022
1036
|
break;
|
|
1023
1037
|
case "google.url_context":
|
|
1024
|
-
if (
|
|
1038
|
+
if (supportsGemini2Tools) {
|
|
1025
1039
|
googleTools2.push({ urlContext: {} });
|
|
1026
1040
|
} else {
|
|
1027
1041
|
toolWarnings.push({
|
|
@@ -1032,7 +1046,7 @@ function prepareTools({
|
|
|
1032
1046
|
}
|
|
1033
1047
|
break;
|
|
1034
1048
|
case "google.code_execution":
|
|
1035
|
-
if (
|
|
1049
|
+
if (supportsGemini2Tools) {
|
|
1036
1050
|
googleTools2.push({ codeExecution: {} });
|
|
1037
1051
|
} else {
|
|
1038
1052
|
toolWarnings.push({
|
|
@@ -1054,7 +1068,7 @@ function prepareTools({
|
|
|
1054
1068
|
}
|
|
1055
1069
|
break;
|
|
1056
1070
|
case "google.vertex_rag_store":
|
|
1057
|
-
if (
|
|
1071
|
+
if (supportsGemini2Tools) {
|
|
1058
1072
|
googleTools2.push({
|
|
1059
1073
|
retrieval: {
|
|
1060
1074
|
vertex_rag_store: {
|
|
@@ -1074,7 +1088,7 @@ function prepareTools({
|
|
|
1074
1088
|
}
|
|
1075
1089
|
break;
|
|
1076
1090
|
case "google.google_maps":
|
|
1077
|
-
if (
|
|
1091
|
+
if (supportsGemini2Tools) {
|
|
1078
1092
|
googleTools2.push({ googleMaps: {} });
|
|
1079
1093
|
} else {
|
|
1080
1094
|
toolWarnings.push({
|
|
@@ -1092,7 +1106,7 @@ function prepareTools({
|
|
|
1092
1106
|
break;
|
|
1093
1107
|
}
|
|
1094
1108
|
});
|
|
1095
|
-
if (hasFunctionTools &&
|
|
1109
|
+
if (hasFunctionTools && usesGemini3Features && googleTools2.length > 0) {
|
|
1096
1110
|
const functionDeclarations2 = [];
|
|
1097
1111
|
for (const tool of tools) {
|
|
1098
1112
|
if (tool.type === "function") {
|
|
@@ -1589,15 +1603,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1589
1603
|
}
|
|
1590
1604
|
}
|
|
1591
1605
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1592
|
-
const
|
|
1593
|
-
const supportsFunctionResponseParts = isGemini3Model;
|
|
1606
|
+
const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
|
|
1594
1607
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
|
|
1595
1608
|
prompt,
|
|
1596
1609
|
{
|
|
1597
1610
|
isGemmaModel,
|
|
1598
|
-
isGemini3Model,
|
|
1611
|
+
isGemini3Model: usesGemini3Features,
|
|
1599
1612
|
providerOptionsName,
|
|
1600
|
-
supportsFunctionResponseParts,
|
|
1613
|
+
supportsFunctionResponseParts: usesGemini3Features,
|
|
1601
1614
|
onWarning: (warning) => warnings.push(warning)
|
|
1602
1615
|
}
|
|
1603
1616
|
);
|