@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.mjs
CHANGED
|
@@ -682,6 +682,38 @@ var Type;
|
|
|
682
682
|
*/
|
|
683
683
|
Type["NULL"] = "NULL";
|
|
684
684
|
})(Type || (Type = {}));
|
|
685
|
+
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
686
|
+
var PhishBlockThreshold;
|
|
687
|
+
(function (PhishBlockThreshold) {
|
|
688
|
+
/**
|
|
689
|
+
* Defaults to unspecified.
|
|
690
|
+
*/
|
|
691
|
+
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
692
|
+
/**
|
|
693
|
+
* Blocks Low and above confidence URL that is risky.
|
|
694
|
+
*/
|
|
695
|
+
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
696
|
+
/**
|
|
697
|
+
* Blocks Medium and above confidence URL that is risky.
|
|
698
|
+
*/
|
|
699
|
+
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
700
|
+
/**
|
|
701
|
+
* Blocks High and above confidence URL that is risky.
|
|
702
|
+
*/
|
|
703
|
+
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
704
|
+
/**
|
|
705
|
+
* Blocks Higher and above confidence URL that is risky.
|
|
706
|
+
*/
|
|
707
|
+
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
708
|
+
/**
|
|
709
|
+
* Blocks Very high and above confidence URL that is risky.
|
|
710
|
+
*/
|
|
711
|
+
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
712
|
+
/**
|
|
713
|
+
* Blocks Extremely high confidence URL that is risky.
|
|
714
|
+
*/
|
|
715
|
+
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
716
|
+
})(PhishBlockThreshold || (PhishBlockThreshold = {}));
|
|
685
717
|
/** The API spec that the external API implements. This enum is not supported in Gemini API. */
|
|
686
718
|
var ApiSpec;
|
|
687
719
|
(function (ApiSpec) {
|
|
@@ -752,38 +784,6 @@ var HttpElementLocation;
|
|
|
752
784
|
*/
|
|
753
785
|
HttpElementLocation["HTTP_IN_COOKIE"] = "HTTP_IN_COOKIE";
|
|
754
786
|
})(HttpElementLocation || (HttpElementLocation = {}));
|
|
755
|
-
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
756
|
-
var PhishBlockThreshold;
|
|
757
|
-
(function (PhishBlockThreshold) {
|
|
758
|
-
/**
|
|
759
|
-
* Defaults to unspecified.
|
|
760
|
-
*/
|
|
761
|
-
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
762
|
-
/**
|
|
763
|
-
* Blocks Low and above confidence URL that is risky.
|
|
764
|
-
*/
|
|
765
|
-
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
766
|
-
/**
|
|
767
|
-
* Blocks Medium and above confidence URL that is risky.
|
|
768
|
-
*/
|
|
769
|
-
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
770
|
-
/**
|
|
771
|
-
* Blocks High and above confidence URL that is risky.
|
|
772
|
-
*/
|
|
773
|
-
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
774
|
-
/**
|
|
775
|
-
* Blocks Higher and above confidence URL that is risky.
|
|
776
|
-
*/
|
|
777
|
-
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
778
|
-
/**
|
|
779
|
-
* Blocks Very high and above confidence URL that is risky.
|
|
780
|
-
*/
|
|
781
|
-
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
782
|
-
/**
|
|
783
|
-
* Blocks Extremely high confidence URL that is risky.
|
|
784
|
-
*/
|
|
785
|
-
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
786
|
-
})(PhishBlockThreshold || (PhishBlockThreshold = {}));
|
|
787
787
|
/** Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This enum is not supported in Vertex AI. */
|
|
788
788
|
var Behavior;
|
|
789
789
|
(function (Behavior) {
|
|
@@ -1366,6 +1366,34 @@ var Environment;
|
|
|
1366
1366
|
*/
|
|
1367
1367
|
Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
|
|
1368
1368
|
})(Environment || (Environment = {}));
|
|
1369
|
+
/** Enum for controlling whether the model can generate images of prominent people (celebrities). */
|
|
1370
|
+
var ProminentPeople;
|
|
1371
|
+
(function (ProminentPeople) {
|
|
1372
|
+
/**
|
|
1373
|
+
* Unspecified value. The model will proceed with the default behavior, which is to allow generation of prominent people.
|
|
1374
|
+
*/
|
|
1375
|
+
ProminentPeople["PROMINENT_PEOPLE_UNSPECIFIED"] = "PROMINENT_PEOPLE_UNSPECIFIED";
|
|
1376
|
+
/**
|
|
1377
|
+
* Allows the model to generate images of prominent people.
|
|
1378
|
+
*/
|
|
1379
|
+
ProminentPeople["ALLOW_PROMINENT_PEOPLE"] = "ALLOW_PROMINENT_PEOPLE";
|
|
1380
|
+
/**
|
|
1381
|
+
* Prevents the model from generating images of prominent people.
|
|
1382
|
+
*/
|
|
1383
|
+
ProminentPeople["BLOCK_PROMINENT_PEOPLE"] = "BLOCK_PROMINENT_PEOPLE";
|
|
1384
|
+
})(ProminentPeople || (ProminentPeople = {}));
|
|
1385
|
+
/** Enum representing the Vertex embedding API to use. */
|
|
1386
|
+
var EmbeddingApiType;
|
|
1387
|
+
(function (EmbeddingApiType) {
|
|
1388
|
+
/**
|
|
1389
|
+
* predict API endpoint (default)
|
|
1390
|
+
*/
|
|
1391
|
+
EmbeddingApiType["PREDICT"] = "PREDICT";
|
|
1392
|
+
/**
|
|
1393
|
+
* embedContent API Endpoint
|
|
1394
|
+
*/
|
|
1395
|
+
EmbeddingApiType["EMBED_CONTENT"] = "EMBED_CONTENT";
|
|
1396
|
+
})(EmbeddingApiType || (EmbeddingApiType = {}));
|
|
1369
1397
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
1370
1398
|
var SafetyFilterLevel;
|
|
1371
1399
|
(function (SafetyFilterLevel) {
|
|
@@ -3397,6 +3425,10 @@ function tJobState(state) {
|
|
|
3397
3425
|
return stateString;
|
|
3398
3426
|
}
|
|
3399
3427
|
}
|
|
3428
|
+
function tIsVertexEmbedContentModel(model) {
|
|
3429
|
+
return ((model.includes('gemini') && model !== 'gemini-embedding-001') ||
|
|
3430
|
+
model.includes('maas'));
|
|
3431
|
+
}
|
|
3400
3432
|
|
|
3401
3433
|
/**
|
|
3402
3434
|
* @license
|
|
@@ -3708,16 +3740,16 @@ function candidateFromMldev$1(fromObject) {
|
|
|
3708
3740
|
if (fromFinishReason != null) {
|
|
3709
3741
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
3710
3742
|
}
|
|
3711
|
-
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
3712
|
-
if (fromAvgLogprobs != null) {
|
|
3713
|
-
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
3714
|
-
}
|
|
3715
3743
|
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
3716
3744
|
'groundingMetadata',
|
|
3717
3745
|
]);
|
|
3718
3746
|
if (fromGroundingMetadata != null) {
|
|
3719
3747
|
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
3720
3748
|
}
|
|
3749
|
+
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
3750
|
+
if (fromAvgLogprobs != null) {
|
|
3751
|
+
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
3752
|
+
}
|
|
3721
3753
|
const fromIndex = getValueByPath(fromObject, ['index']);
|
|
3722
3754
|
if (fromIndex != null) {
|
|
3723
3755
|
setValueByPath(toObject, ['index'], fromIndex);
|
|
@@ -4263,6 +4295,10 @@ function googleMapsToMldev$4(fromObject) {
|
|
|
4263
4295
|
}
|
|
4264
4296
|
function googleSearchToMldev$4(fromObject) {
|
|
4265
4297
|
const toObject = {};
|
|
4298
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
4299
|
+
if (fromSearchTypes != null) {
|
|
4300
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
4301
|
+
}
|
|
4266
4302
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
4267
4303
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
4268
4304
|
}
|
|
@@ -4290,6 +4326,9 @@ function imageConfigToMldev$1(fromObject) {
|
|
|
4290
4326
|
if (getValueByPath(fromObject, ['personGeneration']) !== undefined) {
|
|
4291
4327
|
throw new Error('personGeneration parameter is not supported in Gemini API.');
|
|
4292
4328
|
}
|
|
4329
|
+
if (getValueByPath(fromObject, ['prominentPeople']) !== undefined) {
|
|
4330
|
+
throw new Error('prominentPeople parameter is not supported in Gemini API.');
|
|
4331
|
+
}
|
|
4293
4332
|
if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
|
|
4294
4333
|
throw new Error('outputMimeType parameter is not supported in Gemini API.');
|
|
4295
4334
|
}
|
|
@@ -4546,6 +4585,10 @@ function toolToMldev$4(fromObject) {
|
|
|
4546
4585
|
if (fromFileSearch != null) {
|
|
4547
4586
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
4548
4587
|
}
|
|
4588
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4589
|
+
if (fromGoogleSearch != null) {
|
|
4590
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
4591
|
+
}
|
|
4549
4592
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4550
4593
|
'codeExecution',
|
|
4551
4594
|
]);
|
|
@@ -4571,10 +4614,6 @@ function toolToMldev$4(fromObject) {
|
|
|
4571
4614
|
if (fromGoogleMaps != null) {
|
|
4572
4615
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$4(fromGoogleMaps));
|
|
4573
4616
|
}
|
|
4574
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4575
|
-
if (fromGoogleSearch != null) {
|
|
4576
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
4577
|
-
}
|
|
4578
4617
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
4579
4618
|
'googleSearchRetrieval',
|
|
4580
4619
|
]);
|
|
@@ -4585,6 +4624,16 @@ function toolToMldev$4(fromObject) {
|
|
|
4585
4624
|
if (fromUrlContext != null) {
|
|
4586
4625
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
4587
4626
|
}
|
|
4627
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
4628
|
+
if (fromMcpServers != null) {
|
|
4629
|
+
let transformedList = fromMcpServers;
|
|
4630
|
+
if (Array.isArray(transformedList)) {
|
|
4631
|
+
transformedList = transformedList.map((item) => {
|
|
4632
|
+
return item;
|
|
4633
|
+
});
|
|
4634
|
+
}
|
|
4635
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
4636
|
+
}
|
|
4588
4637
|
return toObject;
|
|
4589
4638
|
}
|
|
4590
4639
|
|
|
@@ -5591,6 +5640,10 @@ function googleMapsToMldev$3(fromObject) {
|
|
|
5591
5640
|
}
|
|
5592
5641
|
function googleSearchToMldev$3(fromObject) {
|
|
5593
5642
|
const toObject = {};
|
|
5643
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
5644
|
+
if (fromSearchTypes != null) {
|
|
5645
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
5646
|
+
}
|
|
5594
5647
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
5595
5648
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
5596
5649
|
}
|
|
@@ -5790,6 +5843,10 @@ function toolToMldev$3(fromObject) {
|
|
|
5790
5843
|
if (fromFileSearch != null) {
|
|
5791
5844
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
5792
5845
|
}
|
|
5846
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5847
|
+
if (fromGoogleSearch != null) {
|
|
5848
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
5849
|
+
}
|
|
5793
5850
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5794
5851
|
'codeExecution',
|
|
5795
5852
|
]);
|
|
@@ -5815,10 +5872,6 @@ function toolToMldev$3(fromObject) {
|
|
|
5815
5872
|
if (fromGoogleMaps != null) {
|
|
5816
5873
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$3(fromGoogleMaps));
|
|
5817
5874
|
}
|
|
5818
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5819
|
-
if (fromGoogleSearch != null) {
|
|
5820
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
5821
|
-
}
|
|
5822
5875
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
5823
5876
|
'googleSearchRetrieval',
|
|
5824
5877
|
]);
|
|
@@ -5829,6 +5882,16 @@ function toolToMldev$3(fromObject) {
|
|
|
5829
5882
|
if (fromUrlContext != null) {
|
|
5830
5883
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
5831
5884
|
}
|
|
5885
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
5886
|
+
if (fromMcpServers != null) {
|
|
5887
|
+
let transformedList = fromMcpServers;
|
|
5888
|
+
if (Array.isArray(transformedList)) {
|
|
5889
|
+
transformedList = transformedList.map((item) => {
|
|
5890
|
+
return item;
|
|
5891
|
+
});
|
|
5892
|
+
}
|
|
5893
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
5894
|
+
}
|
|
5832
5895
|
return toObject;
|
|
5833
5896
|
}
|
|
5834
5897
|
function toolToVertex$2(fromObject) {
|
|
@@ -5844,6 +5907,10 @@ function toolToVertex$2(fromObject) {
|
|
|
5844
5907
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
5845
5908
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
5846
5909
|
}
|
|
5910
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5911
|
+
if (fromGoogleSearch != null) {
|
|
5912
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
5913
|
+
}
|
|
5847
5914
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5848
5915
|
'codeExecution',
|
|
5849
5916
|
]);
|
|
@@ -5872,10 +5939,6 @@ function toolToVertex$2(fromObject) {
|
|
|
5872
5939
|
if (fromGoogleMaps != null) {
|
|
5873
5940
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
5874
5941
|
}
|
|
5875
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5876
|
-
if (fromGoogleSearch != null) {
|
|
5877
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
5878
|
-
}
|
|
5879
5942
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
5880
5943
|
'googleSearchRetrieval',
|
|
5881
5944
|
]);
|
|
@@ -5886,6 +5949,9 @@ function toolToVertex$2(fromObject) {
|
|
|
5886
5949
|
if (fromUrlContext != null) {
|
|
5887
5950
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
5888
5951
|
}
|
|
5952
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
5953
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
5954
|
+
}
|
|
5889
5955
|
return toObject;
|
|
5890
5956
|
}
|
|
5891
5957
|
function updateCachedContentConfigToMldev(fromObject, parentObject) {
|
|
@@ -7419,6 +7485,10 @@ function googleMapsToMldev$2(fromObject) {
|
|
|
7419
7485
|
}
|
|
7420
7486
|
function googleSearchToMldev$2(fromObject) {
|
|
7421
7487
|
const toObject = {};
|
|
7488
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
7489
|
+
if (fromSearchTypes != null) {
|
|
7490
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
7491
|
+
}
|
|
7422
7492
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
7423
7493
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
7424
7494
|
}
|
|
@@ -7934,6 +8004,10 @@ function toolToMldev$2(fromObject) {
|
|
|
7934
8004
|
if (fromFileSearch != null) {
|
|
7935
8005
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
7936
8006
|
}
|
|
8007
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
8008
|
+
if (fromGoogleSearch != null) {
|
|
8009
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
8010
|
+
}
|
|
7937
8011
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
7938
8012
|
'codeExecution',
|
|
7939
8013
|
]);
|
|
@@ -7959,10 +8033,6 @@ function toolToMldev$2(fromObject) {
|
|
|
7959
8033
|
if (fromGoogleMaps != null) {
|
|
7960
8034
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$2(fromGoogleMaps));
|
|
7961
8035
|
}
|
|
7962
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
7963
|
-
if (fromGoogleSearch != null) {
|
|
7964
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
7965
|
-
}
|
|
7966
8036
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
7967
8037
|
'googleSearchRetrieval',
|
|
7968
8038
|
]);
|
|
@@ -7973,6 +8043,16 @@ function toolToMldev$2(fromObject) {
|
|
|
7973
8043
|
if (fromUrlContext != null) {
|
|
7974
8044
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
7975
8045
|
}
|
|
8046
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
8047
|
+
if (fromMcpServers != null) {
|
|
8048
|
+
let transformedList = fromMcpServers;
|
|
8049
|
+
if (Array.isArray(transformedList)) {
|
|
8050
|
+
transformedList = transformedList.map((item) => {
|
|
8051
|
+
return item;
|
|
8052
|
+
});
|
|
8053
|
+
}
|
|
8054
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
8055
|
+
}
|
|
7976
8056
|
return toObject;
|
|
7977
8057
|
}
|
|
7978
8058
|
function toolToVertex$1(fromObject) {
|
|
@@ -7988,6 +8068,10 @@ function toolToVertex$1(fromObject) {
|
|
|
7988
8068
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
7989
8069
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
7990
8070
|
}
|
|
8071
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
8072
|
+
if (fromGoogleSearch != null) {
|
|
8073
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
8074
|
+
}
|
|
7991
8075
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
7992
8076
|
'codeExecution',
|
|
7993
8077
|
]);
|
|
@@ -8016,10 +8100,6 @@ function toolToVertex$1(fromObject) {
|
|
|
8016
8100
|
if (fromGoogleMaps != null) {
|
|
8017
8101
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
8018
8102
|
}
|
|
8019
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
8020
|
-
if (fromGoogleSearch != null) {
|
|
8021
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
8022
|
-
}
|
|
8023
8103
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
8024
8104
|
'googleSearchRetrieval',
|
|
8025
8105
|
]);
|
|
@@ -8030,6 +8110,9 @@ function toolToVertex$1(fromObject) {
|
|
|
8030
8110
|
if (fromUrlContext != null) {
|
|
8031
8111
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
8032
8112
|
}
|
|
8113
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
8114
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
8115
|
+
}
|
|
8033
8116
|
return toObject;
|
|
8034
8117
|
}
|
|
8035
8118
|
function usageMetadataFromVertex(fromObject) {
|
|
@@ -8173,16 +8256,16 @@ function candidateFromMldev(fromObject, rootObject) {
|
|
|
8173
8256
|
if (fromFinishReason != null) {
|
|
8174
8257
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
8175
8258
|
}
|
|
8176
|
-
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
8177
|
-
if (fromAvgLogprobs != null) {
|
|
8178
|
-
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
8179
|
-
}
|
|
8180
8259
|
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
8181
8260
|
'groundingMetadata',
|
|
8182
8261
|
]);
|
|
8183
8262
|
if (fromGroundingMetadata != null) {
|
|
8184
8263
|
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
8185
8264
|
}
|
|
8265
|
+
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
8266
|
+
if (fromAvgLogprobs != null) {
|
|
8267
|
+
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
8268
|
+
}
|
|
8186
8269
|
const fromIndex = getValueByPath(fromObject, ['index']);
|
|
8187
8270
|
if (fromIndex != null) {
|
|
8188
8271
|
setValueByPath(toObject, ['index'], fromIndex);
|
|
@@ -8638,33 +8721,103 @@ function embedContentConfigToMldev(fromObject, parentObject, _rootObject) {
|
|
|
8638
8721
|
}
|
|
8639
8722
|
return toObject;
|
|
8640
8723
|
}
|
|
8641
|
-
function embedContentConfigToVertex(fromObject, parentObject,
|
|
8724
|
+
function embedContentConfigToVertex(fromObject, parentObject, rootObject) {
|
|
8642
8725
|
const toObject = {};
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8726
|
+
let discriminatorTaskType = getValueByPath(rootObject, [
|
|
8727
|
+
'embeddingApiType',
|
|
8728
|
+
]);
|
|
8729
|
+
if (discriminatorTaskType === undefined) {
|
|
8730
|
+
discriminatorTaskType = 'PREDICT';
|
|
8646
8731
|
}
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8732
|
+
if (discriminatorTaskType === 'PREDICT') {
|
|
8733
|
+
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
8734
|
+
if (parentObject !== undefined && fromTaskType != null) {
|
|
8735
|
+
setValueByPath(parentObject, ['instances[]', 'task_type'], fromTaskType);
|
|
8736
|
+
}
|
|
8650
8737
|
}
|
|
8651
|
-
|
|
8652
|
-
'
|
|
8738
|
+
else if (discriminatorTaskType === 'EMBED_CONTENT') {
|
|
8739
|
+
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
8740
|
+
if (parentObject !== undefined && fromTaskType != null) {
|
|
8741
|
+
setValueByPath(parentObject, ['taskType'], fromTaskType);
|
|
8742
|
+
}
|
|
8743
|
+
}
|
|
8744
|
+
let discriminatorTitle = getValueByPath(rootObject, [
|
|
8745
|
+
'embeddingApiType',
|
|
8653
8746
|
]);
|
|
8654
|
-
if (
|
|
8655
|
-
|
|
8747
|
+
if (discriminatorTitle === undefined) {
|
|
8748
|
+
discriminatorTitle = 'PREDICT';
|
|
8656
8749
|
}
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8750
|
+
if (discriminatorTitle === 'PREDICT') {
|
|
8751
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
8752
|
+
if (parentObject !== undefined && fromTitle != null) {
|
|
8753
|
+
setValueByPath(parentObject, ['instances[]', 'title'], fromTitle);
|
|
8754
|
+
}
|
|
8755
|
+
}
|
|
8756
|
+
else if (discriminatorTitle === 'EMBED_CONTENT') {
|
|
8757
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
8758
|
+
if (parentObject !== undefined && fromTitle != null) {
|
|
8759
|
+
setValueByPath(parentObject, ['title'], fromTitle);
|
|
8760
|
+
}
|
|
8761
|
+
}
|
|
8762
|
+
let discriminatorOutputDimensionality = getValueByPath(rootObject, [
|
|
8763
|
+
'embeddingApiType',
|
|
8764
|
+
]);
|
|
8765
|
+
if (discriminatorOutputDimensionality === undefined) {
|
|
8766
|
+
discriminatorOutputDimensionality = 'PREDICT';
|
|
8767
|
+
}
|
|
8768
|
+
if (discriminatorOutputDimensionality === 'PREDICT') {
|
|
8769
|
+
const fromOutputDimensionality = getValueByPath(fromObject, [
|
|
8770
|
+
'outputDimensionality',
|
|
8771
|
+
]);
|
|
8772
|
+
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
8773
|
+
setValueByPath(parentObject, ['parameters', 'outputDimensionality'], fromOutputDimensionality);
|
|
8774
|
+
}
|
|
8775
|
+
}
|
|
8776
|
+
else if (discriminatorOutputDimensionality === 'EMBED_CONTENT') {
|
|
8777
|
+
const fromOutputDimensionality = getValueByPath(fromObject, [
|
|
8778
|
+
'outputDimensionality',
|
|
8779
|
+
]);
|
|
8780
|
+
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
8781
|
+
setValueByPath(parentObject, ['outputDimensionality'], fromOutputDimensionality);
|
|
8782
|
+
}
|
|
8783
|
+
}
|
|
8784
|
+
let discriminatorMimeType = getValueByPath(rootObject, [
|
|
8785
|
+
'embeddingApiType',
|
|
8786
|
+
]);
|
|
8787
|
+
if (discriminatorMimeType === undefined) {
|
|
8788
|
+
discriminatorMimeType = 'PREDICT';
|
|
8789
|
+
}
|
|
8790
|
+
if (discriminatorMimeType === 'PREDICT') {
|
|
8791
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
8792
|
+
if (parentObject !== undefined && fromMimeType != null) {
|
|
8793
|
+
setValueByPath(parentObject, ['instances[]', 'mimeType'], fromMimeType);
|
|
8794
|
+
}
|
|
8660
8795
|
}
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8796
|
+
let discriminatorAutoTruncate = getValueByPath(rootObject, [
|
|
8797
|
+
'embeddingApiType',
|
|
8798
|
+
]);
|
|
8799
|
+
if (discriminatorAutoTruncate === undefined) {
|
|
8800
|
+
discriminatorAutoTruncate = 'PREDICT';
|
|
8801
|
+
}
|
|
8802
|
+
if (discriminatorAutoTruncate === 'PREDICT') {
|
|
8803
|
+
const fromAutoTruncate = getValueByPath(fromObject, [
|
|
8804
|
+
'autoTruncate',
|
|
8805
|
+
]);
|
|
8806
|
+
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
8807
|
+
setValueByPath(parentObject, ['parameters', 'autoTruncate'], fromAutoTruncate);
|
|
8808
|
+
}
|
|
8809
|
+
}
|
|
8810
|
+
else if (discriminatorAutoTruncate === 'EMBED_CONTENT') {
|
|
8811
|
+
const fromAutoTruncate = getValueByPath(fromObject, [
|
|
8812
|
+
'autoTruncate',
|
|
8813
|
+
]);
|
|
8814
|
+
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
8815
|
+
setValueByPath(parentObject, ['autoTruncate'], fromAutoTruncate);
|
|
8816
|
+
}
|
|
8664
8817
|
}
|
|
8665
8818
|
return toObject;
|
|
8666
8819
|
}
|
|
8667
|
-
function
|
|
8820
|
+
function embedContentParametersPrivateToMldev(apiClient, fromObject, rootObject) {
|
|
8668
8821
|
const toObject = {};
|
|
8669
8822
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
8670
8823
|
if (fromModel != null) {
|
|
@@ -8680,6 +8833,10 @@ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
|
|
|
8680
8833
|
}
|
|
8681
8834
|
setValueByPath(toObject, ['requests[]', 'content'], transformedList);
|
|
8682
8835
|
}
|
|
8836
|
+
const fromContent = getValueByPath(fromObject, ['content']);
|
|
8837
|
+
if (fromContent != null) {
|
|
8838
|
+
contentToMldev$1(tContent(fromContent));
|
|
8839
|
+
}
|
|
8683
8840
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8684
8841
|
if (fromConfig != null) {
|
|
8685
8842
|
embedContentConfigToMldev(fromConfig, toObject);
|
|
@@ -8690,25 +8847,45 @@ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
|
|
|
8690
8847
|
}
|
|
8691
8848
|
return toObject;
|
|
8692
8849
|
}
|
|
8693
|
-
function
|
|
8850
|
+
function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject) {
|
|
8694
8851
|
const toObject = {};
|
|
8695
8852
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
8696
8853
|
if (fromModel != null) {
|
|
8697
8854
|
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
8698
8855
|
}
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8856
|
+
let discriminatorContents = getValueByPath(rootObject, [
|
|
8857
|
+
'embeddingApiType',
|
|
8858
|
+
]);
|
|
8859
|
+
if (discriminatorContents === undefined) {
|
|
8860
|
+
discriminatorContents = 'PREDICT';
|
|
8861
|
+
}
|
|
8862
|
+
if (discriminatorContents === 'PREDICT') {
|
|
8863
|
+
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
8864
|
+
if (fromContents != null) {
|
|
8865
|
+
let transformedList = tContentsForEmbed(apiClient, fromContents);
|
|
8866
|
+
if (Array.isArray(transformedList)) {
|
|
8867
|
+
transformedList = transformedList.map((item) => {
|
|
8868
|
+
return item;
|
|
8869
|
+
});
|
|
8870
|
+
}
|
|
8871
|
+
setValueByPath(toObject, ['instances[]', 'content'], transformedList);
|
|
8872
|
+
}
|
|
8873
|
+
}
|
|
8874
|
+
let discriminatorContent = getValueByPath(rootObject, [
|
|
8875
|
+
'embeddingApiType',
|
|
8876
|
+
]);
|
|
8877
|
+
if (discriminatorContent === undefined) {
|
|
8878
|
+
discriminatorContent = 'PREDICT';
|
|
8879
|
+
}
|
|
8880
|
+
if (discriminatorContent === 'EMBED_CONTENT') {
|
|
8881
|
+
const fromContent = getValueByPath(fromObject, ['content']);
|
|
8882
|
+
if (fromContent != null) {
|
|
8883
|
+
setValueByPath(toObject, ['content'], tContent(fromContent));
|
|
8706
8884
|
}
|
|
8707
|
-
setValueByPath(toObject, ['instances[]', 'content'], transformedList);
|
|
8708
8885
|
}
|
|
8709
8886
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8710
8887
|
if (fromConfig != null) {
|
|
8711
|
-
embedContentConfigToVertex(fromConfig, toObject);
|
|
8888
|
+
embedContentConfigToVertex(fromConfig, toObject, rootObject);
|
|
8712
8889
|
}
|
|
8713
8890
|
return toObject;
|
|
8714
8891
|
}
|
|
@@ -8761,6 +8938,24 @@ function embedContentResponseFromVertex(fromObject, rootObject) {
|
|
|
8761
8938
|
if (fromMetadata != null) {
|
|
8762
8939
|
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
8763
8940
|
}
|
|
8941
|
+
if (rootObject &&
|
|
8942
|
+
getValueByPath(rootObject, ['embeddingApiType']) === 'EMBED_CONTENT') {
|
|
8943
|
+
const embedding = getValueByPath(fromObject, ['embedding']);
|
|
8944
|
+
const usageMetadata = getValueByPath(fromObject, ['usageMetadata']);
|
|
8945
|
+
const truncated = getValueByPath(fromObject, ['truncated']);
|
|
8946
|
+
if (embedding) {
|
|
8947
|
+
const stats = {};
|
|
8948
|
+
if (usageMetadata &&
|
|
8949
|
+
usageMetadata['promptTokenCount']) {
|
|
8950
|
+
stats.tokenCount = usageMetadata['promptTokenCount'];
|
|
8951
|
+
}
|
|
8952
|
+
if (truncated) {
|
|
8953
|
+
stats.truncated = truncated;
|
|
8954
|
+
}
|
|
8955
|
+
embedding.statistics = stats;
|
|
8956
|
+
setValueByPath(toObject, ['embeddings'], [embedding]);
|
|
8957
|
+
}
|
|
8958
|
+
}
|
|
8764
8959
|
return toObject;
|
|
8765
8960
|
}
|
|
8766
8961
|
function endpointFromVertex(fromObject, _rootObject) {
|
|
@@ -10187,6 +10382,10 @@ function googleMapsToMldev$1(fromObject, _rootObject) {
|
|
|
10187
10382
|
}
|
|
10188
10383
|
function googleSearchToMldev$1(fromObject, _rootObject) {
|
|
10189
10384
|
const toObject = {};
|
|
10385
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
10386
|
+
if (fromSearchTypes != null) {
|
|
10387
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
10388
|
+
}
|
|
10190
10389
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
10191
10390
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
10192
10391
|
}
|
|
@@ -10214,6 +10413,9 @@ function imageConfigToMldev(fromObject, _rootObject) {
|
|
|
10214
10413
|
if (getValueByPath(fromObject, ['personGeneration']) !== undefined) {
|
|
10215
10414
|
throw new Error('personGeneration parameter is not supported in Gemini API.');
|
|
10216
10415
|
}
|
|
10416
|
+
if (getValueByPath(fromObject, ['prominentPeople']) !== undefined) {
|
|
10417
|
+
throw new Error('prominentPeople parameter is not supported in Gemini API.');
|
|
10418
|
+
}
|
|
10217
10419
|
if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
|
|
10218
10420
|
throw new Error('outputMimeType parameter is not supported in Gemini API.');
|
|
10219
10421
|
}
|
|
@@ -10239,6 +10441,12 @@ function imageConfigToVertex(fromObject, _rootObject) {
|
|
|
10239
10441
|
if (fromPersonGeneration != null) {
|
|
10240
10442
|
setValueByPath(toObject, ['personGeneration'], fromPersonGeneration);
|
|
10241
10443
|
}
|
|
10444
|
+
const fromProminentPeople = getValueByPath(fromObject, [
|
|
10445
|
+
'prominentPeople',
|
|
10446
|
+
]);
|
|
10447
|
+
if (fromProminentPeople != null) {
|
|
10448
|
+
setValueByPath(toObject, ['prominentPeople'], fromProminentPeople);
|
|
10449
|
+
}
|
|
10242
10450
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
10243
10451
|
'outputMimeType',
|
|
10244
10452
|
]);
|
|
@@ -10966,6 +11174,10 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
10966
11174
|
if (fromFileSearch != null) {
|
|
10967
11175
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
10968
11176
|
}
|
|
11177
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11178
|
+
if (fromGoogleSearch != null) {
|
|
11179
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
11180
|
+
}
|
|
10969
11181
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
10970
11182
|
'codeExecution',
|
|
10971
11183
|
]);
|
|
@@ -10991,10 +11203,6 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
10991
11203
|
if (fromGoogleMaps != null) {
|
|
10992
11204
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$1(fromGoogleMaps));
|
|
10993
11205
|
}
|
|
10994
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
10995
|
-
if (fromGoogleSearch != null) {
|
|
10996
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
10997
|
-
}
|
|
10998
11206
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
10999
11207
|
'googleSearchRetrieval',
|
|
11000
11208
|
]);
|
|
@@ -11005,6 +11213,16 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
11005
11213
|
if (fromUrlContext != null) {
|
|
11006
11214
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
11007
11215
|
}
|
|
11216
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
11217
|
+
if (fromMcpServers != null) {
|
|
11218
|
+
let transformedList = fromMcpServers;
|
|
11219
|
+
if (Array.isArray(transformedList)) {
|
|
11220
|
+
transformedList = transformedList.map((item) => {
|
|
11221
|
+
return item;
|
|
11222
|
+
});
|
|
11223
|
+
}
|
|
11224
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
11225
|
+
}
|
|
11008
11226
|
return toObject;
|
|
11009
11227
|
}
|
|
11010
11228
|
function toolToVertex(fromObject, rootObject) {
|
|
@@ -11020,6 +11238,10 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
11020
11238
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
11021
11239
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
11022
11240
|
}
|
|
11241
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11242
|
+
if (fromGoogleSearch != null) {
|
|
11243
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
11244
|
+
}
|
|
11023
11245
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
11024
11246
|
'codeExecution',
|
|
11025
11247
|
]);
|
|
@@ -11048,10 +11270,6 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
11048
11270
|
if (fromGoogleMaps != null) {
|
|
11049
11271
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
11050
11272
|
}
|
|
11051
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11052
|
-
if (fromGoogleSearch != null) {
|
|
11053
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
11054
|
-
}
|
|
11055
11273
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
11056
11274
|
'googleSearchRetrieval',
|
|
11057
11275
|
]);
|
|
@@ -11062,6 +11280,9 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
11062
11280
|
if (fromUrlContext != null) {
|
|
11063
11281
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
11064
11282
|
}
|
|
11283
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
11284
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
11285
|
+
}
|
|
11065
11286
|
return toObject;
|
|
11066
11287
|
}
|
|
11067
11288
|
function tunedModelInfoFromMldev(fromObject, _rootObject) {
|
|
@@ -11618,7 +11839,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
11618
11839
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
11619
11840
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
11620
11841
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
11621
|
-
const SDK_VERSION = '1.
|
|
11842
|
+
const SDK_VERSION = '1.43.0'; // x-release-please-version
|
|
11622
11843
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
11623
11844
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
11624
11845
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13219,6 +13440,47 @@ class Models extends BaseModule {
|
|
|
13219
13440
|
constructor(apiClient) {
|
|
13220
13441
|
super();
|
|
13221
13442
|
this.apiClient = apiClient;
|
|
13443
|
+
/**
|
|
13444
|
+
* Calculates embeddings for the given contents.
|
|
13445
|
+
*
|
|
13446
|
+
* @param params - The parameters for embedding contents.
|
|
13447
|
+
* @return The response from the API.
|
|
13448
|
+
*
|
|
13449
|
+
* @example
|
|
13450
|
+
* ```ts
|
|
13451
|
+
* const response = await ai.models.embedContent({
|
|
13452
|
+
* model: 'text-embedding-004',
|
|
13453
|
+
* contents: [
|
|
13454
|
+
* 'What is your name?',
|
|
13455
|
+
* 'What is your favorite color?',
|
|
13456
|
+
* ],
|
|
13457
|
+
* config: {
|
|
13458
|
+
* outputDimensionality: 64,
|
|
13459
|
+
* },
|
|
13460
|
+
* });
|
|
13461
|
+
* console.log(response);
|
|
13462
|
+
* ```
|
|
13463
|
+
*/
|
|
13464
|
+
this.embedContent = async (params) => {
|
|
13465
|
+
if (!this.apiClient.isVertexAI()) {
|
|
13466
|
+
return await this.embedContentInternal(params);
|
|
13467
|
+
}
|
|
13468
|
+
const isVertexEmbedContentModel = (params.model.includes('gemini') &&
|
|
13469
|
+
params.model !== 'gemini-embedding-001') ||
|
|
13470
|
+
params.model.includes('maas');
|
|
13471
|
+
if (isVertexEmbedContentModel) {
|
|
13472
|
+
const contents = tContents(params.contents);
|
|
13473
|
+
if (contents.length > 1) {
|
|
13474
|
+
throw new Error('The embedContent API for this model only supports one content at a time.');
|
|
13475
|
+
}
|
|
13476
|
+
const paramsPrivate = Object.assign(Object.assign({}, params), { content: contents[0], embeddingApiType: EmbeddingApiType.EMBED_CONTENT });
|
|
13477
|
+
return await this.embedContentInternal(paramsPrivate);
|
|
13478
|
+
}
|
|
13479
|
+
else {
|
|
13480
|
+
const paramsPrivate = Object.assign(Object.assign({}, params), { embeddingApiType: EmbeddingApiType.PREDICT });
|
|
13481
|
+
return await this.embedContentInternal(paramsPrivate);
|
|
13482
|
+
}
|
|
13483
|
+
};
|
|
13222
13484
|
/**
|
|
13223
13485
|
* Makes an API request to generate content with a given model.
|
|
13224
13486
|
*
|
|
@@ -13906,14 +14168,17 @@ class Models extends BaseModule {
|
|
|
13906
14168
|
* console.log(response);
|
|
13907
14169
|
* ```
|
|
13908
14170
|
*/
|
|
13909
|
-
async
|
|
14171
|
+
async embedContentInternal(params) {
|
|
13910
14172
|
var _a, _b, _c, _d;
|
|
13911
14173
|
let response;
|
|
13912
14174
|
let path = '';
|
|
13913
14175
|
let queryParams = {};
|
|
13914
14176
|
if (this.apiClient.isVertexAI()) {
|
|
13915
|
-
const body =
|
|
13916
|
-
|
|
14177
|
+
const body = embedContentParametersPrivateToVertex(this.apiClient, params, params);
|
|
14178
|
+
const endpointUrl = tIsVertexEmbedContentModel(params.model)
|
|
14179
|
+
? '{model}:embedContent'
|
|
14180
|
+
: '{model}:predict';
|
|
14181
|
+
path = formatMap(endpointUrl, body['_url']);
|
|
13917
14182
|
queryParams = body['_query'];
|
|
13918
14183
|
delete body['_url'];
|
|
13919
14184
|
delete body['_query'];
|
|
@@ -13936,14 +14201,14 @@ class Models extends BaseModule {
|
|
|
13936
14201
|
});
|
|
13937
14202
|
});
|
|
13938
14203
|
return response.then((apiResponse) => {
|
|
13939
|
-
const resp = embedContentResponseFromVertex(apiResponse);
|
|
14204
|
+
const resp = embedContentResponseFromVertex(apiResponse, params);
|
|
13940
14205
|
const typedResp = new EmbedContentResponse();
|
|
13941
14206
|
Object.assign(typedResp, resp);
|
|
13942
14207
|
return typedResp;
|
|
13943
14208
|
});
|
|
13944
14209
|
}
|
|
13945
14210
|
else {
|
|
13946
|
-
const body =
|
|
14211
|
+
const body = embedContentParametersPrivateToMldev(this.apiClient, params);
|
|
13947
14212
|
path = formatMap('{model}:batchEmbedContents', body['_url']);
|
|
13948
14213
|
queryParams = body['_query'];
|
|
13949
14214
|
delete body['_url'];
|
|
@@ -15027,6 +15292,10 @@ function googleMapsToMldev(fromObject) {
|
|
|
15027
15292
|
}
|
|
15028
15293
|
function googleSearchToMldev(fromObject) {
|
|
15029
15294
|
const toObject = {};
|
|
15295
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
15296
|
+
if (fromSearchTypes != null) {
|
|
15297
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
15298
|
+
}
|
|
15030
15299
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
15031
15300
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
15032
15301
|
}
|
|
@@ -15250,6 +15519,10 @@ function toolToMldev(fromObject) {
|
|
|
15250
15519
|
if (fromFileSearch != null) {
|
|
15251
15520
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
15252
15521
|
}
|
|
15522
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
15523
|
+
if (fromGoogleSearch != null) {
|
|
15524
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
15525
|
+
}
|
|
15253
15526
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
15254
15527
|
'codeExecution',
|
|
15255
15528
|
]);
|
|
@@ -15275,10 +15548,6 @@ function toolToMldev(fromObject) {
|
|
|
15275
15548
|
if (fromGoogleMaps != null) {
|
|
15276
15549
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev(fromGoogleMaps));
|
|
15277
15550
|
}
|
|
15278
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
15279
|
-
if (fromGoogleSearch != null) {
|
|
15280
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
15281
|
-
}
|
|
15282
15551
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
15283
15552
|
'googleSearchRetrieval',
|
|
15284
15553
|
]);
|
|
@@ -15289,6 +15558,16 @@ function toolToMldev(fromObject) {
|
|
|
15289
15558
|
if (fromUrlContext != null) {
|
|
15290
15559
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
15291
15560
|
}
|
|
15561
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
15562
|
+
if (fromMcpServers != null) {
|
|
15563
|
+
let transformedList = fromMcpServers;
|
|
15564
|
+
if (Array.isArray(transformedList)) {
|
|
15565
|
+
transformedList = transformedList.map((item) => {
|
|
15566
|
+
return item;
|
|
15567
|
+
});
|
|
15568
|
+
}
|
|
15569
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
15570
|
+
}
|
|
15292
15571
|
return toObject;
|
|
15293
15572
|
}
|
|
15294
15573
|
|
|
@@ -16746,14 +17025,17 @@ const createPathTagFunction = (pathEncoder = encodeURIPath) => (function path(st
|
|
|
16746
17025
|
return previousValue + currentValue + (index === params.length ? '' : encoded);
|
|
16747
17026
|
}, '');
|
|
16748
17027
|
const pathOnly = path.split(/[?#]/, 1)[0];
|
|
16749
|
-
const invalidSegmentPattern = /(
|
|
17028
|
+
const invalidSegmentPattern = /(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
16750
17029
|
let match;
|
|
16751
17030
|
// Find all invalid segments
|
|
16752
17031
|
while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
17032
|
+
const hasLeadingSlash = match[0].startsWith('/');
|
|
17033
|
+
const offset = hasLeadingSlash ? 1 : 0;
|
|
17034
|
+
const cleanMatch = hasLeadingSlash ? match[0].slice(1) : match[0];
|
|
16753
17035
|
invalidSegments.push({
|
|
16754
|
-
start: match.index,
|
|
16755
|
-
length:
|
|
16756
|
-
error: `Value "${
|
|
17036
|
+
start: match.index + offset,
|
|
17037
|
+
length: cleanMatch.length,
|
|
17038
|
+
error: `Value "${cleanMatch}" can\'t be safely passed as a path parameter`,
|
|
16757
17039
|
});
|
|
16758
17040
|
}
|
|
16759
17041
|
invalidSegments.sort((a, b) => a.start - b.start);
|
|
@@ -18033,6 +18315,13 @@ class BaseGeminiNextGenAPIClient {
|
|
|
18033
18315
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
18034
18316
|
return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
|
|
18035
18317
|
}
|
|
18318
|
+
else if (typeof body === 'object' &&
|
|
18319
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
18320
|
+
return {
|
|
18321
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
18322
|
+
body: this.stringifyQuery(body),
|
|
18323
|
+
};
|
|
18324
|
+
}
|
|
18036
18325
|
else {
|
|
18037
18326
|
return this.encoder({ body, headers });
|
|
18038
18327
|
}
|
|
@@ -19982,5 +20271,5 @@ function getApiKeyFromEnv() {
|
|
|
19982
20271
|
return envGoogleApiKey || envGeminiApiKey || undefined;
|
|
19983
20272
|
}
|
|
19984
20273
|
|
|
19985
|
-
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, RawReferenceImage, RecontextImageResponse, RegisterFilesResponse, ReplayResponse, ResourceScope, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, TrafficType, TuningMethod, TuningMode, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VadSignalType, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, VoiceActivityType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
20274
|
+
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EmbeddingApiType, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, ProminentPeople, RawReferenceImage, RecontextImageResponse, RegisterFilesResponse, ReplayResponse, ResourceScope, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, TrafficType, TuningMethod, TuningMode, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VadSignalType, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, VoiceActivityType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
19986
20275
|
//# sourceMappingURL=index.mjs.map
|