@google/genai 1.41.0 → 1.43.0
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/genai.d.ts +335 -170
- package/dist/index.cjs +399 -110
- package/dist/index.mjs +400 -111
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +399 -110
- package/dist/node/index.mjs +400 -111
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +335 -170
- package/dist/tokenizer/node.cjs +60 -32
- package/dist/tokenizer/node.d.ts +48 -3
- package/dist/tokenizer/node.mjs +60 -32
- package/dist/tokenizer/node.mjs.map +1 -1
- package/dist/web/index.mjs +400 -111
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +335 -170
- package/package.json +2 -2
package/dist/node/index.cjs
CHANGED
|
@@ -704,6 +704,38 @@ exports.Type = void 0;
|
|
|
704
704
|
*/
|
|
705
705
|
Type["NULL"] = "NULL";
|
|
706
706
|
})(exports.Type || (exports.Type = {}));
|
|
707
|
+
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
708
|
+
exports.PhishBlockThreshold = void 0;
|
|
709
|
+
(function (PhishBlockThreshold) {
|
|
710
|
+
/**
|
|
711
|
+
* Defaults to unspecified.
|
|
712
|
+
*/
|
|
713
|
+
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
714
|
+
/**
|
|
715
|
+
* Blocks Low and above confidence URL that is risky.
|
|
716
|
+
*/
|
|
717
|
+
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
718
|
+
/**
|
|
719
|
+
* Blocks Medium and above confidence URL that is risky.
|
|
720
|
+
*/
|
|
721
|
+
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
722
|
+
/**
|
|
723
|
+
* Blocks High and above confidence URL that is risky.
|
|
724
|
+
*/
|
|
725
|
+
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
726
|
+
/**
|
|
727
|
+
* Blocks Higher and above confidence URL that is risky.
|
|
728
|
+
*/
|
|
729
|
+
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
730
|
+
/**
|
|
731
|
+
* Blocks Very high and above confidence URL that is risky.
|
|
732
|
+
*/
|
|
733
|
+
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
734
|
+
/**
|
|
735
|
+
* Blocks Extremely high confidence URL that is risky.
|
|
736
|
+
*/
|
|
737
|
+
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
738
|
+
})(exports.PhishBlockThreshold || (exports.PhishBlockThreshold = {}));
|
|
707
739
|
/** The API spec that the external API implements. This enum is not supported in Gemini API. */
|
|
708
740
|
exports.ApiSpec = void 0;
|
|
709
741
|
(function (ApiSpec) {
|
|
@@ -774,38 +806,6 @@ exports.HttpElementLocation = void 0;
|
|
|
774
806
|
*/
|
|
775
807
|
HttpElementLocation["HTTP_IN_COOKIE"] = "HTTP_IN_COOKIE";
|
|
776
808
|
})(exports.HttpElementLocation || (exports.HttpElementLocation = {}));
|
|
777
|
-
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
778
|
-
exports.PhishBlockThreshold = void 0;
|
|
779
|
-
(function (PhishBlockThreshold) {
|
|
780
|
-
/**
|
|
781
|
-
* Defaults to unspecified.
|
|
782
|
-
*/
|
|
783
|
-
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
784
|
-
/**
|
|
785
|
-
* Blocks Low and above confidence URL that is risky.
|
|
786
|
-
*/
|
|
787
|
-
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
788
|
-
/**
|
|
789
|
-
* Blocks Medium and above confidence URL that is risky.
|
|
790
|
-
*/
|
|
791
|
-
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
792
|
-
/**
|
|
793
|
-
* Blocks High and above confidence URL that is risky.
|
|
794
|
-
*/
|
|
795
|
-
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
796
|
-
/**
|
|
797
|
-
* Blocks Higher and above confidence URL that is risky.
|
|
798
|
-
*/
|
|
799
|
-
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
800
|
-
/**
|
|
801
|
-
* Blocks Very high and above confidence URL that is risky.
|
|
802
|
-
*/
|
|
803
|
-
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
804
|
-
/**
|
|
805
|
-
* Blocks Extremely high confidence URL that is risky.
|
|
806
|
-
*/
|
|
807
|
-
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
808
|
-
})(exports.PhishBlockThreshold || (exports.PhishBlockThreshold = {}));
|
|
809
809
|
/** Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This enum is not supported in Vertex AI. */
|
|
810
810
|
exports.Behavior = void 0;
|
|
811
811
|
(function (Behavior) {
|
|
@@ -1388,6 +1388,34 @@ exports.Environment = void 0;
|
|
|
1388
1388
|
*/
|
|
1389
1389
|
Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
|
|
1390
1390
|
})(exports.Environment || (exports.Environment = {}));
|
|
1391
|
+
/** Enum for controlling whether the model can generate images of prominent people (celebrities). */
|
|
1392
|
+
exports.ProminentPeople = void 0;
|
|
1393
|
+
(function (ProminentPeople) {
|
|
1394
|
+
/**
|
|
1395
|
+
* Unspecified value. The model will proceed with the default behavior, which is to allow generation of prominent people.
|
|
1396
|
+
*/
|
|
1397
|
+
ProminentPeople["PROMINENT_PEOPLE_UNSPECIFIED"] = "PROMINENT_PEOPLE_UNSPECIFIED";
|
|
1398
|
+
/**
|
|
1399
|
+
* Allows the model to generate images of prominent people.
|
|
1400
|
+
*/
|
|
1401
|
+
ProminentPeople["ALLOW_PROMINENT_PEOPLE"] = "ALLOW_PROMINENT_PEOPLE";
|
|
1402
|
+
/**
|
|
1403
|
+
* Prevents the model from generating images of prominent people.
|
|
1404
|
+
*/
|
|
1405
|
+
ProminentPeople["BLOCK_PROMINENT_PEOPLE"] = "BLOCK_PROMINENT_PEOPLE";
|
|
1406
|
+
})(exports.ProminentPeople || (exports.ProminentPeople = {}));
|
|
1407
|
+
/** Enum representing the Vertex embedding API to use. */
|
|
1408
|
+
exports.EmbeddingApiType = void 0;
|
|
1409
|
+
(function (EmbeddingApiType) {
|
|
1410
|
+
/**
|
|
1411
|
+
* predict API endpoint (default)
|
|
1412
|
+
*/
|
|
1413
|
+
EmbeddingApiType["PREDICT"] = "PREDICT";
|
|
1414
|
+
/**
|
|
1415
|
+
* embedContent API Endpoint
|
|
1416
|
+
*/
|
|
1417
|
+
EmbeddingApiType["EMBED_CONTENT"] = "EMBED_CONTENT";
|
|
1418
|
+
})(exports.EmbeddingApiType || (exports.EmbeddingApiType = {}));
|
|
1391
1419
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
1392
1420
|
exports.SafetyFilterLevel = void 0;
|
|
1393
1421
|
(function (SafetyFilterLevel) {
|
|
@@ -3419,6 +3447,10 @@ function tJobState(state) {
|
|
|
3419
3447
|
return stateString;
|
|
3420
3448
|
}
|
|
3421
3449
|
}
|
|
3450
|
+
function tIsVertexEmbedContentModel(model) {
|
|
3451
|
+
return ((model.includes('gemini') && model !== 'gemini-embedding-001') ||
|
|
3452
|
+
model.includes('maas'));
|
|
3453
|
+
}
|
|
3422
3454
|
|
|
3423
3455
|
/**
|
|
3424
3456
|
* @license
|
|
@@ -3730,16 +3762,16 @@ function candidateFromMldev$1(fromObject) {
|
|
|
3730
3762
|
if (fromFinishReason != null) {
|
|
3731
3763
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
3732
3764
|
}
|
|
3733
|
-
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
3734
|
-
if (fromAvgLogprobs != null) {
|
|
3735
|
-
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
3736
|
-
}
|
|
3737
3765
|
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
3738
3766
|
'groundingMetadata',
|
|
3739
3767
|
]);
|
|
3740
3768
|
if (fromGroundingMetadata != null) {
|
|
3741
3769
|
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
3742
3770
|
}
|
|
3771
|
+
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
3772
|
+
if (fromAvgLogprobs != null) {
|
|
3773
|
+
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
3774
|
+
}
|
|
3743
3775
|
const fromIndex = getValueByPath(fromObject, ['index']);
|
|
3744
3776
|
if (fromIndex != null) {
|
|
3745
3777
|
setValueByPath(toObject, ['index'], fromIndex);
|
|
@@ -4285,6 +4317,10 @@ function googleMapsToMldev$4(fromObject) {
|
|
|
4285
4317
|
}
|
|
4286
4318
|
function googleSearchToMldev$4(fromObject) {
|
|
4287
4319
|
const toObject = {};
|
|
4320
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
4321
|
+
if (fromSearchTypes != null) {
|
|
4322
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
4323
|
+
}
|
|
4288
4324
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
4289
4325
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
4290
4326
|
}
|
|
@@ -4312,6 +4348,9 @@ function imageConfigToMldev$1(fromObject) {
|
|
|
4312
4348
|
if (getValueByPath(fromObject, ['personGeneration']) !== undefined) {
|
|
4313
4349
|
throw new Error('personGeneration parameter is not supported in Gemini API.');
|
|
4314
4350
|
}
|
|
4351
|
+
if (getValueByPath(fromObject, ['prominentPeople']) !== undefined) {
|
|
4352
|
+
throw new Error('prominentPeople parameter is not supported in Gemini API.');
|
|
4353
|
+
}
|
|
4315
4354
|
if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
|
|
4316
4355
|
throw new Error('outputMimeType parameter is not supported in Gemini API.');
|
|
4317
4356
|
}
|
|
@@ -4568,6 +4607,10 @@ function toolToMldev$4(fromObject) {
|
|
|
4568
4607
|
if (fromFileSearch != null) {
|
|
4569
4608
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
4570
4609
|
}
|
|
4610
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4611
|
+
if (fromGoogleSearch != null) {
|
|
4612
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
4613
|
+
}
|
|
4571
4614
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4572
4615
|
'codeExecution',
|
|
4573
4616
|
]);
|
|
@@ -4593,10 +4636,6 @@ function toolToMldev$4(fromObject) {
|
|
|
4593
4636
|
if (fromGoogleMaps != null) {
|
|
4594
4637
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$4(fromGoogleMaps));
|
|
4595
4638
|
}
|
|
4596
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4597
|
-
if (fromGoogleSearch != null) {
|
|
4598
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
4599
|
-
}
|
|
4600
4639
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
4601
4640
|
'googleSearchRetrieval',
|
|
4602
4641
|
]);
|
|
@@ -4607,6 +4646,16 @@ function toolToMldev$4(fromObject) {
|
|
|
4607
4646
|
if (fromUrlContext != null) {
|
|
4608
4647
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
4609
4648
|
}
|
|
4649
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
4650
|
+
if (fromMcpServers != null) {
|
|
4651
|
+
let transformedList = fromMcpServers;
|
|
4652
|
+
if (Array.isArray(transformedList)) {
|
|
4653
|
+
transformedList = transformedList.map((item) => {
|
|
4654
|
+
return item;
|
|
4655
|
+
});
|
|
4656
|
+
}
|
|
4657
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
4658
|
+
}
|
|
4610
4659
|
return toObject;
|
|
4611
4660
|
}
|
|
4612
4661
|
|
|
@@ -5613,6 +5662,10 @@ function googleMapsToMldev$3(fromObject) {
|
|
|
5613
5662
|
}
|
|
5614
5663
|
function googleSearchToMldev$3(fromObject) {
|
|
5615
5664
|
const toObject = {};
|
|
5665
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
5666
|
+
if (fromSearchTypes != null) {
|
|
5667
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
5668
|
+
}
|
|
5616
5669
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
5617
5670
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
5618
5671
|
}
|
|
@@ -5812,6 +5865,10 @@ function toolToMldev$3(fromObject) {
|
|
|
5812
5865
|
if (fromFileSearch != null) {
|
|
5813
5866
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
5814
5867
|
}
|
|
5868
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5869
|
+
if (fromGoogleSearch != null) {
|
|
5870
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
5871
|
+
}
|
|
5815
5872
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5816
5873
|
'codeExecution',
|
|
5817
5874
|
]);
|
|
@@ -5837,10 +5894,6 @@ function toolToMldev$3(fromObject) {
|
|
|
5837
5894
|
if (fromGoogleMaps != null) {
|
|
5838
5895
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$3(fromGoogleMaps));
|
|
5839
5896
|
}
|
|
5840
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5841
|
-
if (fromGoogleSearch != null) {
|
|
5842
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
5843
|
-
}
|
|
5844
5897
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
5845
5898
|
'googleSearchRetrieval',
|
|
5846
5899
|
]);
|
|
@@ -5851,6 +5904,16 @@ function toolToMldev$3(fromObject) {
|
|
|
5851
5904
|
if (fromUrlContext != null) {
|
|
5852
5905
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
5853
5906
|
}
|
|
5907
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
5908
|
+
if (fromMcpServers != null) {
|
|
5909
|
+
let transformedList = fromMcpServers;
|
|
5910
|
+
if (Array.isArray(transformedList)) {
|
|
5911
|
+
transformedList = transformedList.map((item) => {
|
|
5912
|
+
return item;
|
|
5913
|
+
});
|
|
5914
|
+
}
|
|
5915
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
5916
|
+
}
|
|
5854
5917
|
return toObject;
|
|
5855
5918
|
}
|
|
5856
5919
|
function toolToVertex$2(fromObject) {
|
|
@@ -5866,6 +5929,10 @@ function toolToVertex$2(fromObject) {
|
|
|
5866
5929
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
5867
5930
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
5868
5931
|
}
|
|
5932
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5933
|
+
if (fromGoogleSearch != null) {
|
|
5934
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
5935
|
+
}
|
|
5869
5936
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5870
5937
|
'codeExecution',
|
|
5871
5938
|
]);
|
|
@@ -5894,10 +5961,6 @@ function toolToVertex$2(fromObject) {
|
|
|
5894
5961
|
if (fromGoogleMaps != null) {
|
|
5895
5962
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
5896
5963
|
}
|
|
5897
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5898
|
-
if (fromGoogleSearch != null) {
|
|
5899
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
5900
|
-
}
|
|
5901
5964
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
5902
5965
|
'googleSearchRetrieval',
|
|
5903
5966
|
]);
|
|
@@ -5908,6 +5971,9 @@ function toolToVertex$2(fromObject) {
|
|
|
5908
5971
|
if (fromUrlContext != null) {
|
|
5909
5972
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
5910
5973
|
}
|
|
5974
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
5975
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
5976
|
+
}
|
|
5911
5977
|
return toObject;
|
|
5912
5978
|
}
|
|
5913
5979
|
function updateCachedContentConfigToMldev(fromObject, parentObject) {
|
|
@@ -7441,6 +7507,10 @@ function googleMapsToMldev$2(fromObject) {
|
|
|
7441
7507
|
}
|
|
7442
7508
|
function googleSearchToMldev$2(fromObject) {
|
|
7443
7509
|
const toObject = {};
|
|
7510
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
7511
|
+
if (fromSearchTypes != null) {
|
|
7512
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
7513
|
+
}
|
|
7444
7514
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
7445
7515
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
7446
7516
|
}
|
|
@@ -7956,6 +8026,10 @@ function toolToMldev$2(fromObject) {
|
|
|
7956
8026
|
if (fromFileSearch != null) {
|
|
7957
8027
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
7958
8028
|
}
|
|
8029
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
8030
|
+
if (fromGoogleSearch != null) {
|
|
8031
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
8032
|
+
}
|
|
7959
8033
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
7960
8034
|
'codeExecution',
|
|
7961
8035
|
]);
|
|
@@ -7981,10 +8055,6 @@ function toolToMldev$2(fromObject) {
|
|
|
7981
8055
|
if (fromGoogleMaps != null) {
|
|
7982
8056
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$2(fromGoogleMaps));
|
|
7983
8057
|
}
|
|
7984
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
7985
|
-
if (fromGoogleSearch != null) {
|
|
7986
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
7987
|
-
}
|
|
7988
8058
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
7989
8059
|
'googleSearchRetrieval',
|
|
7990
8060
|
]);
|
|
@@ -7995,6 +8065,16 @@ function toolToMldev$2(fromObject) {
|
|
|
7995
8065
|
if (fromUrlContext != null) {
|
|
7996
8066
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
7997
8067
|
}
|
|
8068
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
8069
|
+
if (fromMcpServers != null) {
|
|
8070
|
+
let transformedList = fromMcpServers;
|
|
8071
|
+
if (Array.isArray(transformedList)) {
|
|
8072
|
+
transformedList = transformedList.map((item) => {
|
|
8073
|
+
return item;
|
|
8074
|
+
});
|
|
8075
|
+
}
|
|
8076
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
8077
|
+
}
|
|
7998
8078
|
return toObject;
|
|
7999
8079
|
}
|
|
8000
8080
|
function toolToVertex$1(fromObject) {
|
|
@@ -8010,6 +8090,10 @@ function toolToVertex$1(fromObject) {
|
|
|
8010
8090
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
8011
8091
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
8012
8092
|
}
|
|
8093
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
8094
|
+
if (fromGoogleSearch != null) {
|
|
8095
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
8096
|
+
}
|
|
8013
8097
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
8014
8098
|
'codeExecution',
|
|
8015
8099
|
]);
|
|
@@ -8038,10 +8122,6 @@ function toolToVertex$1(fromObject) {
|
|
|
8038
8122
|
if (fromGoogleMaps != null) {
|
|
8039
8123
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
8040
8124
|
}
|
|
8041
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
8042
|
-
if (fromGoogleSearch != null) {
|
|
8043
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
8044
|
-
}
|
|
8045
8125
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
8046
8126
|
'googleSearchRetrieval',
|
|
8047
8127
|
]);
|
|
@@ -8052,6 +8132,9 @@ function toolToVertex$1(fromObject) {
|
|
|
8052
8132
|
if (fromUrlContext != null) {
|
|
8053
8133
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
8054
8134
|
}
|
|
8135
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
8136
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
8137
|
+
}
|
|
8055
8138
|
return toObject;
|
|
8056
8139
|
}
|
|
8057
8140
|
function usageMetadataFromVertex(fromObject) {
|
|
@@ -8195,16 +8278,16 @@ function candidateFromMldev(fromObject, rootObject) {
|
|
|
8195
8278
|
if (fromFinishReason != null) {
|
|
8196
8279
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
8197
8280
|
}
|
|
8198
|
-
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
8199
|
-
if (fromAvgLogprobs != null) {
|
|
8200
|
-
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
8201
|
-
}
|
|
8202
8281
|
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
8203
8282
|
'groundingMetadata',
|
|
8204
8283
|
]);
|
|
8205
8284
|
if (fromGroundingMetadata != null) {
|
|
8206
8285
|
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
8207
8286
|
}
|
|
8287
|
+
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
8288
|
+
if (fromAvgLogprobs != null) {
|
|
8289
|
+
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
8290
|
+
}
|
|
8208
8291
|
const fromIndex = getValueByPath(fromObject, ['index']);
|
|
8209
8292
|
if (fromIndex != null) {
|
|
8210
8293
|
setValueByPath(toObject, ['index'], fromIndex);
|
|
@@ -8660,33 +8743,103 @@ function embedContentConfigToMldev(fromObject, parentObject, _rootObject) {
|
|
|
8660
8743
|
}
|
|
8661
8744
|
return toObject;
|
|
8662
8745
|
}
|
|
8663
|
-
function embedContentConfigToVertex(fromObject, parentObject,
|
|
8746
|
+
function embedContentConfigToVertex(fromObject, parentObject, rootObject) {
|
|
8664
8747
|
const toObject = {};
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8748
|
+
let discriminatorTaskType = getValueByPath(rootObject, [
|
|
8749
|
+
'embeddingApiType',
|
|
8750
|
+
]);
|
|
8751
|
+
if (discriminatorTaskType === undefined) {
|
|
8752
|
+
discriminatorTaskType = 'PREDICT';
|
|
8668
8753
|
}
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8754
|
+
if (discriminatorTaskType === 'PREDICT') {
|
|
8755
|
+
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
8756
|
+
if (parentObject !== undefined && fromTaskType != null) {
|
|
8757
|
+
setValueByPath(parentObject, ['instances[]', 'task_type'], fromTaskType);
|
|
8758
|
+
}
|
|
8672
8759
|
}
|
|
8673
|
-
|
|
8674
|
-
'
|
|
8760
|
+
else if (discriminatorTaskType === 'EMBED_CONTENT') {
|
|
8761
|
+
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
8762
|
+
if (parentObject !== undefined && fromTaskType != null) {
|
|
8763
|
+
setValueByPath(parentObject, ['taskType'], fromTaskType);
|
|
8764
|
+
}
|
|
8765
|
+
}
|
|
8766
|
+
let discriminatorTitle = getValueByPath(rootObject, [
|
|
8767
|
+
'embeddingApiType',
|
|
8675
8768
|
]);
|
|
8676
|
-
if (
|
|
8677
|
-
|
|
8769
|
+
if (discriminatorTitle === undefined) {
|
|
8770
|
+
discriminatorTitle = 'PREDICT';
|
|
8678
8771
|
}
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8772
|
+
if (discriminatorTitle === 'PREDICT') {
|
|
8773
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
8774
|
+
if (parentObject !== undefined && fromTitle != null) {
|
|
8775
|
+
setValueByPath(parentObject, ['instances[]', 'title'], fromTitle);
|
|
8776
|
+
}
|
|
8777
|
+
}
|
|
8778
|
+
else if (discriminatorTitle === 'EMBED_CONTENT') {
|
|
8779
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
8780
|
+
if (parentObject !== undefined && fromTitle != null) {
|
|
8781
|
+
setValueByPath(parentObject, ['title'], fromTitle);
|
|
8782
|
+
}
|
|
8783
|
+
}
|
|
8784
|
+
let discriminatorOutputDimensionality = getValueByPath(rootObject, [
|
|
8785
|
+
'embeddingApiType',
|
|
8786
|
+
]);
|
|
8787
|
+
if (discriminatorOutputDimensionality === undefined) {
|
|
8788
|
+
discriminatorOutputDimensionality = 'PREDICT';
|
|
8789
|
+
}
|
|
8790
|
+
if (discriminatorOutputDimensionality === 'PREDICT') {
|
|
8791
|
+
const fromOutputDimensionality = getValueByPath(fromObject, [
|
|
8792
|
+
'outputDimensionality',
|
|
8793
|
+
]);
|
|
8794
|
+
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
8795
|
+
setValueByPath(parentObject, ['parameters', 'outputDimensionality'], fromOutputDimensionality);
|
|
8796
|
+
}
|
|
8797
|
+
}
|
|
8798
|
+
else if (discriminatorOutputDimensionality === 'EMBED_CONTENT') {
|
|
8799
|
+
const fromOutputDimensionality = getValueByPath(fromObject, [
|
|
8800
|
+
'outputDimensionality',
|
|
8801
|
+
]);
|
|
8802
|
+
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
8803
|
+
setValueByPath(parentObject, ['outputDimensionality'], fromOutputDimensionality);
|
|
8804
|
+
}
|
|
8805
|
+
}
|
|
8806
|
+
let discriminatorMimeType = getValueByPath(rootObject, [
|
|
8807
|
+
'embeddingApiType',
|
|
8808
|
+
]);
|
|
8809
|
+
if (discriminatorMimeType === undefined) {
|
|
8810
|
+
discriminatorMimeType = 'PREDICT';
|
|
8811
|
+
}
|
|
8812
|
+
if (discriminatorMimeType === 'PREDICT') {
|
|
8813
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
8814
|
+
if (parentObject !== undefined && fromMimeType != null) {
|
|
8815
|
+
setValueByPath(parentObject, ['instances[]', 'mimeType'], fromMimeType);
|
|
8816
|
+
}
|
|
8682
8817
|
}
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8818
|
+
let discriminatorAutoTruncate = getValueByPath(rootObject, [
|
|
8819
|
+
'embeddingApiType',
|
|
8820
|
+
]);
|
|
8821
|
+
if (discriminatorAutoTruncate === undefined) {
|
|
8822
|
+
discriminatorAutoTruncate = 'PREDICT';
|
|
8823
|
+
}
|
|
8824
|
+
if (discriminatorAutoTruncate === 'PREDICT') {
|
|
8825
|
+
const fromAutoTruncate = getValueByPath(fromObject, [
|
|
8826
|
+
'autoTruncate',
|
|
8827
|
+
]);
|
|
8828
|
+
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
8829
|
+
setValueByPath(parentObject, ['parameters', 'autoTruncate'], fromAutoTruncate);
|
|
8830
|
+
}
|
|
8831
|
+
}
|
|
8832
|
+
else if (discriminatorAutoTruncate === 'EMBED_CONTENT') {
|
|
8833
|
+
const fromAutoTruncate = getValueByPath(fromObject, [
|
|
8834
|
+
'autoTruncate',
|
|
8835
|
+
]);
|
|
8836
|
+
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
8837
|
+
setValueByPath(parentObject, ['autoTruncate'], fromAutoTruncate);
|
|
8838
|
+
}
|
|
8686
8839
|
}
|
|
8687
8840
|
return toObject;
|
|
8688
8841
|
}
|
|
8689
|
-
function
|
|
8842
|
+
function embedContentParametersPrivateToMldev(apiClient, fromObject, rootObject) {
|
|
8690
8843
|
const toObject = {};
|
|
8691
8844
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
8692
8845
|
if (fromModel != null) {
|
|
@@ -8702,6 +8855,10 @@ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
|
|
|
8702
8855
|
}
|
|
8703
8856
|
setValueByPath(toObject, ['requests[]', 'content'], transformedList);
|
|
8704
8857
|
}
|
|
8858
|
+
const fromContent = getValueByPath(fromObject, ['content']);
|
|
8859
|
+
if (fromContent != null) {
|
|
8860
|
+
contentToMldev$1(tContent(fromContent));
|
|
8861
|
+
}
|
|
8705
8862
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8706
8863
|
if (fromConfig != null) {
|
|
8707
8864
|
embedContentConfigToMldev(fromConfig, toObject);
|
|
@@ -8712,25 +8869,45 @@ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
|
|
|
8712
8869
|
}
|
|
8713
8870
|
return toObject;
|
|
8714
8871
|
}
|
|
8715
|
-
function
|
|
8872
|
+
function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject) {
|
|
8716
8873
|
const toObject = {};
|
|
8717
8874
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
8718
8875
|
if (fromModel != null) {
|
|
8719
8876
|
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
8720
8877
|
}
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8878
|
+
let discriminatorContents = getValueByPath(rootObject, [
|
|
8879
|
+
'embeddingApiType',
|
|
8880
|
+
]);
|
|
8881
|
+
if (discriminatorContents === undefined) {
|
|
8882
|
+
discriminatorContents = 'PREDICT';
|
|
8883
|
+
}
|
|
8884
|
+
if (discriminatorContents === 'PREDICT') {
|
|
8885
|
+
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
8886
|
+
if (fromContents != null) {
|
|
8887
|
+
let transformedList = tContentsForEmbed(apiClient, fromContents);
|
|
8888
|
+
if (Array.isArray(transformedList)) {
|
|
8889
|
+
transformedList = transformedList.map((item) => {
|
|
8890
|
+
return item;
|
|
8891
|
+
});
|
|
8892
|
+
}
|
|
8893
|
+
setValueByPath(toObject, ['instances[]', 'content'], transformedList);
|
|
8894
|
+
}
|
|
8895
|
+
}
|
|
8896
|
+
let discriminatorContent = getValueByPath(rootObject, [
|
|
8897
|
+
'embeddingApiType',
|
|
8898
|
+
]);
|
|
8899
|
+
if (discriminatorContent === undefined) {
|
|
8900
|
+
discriminatorContent = 'PREDICT';
|
|
8901
|
+
}
|
|
8902
|
+
if (discriminatorContent === 'EMBED_CONTENT') {
|
|
8903
|
+
const fromContent = getValueByPath(fromObject, ['content']);
|
|
8904
|
+
if (fromContent != null) {
|
|
8905
|
+
setValueByPath(toObject, ['content'], tContent(fromContent));
|
|
8728
8906
|
}
|
|
8729
|
-
setValueByPath(toObject, ['instances[]', 'content'], transformedList);
|
|
8730
8907
|
}
|
|
8731
8908
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8732
8909
|
if (fromConfig != null) {
|
|
8733
|
-
embedContentConfigToVertex(fromConfig, toObject);
|
|
8910
|
+
embedContentConfigToVertex(fromConfig, toObject, rootObject);
|
|
8734
8911
|
}
|
|
8735
8912
|
return toObject;
|
|
8736
8913
|
}
|
|
@@ -8783,6 +8960,24 @@ function embedContentResponseFromVertex(fromObject, rootObject) {
|
|
|
8783
8960
|
if (fromMetadata != null) {
|
|
8784
8961
|
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
8785
8962
|
}
|
|
8963
|
+
if (rootObject &&
|
|
8964
|
+
getValueByPath(rootObject, ['embeddingApiType']) === 'EMBED_CONTENT') {
|
|
8965
|
+
const embedding = getValueByPath(fromObject, ['embedding']);
|
|
8966
|
+
const usageMetadata = getValueByPath(fromObject, ['usageMetadata']);
|
|
8967
|
+
const truncated = getValueByPath(fromObject, ['truncated']);
|
|
8968
|
+
if (embedding) {
|
|
8969
|
+
const stats = {};
|
|
8970
|
+
if (usageMetadata &&
|
|
8971
|
+
usageMetadata['promptTokenCount']) {
|
|
8972
|
+
stats.tokenCount = usageMetadata['promptTokenCount'];
|
|
8973
|
+
}
|
|
8974
|
+
if (truncated) {
|
|
8975
|
+
stats.truncated = truncated;
|
|
8976
|
+
}
|
|
8977
|
+
embedding.statistics = stats;
|
|
8978
|
+
setValueByPath(toObject, ['embeddings'], [embedding]);
|
|
8979
|
+
}
|
|
8980
|
+
}
|
|
8786
8981
|
return toObject;
|
|
8787
8982
|
}
|
|
8788
8983
|
function endpointFromVertex(fromObject, _rootObject) {
|
|
@@ -10209,6 +10404,10 @@ function googleMapsToMldev$1(fromObject, _rootObject) {
|
|
|
10209
10404
|
}
|
|
10210
10405
|
function googleSearchToMldev$1(fromObject, _rootObject) {
|
|
10211
10406
|
const toObject = {};
|
|
10407
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
10408
|
+
if (fromSearchTypes != null) {
|
|
10409
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
10410
|
+
}
|
|
10212
10411
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
10213
10412
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
10214
10413
|
}
|
|
@@ -10236,6 +10435,9 @@ function imageConfigToMldev(fromObject, _rootObject) {
|
|
|
10236
10435
|
if (getValueByPath(fromObject, ['personGeneration']) !== undefined) {
|
|
10237
10436
|
throw new Error('personGeneration parameter is not supported in Gemini API.');
|
|
10238
10437
|
}
|
|
10438
|
+
if (getValueByPath(fromObject, ['prominentPeople']) !== undefined) {
|
|
10439
|
+
throw new Error('prominentPeople parameter is not supported in Gemini API.');
|
|
10440
|
+
}
|
|
10239
10441
|
if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
|
|
10240
10442
|
throw new Error('outputMimeType parameter is not supported in Gemini API.');
|
|
10241
10443
|
}
|
|
@@ -10261,6 +10463,12 @@ function imageConfigToVertex(fromObject, _rootObject) {
|
|
|
10261
10463
|
if (fromPersonGeneration != null) {
|
|
10262
10464
|
setValueByPath(toObject, ['personGeneration'], fromPersonGeneration);
|
|
10263
10465
|
}
|
|
10466
|
+
const fromProminentPeople = getValueByPath(fromObject, [
|
|
10467
|
+
'prominentPeople',
|
|
10468
|
+
]);
|
|
10469
|
+
if (fromProminentPeople != null) {
|
|
10470
|
+
setValueByPath(toObject, ['prominentPeople'], fromProminentPeople);
|
|
10471
|
+
}
|
|
10264
10472
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
10265
10473
|
'outputMimeType',
|
|
10266
10474
|
]);
|
|
@@ -10988,6 +11196,10 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
10988
11196
|
if (fromFileSearch != null) {
|
|
10989
11197
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
10990
11198
|
}
|
|
11199
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11200
|
+
if (fromGoogleSearch != null) {
|
|
11201
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
11202
|
+
}
|
|
10991
11203
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
10992
11204
|
'codeExecution',
|
|
10993
11205
|
]);
|
|
@@ -11013,10 +11225,6 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
11013
11225
|
if (fromGoogleMaps != null) {
|
|
11014
11226
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$1(fromGoogleMaps));
|
|
11015
11227
|
}
|
|
11016
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11017
|
-
if (fromGoogleSearch != null) {
|
|
11018
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
11019
|
-
}
|
|
11020
11228
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
11021
11229
|
'googleSearchRetrieval',
|
|
11022
11230
|
]);
|
|
@@ -11027,6 +11235,16 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
11027
11235
|
if (fromUrlContext != null) {
|
|
11028
11236
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
11029
11237
|
}
|
|
11238
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
11239
|
+
if (fromMcpServers != null) {
|
|
11240
|
+
let transformedList = fromMcpServers;
|
|
11241
|
+
if (Array.isArray(transformedList)) {
|
|
11242
|
+
transformedList = transformedList.map((item) => {
|
|
11243
|
+
return item;
|
|
11244
|
+
});
|
|
11245
|
+
}
|
|
11246
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
11247
|
+
}
|
|
11030
11248
|
return toObject;
|
|
11031
11249
|
}
|
|
11032
11250
|
function toolToVertex(fromObject, rootObject) {
|
|
@@ -11042,6 +11260,10 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
11042
11260
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
11043
11261
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
11044
11262
|
}
|
|
11263
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11264
|
+
if (fromGoogleSearch != null) {
|
|
11265
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
11266
|
+
}
|
|
11045
11267
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
11046
11268
|
'codeExecution',
|
|
11047
11269
|
]);
|
|
@@ -11070,10 +11292,6 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
11070
11292
|
if (fromGoogleMaps != null) {
|
|
11071
11293
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
11072
11294
|
}
|
|
11073
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11074
|
-
if (fromGoogleSearch != null) {
|
|
11075
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
11076
|
-
}
|
|
11077
11295
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
11078
11296
|
'googleSearchRetrieval',
|
|
11079
11297
|
]);
|
|
@@ -11084,6 +11302,9 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
11084
11302
|
if (fromUrlContext != null) {
|
|
11085
11303
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
11086
11304
|
}
|
|
11305
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
11306
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
11307
|
+
}
|
|
11087
11308
|
return toObject;
|
|
11088
11309
|
}
|
|
11089
11310
|
function tunedModelInfoFromMldev(fromObject, _rootObject) {
|
|
@@ -11640,7 +11861,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
11640
11861
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
11641
11862
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
11642
11863
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
11643
|
-
const SDK_VERSION = '1.
|
|
11864
|
+
const SDK_VERSION = '1.43.0'; // x-release-please-version
|
|
11644
11865
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
11645
11866
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
11646
11867
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13241,6 +13462,47 @@ class Models extends BaseModule {
|
|
|
13241
13462
|
constructor(apiClient) {
|
|
13242
13463
|
super();
|
|
13243
13464
|
this.apiClient = apiClient;
|
|
13465
|
+
/**
|
|
13466
|
+
* Calculates embeddings for the given contents.
|
|
13467
|
+
*
|
|
13468
|
+
* @param params - The parameters for embedding contents.
|
|
13469
|
+
* @return The response from the API.
|
|
13470
|
+
*
|
|
13471
|
+
* @example
|
|
13472
|
+
* ```ts
|
|
13473
|
+
* const response = await ai.models.embedContent({
|
|
13474
|
+
* model: 'text-embedding-004',
|
|
13475
|
+
* contents: [
|
|
13476
|
+
* 'What is your name?',
|
|
13477
|
+
* 'What is your favorite color?',
|
|
13478
|
+
* ],
|
|
13479
|
+
* config: {
|
|
13480
|
+
* outputDimensionality: 64,
|
|
13481
|
+
* },
|
|
13482
|
+
* });
|
|
13483
|
+
* console.log(response);
|
|
13484
|
+
* ```
|
|
13485
|
+
*/
|
|
13486
|
+
this.embedContent = async (params) => {
|
|
13487
|
+
if (!this.apiClient.isVertexAI()) {
|
|
13488
|
+
return await this.embedContentInternal(params);
|
|
13489
|
+
}
|
|
13490
|
+
const isVertexEmbedContentModel = (params.model.includes('gemini') &&
|
|
13491
|
+
params.model !== 'gemini-embedding-001') ||
|
|
13492
|
+
params.model.includes('maas');
|
|
13493
|
+
if (isVertexEmbedContentModel) {
|
|
13494
|
+
const contents = tContents(params.contents);
|
|
13495
|
+
if (contents.length > 1) {
|
|
13496
|
+
throw new Error('The embedContent API for this model only supports one content at a time.');
|
|
13497
|
+
}
|
|
13498
|
+
const paramsPrivate = Object.assign(Object.assign({}, params), { content: contents[0], embeddingApiType: exports.EmbeddingApiType.EMBED_CONTENT });
|
|
13499
|
+
return await this.embedContentInternal(paramsPrivate);
|
|
13500
|
+
}
|
|
13501
|
+
else {
|
|
13502
|
+
const paramsPrivate = Object.assign(Object.assign({}, params), { embeddingApiType: exports.EmbeddingApiType.PREDICT });
|
|
13503
|
+
return await this.embedContentInternal(paramsPrivate);
|
|
13504
|
+
}
|
|
13505
|
+
};
|
|
13244
13506
|
/**
|
|
13245
13507
|
* Makes an API request to generate content with a given model.
|
|
13246
13508
|
*
|
|
@@ -13928,14 +14190,17 @@ class Models extends BaseModule {
|
|
|
13928
14190
|
* console.log(response);
|
|
13929
14191
|
* ```
|
|
13930
14192
|
*/
|
|
13931
|
-
async
|
|
14193
|
+
async embedContentInternal(params) {
|
|
13932
14194
|
var _a, _b, _c, _d;
|
|
13933
14195
|
let response;
|
|
13934
14196
|
let path = '';
|
|
13935
14197
|
let queryParams = {};
|
|
13936
14198
|
if (this.apiClient.isVertexAI()) {
|
|
13937
|
-
const body =
|
|
13938
|
-
|
|
14199
|
+
const body = embedContentParametersPrivateToVertex(this.apiClient, params, params);
|
|
14200
|
+
const endpointUrl = tIsVertexEmbedContentModel(params.model)
|
|
14201
|
+
? '{model}:embedContent'
|
|
14202
|
+
: '{model}:predict';
|
|
14203
|
+
path = formatMap(endpointUrl, body['_url']);
|
|
13939
14204
|
queryParams = body['_query'];
|
|
13940
14205
|
delete body['_url'];
|
|
13941
14206
|
delete body['_query'];
|
|
@@ -13958,14 +14223,14 @@ class Models extends BaseModule {
|
|
|
13958
14223
|
});
|
|
13959
14224
|
});
|
|
13960
14225
|
return response.then((apiResponse) => {
|
|
13961
|
-
const resp = embedContentResponseFromVertex(apiResponse);
|
|
14226
|
+
const resp = embedContentResponseFromVertex(apiResponse, params);
|
|
13962
14227
|
const typedResp = new EmbedContentResponse();
|
|
13963
14228
|
Object.assign(typedResp, resp);
|
|
13964
14229
|
return typedResp;
|
|
13965
14230
|
});
|
|
13966
14231
|
}
|
|
13967
14232
|
else {
|
|
13968
|
-
const body =
|
|
14233
|
+
const body = embedContentParametersPrivateToMldev(this.apiClient, params);
|
|
13969
14234
|
path = formatMap('{model}:batchEmbedContents', body['_url']);
|
|
13970
14235
|
queryParams = body['_query'];
|
|
13971
14236
|
delete body['_url'];
|
|
@@ -15049,6 +15314,10 @@ function googleMapsToMldev(fromObject) {
|
|
|
15049
15314
|
}
|
|
15050
15315
|
function googleSearchToMldev(fromObject) {
|
|
15051
15316
|
const toObject = {};
|
|
15317
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
15318
|
+
if (fromSearchTypes != null) {
|
|
15319
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
15320
|
+
}
|
|
15052
15321
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
15053
15322
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
15054
15323
|
}
|
|
@@ -15272,6 +15541,10 @@ function toolToMldev(fromObject) {
|
|
|
15272
15541
|
if (fromFileSearch != null) {
|
|
15273
15542
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
15274
15543
|
}
|
|
15544
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
15545
|
+
if (fromGoogleSearch != null) {
|
|
15546
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
15547
|
+
}
|
|
15275
15548
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
15276
15549
|
'codeExecution',
|
|
15277
15550
|
]);
|
|
@@ -15297,10 +15570,6 @@ function toolToMldev(fromObject) {
|
|
|
15297
15570
|
if (fromGoogleMaps != null) {
|
|
15298
15571
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev(fromGoogleMaps));
|
|
15299
15572
|
}
|
|
15300
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
15301
|
-
if (fromGoogleSearch != null) {
|
|
15302
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
15303
|
-
}
|
|
15304
15573
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
15305
15574
|
'googleSearchRetrieval',
|
|
15306
15575
|
]);
|
|
@@ -15311,6 +15580,16 @@ function toolToMldev(fromObject) {
|
|
|
15311
15580
|
if (fromUrlContext != null) {
|
|
15312
15581
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
15313
15582
|
}
|
|
15583
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
15584
|
+
if (fromMcpServers != null) {
|
|
15585
|
+
let transformedList = fromMcpServers;
|
|
15586
|
+
if (Array.isArray(transformedList)) {
|
|
15587
|
+
transformedList = transformedList.map((item) => {
|
|
15588
|
+
return item;
|
|
15589
|
+
});
|
|
15590
|
+
}
|
|
15591
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
15592
|
+
}
|
|
15314
15593
|
return toObject;
|
|
15315
15594
|
}
|
|
15316
15595
|
|
|
@@ -16768,14 +17047,17 @@ const createPathTagFunction = (pathEncoder = encodeURIPath) => (function path(st
|
|
|
16768
17047
|
return previousValue + currentValue + (index === params.length ? '' : encoded);
|
|
16769
17048
|
}, '');
|
|
16770
17049
|
const pathOnly = path.split(/[?#]/, 1)[0];
|
|
16771
|
-
const invalidSegmentPattern = /(
|
|
17050
|
+
const invalidSegmentPattern = /(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
16772
17051
|
let match;
|
|
16773
17052
|
// Find all invalid segments
|
|
16774
17053
|
while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
17054
|
+
const hasLeadingSlash = match[0].startsWith('/');
|
|
17055
|
+
const offset = hasLeadingSlash ? 1 : 0;
|
|
17056
|
+
const cleanMatch = hasLeadingSlash ? match[0].slice(1) : match[0];
|
|
16775
17057
|
invalidSegments.push({
|
|
16776
|
-
start: match.index,
|
|
16777
|
-
length:
|
|
16778
|
-
error: `Value "${
|
|
17058
|
+
start: match.index + offset,
|
|
17059
|
+
length: cleanMatch.length,
|
|
17060
|
+
error: `Value "${cleanMatch}" can\'t be safely passed as a path parameter`,
|
|
16779
17061
|
});
|
|
16780
17062
|
}
|
|
16781
17063
|
invalidSegments.sort((a, b) => a.start - b.start);
|
|
@@ -18055,6 +18337,13 @@ class BaseGeminiNextGenAPIClient {
|
|
|
18055
18337
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
18056
18338
|
return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
|
|
18057
18339
|
}
|
|
18340
|
+
else if (typeof body === 'object' &&
|
|
18341
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
18342
|
+
return {
|
|
18343
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
18344
|
+
body: this.stringifyQuery(body),
|
|
18345
|
+
};
|
|
18346
|
+
}
|
|
18058
18347
|
else {
|
|
18059
18348
|
return this.encoder({ body, headers });
|
|
18060
18349
|
}
|