@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/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 ? "3.0.99" : "0.0.0-test";
10
+ var VERSION = true ? "3.0.100" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -972,6 +972,27 @@ var googleLanguageModelOptions = lazySchema4(
972
972
  )
973
973
  );
974
974
 
975
+ // src/google-model-capabilities.ts
976
+ var gemini1ModelPattern = /(^|\/)gemini-1(?:[.-]|$)/i;
977
+ var gemini2ModelPattern = /(^|\/)gemini-2(?:[.-]|$)/i;
978
+ var gemini25ModelPattern = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
979
+ var geminiModelPattern = /(^|\/)gemini-/i;
980
+ function isKnownPreGemini2Model(modelId) {
981
+ return gemini1ModelPattern.test(modelId) || /(^|\/)gemini-pro(?:-vision)?$/i.test(modelId) || /(^|\/)gemini-robotics-er-1\.5(?:[.-]|$)/i.test(modelId);
982
+ }
983
+ function getGoogleModelCapabilities(modelId) {
984
+ const isGeminiModel2 = geminiModelPattern.test(modelId);
985
+ const isGemini2Model = gemini2ModelPattern.test(modelId);
986
+ const isKnownPreGemini2 = isKnownPreGemini2Model(modelId);
987
+ const isKnownOlderModel = isKnownPreGemini2 || isGemini2Model;
988
+ const usesGemini3Features = isGeminiModel2 && !isKnownOlderModel;
989
+ return {
990
+ supportsGemini2Tools: isGeminiModel2 && !isKnownPreGemini2 || modelId.toLowerCase().includes("nano-banana"),
991
+ supportsFileSearch: gemini25ModelPattern.test(modelId) || usesGemini3Features,
992
+ usesGemini3Features
993
+ };
994
+ }
995
+
975
996
  // src/google-prepare-tools.ts
976
997
  import {
977
998
  UnsupportedFunctionalityError as UnsupportedFunctionalityError2
@@ -985,20 +1006,13 @@ function prepareTools({
985
1006
  var _a, _b;
986
1007
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
987
1008
  const toolWarnings = [];
988
- const isLatest = [
989
- "gemini-flash-latest",
990
- "gemini-flash-lite-latest",
991
- "gemini-pro-latest"
992
- ].some((id) => id === modelId);
993
- const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
994
- const isGemini3orNewer = modelId.includes("gemini-3");
995
- const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
1009
+ const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
996
1010
  if (tools == null) {
997
1011
  return { tools: void 0, toolConfig: void 0, toolWarnings };
998
1012
  }
999
1013
  const hasFunctionTools = tools.some((tool) => tool.type === "function");
1000
1014
  const hasProviderTools = tools.some((tool) => tool.type === "provider");
1001
- if (hasFunctionTools && hasProviderTools && !isGemini3orNewer) {
1015
+ if (hasFunctionTools && hasProviderTools && !usesGemini3Features) {
1002
1016
  toolWarnings.push({
1003
1017
  type: "unsupported",
1004
1018
  feature: `combination of function and provider-defined tools`
@@ -1010,7 +1024,7 @@ function prepareTools({
1010
1024
  ProviderTools.forEach((tool) => {
1011
1025
  switch (tool.id) {
1012
1026
  case "google.google_search":
1013
- if (isGemini2orNewer) {
1027
+ if (supportsGemini2Tools) {
1014
1028
  googleTools2.push({ googleSearch: { ...tool.args } });
1015
1029
  } else {
1016
1030
  toolWarnings.push({
@@ -1021,7 +1035,7 @@ function prepareTools({
1021
1035
  }
1022
1036
  break;
1023
1037
  case "google.enterprise_web_search":
1024
- if (isGemini2orNewer) {
1038
+ if (supportsGemini2Tools) {
1025
1039
  googleTools2.push({ enterpriseWebSearch: {} });
1026
1040
  } else {
1027
1041
  toolWarnings.push({
@@ -1032,7 +1046,7 @@ function prepareTools({
1032
1046
  }
1033
1047
  break;
1034
1048
  case "google.url_context":
1035
- if (isGemini2orNewer) {
1049
+ if (supportsGemini2Tools) {
1036
1050
  googleTools2.push({ urlContext: {} });
1037
1051
  } else {
1038
1052
  toolWarnings.push({
@@ -1043,7 +1057,7 @@ function prepareTools({
1043
1057
  }
1044
1058
  break;
1045
1059
  case "google.code_execution":
1046
- if (isGemini2orNewer) {
1060
+ if (supportsGemini2Tools) {
1047
1061
  googleTools2.push({ codeExecution: {} });
1048
1062
  } else {
1049
1063
  toolWarnings.push({
@@ -1065,7 +1079,7 @@ function prepareTools({
1065
1079
  }
1066
1080
  break;
1067
1081
  case "google.vertex_rag_store":
1068
- if (isGemini2orNewer) {
1082
+ if (supportsGemini2Tools) {
1069
1083
  googleTools2.push({
1070
1084
  retrieval: {
1071
1085
  vertex_rag_store: {
@@ -1085,7 +1099,7 @@ function prepareTools({
1085
1099
  }
1086
1100
  break;
1087
1101
  case "google.google_maps":
1088
- if (isGemini2orNewer) {
1102
+ if (supportsGemini2Tools) {
1089
1103
  googleTools2.push({ googleMaps: {} });
1090
1104
  } else {
1091
1105
  toolWarnings.push({
@@ -1103,7 +1117,7 @@ function prepareTools({
1103
1117
  break;
1104
1118
  }
1105
1119
  });
1106
- if (hasFunctionTools && isGemini3orNewer && googleTools2.length > 0) {
1120
+ if (hasFunctionTools && usesGemini3Features && googleTools2.length > 0) {
1107
1121
  const functionDeclarations2 = [];
1108
1122
  for (const tool of tools) {
1109
1123
  if (tool.type === "function") {
@@ -1600,15 +1614,14 @@ var GoogleGenerativeAILanguageModel = class {
1600
1614
  }
1601
1615
  }
1602
1616
  const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
1603
- const isGemini3Model = /^gemini-3[.-]/.test(this.modelId);
1604
- const supportsFunctionResponseParts = isGemini3Model;
1617
+ const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
1605
1618
  const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
1606
1619
  prompt,
1607
1620
  {
1608
1621
  isGemmaModel,
1609
- isGemini3Model,
1622
+ isGemini3Model: usesGemini3Features,
1610
1623
  providerOptionsName,
1611
- supportsFunctionResponseParts,
1624
+ supportsFunctionResponseParts: usesGemini3Features,
1612
1625
  onWarning: (warning) => warnings.push(warning)
1613
1626
  }
1614
1627
  );