@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/index.cjs
CHANGED
|
@@ -646,6 +646,38 @@ exports.Type = void 0;
|
|
|
646
646
|
*/
|
|
647
647
|
Type["NULL"] = "NULL";
|
|
648
648
|
})(exports.Type || (exports.Type = {}));
|
|
649
|
+
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
650
|
+
exports.PhishBlockThreshold = void 0;
|
|
651
|
+
(function (PhishBlockThreshold) {
|
|
652
|
+
/**
|
|
653
|
+
* Defaults to unspecified.
|
|
654
|
+
*/
|
|
655
|
+
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
656
|
+
/**
|
|
657
|
+
* Blocks Low and above confidence URL that is risky.
|
|
658
|
+
*/
|
|
659
|
+
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
660
|
+
/**
|
|
661
|
+
* Blocks Medium and above confidence URL that is risky.
|
|
662
|
+
*/
|
|
663
|
+
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
664
|
+
/**
|
|
665
|
+
* Blocks High and above confidence URL that is risky.
|
|
666
|
+
*/
|
|
667
|
+
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
668
|
+
/**
|
|
669
|
+
* Blocks Higher and above confidence URL that is risky.
|
|
670
|
+
*/
|
|
671
|
+
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
672
|
+
/**
|
|
673
|
+
* Blocks Very high and above confidence URL that is risky.
|
|
674
|
+
*/
|
|
675
|
+
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
676
|
+
/**
|
|
677
|
+
* Blocks Extremely high confidence URL that is risky.
|
|
678
|
+
*/
|
|
679
|
+
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
680
|
+
})(exports.PhishBlockThreshold || (exports.PhishBlockThreshold = {}));
|
|
649
681
|
/** The API spec that the external API implements. This enum is not supported in Gemini API. */
|
|
650
682
|
exports.ApiSpec = void 0;
|
|
651
683
|
(function (ApiSpec) {
|
|
@@ -716,38 +748,6 @@ exports.HttpElementLocation = void 0;
|
|
|
716
748
|
*/
|
|
717
749
|
HttpElementLocation["HTTP_IN_COOKIE"] = "HTTP_IN_COOKIE";
|
|
718
750
|
})(exports.HttpElementLocation || (exports.HttpElementLocation = {}));
|
|
719
|
-
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
720
|
-
exports.PhishBlockThreshold = void 0;
|
|
721
|
-
(function (PhishBlockThreshold) {
|
|
722
|
-
/**
|
|
723
|
-
* Defaults to unspecified.
|
|
724
|
-
*/
|
|
725
|
-
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
726
|
-
/**
|
|
727
|
-
* Blocks Low and above confidence URL that is risky.
|
|
728
|
-
*/
|
|
729
|
-
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
730
|
-
/**
|
|
731
|
-
* Blocks Medium and above confidence URL that is risky.
|
|
732
|
-
*/
|
|
733
|
-
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
734
|
-
/**
|
|
735
|
-
* Blocks High and above confidence URL that is risky.
|
|
736
|
-
*/
|
|
737
|
-
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
738
|
-
/**
|
|
739
|
-
* Blocks Higher and above confidence URL that is risky.
|
|
740
|
-
*/
|
|
741
|
-
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
742
|
-
/**
|
|
743
|
-
* Blocks Very high and above confidence URL that is risky.
|
|
744
|
-
*/
|
|
745
|
-
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
746
|
-
/**
|
|
747
|
-
* Blocks Extremely high confidence URL that is risky.
|
|
748
|
-
*/
|
|
749
|
-
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
750
|
-
})(exports.PhishBlockThreshold || (exports.PhishBlockThreshold = {}));
|
|
751
751
|
/** Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This enum is not supported in Vertex AI. */
|
|
752
752
|
exports.Behavior = void 0;
|
|
753
753
|
(function (Behavior) {
|
|
@@ -1330,6 +1330,34 @@ exports.Environment = void 0;
|
|
|
1330
1330
|
*/
|
|
1331
1331
|
Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
|
|
1332
1332
|
})(exports.Environment || (exports.Environment = {}));
|
|
1333
|
+
/** Enum for controlling whether the model can generate images of prominent people (celebrities). */
|
|
1334
|
+
exports.ProminentPeople = void 0;
|
|
1335
|
+
(function (ProminentPeople) {
|
|
1336
|
+
/**
|
|
1337
|
+
* Unspecified value. The model will proceed with the default behavior, which is to allow generation of prominent people.
|
|
1338
|
+
*/
|
|
1339
|
+
ProminentPeople["PROMINENT_PEOPLE_UNSPECIFIED"] = "PROMINENT_PEOPLE_UNSPECIFIED";
|
|
1340
|
+
/**
|
|
1341
|
+
* Allows the model to generate images of prominent people.
|
|
1342
|
+
*/
|
|
1343
|
+
ProminentPeople["ALLOW_PROMINENT_PEOPLE"] = "ALLOW_PROMINENT_PEOPLE";
|
|
1344
|
+
/**
|
|
1345
|
+
* Prevents the model from generating images of prominent people.
|
|
1346
|
+
*/
|
|
1347
|
+
ProminentPeople["BLOCK_PROMINENT_PEOPLE"] = "BLOCK_PROMINENT_PEOPLE";
|
|
1348
|
+
})(exports.ProminentPeople || (exports.ProminentPeople = {}));
|
|
1349
|
+
/** Enum representing the Vertex embedding API to use. */
|
|
1350
|
+
exports.EmbeddingApiType = void 0;
|
|
1351
|
+
(function (EmbeddingApiType) {
|
|
1352
|
+
/**
|
|
1353
|
+
* predict API endpoint (default)
|
|
1354
|
+
*/
|
|
1355
|
+
EmbeddingApiType["PREDICT"] = "PREDICT";
|
|
1356
|
+
/**
|
|
1357
|
+
* embedContent API Endpoint
|
|
1358
|
+
*/
|
|
1359
|
+
EmbeddingApiType["EMBED_CONTENT"] = "EMBED_CONTENT";
|
|
1360
|
+
})(exports.EmbeddingApiType || (exports.EmbeddingApiType = {}));
|
|
1333
1361
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
1334
1362
|
exports.SafetyFilterLevel = void 0;
|
|
1335
1363
|
(function (SafetyFilterLevel) {
|
|
@@ -3361,6 +3389,10 @@ function tJobState(state) {
|
|
|
3361
3389
|
return stateString;
|
|
3362
3390
|
}
|
|
3363
3391
|
}
|
|
3392
|
+
function tIsVertexEmbedContentModel(model) {
|
|
3393
|
+
return ((model.includes('gemini') && model !== 'gemini-embedding-001') ||
|
|
3394
|
+
model.includes('maas'));
|
|
3395
|
+
}
|
|
3364
3396
|
|
|
3365
3397
|
/**
|
|
3366
3398
|
* @license
|
|
@@ -3672,16 +3704,16 @@ function candidateFromMldev$1(fromObject) {
|
|
|
3672
3704
|
if (fromFinishReason != null) {
|
|
3673
3705
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
3674
3706
|
}
|
|
3675
|
-
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
3676
|
-
if (fromAvgLogprobs != null) {
|
|
3677
|
-
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
3678
|
-
}
|
|
3679
3707
|
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
3680
3708
|
'groundingMetadata',
|
|
3681
3709
|
]);
|
|
3682
3710
|
if (fromGroundingMetadata != null) {
|
|
3683
3711
|
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
3684
3712
|
}
|
|
3713
|
+
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
3714
|
+
if (fromAvgLogprobs != null) {
|
|
3715
|
+
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
3716
|
+
}
|
|
3685
3717
|
const fromIndex = getValueByPath(fromObject, ['index']);
|
|
3686
3718
|
if (fromIndex != null) {
|
|
3687
3719
|
setValueByPath(toObject, ['index'], fromIndex);
|
|
@@ -4227,6 +4259,10 @@ function googleMapsToMldev$4(fromObject) {
|
|
|
4227
4259
|
}
|
|
4228
4260
|
function googleSearchToMldev$4(fromObject) {
|
|
4229
4261
|
const toObject = {};
|
|
4262
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
4263
|
+
if (fromSearchTypes != null) {
|
|
4264
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
4265
|
+
}
|
|
4230
4266
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
4231
4267
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
4232
4268
|
}
|
|
@@ -4254,6 +4290,9 @@ function imageConfigToMldev$1(fromObject) {
|
|
|
4254
4290
|
if (getValueByPath(fromObject, ['personGeneration']) !== undefined) {
|
|
4255
4291
|
throw new Error('personGeneration parameter is not supported in Gemini API.');
|
|
4256
4292
|
}
|
|
4293
|
+
if (getValueByPath(fromObject, ['prominentPeople']) !== undefined) {
|
|
4294
|
+
throw new Error('prominentPeople parameter is not supported in Gemini API.');
|
|
4295
|
+
}
|
|
4257
4296
|
if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
|
|
4258
4297
|
throw new Error('outputMimeType parameter is not supported in Gemini API.');
|
|
4259
4298
|
}
|
|
@@ -4510,6 +4549,10 @@ function toolToMldev$4(fromObject) {
|
|
|
4510
4549
|
if (fromFileSearch != null) {
|
|
4511
4550
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
4512
4551
|
}
|
|
4552
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4553
|
+
if (fromGoogleSearch != null) {
|
|
4554
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
4555
|
+
}
|
|
4513
4556
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4514
4557
|
'codeExecution',
|
|
4515
4558
|
]);
|
|
@@ -4535,10 +4578,6 @@ function toolToMldev$4(fromObject) {
|
|
|
4535
4578
|
if (fromGoogleMaps != null) {
|
|
4536
4579
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$4(fromGoogleMaps));
|
|
4537
4580
|
}
|
|
4538
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4539
|
-
if (fromGoogleSearch != null) {
|
|
4540
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
4541
|
-
}
|
|
4542
4581
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
4543
4582
|
'googleSearchRetrieval',
|
|
4544
4583
|
]);
|
|
@@ -4549,6 +4588,16 @@ function toolToMldev$4(fromObject) {
|
|
|
4549
4588
|
if (fromUrlContext != null) {
|
|
4550
4589
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
4551
4590
|
}
|
|
4591
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
4592
|
+
if (fromMcpServers != null) {
|
|
4593
|
+
let transformedList = fromMcpServers;
|
|
4594
|
+
if (Array.isArray(transformedList)) {
|
|
4595
|
+
transformedList = transformedList.map((item) => {
|
|
4596
|
+
return item;
|
|
4597
|
+
});
|
|
4598
|
+
}
|
|
4599
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
4600
|
+
}
|
|
4552
4601
|
return toObject;
|
|
4553
4602
|
}
|
|
4554
4603
|
|
|
@@ -5555,6 +5604,10 @@ function googleMapsToMldev$3(fromObject) {
|
|
|
5555
5604
|
}
|
|
5556
5605
|
function googleSearchToMldev$3(fromObject) {
|
|
5557
5606
|
const toObject = {};
|
|
5607
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
5608
|
+
if (fromSearchTypes != null) {
|
|
5609
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
5610
|
+
}
|
|
5558
5611
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
5559
5612
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
5560
5613
|
}
|
|
@@ -5754,6 +5807,10 @@ function toolToMldev$3(fromObject) {
|
|
|
5754
5807
|
if (fromFileSearch != null) {
|
|
5755
5808
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
5756
5809
|
}
|
|
5810
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5811
|
+
if (fromGoogleSearch != null) {
|
|
5812
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
5813
|
+
}
|
|
5757
5814
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5758
5815
|
'codeExecution',
|
|
5759
5816
|
]);
|
|
@@ -5779,10 +5836,6 @@ function toolToMldev$3(fromObject) {
|
|
|
5779
5836
|
if (fromGoogleMaps != null) {
|
|
5780
5837
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$3(fromGoogleMaps));
|
|
5781
5838
|
}
|
|
5782
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5783
|
-
if (fromGoogleSearch != null) {
|
|
5784
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
5785
|
-
}
|
|
5786
5839
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
5787
5840
|
'googleSearchRetrieval',
|
|
5788
5841
|
]);
|
|
@@ -5793,6 +5846,16 @@ function toolToMldev$3(fromObject) {
|
|
|
5793
5846
|
if (fromUrlContext != null) {
|
|
5794
5847
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
5795
5848
|
}
|
|
5849
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
5850
|
+
if (fromMcpServers != null) {
|
|
5851
|
+
let transformedList = fromMcpServers;
|
|
5852
|
+
if (Array.isArray(transformedList)) {
|
|
5853
|
+
transformedList = transformedList.map((item) => {
|
|
5854
|
+
return item;
|
|
5855
|
+
});
|
|
5856
|
+
}
|
|
5857
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
5858
|
+
}
|
|
5796
5859
|
return toObject;
|
|
5797
5860
|
}
|
|
5798
5861
|
function toolToVertex$2(fromObject) {
|
|
@@ -5808,6 +5871,10 @@ function toolToVertex$2(fromObject) {
|
|
|
5808
5871
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
5809
5872
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
5810
5873
|
}
|
|
5874
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5875
|
+
if (fromGoogleSearch != null) {
|
|
5876
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
5877
|
+
}
|
|
5811
5878
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5812
5879
|
'codeExecution',
|
|
5813
5880
|
]);
|
|
@@ -5836,10 +5903,6 @@ function toolToVertex$2(fromObject) {
|
|
|
5836
5903
|
if (fromGoogleMaps != null) {
|
|
5837
5904
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
5838
5905
|
}
|
|
5839
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5840
|
-
if (fromGoogleSearch != null) {
|
|
5841
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
5842
|
-
}
|
|
5843
5906
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
5844
5907
|
'googleSearchRetrieval',
|
|
5845
5908
|
]);
|
|
@@ -5850,6 +5913,9 @@ function toolToVertex$2(fromObject) {
|
|
|
5850
5913
|
if (fromUrlContext != null) {
|
|
5851
5914
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
5852
5915
|
}
|
|
5916
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
5917
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
5918
|
+
}
|
|
5853
5919
|
return toObject;
|
|
5854
5920
|
}
|
|
5855
5921
|
function updateCachedContentConfigToMldev(fromObject, parentObject) {
|
|
@@ -6933,7 +6999,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6933
6999
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6934
7000
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6935
7001
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6936
|
-
const SDK_VERSION = '1.
|
|
7002
|
+
const SDK_VERSION = '1.43.0'; // x-release-please-version
|
|
6937
7003
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6938
7004
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6939
7005
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -9374,14 +9440,17 @@ const createPathTagFunction = (pathEncoder = encodeURIPath) => (function path(st
|
|
|
9374
9440
|
return previousValue + currentValue + (index === params.length ? '' : encoded);
|
|
9375
9441
|
}, '');
|
|
9376
9442
|
const pathOnly = path.split(/[?#]/, 1)[0];
|
|
9377
|
-
const invalidSegmentPattern = /(
|
|
9443
|
+
const invalidSegmentPattern = /(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
9378
9444
|
let match;
|
|
9379
9445
|
// Find all invalid segments
|
|
9380
9446
|
while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
9447
|
+
const hasLeadingSlash = match[0].startsWith('/');
|
|
9448
|
+
const offset = hasLeadingSlash ? 1 : 0;
|
|
9449
|
+
const cleanMatch = hasLeadingSlash ? match[0].slice(1) : match[0];
|
|
9381
9450
|
invalidSegments.push({
|
|
9382
|
-
start: match.index,
|
|
9383
|
-
length:
|
|
9384
|
-
error: `Value "${
|
|
9451
|
+
start: match.index + offset,
|
|
9452
|
+
length: cleanMatch.length,
|
|
9453
|
+
error: `Value "${cleanMatch}" can\'t be safely passed as a path parameter`,
|
|
9385
9454
|
});
|
|
9386
9455
|
}
|
|
9387
9456
|
invalidSegments.sort((a, b) => a.start - b.start);
|
|
@@ -10661,6 +10730,13 @@ class BaseGeminiNextGenAPIClient {
|
|
|
10661
10730
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
10662
10731
|
return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
|
|
10663
10732
|
}
|
|
10733
|
+
else if (typeof body === 'object' &&
|
|
10734
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
10735
|
+
return {
|
|
10736
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
10737
|
+
body: this.stringifyQuery(body),
|
|
10738
|
+
};
|
|
10739
|
+
}
|
|
10664
10740
|
else {
|
|
10665
10741
|
return this.encoder({ body, headers });
|
|
10666
10742
|
}
|
|
@@ -10945,6 +11021,10 @@ function googleMapsToMldev$2(fromObject) {
|
|
|
10945
11021
|
}
|
|
10946
11022
|
function googleSearchToMldev$2(fromObject) {
|
|
10947
11023
|
const toObject = {};
|
|
11024
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
11025
|
+
if (fromSearchTypes != null) {
|
|
11026
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
11027
|
+
}
|
|
10948
11028
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
10949
11029
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
10950
11030
|
}
|
|
@@ -11460,6 +11540,10 @@ function toolToMldev$2(fromObject) {
|
|
|
11460
11540
|
if (fromFileSearch != null) {
|
|
11461
11541
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
11462
11542
|
}
|
|
11543
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11544
|
+
if (fromGoogleSearch != null) {
|
|
11545
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
11546
|
+
}
|
|
11463
11547
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
11464
11548
|
'codeExecution',
|
|
11465
11549
|
]);
|
|
@@ -11485,10 +11569,6 @@ function toolToMldev$2(fromObject) {
|
|
|
11485
11569
|
if (fromGoogleMaps != null) {
|
|
11486
11570
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$2(fromGoogleMaps));
|
|
11487
11571
|
}
|
|
11488
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11489
|
-
if (fromGoogleSearch != null) {
|
|
11490
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
11491
|
-
}
|
|
11492
11572
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
11493
11573
|
'googleSearchRetrieval',
|
|
11494
11574
|
]);
|
|
@@ -11499,6 +11579,16 @@ function toolToMldev$2(fromObject) {
|
|
|
11499
11579
|
if (fromUrlContext != null) {
|
|
11500
11580
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
11501
11581
|
}
|
|
11582
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
11583
|
+
if (fromMcpServers != null) {
|
|
11584
|
+
let transformedList = fromMcpServers;
|
|
11585
|
+
if (Array.isArray(transformedList)) {
|
|
11586
|
+
transformedList = transformedList.map((item) => {
|
|
11587
|
+
return item;
|
|
11588
|
+
});
|
|
11589
|
+
}
|
|
11590
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
11591
|
+
}
|
|
11502
11592
|
return toObject;
|
|
11503
11593
|
}
|
|
11504
11594
|
function toolToVertex$1(fromObject) {
|
|
@@ -11514,6 +11604,10 @@ function toolToVertex$1(fromObject) {
|
|
|
11514
11604
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
11515
11605
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
11516
11606
|
}
|
|
11607
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11608
|
+
if (fromGoogleSearch != null) {
|
|
11609
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
11610
|
+
}
|
|
11517
11611
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
11518
11612
|
'codeExecution',
|
|
11519
11613
|
]);
|
|
@@ -11542,10 +11636,6 @@ function toolToVertex$1(fromObject) {
|
|
|
11542
11636
|
if (fromGoogleMaps != null) {
|
|
11543
11637
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
11544
11638
|
}
|
|
11545
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11546
|
-
if (fromGoogleSearch != null) {
|
|
11547
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
11548
|
-
}
|
|
11549
11639
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
11550
11640
|
'googleSearchRetrieval',
|
|
11551
11641
|
]);
|
|
@@ -11556,6 +11646,9 @@ function toolToVertex$1(fromObject) {
|
|
|
11556
11646
|
if (fromUrlContext != null) {
|
|
11557
11647
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
11558
11648
|
}
|
|
11649
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
11650
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
11651
|
+
}
|
|
11559
11652
|
return toObject;
|
|
11560
11653
|
}
|
|
11561
11654
|
function usageMetadataFromVertex(fromObject) {
|
|
@@ -11699,16 +11792,16 @@ function candidateFromMldev(fromObject, rootObject) {
|
|
|
11699
11792
|
if (fromFinishReason != null) {
|
|
11700
11793
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
11701
11794
|
}
|
|
11702
|
-
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
11703
|
-
if (fromAvgLogprobs != null) {
|
|
11704
|
-
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
11705
|
-
}
|
|
11706
11795
|
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
11707
11796
|
'groundingMetadata',
|
|
11708
11797
|
]);
|
|
11709
11798
|
if (fromGroundingMetadata != null) {
|
|
11710
11799
|
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
11711
11800
|
}
|
|
11801
|
+
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
11802
|
+
if (fromAvgLogprobs != null) {
|
|
11803
|
+
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
11804
|
+
}
|
|
11712
11805
|
const fromIndex = getValueByPath(fromObject, ['index']);
|
|
11713
11806
|
if (fromIndex != null) {
|
|
11714
11807
|
setValueByPath(toObject, ['index'], fromIndex);
|
|
@@ -12164,33 +12257,103 @@ function embedContentConfigToMldev(fromObject, parentObject, _rootObject) {
|
|
|
12164
12257
|
}
|
|
12165
12258
|
return toObject;
|
|
12166
12259
|
}
|
|
12167
|
-
function embedContentConfigToVertex(fromObject, parentObject,
|
|
12260
|
+
function embedContentConfigToVertex(fromObject, parentObject, rootObject) {
|
|
12168
12261
|
const toObject = {};
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
|
|
12262
|
+
let discriminatorTaskType = getValueByPath(rootObject, [
|
|
12263
|
+
'embeddingApiType',
|
|
12264
|
+
]);
|
|
12265
|
+
if (discriminatorTaskType === undefined) {
|
|
12266
|
+
discriminatorTaskType = 'PREDICT';
|
|
12172
12267
|
}
|
|
12173
|
-
|
|
12174
|
-
|
|
12175
|
-
|
|
12268
|
+
if (discriminatorTaskType === 'PREDICT') {
|
|
12269
|
+
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
12270
|
+
if (parentObject !== undefined && fromTaskType != null) {
|
|
12271
|
+
setValueByPath(parentObject, ['instances[]', 'task_type'], fromTaskType);
|
|
12272
|
+
}
|
|
12176
12273
|
}
|
|
12177
|
-
|
|
12178
|
-
'
|
|
12274
|
+
else if (discriminatorTaskType === 'EMBED_CONTENT') {
|
|
12275
|
+
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
12276
|
+
if (parentObject !== undefined && fromTaskType != null) {
|
|
12277
|
+
setValueByPath(parentObject, ['taskType'], fromTaskType);
|
|
12278
|
+
}
|
|
12279
|
+
}
|
|
12280
|
+
let discriminatorTitle = getValueByPath(rootObject, [
|
|
12281
|
+
'embeddingApiType',
|
|
12179
12282
|
]);
|
|
12180
|
-
if (
|
|
12181
|
-
|
|
12283
|
+
if (discriminatorTitle === undefined) {
|
|
12284
|
+
discriminatorTitle = 'PREDICT';
|
|
12182
12285
|
}
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
|
|
12286
|
+
if (discriminatorTitle === 'PREDICT') {
|
|
12287
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
12288
|
+
if (parentObject !== undefined && fromTitle != null) {
|
|
12289
|
+
setValueByPath(parentObject, ['instances[]', 'title'], fromTitle);
|
|
12290
|
+
}
|
|
12291
|
+
}
|
|
12292
|
+
else if (discriminatorTitle === 'EMBED_CONTENT') {
|
|
12293
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
12294
|
+
if (parentObject !== undefined && fromTitle != null) {
|
|
12295
|
+
setValueByPath(parentObject, ['title'], fromTitle);
|
|
12296
|
+
}
|
|
12297
|
+
}
|
|
12298
|
+
let discriminatorOutputDimensionality = getValueByPath(rootObject, [
|
|
12299
|
+
'embeddingApiType',
|
|
12300
|
+
]);
|
|
12301
|
+
if (discriminatorOutputDimensionality === undefined) {
|
|
12302
|
+
discriminatorOutputDimensionality = 'PREDICT';
|
|
12303
|
+
}
|
|
12304
|
+
if (discriminatorOutputDimensionality === 'PREDICT') {
|
|
12305
|
+
const fromOutputDimensionality = getValueByPath(fromObject, [
|
|
12306
|
+
'outputDimensionality',
|
|
12307
|
+
]);
|
|
12308
|
+
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
12309
|
+
setValueByPath(parentObject, ['parameters', 'outputDimensionality'], fromOutputDimensionality);
|
|
12310
|
+
}
|
|
12311
|
+
}
|
|
12312
|
+
else if (discriminatorOutputDimensionality === 'EMBED_CONTENT') {
|
|
12313
|
+
const fromOutputDimensionality = getValueByPath(fromObject, [
|
|
12314
|
+
'outputDimensionality',
|
|
12315
|
+
]);
|
|
12316
|
+
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
12317
|
+
setValueByPath(parentObject, ['outputDimensionality'], fromOutputDimensionality);
|
|
12318
|
+
}
|
|
12186
12319
|
}
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12320
|
+
let discriminatorMimeType = getValueByPath(rootObject, [
|
|
12321
|
+
'embeddingApiType',
|
|
12322
|
+
]);
|
|
12323
|
+
if (discriminatorMimeType === undefined) {
|
|
12324
|
+
discriminatorMimeType = 'PREDICT';
|
|
12325
|
+
}
|
|
12326
|
+
if (discriminatorMimeType === 'PREDICT') {
|
|
12327
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
12328
|
+
if (parentObject !== undefined && fromMimeType != null) {
|
|
12329
|
+
setValueByPath(parentObject, ['instances[]', 'mimeType'], fromMimeType);
|
|
12330
|
+
}
|
|
12331
|
+
}
|
|
12332
|
+
let discriminatorAutoTruncate = getValueByPath(rootObject, [
|
|
12333
|
+
'embeddingApiType',
|
|
12334
|
+
]);
|
|
12335
|
+
if (discriminatorAutoTruncate === undefined) {
|
|
12336
|
+
discriminatorAutoTruncate = 'PREDICT';
|
|
12337
|
+
}
|
|
12338
|
+
if (discriminatorAutoTruncate === 'PREDICT') {
|
|
12339
|
+
const fromAutoTruncate = getValueByPath(fromObject, [
|
|
12340
|
+
'autoTruncate',
|
|
12341
|
+
]);
|
|
12342
|
+
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
12343
|
+
setValueByPath(parentObject, ['parameters', 'autoTruncate'], fromAutoTruncate);
|
|
12344
|
+
}
|
|
12345
|
+
}
|
|
12346
|
+
else if (discriminatorAutoTruncate === 'EMBED_CONTENT') {
|
|
12347
|
+
const fromAutoTruncate = getValueByPath(fromObject, [
|
|
12348
|
+
'autoTruncate',
|
|
12349
|
+
]);
|
|
12350
|
+
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
12351
|
+
setValueByPath(parentObject, ['autoTruncate'], fromAutoTruncate);
|
|
12352
|
+
}
|
|
12190
12353
|
}
|
|
12191
12354
|
return toObject;
|
|
12192
12355
|
}
|
|
12193
|
-
function
|
|
12356
|
+
function embedContentParametersPrivateToMldev(apiClient, fromObject, rootObject) {
|
|
12194
12357
|
const toObject = {};
|
|
12195
12358
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
12196
12359
|
if (fromModel != null) {
|
|
@@ -12206,6 +12369,10 @@ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
|
|
|
12206
12369
|
}
|
|
12207
12370
|
setValueByPath(toObject, ['requests[]', 'content'], transformedList);
|
|
12208
12371
|
}
|
|
12372
|
+
const fromContent = getValueByPath(fromObject, ['content']);
|
|
12373
|
+
if (fromContent != null) {
|
|
12374
|
+
contentToMldev$1(tContent(fromContent));
|
|
12375
|
+
}
|
|
12209
12376
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12210
12377
|
if (fromConfig != null) {
|
|
12211
12378
|
embedContentConfigToMldev(fromConfig, toObject);
|
|
@@ -12216,25 +12383,45 @@ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
|
|
|
12216
12383
|
}
|
|
12217
12384
|
return toObject;
|
|
12218
12385
|
}
|
|
12219
|
-
function
|
|
12386
|
+
function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject) {
|
|
12220
12387
|
const toObject = {};
|
|
12221
12388
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
12222
12389
|
if (fromModel != null) {
|
|
12223
12390
|
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
12224
12391
|
}
|
|
12225
|
-
|
|
12226
|
-
|
|
12227
|
-
|
|
12228
|
-
|
|
12229
|
-
|
|
12230
|
-
|
|
12231
|
-
|
|
12392
|
+
let discriminatorContents = getValueByPath(rootObject, [
|
|
12393
|
+
'embeddingApiType',
|
|
12394
|
+
]);
|
|
12395
|
+
if (discriminatorContents === undefined) {
|
|
12396
|
+
discriminatorContents = 'PREDICT';
|
|
12397
|
+
}
|
|
12398
|
+
if (discriminatorContents === 'PREDICT') {
|
|
12399
|
+
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
12400
|
+
if (fromContents != null) {
|
|
12401
|
+
let transformedList = tContentsForEmbed(apiClient, fromContents);
|
|
12402
|
+
if (Array.isArray(transformedList)) {
|
|
12403
|
+
transformedList = transformedList.map((item) => {
|
|
12404
|
+
return item;
|
|
12405
|
+
});
|
|
12406
|
+
}
|
|
12407
|
+
setValueByPath(toObject, ['instances[]', 'content'], transformedList);
|
|
12408
|
+
}
|
|
12409
|
+
}
|
|
12410
|
+
let discriminatorContent = getValueByPath(rootObject, [
|
|
12411
|
+
'embeddingApiType',
|
|
12412
|
+
]);
|
|
12413
|
+
if (discriminatorContent === undefined) {
|
|
12414
|
+
discriminatorContent = 'PREDICT';
|
|
12415
|
+
}
|
|
12416
|
+
if (discriminatorContent === 'EMBED_CONTENT') {
|
|
12417
|
+
const fromContent = getValueByPath(fromObject, ['content']);
|
|
12418
|
+
if (fromContent != null) {
|
|
12419
|
+
setValueByPath(toObject, ['content'], tContent(fromContent));
|
|
12232
12420
|
}
|
|
12233
|
-
setValueByPath(toObject, ['instances[]', 'content'], transformedList);
|
|
12234
12421
|
}
|
|
12235
12422
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12236
12423
|
if (fromConfig != null) {
|
|
12237
|
-
embedContentConfigToVertex(fromConfig, toObject);
|
|
12424
|
+
embedContentConfigToVertex(fromConfig, toObject, rootObject);
|
|
12238
12425
|
}
|
|
12239
12426
|
return toObject;
|
|
12240
12427
|
}
|
|
@@ -12287,6 +12474,24 @@ function embedContentResponseFromVertex(fromObject, rootObject) {
|
|
|
12287
12474
|
if (fromMetadata != null) {
|
|
12288
12475
|
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
12289
12476
|
}
|
|
12477
|
+
if (rootObject &&
|
|
12478
|
+
getValueByPath(rootObject, ['embeddingApiType']) === 'EMBED_CONTENT') {
|
|
12479
|
+
const embedding = getValueByPath(fromObject, ['embedding']);
|
|
12480
|
+
const usageMetadata = getValueByPath(fromObject, ['usageMetadata']);
|
|
12481
|
+
const truncated = getValueByPath(fromObject, ['truncated']);
|
|
12482
|
+
if (embedding) {
|
|
12483
|
+
const stats = {};
|
|
12484
|
+
if (usageMetadata &&
|
|
12485
|
+
usageMetadata['promptTokenCount']) {
|
|
12486
|
+
stats.tokenCount = usageMetadata['promptTokenCount'];
|
|
12487
|
+
}
|
|
12488
|
+
if (truncated) {
|
|
12489
|
+
stats.truncated = truncated;
|
|
12490
|
+
}
|
|
12491
|
+
embedding.statistics = stats;
|
|
12492
|
+
setValueByPath(toObject, ['embeddings'], [embedding]);
|
|
12493
|
+
}
|
|
12494
|
+
}
|
|
12290
12495
|
return toObject;
|
|
12291
12496
|
}
|
|
12292
12497
|
function endpointFromVertex(fromObject, _rootObject) {
|
|
@@ -13713,6 +13918,10 @@ function googleMapsToMldev$1(fromObject, _rootObject) {
|
|
|
13713
13918
|
}
|
|
13714
13919
|
function googleSearchToMldev$1(fromObject, _rootObject) {
|
|
13715
13920
|
const toObject = {};
|
|
13921
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
13922
|
+
if (fromSearchTypes != null) {
|
|
13923
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
13924
|
+
}
|
|
13716
13925
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
13717
13926
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
13718
13927
|
}
|
|
@@ -13740,6 +13949,9 @@ function imageConfigToMldev(fromObject, _rootObject) {
|
|
|
13740
13949
|
if (getValueByPath(fromObject, ['personGeneration']) !== undefined) {
|
|
13741
13950
|
throw new Error('personGeneration parameter is not supported in Gemini API.');
|
|
13742
13951
|
}
|
|
13952
|
+
if (getValueByPath(fromObject, ['prominentPeople']) !== undefined) {
|
|
13953
|
+
throw new Error('prominentPeople parameter is not supported in Gemini API.');
|
|
13954
|
+
}
|
|
13743
13955
|
if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
|
|
13744
13956
|
throw new Error('outputMimeType parameter is not supported in Gemini API.');
|
|
13745
13957
|
}
|
|
@@ -13765,6 +13977,12 @@ function imageConfigToVertex(fromObject, _rootObject) {
|
|
|
13765
13977
|
if (fromPersonGeneration != null) {
|
|
13766
13978
|
setValueByPath(toObject, ['personGeneration'], fromPersonGeneration);
|
|
13767
13979
|
}
|
|
13980
|
+
const fromProminentPeople = getValueByPath(fromObject, [
|
|
13981
|
+
'prominentPeople',
|
|
13982
|
+
]);
|
|
13983
|
+
if (fromProminentPeople != null) {
|
|
13984
|
+
setValueByPath(toObject, ['prominentPeople'], fromProminentPeople);
|
|
13985
|
+
}
|
|
13768
13986
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
13769
13987
|
'outputMimeType',
|
|
13770
13988
|
]);
|
|
@@ -14492,6 +14710,10 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
14492
14710
|
if (fromFileSearch != null) {
|
|
14493
14711
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
14494
14712
|
}
|
|
14713
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
14714
|
+
if (fromGoogleSearch != null) {
|
|
14715
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
14716
|
+
}
|
|
14495
14717
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
14496
14718
|
'codeExecution',
|
|
14497
14719
|
]);
|
|
@@ -14517,10 +14739,6 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
14517
14739
|
if (fromGoogleMaps != null) {
|
|
14518
14740
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$1(fromGoogleMaps));
|
|
14519
14741
|
}
|
|
14520
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
14521
|
-
if (fromGoogleSearch != null) {
|
|
14522
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
14523
|
-
}
|
|
14524
14742
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
14525
14743
|
'googleSearchRetrieval',
|
|
14526
14744
|
]);
|
|
@@ -14531,6 +14749,16 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
14531
14749
|
if (fromUrlContext != null) {
|
|
14532
14750
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
14533
14751
|
}
|
|
14752
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
14753
|
+
if (fromMcpServers != null) {
|
|
14754
|
+
let transformedList = fromMcpServers;
|
|
14755
|
+
if (Array.isArray(transformedList)) {
|
|
14756
|
+
transformedList = transformedList.map((item) => {
|
|
14757
|
+
return item;
|
|
14758
|
+
});
|
|
14759
|
+
}
|
|
14760
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
14761
|
+
}
|
|
14534
14762
|
return toObject;
|
|
14535
14763
|
}
|
|
14536
14764
|
function toolToVertex(fromObject, rootObject) {
|
|
@@ -14546,6 +14774,10 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
14546
14774
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
14547
14775
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
14548
14776
|
}
|
|
14777
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
14778
|
+
if (fromGoogleSearch != null) {
|
|
14779
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
14780
|
+
}
|
|
14549
14781
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
14550
14782
|
'codeExecution',
|
|
14551
14783
|
]);
|
|
@@ -14574,10 +14806,6 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
14574
14806
|
if (fromGoogleMaps != null) {
|
|
14575
14807
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
14576
14808
|
}
|
|
14577
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
14578
|
-
if (fromGoogleSearch != null) {
|
|
14579
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
14580
|
-
}
|
|
14581
14809
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
14582
14810
|
'googleSearchRetrieval',
|
|
14583
14811
|
]);
|
|
@@ -14588,6 +14816,9 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
14588
14816
|
if (fromUrlContext != null) {
|
|
14589
14817
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
14590
14818
|
}
|
|
14819
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
14820
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
14821
|
+
}
|
|
14591
14822
|
return toObject;
|
|
14592
14823
|
}
|
|
14593
14824
|
function tunedModelInfoFromMldev(fromObject, _rootObject) {
|
|
@@ -15835,6 +16066,47 @@ class Models extends BaseModule {
|
|
|
15835
16066
|
constructor(apiClient) {
|
|
15836
16067
|
super();
|
|
15837
16068
|
this.apiClient = apiClient;
|
|
16069
|
+
/**
|
|
16070
|
+
* Calculates embeddings for the given contents.
|
|
16071
|
+
*
|
|
16072
|
+
* @param params - The parameters for embedding contents.
|
|
16073
|
+
* @return The response from the API.
|
|
16074
|
+
*
|
|
16075
|
+
* @example
|
|
16076
|
+
* ```ts
|
|
16077
|
+
* const response = await ai.models.embedContent({
|
|
16078
|
+
* model: 'text-embedding-004',
|
|
16079
|
+
* contents: [
|
|
16080
|
+
* 'What is your name?',
|
|
16081
|
+
* 'What is your favorite color?',
|
|
16082
|
+
* ],
|
|
16083
|
+
* config: {
|
|
16084
|
+
* outputDimensionality: 64,
|
|
16085
|
+
* },
|
|
16086
|
+
* });
|
|
16087
|
+
* console.log(response);
|
|
16088
|
+
* ```
|
|
16089
|
+
*/
|
|
16090
|
+
this.embedContent = async (params) => {
|
|
16091
|
+
if (!this.apiClient.isVertexAI()) {
|
|
16092
|
+
return await this.embedContentInternal(params);
|
|
16093
|
+
}
|
|
16094
|
+
const isVertexEmbedContentModel = (params.model.includes('gemini') &&
|
|
16095
|
+
params.model !== 'gemini-embedding-001') ||
|
|
16096
|
+
params.model.includes('maas');
|
|
16097
|
+
if (isVertexEmbedContentModel) {
|
|
16098
|
+
const contents = tContents(params.contents);
|
|
16099
|
+
if (contents.length > 1) {
|
|
16100
|
+
throw new Error('The embedContent API for this model only supports one content at a time.');
|
|
16101
|
+
}
|
|
16102
|
+
const paramsPrivate = Object.assign(Object.assign({}, params), { content: contents[0], embeddingApiType: exports.EmbeddingApiType.EMBED_CONTENT });
|
|
16103
|
+
return await this.embedContentInternal(paramsPrivate);
|
|
16104
|
+
}
|
|
16105
|
+
else {
|
|
16106
|
+
const paramsPrivate = Object.assign(Object.assign({}, params), { embeddingApiType: exports.EmbeddingApiType.PREDICT });
|
|
16107
|
+
return await this.embedContentInternal(paramsPrivate);
|
|
16108
|
+
}
|
|
16109
|
+
};
|
|
15838
16110
|
/**
|
|
15839
16111
|
* Makes an API request to generate content with a given model.
|
|
15840
16112
|
*
|
|
@@ -16522,14 +16794,17 @@ class Models extends BaseModule {
|
|
|
16522
16794
|
* console.log(response);
|
|
16523
16795
|
* ```
|
|
16524
16796
|
*/
|
|
16525
|
-
async
|
|
16797
|
+
async embedContentInternal(params) {
|
|
16526
16798
|
var _a, _b, _c, _d;
|
|
16527
16799
|
let response;
|
|
16528
16800
|
let path = '';
|
|
16529
16801
|
let queryParams = {};
|
|
16530
16802
|
if (this.apiClient.isVertexAI()) {
|
|
16531
|
-
const body =
|
|
16532
|
-
|
|
16803
|
+
const body = embedContentParametersPrivateToVertex(this.apiClient, params, params);
|
|
16804
|
+
const endpointUrl = tIsVertexEmbedContentModel(params.model)
|
|
16805
|
+
? '{model}:embedContent'
|
|
16806
|
+
: '{model}:predict';
|
|
16807
|
+
path = formatMap(endpointUrl, body['_url']);
|
|
16533
16808
|
queryParams = body['_query'];
|
|
16534
16809
|
delete body['_url'];
|
|
16535
16810
|
delete body['_query'];
|
|
@@ -16552,14 +16827,14 @@ class Models extends BaseModule {
|
|
|
16552
16827
|
});
|
|
16553
16828
|
});
|
|
16554
16829
|
return response.then((apiResponse) => {
|
|
16555
|
-
const resp = embedContentResponseFromVertex(apiResponse);
|
|
16830
|
+
const resp = embedContentResponseFromVertex(apiResponse, params);
|
|
16556
16831
|
const typedResp = new EmbedContentResponse();
|
|
16557
16832
|
Object.assign(typedResp, resp);
|
|
16558
16833
|
return typedResp;
|
|
16559
16834
|
});
|
|
16560
16835
|
}
|
|
16561
16836
|
else {
|
|
16562
|
-
const body =
|
|
16837
|
+
const body = embedContentParametersPrivateToMldev(this.apiClient, params);
|
|
16563
16838
|
path = formatMap('{model}:batchEmbedContents', body['_url']);
|
|
16564
16839
|
queryParams = body['_query'];
|
|
16565
16840
|
delete body['_url'];
|
|
@@ -17643,6 +17918,10 @@ function googleMapsToMldev(fromObject) {
|
|
|
17643
17918
|
}
|
|
17644
17919
|
function googleSearchToMldev(fromObject) {
|
|
17645
17920
|
const toObject = {};
|
|
17921
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
17922
|
+
if (fromSearchTypes != null) {
|
|
17923
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
17924
|
+
}
|
|
17646
17925
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
17647
17926
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
17648
17927
|
}
|
|
@@ -17866,6 +18145,10 @@ function toolToMldev(fromObject) {
|
|
|
17866
18145
|
if (fromFileSearch != null) {
|
|
17867
18146
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
17868
18147
|
}
|
|
18148
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
18149
|
+
if (fromGoogleSearch != null) {
|
|
18150
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
18151
|
+
}
|
|
17869
18152
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
17870
18153
|
'codeExecution',
|
|
17871
18154
|
]);
|
|
@@ -17891,10 +18174,6 @@ function toolToMldev(fromObject) {
|
|
|
17891
18174
|
if (fromGoogleMaps != null) {
|
|
17892
18175
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev(fromGoogleMaps));
|
|
17893
18176
|
}
|
|
17894
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
17895
|
-
if (fromGoogleSearch != null) {
|
|
17896
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
17897
|
-
}
|
|
17898
18177
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
17899
18178
|
'googleSearchRetrieval',
|
|
17900
18179
|
]);
|
|
@@ -17905,6 +18184,16 @@ function toolToMldev(fromObject) {
|
|
|
17905
18184
|
if (fromUrlContext != null) {
|
|
17906
18185
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
17907
18186
|
}
|
|
18187
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
18188
|
+
if (fromMcpServers != null) {
|
|
18189
|
+
let transformedList = fromMcpServers;
|
|
18190
|
+
if (Array.isArray(transformedList)) {
|
|
18191
|
+
transformedList = transformedList.map((item) => {
|
|
18192
|
+
return item;
|
|
18193
|
+
});
|
|
18194
|
+
}
|
|
18195
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
18196
|
+
}
|
|
17908
18197
|
return toObject;
|
|
17909
18198
|
}
|
|
17910
18199
|
|