@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/dist/internal/index.mjs
CHANGED
|
@@ -755,6 +755,27 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
755
755
|
)
|
|
756
756
|
);
|
|
757
757
|
|
|
758
|
+
// src/google-model-capabilities.ts
|
|
759
|
+
var gemini1ModelPattern = /(^|\/)gemini-1(?:[.-]|$)/i;
|
|
760
|
+
var gemini2ModelPattern = /(^|\/)gemini-2(?:[.-]|$)/i;
|
|
761
|
+
var gemini25ModelPattern = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
|
|
762
|
+
var geminiModelPattern = /(^|\/)gemini-/i;
|
|
763
|
+
function isKnownPreGemini2Model(modelId) {
|
|
764
|
+
return gemini1ModelPattern.test(modelId) || /(^|\/)gemini-pro(?:-vision)?$/i.test(modelId) || /(^|\/)gemini-robotics-er-1\.5(?:[.-]|$)/i.test(modelId);
|
|
765
|
+
}
|
|
766
|
+
function getGoogleModelCapabilities(modelId) {
|
|
767
|
+
const isGeminiModel = geminiModelPattern.test(modelId);
|
|
768
|
+
const isGemini2Model = gemini2ModelPattern.test(modelId);
|
|
769
|
+
const isKnownPreGemini2 = isKnownPreGemini2Model(modelId);
|
|
770
|
+
const isKnownOlderModel = isKnownPreGemini2 || isGemini2Model;
|
|
771
|
+
const usesGemini3Features = isGeminiModel && !isKnownOlderModel;
|
|
772
|
+
return {
|
|
773
|
+
supportsGemini2Tools: isGeminiModel && !isKnownPreGemini2 || modelId.toLowerCase().includes("nano-banana"),
|
|
774
|
+
supportsFileSearch: gemini25ModelPattern.test(modelId) || usesGemini3Features,
|
|
775
|
+
usesGemini3Features
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
|
|
758
779
|
// src/google-prepare-tools.ts
|
|
759
780
|
import {
|
|
760
781
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
@@ -768,20 +789,13 @@ function prepareTools({
|
|
|
768
789
|
var _a, _b;
|
|
769
790
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
770
791
|
const toolWarnings = [];
|
|
771
|
-
const
|
|
772
|
-
"gemini-flash-latest",
|
|
773
|
-
"gemini-flash-lite-latest",
|
|
774
|
-
"gemini-pro-latest"
|
|
775
|
-
].some((id) => id === modelId);
|
|
776
|
-
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
|
|
777
|
-
const isGemini3orNewer = modelId.includes("gemini-3");
|
|
778
|
-
const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
|
|
792
|
+
const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
779
793
|
if (tools == null) {
|
|
780
794
|
return { tools: void 0, toolConfig: void 0, toolWarnings };
|
|
781
795
|
}
|
|
782
796
|
const hasFunctionTools = tools.some((tool) => tool.type === "function");
|
|
783
797
|
const hasProviderTools = tools.some((tool) => tool.type === "provider");
|
|
784
|
-
if (hasFunctionTools && hasProviderTools && !
|
|
798
|
+
if (hasFunctionTools && hasProviderTools && !usesGemini3Features) {
|
|
785
799
|
toolWarnings.push({
|
|
786
800
|
type: "unsupported",
|
|
787
801
|
feature: `combination of function and provider-defined tools`
|
|
@@ -793,7 +807,7 @@ function prepareTools({
|
|
|
793
807
|
ProviderTools.forEach((tool) => {
|
|
794
808
|
switch (tool.id) {
|
|
795
809
|
case "google.google_search":
|
|
796
|
-
if (
|
|
810
|
+
if (supportsGemini2Tools) {
|
|
797
811
|
googleTools2.push({ googleSearch: { ...tool.args } });
|
|
798
812
|
} else {
|
|
799
813
|
toolWarnings.push({
|
|
@@ -804,7 +818,7 @@ function prepareTools({
|
|
|
804
818
|
}
|
|
805
819
|
break;
|
|
806
820
|
case "google.enterprise_web_search":
|
|
807
|
-
if (
|
|
821
|
+
if (supportsGemini2Tools) {
|
|
808
822
|
googleTools2.push({ enterpriseWebSearch: {} });
|
|
809
823
|
} else {
|
|
810
824
|
toolWarnings.push({
|
|
@@ -815,7 +829,7 @@ function prepareTools({
|
|
|
815
829
|
}
|
|
816
830
|
break;
|
|
817
831
|
case "google.url_context":
|
|
818
|
-
if (
|
|
832
|
+
if (supportsGemini2Tools) {
|
|
819
833
|
googleTools2.push({ urlContext: {} });
|
|
820
834
|
} else {
|
|
821
835
|
toolWarnings.push({
|
|
@@ -826,7 +840,7 @@ function prepareTools({
|
|
|
826
840
|
}
|
|
827
841
|
break;
|
|
828
842
|
case "google.code_execution":
|
|
829
|
-
if (
|
|
843
|
+
if (supportsGemini2Tools) {
|
|
830
844
|
googleTools2.push({ codeExecution: {} });
|
|
831
845
|
} else {
|
|
832
846
|
toolWarnings.push({
|
|
@@ -848,7 +862,7 @@ function prepareTools({
|
|
|
848
862
|
}
|
|
849
863
|
break;
|
|
850
864
|
case "google.vertex_rag_store":
|
|
851
|
-
if (
|
|
865
|
+
if (supportsGemini2Tools) {
|
|
852
866
|
googleTools2.push({
|
|
853
867
|
retrieval: {
|
|
854
868
|
vertex_rag_store: {
|
|
@@ -868,7 +882,7 @@ function prepareTools({
|
|
|
868
882
|
}
|
|
869
883
|
break;
|
|
870
884
|
case "google.google_maps":
|
|
871
|
-
if (
|
|
885
|
+
if (supportsGemini2Tools) {
|
|
872
886
|
googleTools2.push({ googleMaps: {} });
|
|
873
887
|
} else {
|
|
874
888
|
toolWarnings.push({
|
|
@@ -886,7 +900,7 @@ function prepareTools({
|
|
|
886
900
|
break;
|
|
887
901
|
}
|
|
888
902
|
});
|
|
889
|
-
if (hasFunctionTools &&
|
|
903
|
+
if (hasFunctionTools && usesGemini3Features && googleTools2.length > 0) {
|
|
890
904
|
const functionDeclarations2 = [];
|
|
891
905
|
for (const tool of tools) {
|
|
892
906
|
if (tool.type === "function") {
|
|
@@ -1383,15 +1397,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1383
1397
|
}
|
|
1384
1398
|
}
|
|
1385
1399
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1386
|
-
const
|
|
1387
|
-
const supportsFunctionResponseParts = isGemini3Model;
|
|
1400
|
+
const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
|
|
1388
1401
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
|
|
1389
1402
|
prompt,
|
|
1390
1403
|
{
|
|
1391
1404
|
isGemmaModel,
|
|
1392
|
-
isGemini3Model,
|
|
1405
|
+
isGemini3Model: usesGemini3Features,
|
|
1393
1406
|
providerOptionsName,
|
|
1394
|
-
supportsFunctionResponseParts,
|
|
1407
|
+
supportsFunctionResponseParts: usesGemini3Features,
|
|
1395
1408
|
onWarning: (warning) => warnings.push(warning)
|
|
1396
1409
|
}
|
|
1397
1410
|
);
|