@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/web/index.mjs
CHANGED
|
@@ -674,6 +674,38 @@ var Type;
|
|
|
674
674
|
*/
|
|
675
675
|
Type["NULL"] = "NULL";
|
|
676
676
|
})(Type || (Type = {}));
|
|
677
|
+
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
678
|
+
var PhishBlockThreshold;
|
|
679
|
+
(function (PhishBlockThreshold) {
|
|
680
|
+
/**
|
|
681
|
+
* Defaults to unspecified.
|
|
682
|
+
*/
|
|
683
|
+
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
684
|
+
/**
|
|
685
|
+
* Blocks Low and above confidence URL that is risky.
|
|
686
|
+
*/
|
|
687
|
+
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
688
|
+
/**
|
|
689
|
+
* Blocks Medium and above confidence URL that is risky.
|
|
690
|
+
*/
|
|
691
|
+
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
692
|
+
/**
|
|
693
|
+
* Blocks High and above confidence URL that is risky.
|
|
694
|
+
*/
|
|
695
|
+
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
696
|
+
/**
|
|
697
|
+
* Blocks Higher and above confidence URL that is risky.
|
|
698
|
+
*/
|
|
699
|
+
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
700
|
+
/**
|
|
701
|
+
* Blocks Very high and above confidence URL that is risky.
|
|
702
|
+
*/
|
|
703
|
+
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
704
|
+
/**
|
|
705
|
+
* Blocks Extremely high confidence URL that is risky.
|
|
706
|
+
*/
|
|
707
|
+
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
708
|
+
})(PhishBlockThreshold || (PhishBlockThreshold = {}));
|
|
677
709
|
/** The API spec that the external API implements. This enum is not supported in Gemini API. */
|
|
678
710
|
var ApiSpec;
|
|
679
711
|
(function (ApiSpec) {
|
|
@@ -744,38 +776,6 @@ var HttpElementLocation;
|
|
|
744
776
|
*/
|
|
745
777
|
HttpElementLocation["HTTP_IN_COOKIE"] = "HTTP_IN_COOKIE";
|
|
746
778
|
})(HttpElementLocation || (HttpElementLocation = {}));
|
|
747
|
-
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
748
|
-
var PhishBlockThreshold;
|
|
749
|
-
(function (PhishBlockThreshold) {
|
|
750
|
-
/**
|
|
751
|
-
* Defaults to unspecified.
|
|
752
|
-
*/
|
|
753
|
-
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
754
|
-
/**
|
|
755
|
-
* Blocks Low and above confidence URL that is risky.
|
|
756
|
-
*/
|
|
757
|
-
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
758
|
-
/**
|
|
759
|
-
* Blocks Medium and above confidence URL that is risky.
|
|
760
|
-
*/
|
|
761
|
-
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
762
|
-
/**
|
|
763
|
-
* Blocks High and above confidence URL that is risky.
|
|
764
|
-
*/
|
|
765
|
-
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
766
|
-
/**
|
|
767
|
-
* Blocks Higher and above confidence URL that is risky.
|
|
768
|
-
*/
|
|
769
|
-
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
770
|
-
/**
|
|
771
|
-
* Blocks Very high and above confidence URL that is risky.
|
|
772
|
-
*/
|
|
773
|
-
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
774
|
-
/**
|
|
775
|
-
* Blocks Extremely high confidence URL that is risky.
|
|
776
|
-
*/
|
|
777
|
-
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
778
|
-
})(PhishBlockThreshold || (PhishBlockThreshold = {}));
|
|
779
779
|
/** Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This enum is not supported in Vertex AI. */
|
|
780
780
|
var Behavior;
|
|
781
781
|
(function (Behavior) {
|
|
@@ -1358,6 +1358,34 @@ var Environment;
|
|
|
1358
1358
|
*/
|
|
1359
1359
|
Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
|
|
1360
1360
|
})(Environment || (Environment = {}));
|
|
1361
|
+
/** Enum for controlling whether the model can generate images of prominent people (celebrities). */
|
|
1362
|
+
var ProminentPeople;
|
|
1363
|
+
(function (ProminentPeople) {
|
|
1364
|
+
/**
|
|
1365
|
+
* Unspecified value. The model will proceed with the default behavior, which is to allow generation of prominent people.
|
|
1366
|
+
*/
|
|
1367
|
+
ProminentPeople["PROMINENT_PEOPLE_UNSPECIFIED"] = "PROMINENT_PEOPLE_UNSPECIFIED";
|
|
1368
|
+
/**
|
|
1369
|
+
* Allows the model to generate images of prominent people.
|
|
1370
|
+
*/
|
|
1371
|
+
ProminentPeople["ALLOW_PROMINENT_PEOPLE"] = "ALLOW_PROMINENT_PEOPLE";
|
|
1372
|
+
/**
|
|
1373
|
+
* Prevents the model from generating images of prominent people.
|
|
1374
|
+
*/
|
|
1375
|
+
ProminentPeople["BLOCK_PROMINENT_PEOPLE"] = "BLOCK_PROMINENT_PEOPLE";
|
|
1376
|
+
})(ProminentPeople || (ProminentPeople = {}));
|
|
1377
|
+
/** Enum representing the Vertex embedding API to use. */
|
|
1378
|
+
var EmbeddingApiType;
|
|
1379
|
+
(function (EmbeddingApiType) {
|
|
1380
|
+
/**
|
|
1381
|
+
* predict API endpoint (default)
|
|
1382
|
+
*/
|
|
1383
|
+
EmbeddingApiType["PREDICT"] = "PREDICT";
|
|
1384
|
+
/**
|
|
1385
|
+
* embedContent API Endpoint
|
|
1386
|
+
*/
|
|
1387
|
+
EmbeddingApiType["EMBED_CONTENT"] = "EMBED_CONTENT";
|
|
1388
|
+
})(EmbeddingApiType || (EmbeddingApiType = {}));
|
|
1361
1389
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
1362
1390
|
var SafetyFilterLevel;
|
|
1363
1391
|
(function (SafetyFilterLevel) {
|
|
@@ -3389,6 +3417,10 @@ function tJobState(state) {
|
|
|
3389
3417
|
return stateString;
|
|
3390
3418
|
}
|
|
3391
3419
|
}
|
|
3420
|
+
function tIsVertexEmbedContentModel(model) {
|
|
3421
|
+
return ((model.includes('gemini') && model !== 'gemini-embedding-001') ||
|
|
3422
|
+
model.includes('maas'));
|
|
3423
|
+
}
|
|
3392
3424
|
|
|
3393
3425
|
/**
|
|
3394
3426
|
* @license
|
|
@@ -3700,16 +3732,16 @@ function candidateFromMldev$1(fromObject) {
|
|
|
3700
3732
|
if (fromFinishReason != null) {
|
|
3701
3733
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
3702
3734
|
}
|
|
3703
|
-
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
3704
|
-
if (fromAvgLogprobs != null) {
|
|
3705
|
-
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
3706
|
-
}
|
|
3707
3735
|
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
3708
3736
|
'groundingMetadata',
|
|
3709
3737
|
]);
|
|
3710
3738
|
if (fromGroundingMetadata != null) {
|
|
3711
3739
|
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
3712
3740
|
}
|
|
3741
|
+
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
3742
|
+
if (fromAvgLogprobs != null) {
|
|
3743
|
+
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
3744
|
+
}
|
|
3713
3745
|
const fromIndex = getValueByPath(fromObject, ['index']);
|
|
3714
3746
|
if (fromIndex != null) {
|
|
3715
3747
|
setValueByPath(toObject, ['index'], fromIndex);
|
|
@@ -4255,6 +4287,10 @@ function googleMapsToMldev$4(fromObject) {
|
|
|
4255
4287
|
}
|
|
4256
4288
|
function googleSearchToMldev$4(fromObject) {
|
|
4257
4289
|
const toObject = {};
|
|
4290
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
4291
|
+
if (fromSearchTypes != null) {
|
|
4292
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
4293
|
+
}
|
|
4258
4294
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
4259
4295
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
4260
4296
|
}
|
|
@@ -4282,6 +4318,9 @@ function imageConfigToMldev$1(fromObject) {
|
|
|
4282
4318
|
if (getValueByPath(fromObject, ['personGeneration']) !== undefined) {
|
|
4283
4319
|
throw new Error('personGeneration parameter is not supported in Gemini API.');
|
|
4284
4320
|
}
|
|
4321
|
+
if (getValueByPath(fromObject, ['prominentPeople']) !== undefined) {
|
|
4322
|
+
throw new Error('prominentPeople parameter is not supported in Gemini API.');
|
|
4323
|
+
}
|
|
4285
4324
|
if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
|
|
4286
4325
|
throw new Error('outputMimeType parameter is not supported in Gemini API.');
|
|
4287
4326
|
}
|
|
@@ -4538,6 +4577,10 @@ function toolToMldev$4(fromObject) {
|
|
|
4538
4577
|
if (fromFileSearch != null) {
|
|
4539
4578
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
4540
4579
|
}
|
|
4580
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4581
|
+
if (fromGoogleSearch != null) {
|
|
4582
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
4583
|
+
}
|
|
4541
4584
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4542
4585
|
'codeExecution',
|
|
4543
4586
|
]);
|
|
@@ -4563,10 +4606,6 @@ function toolToMldev$4(fromObject) {
|
|
|
4563
4606
|
if (fromGoogleMaps != null) {
|
|
4564
4607
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$4(fromGoogleMaps));
|
|
4565
4608
|
}
|
|
4566
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4567
|
-
if (fromGoogleSearch != null) {
|
|
4568
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
4569
|
-
}
|
|
4570
4609
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
4571
4610
|
'googleSearchRetrieval',
|
|
4572
4611
|
]);
|
|
@@ -4577,6 +4616,16 @@ function toolToMldev$4(fromObject) {
|
|
|
4577
4616
|
if (fromUrlContext != null) {
|
|
4578
4617
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
4579
4618
|
}
|
|
4619
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
4620
|
+
if (fromMcpServers != null) {
|
|
4621
|
+
let transformedList = fromMcpServers;
|
|
4622
|
+
if (Array.isArray(transformedList)) {
|
|
4623
|
+
transformedList = transformedList.map((item) => {
|
|
4624
|
+
return item;
|
|
4625
|
+
});
|
|
4626
|
+
}
|
|
4627
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
4628
|
+
}
|
|
4580
4629
|
return toObject;
|
|
4581
4630
|
}
|
|
4582
4631
|
|
|
@@ -5583,6 +5632,10 @@ function googleMapsToMldev$3(fromObject) {
|
|
|
5583
5632
|
}
|
|
5584
5633
|
function googleSearchToMldev$3(fromObject) {
|
|
5585
5634
|
const toObject = {};
|
|
5635
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
5636
|
+
if (fromSearchTypes != null) {
|
|
5637
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
5638
|
+
}
|
|
5586
5639
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
5587
5640
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
5588
5641
|
}
|
|
@@ -5782,6 +5835,10 @@ function toolToMldev$3(fromObject) {
|
|
|
5782
5835
|
if (fromFileSearch != null) {
|
|
5783
5836
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
5784
5837
|
}
|
|
5838
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5839
|
+
if (fromGoogleSearch != null) {
|
|
5840
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
5841
|
+
}
|
|
5785
5842
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5786
5843
|
'codeExecution',
|
|
5787
5844
|
]);
|
|
@@ -5807,10 +5864,6 @@ function toolToMldev$3(fromObject) {
|
|
|
5807
5864
|
if (fromGoogleMaps != null) {
|
|
5808
5865
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$3(fromGoogleMaps));
|
|
5809
5866
|
}
|
|
5810
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5811
|
-
if (fromGoogleSearch != null) {
|
|
5812
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
5813
|
-
}
|
|
5814
5867
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
5815
5868
|
'googleSearchRetrieval',
|
|
5816
5869
|
]);
|
|
@@ -5821,6 +5874,16 @@ function toolToMldev$3(fromObject) {
|
|
|
5821
5874
|
if (fromUrlContext != null) {
|
|
5822
5875
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
5823
5876
|
}
|
|
5877
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
5878
|
+
if (fromMcpServers != null) {
|
|
5879
|
+
let transformedList = fromMcpServers;
|
|
5880
|
+
if (Array.isArray(transformedList)) {
|
|
5881
|
+
transformedList = transformedList.map((item) => {
|
|
5882
|
+
return item;
|
|
5883
|
+
});
|
|
5884
|
+
}
|
|
5885
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
5886
|
+
}
|
|
5824
5887
|
return toObject;
|
|
5825
5888
|
}
|
|
5826
5889
|
function toolToVertex$2(fromObject) {
|
|
@@ -5836,6 +5899,10 @@ function toolToVertex$2(fromObject) {
|
|
|
5836
5899
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
5837
5900
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
5838
5901
|
}
|
|
5902
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5903
|
+
if (fromGoogleSearch != null) {
|
|
5904
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
5905
|
+
}
|
|
5839
5906
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5840
5907
|
'codeExecution',
|
|
5841
5908
|
]);
|
|
@@ -5864,10 +5931,6 @@ function toolToVertex$2(fromObject) {
|
|
|
5864
5931
|
if (fromGoogleMaps != null) {
|
|
5865
5932
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
5866
5933
|
}
|
|
5867
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5868
|
-
if (fromGoogleSearch != null) {
|
|
5869
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
5870
|
-
}
|
|
5871
5934
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
5872
5935
|
'googleSearchRetrieval',
|
|
5873
5936
|
]);
|
|
@@ -5878,6 +5941,9 @@ function toolToVertex$2(fromObject) {
|
|
|
5878
5941
|
if (fromUrlContext != null) {
|
|
5879
5942
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
5880
5943
|
}
|
|
5944
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
5945
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
5946
|
+
}
|
|
5881
5947
|
return toObject;
|
|
5882
5948
|
}
|
|
5883
5949
|
function updateCachedContentConfigToMldev(fromObject, parentObject) {
|
|
@@ -7411,6 +7477,10 @@ function googleMapsToMldev$2(fromObject) {
|
|
|
7411
7477
|
}
|
|
7412
7478
|
function googleSearchToMldev$2(fromObject) {
|
|
7413
7479
|
const toObject = {};
|
|
7480
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
7481
|
+
if (fromSearchTypes != null) {
|
|
7482
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
7483
|
+
}
|
|
7414
7484
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
7415
7485
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
7416
7486
|
}
|
|
@@ -7926,6 +7996,10 @@ function toolToMldev$2(fromObject) {
|
|
|
7926
7996
|
if (fromFileSearch != null) {
|
|
7927
7997
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
7928
7998
|
}
|
|
7999
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
8000
|
+
if (fromGoogleSearch != null) {
|
|
8001
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
8002
|
+
}
|
|
7929
8003
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
7930
8004
|
'codeExecution',
|
|
7931
8005
|
]);
|
|
@@ -7951,10 +8025,6 @@ function toolToMldev$2(fromObject) {
|
|
|
7951
8025
|
if (fromGoogleMaps != null) {
|
|
7952
8026
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$2(fromGoogleMaps));
|
|
7953
8027
|
}
|
|
7954
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
7955
|
-
if (fromGoogleSearch != null) {
|
|
7956
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
7957
|
-
}
|
|
7958
8028
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
7959
8029
|
'googleSearchRetrieval',
|
|
7960
8030
|
]);
|
|
@@ -7965,6 +8035,16 @@ function toolToMldev$2(fromObject) {
|
|
|
7965
8035
|
if (fromUrlContext != null) {
|
|
7966
8036
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
7967
8037
|
}
|
|
8038
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
8039
|
+
if (fromMcpServers != null) {
|
|
8040
|
+
let transformedList = fromMcpServers;
|
|
8041
|
+
if (Array.isArray(transformedList)) {
|
|
8042
|
+
transformedList = transformedList.map((item) => {
|
|
8043
|
+
return item;
|
|
8044
|
+
});
|
|
8045
|
+
}
|
|
8046
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
8047
|
+
}
|
|
7968
8048
|
return toObject;
|
|
7969
8049
|
}
|
|
7970
8050
|
function toolToVertex$1(fromObject) {
|
|
@@ -7980,6 +8060,10 @@ function toolToVertex$1(fromObject) {
|
|
|
7980
8060
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
7981
8061
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
7982
8062
|
}
|
|
8063
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
8064
|
+
if (fromGoogleSearch != null) {
|
|
8065
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
8066
|
+
}
|
|
7983
8067
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
7984
8068
|
'codeExecution',
|
|
7985
8069
|
]);
|
|
@@ -8008,10 +8092,6 @@ function toolToVertex$1(fromObject) {
|
|
|
8008
8092
|
if (fromGoogleMaps != null) {
|
|
8009
8093
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
8010
8094
|
}
|
|
8011
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
8012
|
-
if (fromGoogleSearch != null) {
|
|
8013
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
8014
|
-
}
|
|
8015
8095
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
8016
8096
|
'googleSearchRetrieval',
|
|
8017
8097
|
]);
|
|
@@ -8022,6 +8102,9 @@ function toolToVertex$1(fromObject) {
|
|
|
8022
8102
|
if (fromUrlContext != null) {
|
|
8023
8103
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
8024
8104
|
}
|
|
8105
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
8106
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
8107
|
+
}
|
|
8025
8108
|
return toObject;
|
|
8026
8109
|
}
|
|
8027
8110
|
function usageMetadataFromVertex(fromObject) {
|
|
@@ -8165,16 +8248,16 @@ function candidateFromMldev(fromObject, rootObject) {
|
|
|
8165
8248
|
if (fromFinishReason != null) {
|
|
8166
8249
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
8167
8250
|
}
|
|
8168
|
-
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
8169
|
-
if (fromAvgLogprobs != null) {
|
|
8170
|
-
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
8171
|
-
}
|
|
8172
8251
|
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
8173
8252
|
'groundingMetadata',
|
|
8174
8253
|
]);
|
|
8175
8254
|
if (fromGroundingMetadata != null) {
|
|
8176
8255
|
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
8177
8256
|
}
|
|
8257
|
+
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
8258
|
+
if (fromAvgLogprobs != null) {
|
|
8259
|
+
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
8260
|
+
}
|
|
8178
8261
|
const fromIndex = getValueByPath(fromObject, ['index']);
|
|
8179
8262
|
if (fromIndex != null) {
|
|
8180
8263
|
setValueByPath(toObject, ['index'], fromIndex);
|
|
@@ -8630,33 +8713,103 @@ function embedContentConfigToMldev(fromObject, parentObject, _rootObject) {
|
|
|
8630
8713
|
}
|
|
8631
8714
|
return toObject;
|
|
8632
8715
|
}
|
|
8633
|
-
function embedContentConfigToVertex(fromObject, parentObject,
|
|
8716
|
+
function embedContentConfigToVertex(fromObject, parentObject, rootObject) {
|
|
8634
8717
|
const toObject = {};
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8718
|
+
let discriminatorTaskType = getValueByPath(rootObject, [
|
|
8719
|
+
'embeddingApiType',
|
|
8720
|
+
]);
|
|
8721
|
+
if (discriminatorTaskType === undefined) {
|
|
8722
|
+
discriminatorTaskType = 'PREDICT';
|
|
8638
8723
|
}
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8724
|
+
if (discriminatorTaskType === 'PREDICT') {
|
|
8725
|
+
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
8726
|
+
if (parentObject !== undefined && fromTaskType != null) {
|
|
8727
|
+
setValueByPath(parentObject, ['instances[]', 'task_type'], fromTaskType);
|
|
8728
|
+
}
|
|
8642
8729
|
}
|
|
8643
|
-
|
|
8644
|
-
'
|
|
8730
|
+
else if (discriminatorTaskType === 'EMBED_CONTENT') {
|
|
8731
|
+
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
8732
|
+
if (parentObject !== undefined && fromTaskType != null) {
|
|
8733
|
+
setValueByPath(parentObject, ['taskType'], fromTaskType);
|
|
8734
|
+
}
|
|
8735
|
+
}
|
|
8736
|
+
let discriminatorTitle = getValueByPath(rootObject, [
|
|
8737
|
+
'embeddingApiType',
|
|
8645
8738
|
]);
|
|
8646
|
-
if (
|
|
8647
|
-
|
|
8739
|
+
if (discriminatorTitle === undefined) {
|
|
8740
|
+
discriminatorTitle = 'PREDICT';
|
|
8648
8741
|
}
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8742
|
+
if (discriminatorTitle === 'PREDICT') {
|
|
8743
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
8744
|
+
if (parentObject !== undefined && fromTitle != null) {
|
|
8745
|
+
setValueByPath(parentObject, ['instances[]', 'title'], fromTitle);
|
|
8746
|
+
}
|
|
8747
|
+
}
|
|
8748
|
+
else if (discriminatorTitle === 'EMBED_CONTENT') {
|
|
8749
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
8750
|
+
if (parentObject !== undefined && fromTitle != null) {
|
|
8751
|
+
setValueByPath(parentObject, ['title'], fromTitle);
|
|
8752
|
+
}
|
|
8753
|
+
}
|
|
8754
|
+
let discriminatorOutputDimensionality = getValueByPath(rootObject, [
|
|
8755
|
+
'embeddingApiType',
|
|
8756
|
+
]);
|
|
8757
|
+
if (discriminatorOutputDimensionality === undefined) {
|
|
8758
|
+
discriminatorOutputDimensionality = 'PREDICT';
|
|
8759
|
+
}
|
|
8760
|
+
if (discriminatorOutputDimensionality === 'PREDICT') {
|
|
8761
|
+
const fromOutputDimensionality = getValueByPath(fromObject, [
|
|
8762
|
+
'outputDimensionality',
|
|
8763
|
+
]);
|
|
8764
|
+
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
8765
|
+
setValueByPath(parentObject, ['parameters', 'outputDimensionality'], fromOutputDimensionality);
|
|
8766
|
+
}
|
|
8767
|
+
}
|
|
8768
|
+
else if (discriminatorOutputDimensionality === 'EMBED_CONTENT') {
|
|
8769
|
+
const fromOutputDimensionality = getValueByPath(fromObject, [
|
|
8770
|
+
'outputDimensionality',
|
|
8771
|
+
]);
|
|
8772
|
+
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
8773
|
+
setValueByPath(parentObject, ['outputDimensionality'], fromOutputDimensionality);
|
|
8774
|
+
}
|
|
8775
|
+
}
|
|
8776
|
+
let discriminatorMimeType = getValueByPath(rootObject, [
|
|
8777
|
+
'embeddingApiType',
|
|
8778
|
+
]);
|
|
8779
|
+
if (discriminatorMimeType === undefined) {
|
|
8780
|
+
discriminatorMimeType = 'PREDICT';
|
|
8781
|
+
}
|
|
8782
|
+
if (discriminatorMimeType === 'PREDICT') {
|
|
8783
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
8784
|
+
if (parentObject !== undefined && fromMimeType != null) {
|
|
8785
|
+
setValueByPath(parentObject, ['instances[]', 'mimeType'], fromMimeType);
|
|
8786
|
+
}
|
|
8652
8787
|
}
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8788
|
+
let discriminatorAutoTruncate = getValueByPath(rootObject, [
|
|
8789
|
+
'embeddingApiType',
|
|
8790
|
+
]);
|
|
8791
|
+
if (discriminatorAutoTruncate === undefined) {
|
|
8792
|
+
discriminatorAutoTruncate = 'PREDICT';
|
|
8793
|
+
}
|
|
8794
|
+
if (discriminatorAutoTruncate === 'PREDICT') {
|
|
8795
|
+
const fromAutoTruncate = getValueByPath(fromObject, [
|
|
8796
|
+
'autoTruncate',
|
|
8797
|
+
]);
|
|
8798
|
+
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
8799
|
+
setValueByPath(parentObject, ['parameters', 'autoTruncate'], fromAutoTruncate);
|
|
8800
|
+
}
|
|
8801
|
+
}
|
|
8802
|
+
else if (discriminatorAutoTruncate === 'EMBED_CONTENT') {
|
|
8803
|
+
const fromAutoTruncate = getValueByPath(fromObject, [
|
|
8804
|
+
'autoTruncate',
|
|
8805
|
+
]);
|
|
8806
|
+
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
8807
|
+
setValueByPath(parentObject, ['autoTruncate'], fromAutoTruncate);
|
|
8808
|
+
}
|
|
8656
8809
|
}
|
|
8657
8810
|
return toObject;
|
|
8658
8811
|
}
|
|
8659
|
-
function
|
|
8812
|
+
function embedContentParametersPrivateToMldev(apiClient, fromObject, rootObject) {
|
|
8660
8813
|
const toObject = {};
|
|
8661
8814
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
8662
8815
|
if (fromModel != null) {
|
|
@@ -8672,6 +8825,10 @@ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
|
|
|
8672
8825
|
}
|
|
8673
8826
|
setValueByPath(toObject, ['requests[]', 'content'], transformedList);
|
|
8674
8827
|
}
|
|
8828
|
+
const fromContent = getValueByPath(fromObject, ['content']);
|
|
8829
|
+
if (fromContent != null) {
|
|
8830
|
+
contentToMldev$1(tContent(fromContent));
|
|
8831
|
+
}
|
|
8675
8832
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8676
8833
|
if (fromConfig != null) {
|
|
8677
8834
|
embedContentConfigToMldev(fromConfig, toObject);
|
|
@@ -8682,25 +8839,45 @@ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
|
|
|
8682
8839
|
}
|
|
8683
8840
|
return toObject;
|
|
8684
8841
|
}
|
|
8685
|
-
function
|
|
8842
|
+
function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject) {
|
|
8686
8843
|
const toObject = {};
|
|
8687
8844
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
8688
8845
|
if (fromModel != null) {
|
|
8689
8846
|
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
8690
8847
|
}
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8848
|
+
let discriminatorContents = getValueByPath(rootObject, [
|
|
8849
|
+
'embeddingApiType',
|
|
8850
|
+
]);
|
|
8851
|
+
if (discriminatorContents === undefined) {
|
|
8852
|
+
discriminatorContents = 'PREDICT';
|
|
8853
|
+
}
|
|
8854
|
+
if (discriminatorContents === 'PREDICT') {
|
|
8855
|
+
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
8856
|
+
if (fromContents != null) {
|
|
8857
|
+
let transformedList = tContentsForEmbed(apiClient, fromContents);
|
|
8858
|
+
if (Array.isArray(transformedList)) {
|
|
8859
|
+
transformedList = transformedList.map((item) => {
|
|
8860
|
+
return item;
|
|
8861
|
+
});
|
|
8862
|
+
}
|
|
8863
|
+
setValueByPath(toObject, ['instances[]', 'content'], transformedList);
|
|
8864
|
+
}
|
|
8865
|
+
}
|
|
8866
|
+
let discriminatorContent = getValueByPath(rootObject, [
|
|
8867
|
+
'embeddingApiType',
|
|
8868
|
+
]);
|
|
8869
|
+
if (discriminatorContent === undefined) {
|
|
8870
|
+
discriminatorContent = 'PREDICT';
|
|
8871
|
+
}
|
|
8872
|
+
if (discriminatorContent === 'EMBED_CONTENT') {
|
|
8873
|
+
const fromContent = getValueByPath(fromObject, ['content']);
|
|
8874
|
+
if (fromContent != null) {
|
|
8875
|
+
setValueByPath(toObject, ['content'], tContent(fromContent));
|
|
8698
8876
|
}
|
|
8699
|
-
setValueByPath(toObject, ['instances[]', 'content'], transformedList);
|
|
8700
8877
|
}
|
|
8701
8878
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8702
8879
|
if (fromConfig != null) {
|
|
8703
|
-
embedContentConfigToVertex(fromConfig, toObject);
|
|
8880
|
+
embedContentConfigToVertex(fromConfig, toObject, rootObject);
|
|
8704
8881
|
}
|
|
8705
8882
|
return toObject;
|
|
8706
8883
|
}
|
|
@@ -8753,6 +8930,24 @@ function embedContentResponseFromVertex(fromObject, rootObject) {
|
|
|
8753
8930
|
if (fromMetadata != null) {
|
|
8754
8931
|
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
8755
8932
|
}
|
|
8933
|
+
if (rootObject &&
|
|
8934
|
+
getValueByPath(rootObject, ['embeddingApiType']) === 'EMBED_CONTENT') {
|
|
8935
|
+
const embedding = getValueByPath(fromObject, ['embedding']);
|
|
8936
|
+
const usageMetadata = getValueByPath(fromObject, ['usageMetadata']);
|
|
8937
|
+
const truncated = getValueByPath(fromObject, ['truncated']);
|
|
8938
|
+
if (embedding) {
|
|
8939
|
+
const stats = {};
|
|
8940
|
+
if (usageMetadata &&
|
|
8941
|
+
usageMetadata['promptTokenCount']) {
|
|
8942
|
+
stats.tokenCount = usageMetadata['promptTokenCount'];
|
|
8943
|
+
}
|
|
8944
|
+
if (truncated) {
|
|
8945
|
+
stats.truncated = truncated;
|
|
8946
|
+
}
|
|
8947
|
+
embedding.statistics = stats;
|
|
8948
|
+
setValueByPath(toObject, ['embeddings'], [embedding]);
|
|
8949
|
+
}
|
|
8950
|
+
}
|
|
8756
8951
|
return toObject;
|
|
8757
8952
|
}
|
|
8758
8953
|
function endpointFromVertex(fromObject, _rootObject) {
|
|
@@ -10179,6 +10374,10 @@ function googleMapsToMldev$1(fromObject, _rootObject) {
|
|
|
10179
10374
|
}
|
|
10180
10375
|
function googleSearchToMldev$1(fromObject, _rootObject) {
|
|
10181
10376
|
const toObject = {};
|
|
10377
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
10378
|
+
if (fromSearchTypes != null) {
|
|
10379
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
10380
|
+
}
|
|
10182
10381
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
10183
10382
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
10184
10383
|
}
|
|
@@ -10206,6 +10405,9 @@ function imageConfigToMldev(fromObject, _rootObject) {
|
|
|
10206
10405
|
if (getValueByPath(fromObject, ['personGeneration']) !== undefined) {
|
|
10207
10406
|
throw new Error('personGeneration parameter is not supported in Gemini API.');
|
|
10208
10407
|
}
|
|
10408
|
+
if (getValueByPath(fromObject, ['prominentPeople']) !== undefined) {
|
|
10409
|
+
throw new Error('prominentPeople parameter is not supported in Gemini API.');
|
|
10410
|
+
}
|
|
10209
10411
|
if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
|
|
10210
10412
|
throw new Error('outputMimeType parameter is not supported in Gemini API.');
|
|
10211
10413
|
}
|
|
@@ -10231,6 +10433,12 @@ function imageConfigToVertex(fromObject, _rootObject) {
|
|
|
10231
10433
|
if (fromPersonGeneration != null) {
|
|
10232
10434
|
setValueByPath(toObject, ['personGeneration'], fromPersonGeneration);
|
|
10233
10435
|
}
|
|
10436
|
+
const fromProminentPeople = getValueByPath(fromObject, [
|
|
10437
|
+
'prominentPeople',
|
|
10438
|
+
]);
|
|
10439
|
+
if (fromProminentPeople != null) {
|
|
10440
|
+
setValueByPath(toObject, ['prominentPeople'], fromProminentPeople);
|
|
10441
|
+
}
|
|
10234
10442
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
10235
10443
|
'outputMimeType',
|
|
10236
10444
|
]);
|
|
@@ -10958,6 +11166,10 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
10958
11166
|
if (fromFileSearch != null) {
|
|
10959
11167
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
10960
11168
|
}
|
|
11169
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11170
|
+
if (fromGoogleSearch != null) {
|
|
11171
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
11172
|
+
}
|
|
10961
11173
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
10962
11174
|
'codeExecution',
|
|
10963
11175
|
]);
|
|
@@ -10983,10 +11195,6 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
10983
11195
|
if (fromGoogleMaps != null) {
|
|
10984
11196
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$1(fromGoogleMaps));
|
|
10985
11197
|
}
|
|
10986
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
10987
|
-
if (fromGoogleSearch != null) {
|
|
10988
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
10989
|
-
}
|
|
10990
11198
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
10991
11199
|
'googleSearchRetrieval',
|
|
10992
11200
|
]);
|
|
@@ -10997,6 +11205,16 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
10997
11205
|
if (fromUrlContext != null) {
|
|
10998
11206
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
10999
11207
|
}
|
|
11208
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
11209
|
+
if (fromMcpServers != null) {
|
|
11210
|
+
let transformedList = fromMcpServers;
|
|
11211
|
+
if (Array.isArray(transformedList)) {
|
|
11212
|
+
transformedList = transformedList.map((item) => {
|
|
11213
|
+
return item;
|
|
11214
|
+
});
|
|
11215
|
+
}
|
|
11216
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
11217
|
+
}
|
|
11000
11218
|
return toObject;
|
|
11001
11219
|
}
|
|
11002
11220
|
function toolToVertex(fromObject, rootObject) {
|
|
@@ -11012,6 +11230,10 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
11012
11230
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
11013
11231
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
11014
11232
|
}
|
|
11233
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11234
|
+
if (fromGoogleSearch != null) {
|
|
11235
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
11236
|
+
}
|
|
11015
11237
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
11016
11238
|
'codeExecution',
|
|
11017
11239
|
]);
|
|
@@ -11040,10 +11262,6 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
11040
11262
|
if (fromGoogleMaps != null) {
|
|
11041
11263
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
11042
11264
|
}
|
|
11043
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11044
|
-
if (fromGoogleSearch != null) {
|
|
11045
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
11046
|
-
}
|
|
11047
11265
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
11048
11266
|
'googleSearchRetrieval',
|
|
11049
11267
|
]);
|
|
@@ -11054,6 +11272,9 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
11054
11272
|
if (fromUrlContext != null) {
|
|
11055
11273
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
11056
11274
|
}
|
|
11275
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
11276
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
11277
|
+
}
|
|
11057
11278
|
return toObject;
|
|
11058
11279
|
}
|
|
11059
11280
|
function tunedModelInfoFromMldev(fromObject, _rootObject) {
|
|
@@ -11610,7 +11831,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
11610
11831
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
11611
11832
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
11612
11833
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
11613
|
-
const SDK_VERSION = '1.
|
|
11834
|
+
const SDK_VERSION = '1.43.0'; // x-release-please-version
|
|
11614
11835
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
11615
11836
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
11616
11837
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13211,6 +13432,47 @@ class Models extends BaseModule {
|
|
|
13211
13432
|
constructor(apiClient) {
|
|
13212
13433
|
super();
|
|
13213
13434
|
this.apiClient = apiClient;
|
|
13435
|
+
/**
|
|
13436
|
+
* Calculates embeddings for the given contents.
|
|
13437
|
+
*
|
|
13438
|
+
* @param params - The parameters for embedding contents.
|
|
13439
|
+
* @return The response from the API.
|
|
13440
|
+
*
|
|
13441
|
+
* @example
|
|
13442
|
+
* ```ts
|
|
13443
|
+
* const response = await ai.models.embedContent({
|
|
13444
|
+
* model: 'text-embedding-004',
|
|
13445
|
+
* contents: [
|
|
13446
|
+
* 'What is your name?',
|
|
13447
|
+
* 'What is your favorite color?',
|
|
13448
|
+
* ],
|
|
13449
|
+
* config: {
|
|
13450
|
+
* outputDimensionality: 64,
|
|
13451
|
+
* },
|
|
13452
|
+
* });
|
|
13453
|
+
* console.log(response);
|
|
13454
|
+
* ```
|
|
13455
|
+
*/
|
|
13456
|
+
this.embedContent = async (params) => {
|
|
13457
|
+
if (!this.apiClient.isVertexAI()) {
|
|
13458
|
+
return await this.embedContentInternal(params);
|
|
13459
|
+
}
|
|
13460
|
+
const isVertexEmbedContentModel = (params.model.includes('gemini') &&
|
|
13461
|
+
params.model !== 'gemini-embedding-001') ||
|
|
13462
|
+
params.model.includes('maas');
|
|
13463
|
+
if (isVertexEmbedContentModel) {
|
|
13464
|
+
const contents = tContents(params.contents);
|
|
13465
|
+
if (contents.length > 1) {
|
|
13466
|
+
throw new Error('The embedContent API for this model only supports one content at a time.');
|
|
13467
|
+
}
|
|
13468
|
+
const paramsPrivate = Object.assign(Object.assign({}, params), { content: contents[0], embeddingApiType: EmbeddingApiType.EMBED_CONTENT });
|
|
13469
|
+
return await this.embedContentInternal(paramsPrivate);
|
|
13470
|
+
}
|
|
13471
|
+
else {
|
|
13472
|
+
const paramsPrivate = Object.assign(Object.assign({}, params), { embeddingApiType: EmbeddingApiType.PREDICT });
|
|
13473
|
+
return await this.embedContentInternal(paramsPrivate);
|
|
13474
|
+
}
|
|
13475
|
+
};
|
|
13214
13476
|
/**
|
|
13215
13477
|
* Makes an API request to generate content with a given model.
|
|
13216
13478
|
*
|
|
@@ -13898,14 +14160,17 @@ class Models extends BaseModule {
|
|
|
13898
14160
|
* console.log(response);
|
|
13899
14161
|
* ```
|
|
13900
14162
|
*/
|
|
13901
|
-
async
|
|
14163
|
+
async embedContentInternal(params) {
|
|
13902
14164
|
var _a, _b, _c, _d;
|
|
13903
14165
|
let response;
|
|
13904
14166
|
let path = '';
|
|
13905
14167
|
let queryParams = {};
|
|
13906
14168
|
if (this.apiClient.isVertexAI()) {
|
|
13907
|
-
const body =
|
|
13908
|
-
|
|
14169
|
+
const body = embedContentParametersPrivateToVertex(this.apiClient, params, params);
|
|
14170
|
+
const endpointUrl = tIsVertexEmbedContentModel(params.model)
|
|
14171
|
+
? '{model}:embedContent'
|
|
14172
|
+
: '{model}:predict';
|
|
14173
|
+
path = formatMap(endpointUrl, body['_url']);
|
|
13909
14174
|
queryParams = body['_query'];
|
|
13910
14175
|
delete body['_url'];
|
|
13911
14176
|
delete body['_query'];
|
|
@@ -13928,14 +14193,14 @@ class Models extends BaseModule {
|
|
|
13928
14193
|
});
|
|
13929
14194
|
});
|
|
13930
14195
|
return response.then((apiResponse) => {
|
|
13931
|
-
const resp = embedContentResponseFromVertex(apiResponse);
|
|
14196
|
+
const resp = embedContentResponseFromVertex(apiResponse, params);
|
|
13932
14197
|
const typedResp = new EmbedContentResponse();
|
|
13933
14198
|
Object.assign(typedResp, resp);
|
|
13934
14199
|
return typedResp;
|
|
13935
14200
|
});
|
|
13936
14201
|
}
|
|
13937
14202
|
else {
|
|
13938
|
-
const body =
|
|
14203
|
+
const body = embedContentParametersPrivateToMldev(this.apiClient, params);
|
|
13939
14204
|
path = formatMap('{model}:batchEmbedContents', body['_url']);
|
|
13940
14205
|
queryParams = body['_query'];
|
|
13941
14206
|
delete body['_url'];
|
|
@@ -15019,6 +15284,10 @@ function googleMapsToMldev(fromObject) {
|
|
|
15019
15284
|
}
|
|
15020
15285
|
function googleSearchToMldev(fromObject) {
|
|
15021
15286
|
const toObject = {};
|
|
15287
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
15288
|
+
if (fromSearchTypes != null) {
|
|
15289
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
15290
|
+
}
|
|
15022
15291
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
15023
15292
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
15024
15293
|
}
|
|
@@ -15242,6 +15511,10 @@ function toolToMldev(fromObject) {
|
|
|
15242
15511
|
if (fromFileSearch != null) {
|
|
15243
15512
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
15244
15513
|
}
|
|
15514
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
15515
|
+
if (fromGoogleSearch != null) {
|
|
15516
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
15517
|
+
}
|
|
15245
15518
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
15246
15519
|
'codeExecution',
|
|
15247
15520
|
]);
|
|
@@ -15267,10 +15540,6 @@ function toolToMldev(fromObject) {
|
|
|
15267
15540
|
if (fromGoogleMaps != null) {
|
|
15268
15541
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev(fromGoogleMaps));
|
|
15269
15542
|
}
|
|
15270
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
15271
|
-
if (fromGoogleSearch != null) {
|
|
15272
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
15273
|
-
}
|
|
15274
15543
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
15275
15544
|
'googleSearchRetrieval',
|
|
15276
15545
|
]);
|
|
@@ -15281,6 +15550,16 @@ function toolToMldev(fromObject) {
|
|
|
15281
15550
|
if (fromUrlContext != null) {
|
|
15282
15551
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
15283
15552
|
}
|
|
15553
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
15554
|
+
if (fromMcpServers != null) {
|
|
15555
|
+
let transformedList = fromMcpServers;
|
|
15556
|
+
if (Array.isArray(transformedList)) {
|
|
15557
|
+
transformedList = transformedList.map((item) => {
|
|
15558
|
+
return item;
|
|
15559
|
+
});
|
|
15560
|
+
}
|
|
15561
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
15562
|
+
}
|
|
15284
15563
|
return toObject;
|
|
15285
15564
|
}
|
|
15286
15565
|
|
|
@@ -16738,14 +17017,17 @@ const createPathTagFunction = (pathEncoder = encodeURIPath) => (function path(st
|
|
|
16738
17017
|
return previousValue + currentValue + (index === params.length ? '' : encoded);
|
|
16739
17018
|
}, '');
|
|
16740
17019
|
const pathOnly = path.split(/[?#]/, 1)[0];
|
|
16741
|
-
const invalidSegmentPattern = /(
|
|
17020
|
+
const invalidSegmentPattern = /(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
16742
17021
|
let match;
|
|
16743
17022
|
// Find all invalid segments
|
|
16744
17023
|
while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
17024
|
+
const hasLeadingSlash = match[0].startsWith('/');
|
|
17025
|
+
const offset = hasLeadingSlash ? 1 : 0;
|
|
17026
|
+
const cleanMatch = hasLeadingSlash ? match[0].slice(1) : match[0];
|
|
16745
17027
|
invalidSegments.push({
|
|
16746
|
-
start: match.index,
|
|
16747
|
-
length:
|
|
16748
|
-
error: `Value "${
|
|
17028
|
+
start: match.index + offset,
|
|
17029
|
+
length: cleanMatch.length,
|
|
17030
|
+
error: `Value "${cleanMatch}" can\'t be safely passed as a path parameter`,
|
|
16749
17031
|
});
|
|
16750
17032
|
}
|
|
16751
17033
|
invalidSegments.sort((a, b) => a.start - b.start);
|
|
@@ -18025,6 +18307,13 @@ class BaseGeminiNextGenAPIClient {
|
|
|
18025
18307
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
18026
18308
|
return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
|
|
18027
18309
|
}
|
|
18310
|
+
else if (typeof body === 'object' &&
|
|
18311
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
18312
|
+
return {
|
|
18313
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
18314
|
+
body: this.stringifyQuery(body),
|
|
18315
|
+
};
|
|
18316
|
+
}
|
|
18028
18317
|
else {
|
|
18029
18318
|
return this.encoder({ body, headers });
|
|
18030
18319
|
}
|
|
@@ -19569,5 +19858,5 @@ class GoogleGenAI {
|
|
|
19569
19858
|
}
|
|
19570
19859
|
}
|
|
19571
19860
|
|
|
19572
|
-
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 };
|
|
19861
|
+
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 };
|
|
19573
19862
|
//# sourceMappingURL=index.mjs.map
|