@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.mjs
CHANGED
|
@@ -644,6 +644,38 @@ var Type;
|
|
|
644
644
|
*/
|
|
645
645
|
Type["NULL"] = "NULL";
|
|
646
646
|
})(Type || (Type = {}));
|
|
647
|
+
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
648
|
+
var PhishBlockThreshold;
|
|
649
|
+
(function (PhishBlockThreshold) {
|
|
650
|
+
/**
|
|
651
|
+
* Defaults to unspecified.
|
|
652
|
+
*/
|
|
653
|
+
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
654
|
+
/**
|
|
655
|
+
* Blocks Low and above confidence URL that is risky.
|
|
656
|
+
*/
|
|
657
|
+
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
658
|
+
/**
|
|
659
|
+
* Blocks Medium and above confidence URL that is risky.
|
|
660
|
+
*/
|
|
661
|
+
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
662
|
+
/**
|
|
663
|
+
* Blocks High and above confidence URL that is risky.
|
|
664
|
+
*/
|
|
665
|
+
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
666
|
+
/**
|
|
667
|
+
* Blocks Higher and above confidence URL that is risky.
|
|
668
|
+
*/
|
|
669
|
+
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
670
|
+
/**
|
|
671
|
+
* Blocks Very high and above confidence URL that is risky.
|
|
672
|
+
*/
|
|
673
|
+
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
674
|
+
/**
|
|
675
|
+
* Blocks Extremely high confidence URL that is risky.
|
|
676
|
+
*/
|
|
677
|
+
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
678
|
+
})(PhishBlockThreshold || (PhishBlockThreshold = {}));
|
|
647
679
|
/** The API spec that the external API implements. This enum is not supported in Gemini API. */
|
|
648
680
|
var ApiSpec;
|
|
649
681
|
(function (ApiSpec) {
|
|
@@ -714,38 +746,6 @@ var HttpElementLocation;
|
|
|
714
746
|
*/
|
|
715
747
|
HttpElementLocation["HTTP_IN_COOKIE"] = "HTTP_IN_COOKIE";
|
|
716
748
|
})(HttpElementLocation || (HttpElementLocation = {}));
|
|
717
|
-
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
718
|
-
var PhishBlockThreshold;
|
|
719
|
-
(function (PhishBlockThreshold) {
|
|
720
|
-
/**
|
|
721
|
-
* Defaults to unspecified.
|
|
722
|
-
*/
|
|
723
|
-
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
724
|
-
/**
|
|
725
|
-
* Blocks Low and above confidence URL that is risky.
|
|
726
|
-
*/
|
|
727
|
-
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
728
|
-
/**
|
|
729
|
-
* Blocks Medium and above confidence URL that is risky.
|
|
730
|
-
*/
|
|
731
|
-
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
732
|
-
/**
|
|
733
|
-
* Blocks High and above confidence URL that is risky.
|
|
734
|
-
*/
|
|
735
|
-
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
736
|
-
/**
|
|
737
|
-
* Blocks Higher and above confidence URL that is risky.
|
|
738
|
-
*/
|
|
739
|
-
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
740
|
-
/**
|
|
741
|
-
* Blocks Very high and above confidence URL that is risky.
|
|
742
|
-
*/
|
|
743
|
-
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
744
|
-
/**
|
|
745
|
-
* Blocks Extremely high confidence URL that is risky.
|
|
746
|
-
*/
|
|
747
|
-
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
748
|
-
})(PhishBlockThreshold || (PhishBlockThreshold = {}));
|
|
749
749
|
/** Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This enum is not supported in Vertex AI. */
|
|
750
750
|
var Behavior;
|
|
751
751
|
(function (Behavior) {
|
|
@@ -1328,6 +1328,34 @@ var Environment;
|
|
|
1328
1328
|
*/
|
|
1329
1329
|
Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
|
|
1330
1330
|
})(Environment || (Environment = {}));
|
|
1331
|
+
/** Enum for controlling whether the model can generate images of prominent people (celebrities). */
|
|
1332
|
+
var ProminentPeople;
|
|
1333
|
+
(function (ProminentPeople) {
|
|
1334
|
+
/**
|
|
1335
|
+
* Unspecified value. The model will proceed with the default behavior, which is to allow generation of prominent people.
|
|
1336
|
+
*/
|
|
1337
|
+
ProminentPeople["PROMINENT_PEOPLE_UNSPECIFIED"] = "PROMINENT_PEOPLE_UNSPECIFIED";
|
|
1338
|
+
/**
|
|
1339
|
+
* Allows the model to generate images of prominent people.
|
|
1340
|
+
*/
|
|
1341
|
+
ProminentPeople["ALLOW_PROMINENT_PEOPLE"] = "ALLOW_PROMINENT_PEOPLE";
|
|
1342
|
+
/**
|
|
1343
|
+
* Prevents the model from generating images of prominent people.
|
|
1344
|
+
*/
|
|
1345
|
+
ProminentPeople["BLOCK_PROMINENT_PEOPLE"] = "BLOCK_PROMINENT_PEOPLE";
|
|
1346
|
+
})(ProminentPeople || (ProminentPeople = {}));
|
|
1347
|
+
/** Enum representing the Vertex embedding API to use. */
|
|
1348
|
+
var EmbeddingApiType;
|
|
1349
|
+
(function (EmbeddingApiType) {
|
|
1350
|
+
/**
|
|
1351
|
+
* predict API endpoint (default)
|
|
1352
|
+
*/
|
|
1353
|
+
EmbeddingApiType["PREDICT"] = "PREDICT";
|
|
1354
|
+
/**
|
|
1355
|
+
* embedContent API Endpoint
|
|
1356
|
+
*/
|
|
1357
|
+
EmbeddingApiType["EMBED_CONTENT"] = "EMBED_CONTENT";
|
|
1358
|
+
})(EmbeddingApiType || (EmbeddingApiType = {}));
|
|
1331
1359
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
1332
1360
|
var SafetyFilterLevel;
|
|
1333
1361
|
(function (SafetyFilterLevel) {
|
|
@@ -3359,6 +3387,10 @@ function tJobState(state) {
|
|
|
3359
3387
|
return stateString;
|
|
3360
3388
|
}
|
|
3361
3389
|
}
|
|
3390
|
+
function tIsVertexEmbedContentModel(model) {
|
|
3391
|
+
return ((model.includes('gemini') && model !== 'gemini-embedding-001') ||
|
|
3392
|
+
model.includes('maas'));
|
|
3393
|
+
}
|
|
3362
3394
|
|
|
3363
3395
|
/**
|
|
3364
3396
|
* @license
|
|
@@ -3670,16 +3702,16 @@ function candidateFromMldev$1(fromObject) {
|
|
|
3670
3702
|
if (fromFinishReason != null) {
|
|
3671
3703
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
3672
3704
|
}
|
|
3673
|
-
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
3674
|
-
if (fromAvgLogprobs != null) {
|
|
3675
|
-
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
3676
|
-
}
|
|
3677
3705
|
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
3678
3706
|
'groundingMetadata',
|
|
3679
3707
|
]);
|
|
3680
3708
|
if (fromGroundingMetadata != null) {
|
|
3681
3709
|
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
3682
3710
|
}
|
|
3711
|
+
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
3712
|
+
if (fromAvgLogprobs != null) {
|
|
3713
|
+
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
3714
|
+
}
|
|
3683
3715
|
const fromIndex = getValueByPath(fromObject, ['index']);
|
|
3684
3716
|
if (fromIndex != null) {
|
|
3685
3717
|
setValueByPath(toObject, ['index'], fromIndex);
|
|
@@ -4225,6 +4257,10 @@ function googleMapsToMldev$4(fromObject) {
|
|
|
4225
4257
|
}
|
|
4226
4258
|
function googleSearchToMldev$4(fromObject) {
|
|
4227
4259
|
const toObject = {};
|
|
4260
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
4261
|
+
if (fromSearchTypes != null) {
|
|
4262
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
4263
|
+
}
|
|
4228
4264
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
4229
4265
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
4230
4266
|
}
|
|
@@ -4252,6 +4288,9 @@ function imageConfigToMldev$1(fromObject) {
|
|
|
4252
4288
|
if (getValueByPath(fromObject, ['personGeneration']) !== undefined) {
|
|
4253
4289
|
throw new Error('personGeneration parameter is not supported in Gemini API.');
|
|
4254
4290
|
}
|
|
4291
|
+
if (getValueByPath(fromObject, ['prominentPeople']) !== undefined) {
|
|
4292
|
+
throw new Error('prominentPeople parameter is not supported in Gemini API.');
|
|
4293
|
+
}
|
|
4255
4294
|
if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
|
|
4256
4295
|
throw new Error('outputMimeType parameter is not supported in Gemini API.');
|
|
4257
4296
|
}
|
|
@@ -4508,6 +4547,10 @@ function toolToMldev$4(fromObject) {
|
|
|
4508
4547
|
if (fromFileSearch != null) {
|
|
4509
4548
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
4510
4549
|
}
|
|
4550
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4551
|
+
if (fromGoogleSearch != null) {
|
|
4552
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
4553
|
+
}
|
|
4511
4554
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4512
4555
|
'codeExecution',
|
|
4513
4556
|
]);
|
|
@@ -4533,10 +4576,6 @@ function toolToMldev$4(fromObject) {
|
|
|
4533
4576
|
if (fromGoogleMaps != null) {
|
|
4534
4577
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$4(fromGoogleMaps));
|
|
4535
4578
|
}
|
|
4536
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4537
|
-
if (fromGoogleSearch != null) {
|
|
4538
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
4539
|
-
}
|
|
4540
4579
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
4541
4580
|
'googleSearchRetrieval',
|
|
4542
4581
|
]);
|
|
@@ -4547,6 +4586,16 @@ function toolToMldev$4(fromObject) {
|
|
|
4547
4586
|
if (fromUrlContext != null) {
|
|
4548
4587
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
4549
4588
|
}
|
|
4589
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
4590
|
+
if (fromMcpServers != null) {
|
|
4591
|
+
let transformedList = fromMcpServers;
|
|
4592
|
+
if (Array.isArray(transformedList)) {
|
|
4593
|
+
transformedList = transformedList.map((item) => {
|
|
4594
|
+
return item;
|
|
4595
|
+
});
|
|
4596
|
+
}
|
|
4597
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
4598
|
+
}
|
|
4550
4599
|
return toObject;
|
|
4551
4600
|
}
|
|
4552
4601
|
|
|
@@ -5553,6 +5602,10 @@ function googleMapsToMldev$3(fromObject) {
|
|
|
5553
5602
|
}
|
|
5554
5603
|
function googleSearchToMldev$3(fromObject) {
|
|
5555
5604
|
const toObject = {};
|
|
5605
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
5606
|
+
if (fromSearchTypes != null) {
|
|
5607
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
5608
|
+
}
|
|
5556
5609
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
5557
5610
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
5558
5611
|
}
|
|
@@ -5752,6 +5805,10 @@ function toolToMldev$3(fromObject) {
|
|
|
5752
5805
|
if (fromFileSearch != null) {
|
|
5753
5806
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
5754
5807
|
}
|
|
5808
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5809
|
+
if (fromGoogleSearch != null) {
|
|
5810
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
5811
|
+
}
|
|
5755
5812
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5756
5813
|
'codeExecution',
|
|
5757
5814
|
]);
|
|
@@ -5777,10 +5834,6 @@ function toolToMldev$3(fromObject) {
|
|
|
5777
5834
|
if (fromGoogleMaps != null) {
|
|
5778
5835
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$3(fromGoogleMaps));
|
|
5779
5836
|
}
|
|
5780
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5781
|
-
if (fromGoogleSearch != null) {
|
|
5782
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
5783
|
-
}
|
|
5784
5837
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
5785
5838
|
'googleSearchRetrieval',
|
|
5786
5839
|
]);
|
|
@@ -5791,6 +5844,16 @@ function toolToMldev$3(fromObject) {
|
|
|
5791
5844
|
if (fromUrlContext != null) {
|
|
5792
5845
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
5793
5846
|
}
|
|
5847
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
5848
|
+
if (fromMcpServers != null) {
|
|
5849
|
+
let transformedList = fromMcpServers;
|
|
5850
|
+
if (Array.isArray(transformedList)) {
|
|
5851
|
+
transformedList = transformedList.map((item) => {
|
|
5852
|
+
return item;
|
|
5853
|
+
});
|
|
5854
|
+
}
|
|
5855
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
5856
|
+
}
|
|
5794
5857
|
return toObject;
|
|
5795
5858
|
}
|
|
5796
5859
|
function toolToVertex$2(fromObject) {
|
|
@@ -5806,6 +5869,10 @@ function toolToVertex$2(fromObject) {
|
|
|
5806
5869
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
5807
5870
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
5808
5871
|
}
|
|
5872
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5873
|
+
if (fromGoogleSearch != null) {
|
|
5874
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
5875
|
+
}
|
|
5809
5876
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5810
5877
|
'codeExecution',
|
|
5811
5878
|
]);
|
|
@@ -5834,10 +5901,6 @@ function toolToVertex$2(fromObject) {
|
|
|
5834
5901
|
if (fromGoogleMaps != null) {
|
|
5835
5902
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
5836
5903
|
}
|
|
5837
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5838
|
-
if (fromGoogleSearch != null) {
|
|
5839
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
5840
|
-
}
|
|
5841
5904
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
5842
5905
|
'googleSearchRetrieval',
|
|
5843
5906
|
]);
|
|
@@ -5848,6 +5911,9 @@ function toolToVertex$2(fromObject) {
|
|
|
5848
5911
|
if (fromUrlContext != null) {
|
|
5849
5912
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
5850
5913
|
}
|
|
5914
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
5915
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
5916
|
+
}
|
|
5851
5917
|
return toObject;
|
|
5852
5918
|
}
|
|
5853
5919
|
function updateCachedContentConfigToMldev(fromObject, parentObject) {
|
|
@@ -6931,7 +6997,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6931
6997
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6932
6998
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6933
6999
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6934
|
-
const SDK_VERSION = '1.
|
|
7000
|
+
const SDK_VERSION = '1.43.0'; // x-release-please-version
|
|
6935
7001
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6936
7002
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6937
7003
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -9372,14 +9438,17 @@ const createPathTagFunction = (pathEncoder = encodeURIPath) => (function path(st
|
|
|
9372
9438
|
return previousValue + currentValue + (index === params.length ? '' : encoded);
|
|
9373
9439
|
}, '');
|
|
9374
9440
|
const pathOnly = path.split(/[?#]/, 1)[0];
|
|
9375
|
-
const invalidSegmentPattern = /(
|
|
9441
|
+
const invalidSegmentPattern = /(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
9376
9442
|
let match;
|
|
9377
9443
|
// Find all invalid segments
|
|
9378
9444
|
while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
9445
|
+
const hasLeadingSlash = match[0].startsWith('/');
|
|
9446
|
+
const offset = hasLeadingSlash ? 1 : 0;
|
|
9447
|
+
const cleanMatch = hasLeadingSlash ? match[0].slice(1) : match[0];
|
|
9379
9448
|
invalidSegments.push({
|
|
9380
|
-
start: match.index,
|
|
9381
|
-
length:
|
|
9382
|
-
error: `Value "${
|
|
9449
|
+
start: match.index + offset,
|
|
9450
|
+
length: cleanMatch.length,
|
|
9451
|
+
error: `Value "${cleanMatch}" can\'t be safely passed as a path parameter`,
|
|
9383
9452
|
});
|
|
9384
9453
|
}
|
|
9385
9454
|
invalidSegments.sort((a, b) => a.start - b.start);
|
|
@@ -10659,6 +10728,13 @@ class BaseGeminiNextGenAPIClient {
|
|
|
10659
10728
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
10660
10729
|
return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
|
|
10661
10730
|
}
|
|
10731
|
+
else if (typeof body === 'object' &&
|
|
10732
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
10733
|
+
return {
|
|
10734
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
10735
|
+
body: this.stringifyQuery(body),
|
|
10736
|
+
};
|
|
10737
|
+
}
|
|
10662
10738
|
else {
|
|
10663
10739
|
return this.encoder({ body, headers });
|
|
10664
10740
|
}
|
|
@@ -10943,6 +11019,10 @@ function googleMapsToMldev$2(fromObject) {
|
|
|
10943
11019
|
}
|
|
10944
11020
|
function googleSearchToMldev$2(fromObject) {
|
|
10945
11021
|
const toObject = {};
|
|
11022
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
11023
|
+
if (fromSearchTypes != null) {
|
|
11024
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
11025
|
+
}
|
|
10946
11026
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
10947
11027
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
10948
11028
|
}
|
|
@@ -11458,6 +11538,10 @@ function toolToMldev$2(fromObject) {
|
|
|
11458
11538
|
if (fromFileSearch != null) {
|
|
11459
11539
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
11460
11540
|
}
|
|
11541
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11542
|
+
if (fromGoogleSearch != null) {
|
|
11543
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
11544
|
+
}
|
|
11461
11545
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
11462
11546
|
'codeExecution',
|
|
11463
11547
|
]);
|
|
@@ -11483,10 +11567,6 @@ function toolToMldev$2(fromObject) {
|
|
|
11483
11567
|
if (fromGoogleMaps != null) {
|
|
11484
11568
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$2(fromGoogleMaps));
|
|
11485
11569
|
}
|
|
11486
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11487
|
-
if (fromGoogleSearch != null) {
|
|
11488
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
11489
|
-
}
|
|
11490
11570
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
11491
11571
|
'googleSearchRetrieval',
|
|
11492
11572
|
]);
|
|
@@ -11497,6 +11577,16 @@ function toolToMldev$2(fromObject) {
|
|
|
11497
11577
|
if (fromUrlContext != null) {
|
|
11498
11578
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
11499
11579
|
}
|
|
11580
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
11581
|
+
if (fromMcpServers != null) {
|
|
11582
|
+
let transformedList = fromMcpServers;
|
|
11583
|
+
if (Array.isArray(transformedList)) {
|
|
11584
|
+
transformedList = transformedList.map((item) => {
|
|
11585
|
+
return item;
|
|
11586
|
+
});
|
|
11587
|
+
}
|
|
11588
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
11589
|
+
}
|
|
11500
11590
|
return toObject;
|
|
11501
11591
|
}
|
|
11502
11592
|
function toolToVertex$1(fromObject) {
|
|
@@ -11512,6 +11602,10 @@ function toolToVertex$1(fromObject) {
|
|
|
11512
11602
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
11513
11603
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
11514
11604
|
}
|
|
11605
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11606
|
+
if (fromGoogleSearch != null) {
|
|
11607
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
11608
|
+
}
|
|
11515
11609
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
11516
11610
|
'codeExecution',
|
|
11517
11611
|
]);
|
|
@@ -11540,10 +11634,6 @@ function toolToVertex$1(fromObject) {
|
|
|
11540
11634
|
if (fromGoogleMaps != null) {
|
|
11541
11635
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
11542
11636
|
}
|
|
11543
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
11544
|
-
if (fromGoogleSearch != null) {
|
|
11545
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
11546
|
-
}
|
|
11547
11637
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
11548
11638
|
'googleSearchRetrieval',
|
|
11549
11639
|
]);
|
|
@@ -11554,6 +11644,9 @@ function toolToVertex$1(fromObject) {
|
|
|
11554
11644
|
if (fromUrlContext != null) {
|
|
11555
11645
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
11556
11646
|
}
|
|
11647
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
11648
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
11649
|
+
}
|
|
11557
11650
|
return toObject;
|
|
11558
11651
|
}
|
|
11559
11652
|
function usageMetadataFromVertex(fromObject) {
|
|
@@ -11697,16 +11790,16 @@ function candidateFromMldev(fromObject, rootObject) {
|
|
|
11697
11790
|
if (fromFinishReason != null) {
|
|
11698
11791
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
11699
11792
|
}
|
|
11700
|
-
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
11701
|
-
if (fromAvgLogprobs != null) {
|
|
11702
|
-
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
11703
|
-
}
|
|
11704
11793
|
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
11705
11794
|
'groundingMetadata',
|
|
11706
11795
|
]);
|
|
11707
11796
|
if (fromGroundingMetadata != null) {
|
|
11708
11797
|
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
11709
11798
|
}
|
|
11799
|
+
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
11800
|
+
if (fromAvgLogprobs != null) {
|
|
11801
|
+
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
11802
|
+
}
|
|
11710
11803
|
const fromIndex = getValueByPath(fromObject, ['index']);
|
|
11711
11804
|
if (fromIndex != null) {
|
|
11712
11805
|
setValueByPath(toObject, ['index'], fromIndex);
|
|
@@ -12162,33 +12255,103 @@ function embedContentConfigToMldev(fromObject, parentObject, _rootObject) {
|
|
|
12162
12255
|
}
|
|
12163
12256
|
return toObject;
|
|
12164
12257
|
}
|
|
12165
|
-
function embedContentConfigToVertex(fromObject, parentObject,
|
|
12258
|
+
function embedContentConfigToVertex(fromObject, parentObject, rootObject) {
|
|
12166
12259
|
const toObject = {};
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12260
|
+
let discriminatorTaskType = getValueByPath(rootObject, [
|
|
12261
|
+
'embeddingApiType',
|
|
12262
|
+
]);
|
|
12263
|
+
if (discriminatorTaskType === undefined) {
|
|
12264
|
+
discriminatorTaskType = 'PREDICT';
|
|
12170
12265
|
}
|
|
12171
|
-
|
|
12172
|
-
|
|
12173
|
-
|
|
12266
|
+
if (discriminatorTaskType === 'PREDICT') {
|
|
12267
|
+
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
12268
|
+
if (parentObject !== undefined && fromTaskType != null) {
|
|
12269
|
+
setValueByPath(parentObject, ['instances[]', 'task_type'], fromTaskType);
|
|
12270
|
+
}
|
|
12174
12271
|
}
|
|
12175
|
-
|
|
12176
|
-
'
|
|
12272
|
+
else if (discriminatorTaskType === 'EMBED_CONTENT') {
|
|
12273
|
+
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
12274
|
+
if (parentObject !== undefined && fromTaskType != null) {
|
|
12275
|
+
setValueByPath(parentObject, ['taskType'], fromTaskType);
|
|
12276
|
+
}
|
|
12277
|
+
}
|
|
12278
|
+
let discriminatorTitle = getValueByPath(rootObject, [
|
|
12279
|
+
'embeddingApiType',
|
|
12177
12280
|
]);
|
|
12178
|
-
if (
|
|
12179
|
-
|
|
12281
|
+
if (discriminatorTitle === undefined) {
|
|
12282
|
+
discriminatorTitle = 'PREDICT';
|
|
12180
12283
|
}
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12284
|
+
if (discriminatorTitle === 'PREDICT') {
|
|
12285
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
12286
|
+
if (parentObject !== undefined && fromTitle != null) {
|
|
12287
|
+
setValueByPath(parentObject, ['instances[]', 'title'], fromTitle);
|
|
12288
|
+
}
|
|
12289
|
+
}
|
|
12290
|
+
else if (discriminatorTitle === 'EMBED_CONTENT') {
|
|
12291
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
12292
|
+
if (parentObject !== undefined && fromTitle != null) {
|
|
12293
|
+
setValueByPath(parentObject, ['title'], fromTitle);
|
|
12294
|
+
}
|
|
12295
|
+
}
|
|
12296
|
+
let discriminatorOutputDimensionality = getValueByPath(rootObject, [
|
|
12297
|
+
'embeddingApiType',
|
|
12298
|
+
]);
|
|
12299
|
+
if (discriminatorOutputDimensionality === undefined) {
|
|
12300
|
+
discriminatorOutputDimensionality = 'PREDICT';
|
|
12301
|
+
}
|
|
12302
|
+
if (discriminatorOutputDimensionality === 'PREDICT') {
|
|
12303
|
+
const fromOutputDimensionality = getValueByPath(fromObject, [
|
|
12304
|
+
'outputDimensionality',
|
|
12305
|
+
]);
|
|
12306
|
+
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
12307
|
+
setValueByPath(parentObject, ['parameters', 'outputDimensionality'], fromOutputDimensionality);
|
|
12308
|
+
}
|
|
12309
|
+
}
|
|
12310
|
+
else if (discriminatorOutputDimensionality === 'EMBED_CONTENT') {
|
|
12311
|
+
const fromOutputDimensionality = getValueByPath(fromObject, [
|
|
12312
|
+
'outputDimensionality',
|
|
12313
|
+
]);
|
|
12314
|
+
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
12315
|
+
setValueByPath(parentObject, ['outputDimensionality'], fromOutputDimensionality);
|
|
12316
|
+
}
|
|
12184
12317
|
}
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12318
|
+
let discriminatorMimeType = getValueByPath(rootObject, [
|
|
12319
|
+
'embeddingApiType',
|
|
12320
|
+
]);
|
|
12321
|
+
if (discriminatorMimeType === undefined) {
|
|
12322
|
+
discriminatorMimeType = 'PREDICT';
|
|
12323
|
+
}
|
|
12324
|
+
if (discriminatorMimeType === 'PREDICT') {
|
|
12325
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
12326
|
+
if (parentObject !== undefined && fromMimeType != null) {
|
|
12327
|
+
setValueByPath(parentObject, ['instances[]', 'mimeType'], fromMimeType);
|
|
12328
|
+
}
|
|
12329
|
+
}
|
|
12330
|
+
let discriminatorAutoTruncate = getValueByPath(rootObject, [
|
|
12331
|
+
'embeddingApiType',
|
|
12332
|
+
]);
|
|
12333
|
+
if (discriminatorAutoTruncate === undefined) {
|
|
12334
|
+
discriminatorAutoTruncate = 'PREDICT';
|
|
12335
|
+
}
|
|
12336
|
+
if (discriminatorAutoTruncate === 'PREDICT') {
|
|
12337
|
+
const fromAutoTruncate = getValueByPath(fromObject, [
|
|
12338
|
+
'autoTruncate',
|
|
12339
|
+
]);
|
|
12340
|
+
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
12341
|
+
setValueByPath(parentObject, ['parameters', 'autoTruncate'], fromAutoTruncate);
|
|
12342
|
+
}
|
|
12343
|
+
}
|
|
12344
|
+
else if (discriminatorAutoTruncate === 'EMBED_CONTENT') {
|
|
12345
|
+
const fromAutoTruncate = getValueByPath(fromObject, [
|
|
12346
|
+
'autoTruncate',
|
|
12347
|
+
]);
|
|
12348
|
+
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
12349
|
+
setValueByPath(parentObject, ['autoTruncate'], fromAutoTruncate);
|
|
12350
|
+
}
|
|
12188
12351
|
}
|
|
12189
12352
|
return toObject;
|
|
12190
12353
|
}
|
|
12191
|
-
function
|
|
12354
|
+
function embedContentParametersPrivateToMldev(apiClient, fromObject, rootObject) {
|
|
12192
12355
|
const toObject = {};
|
|
12193
12356
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
12194
12357
|
if (fromModel != null) {
|
|
@@ -12204,6 +12367,10 @@ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
|
|
|
12204
12367
|
}
|
|
12205
12368
|
setValueByPath(toObject, ['requests[]', 'content'], transformedList);
|
|
12206
12369
|
}
|
|
12370
|
+
const fromContent = getValueByPath(fromObject, ['content']);
|
|
12371
|
+
if (fromContent != null) {
|
|
12372
|
+
contentToMldev$1(tContent(fromContent));
|
|
12373
|
+
}
|
|
12207
12374
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12208
12375
|
if (fromConfig != null) {
|
|
12209
12376
|
embedContentConfigToMldev(fromConfig, toObject);
|
|
@@ -12214,25 +12381,45 @@ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
|
|
|
12214
12381
|
}
|
|
12215
12382
|
return toObject;
|
|
12216
12383
|
}
|
|
12217
|
-
function
|
|
12384
|
+
function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject) {
|
|
12218
12385
|
const toObject = {};
|
|
12219
12386
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
12220
12387
|
if (fromModel != null) {
|
|
12221
12388
|
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
12222
12389
|
}
|
|
12223
|
-
|
|
12224
|
-
|
|
12225
|
-
|
|
12226
|
-
|
|
12227
|
-
|
|
12228
|
-
|
|
12229
|
-
|
|
12390
|
+
let discriminatorContents = getValueByPath(rootObject, [
|
|
12391
|
+
'embeddingApiType',
|
|
12392
|
+
]);
|
|
12393
|
+
if (discriminatorContents === undefined) {
|
|
12394
|
+
discriminatorContents = 'PREDICT';
|
|
12395
|
+
}
|
|
12396
|
+
if (discriminatorContents === 'PREDICT') {
|
|
12397
|
+
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
12398
|
+
if (fromContents != null) {
|
|
12399
|
+
let transformedList = tContentsForEmbed(apiClient, fromContents);
|
|
12400
|
+
if (Array.isArray(transformedList)) {
|
|
12401
|
+
transformedList = transformedList.map((item) => {
|
|
12402
|
+
return item;
|
|
12403
|
+
});
|
|
12404
|
+
}
|
|
12405
|
+
setValueByPath(toObject, ['instances[]', 'content'], transformedList);
|
|
12406
|
+
}
|
|
12407
|
+
}
|
|
12408
|
+
let discriminatorContent = getValueByPath(rootObject, [
|
|
12409
|
+
'embeddingApiType',
|
|
12410
|
+
]);
|
|
12411
|
+
if (discriminatorContent === undefined) {
|
|
12412
|
+
discriminatorContent = 'PREDICT';
|
|
12413
|
+
}
|
|
12414
|
+
if (discriminatorContent === 'EMBED_CONTENT') {
|
|
12415
|
+
const fromContent = getValueByPath(fromObject, ['content']);
|
|
12416
|
+
if (fromContent != null) {
|
|
12417
|
+
setValueByPath(toObject, ['content'], tContent(fromContent));
|
|
12230
12418
|
}
|
|
12231
|
-
setValueByPath(toObject, ['instances[]', 'content'], transformedList);
|
|
12232
12419
|
}
|
|
12233
12420
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12234
12421
|
if (fromConfig != null) {
|
|
12235
|
-
embedContentConfigToVertex(fromConfig, toObject);
|
|
12422
|
+
embedContentConfigToVertex(fromConfig, toObject, rootObject);
|
|
12236
12423
|
}
|
|
12237
12424
|
return toObject;
|
|
12238
12425
|
}
|
|
@@ -12285,6 +12472,24 @@ function embedContentResponseFromVertex(fromObject, rootObject) {
|
|
|
12285
12472
|
if (fromMetadata != null) {
|
|
12286
12473
|
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
12287
12474
|
}
|
|
12475
|
+
if (rootObject &&
|
|
12476
|
+
getValueByPath(rootObject, ['embeddingApiType']) === 'EMBED_CONTENT') {
|
|
12477
|
+
const embedding = getValueByPath(fromObject, ['embedding']);
|
|
12478
|
+
const usageMetadata = getValueByPath(fromObject, ['usageMetadata']);
|
|
12479
|
+
const truncated = getValueByPath(fromObject, ['truncated']);
|
|
12480
|
+
if (embedding) {
|
|
12481
|
+
const stats = {};
|
|
12482
|
+
if (usageMetadata &&
|
|
12483
|
+
usageMetadata['promptTokenCount']) {
|
|
12484
|
+
stats.tokenCount = usageMetadata['promptTokenCount'];
|
|
12485
|
+
}
|
|
12486
|
+
if (truncated) {
|
|
12487
|
+
stats.truncated = truncated;
|
|
12488
|
+
}
|
|
12489
|
+
embedding.statistics = stats;
|
|
12490
|
+
setValueByPath(toObject, ['embeddings'], [embedding]);
|
|
12491
|
+
}
|
|
12492
|
+
}
|
|
12288
12493
|
return toObject;
|
|
12289
12494
|
}
|
|
12290
12495
|
function endpointFromVertex(fromObject, _rootObject) {
|
|
@@ -13711,6 +13916,10 @@ function googleMapsToMldev$1(fromObject, _rootObject) {
|
|
|
13711
13916
|
}
|
|
13712
13917
|
function googleSearchToMldev$1(fromObject, _rootObject) {
|
|
13713
13918
|
const toObject = {};
|
|
13919
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
13920
|
+
if (fromSearchTypes != null) {
|
|
13921
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
13922
|
+
}
|
|
13714
13923
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
13715
13924
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
13716
13925
|
}
|
|
@@ -13738,6 +13947,9 @@ function imageConfigToMldev(fromObject, _rootObject) {
|
|
|
13738
13947
|
if (getValueByPath(fromObject, ['personGeneration']) !== undefined) {
|
|
13739
13948
|
throw new Error('personGeneration parameter is not supported in Gemini API.');
|
|
13740
13949
|
}
|
|
13950
|
+
if (getValueByPath(fromObject, ['prominentPeople']) !== undefined) {
|
|
13951
|
+
throw new Error('prominentPeople parameter is not supported in Gemini API.');
|
|
13952
|
+
}
|
|
13741
13953
|
if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
|
|
13742
13954
|
throw new Error('outputMimeType parameter is not supported in Gemini API.');
|
|
13743
13955
|
}
|
|
@@ -13763,6 +13975,12 @@ function imageConfigToVertex(fromObject, _rootObject) {
|
|
|
13763
13975
|
if (fromPersonGeneration != null) {
|
|
13764
13976
|
setValueByPath(toObject, ['personGeneration'], fromPersonGeneration);
|
|
13765
13977
|
}
|
|
13978
|
+
const fromProminentPeople = getValueByPath(fromObject, [
|
|
13979
|
+
'prominentPeople',
|
|
13980
|
+
]);
|
|
13981
|
+
if (fromProminentPeople != null) {
|
|
13982
|
+
setValueByPath(toObject, ['prominentPeople'], fromProminentPeople);
|
|
13983
|
+
}
|
|
13766
13984
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
13767
13985
|
'outputMimeType',
|
|
13768
13986
|
]);
|
|
@@ -14490,6 +14708,10 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
14490
14708
|
if (fromFileSearch != null) {
|
|
14491
14709
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
14492
14710
|
}
|
|
14711
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
14712
|
+
if (fromGoogleSearch != null) {
|
|
14713
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
14714
|
+
}
|
|
14493
14715
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
14494
14716
|
'codeExecution',
|
|
14495
14717
|
]);
|
|
@@ -14515,10 +14737,6 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
14515
14737
|
if (fromGoogleMaps != null) {
|
|
14516
14738
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$1(fromGoogleMaps));
|
|
14517
14739
|
}
|
|
14518
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
14519
|
-
if (fromGoogleSearch != null) {
|
|
14520
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
14521
|
-
}
|
|
14522
14740
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
14523
14741
|
'googleSearchRetrieval',
|
|
14524
14742
|
]);
|
|
@@ -14529,6 +14747,16 @@ function toolToMldev$1(fromObject, rootObject) {
|
|
|
14529
14747
|
if (fromUrlContext != null) {
|
|
14530
14748
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
14531
14749
|
}
|
|
14750
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
14751
|
+
if (fromMcpServers != null) {
|
|
14752
|
+
let transformedList = fromMcpServers;
|
|
14753
|
+
if (Array.isArray(transformedList)) {
|
|
14754
|
+
transformedList = transformedList.map((item) => {
|
|
14755
|
+
return item;
|
|
14756
|
+
});
|
|
14757
|
+
}
|
|
14758
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
14759
|
+
}
|
|
14532
14760
|
return toObject;
|
|
14533
14761
|
}
|
|
14534
14762
|
function toolToVertex(fromObject, rootObject) {
|
|
@@ -14544,6 +14772,10 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
14544
14772
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
14545
14773
|
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
14546
14774
|
}
|
|
14775
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
14776
|
+
if (fromGoogleSearch != null) {
|
|
14777
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
14778
|
+
}
|
|
14547
14779
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
14548
14780
|
'codeExecution',
|
|
14549
14781
|
]);
|
|
@@ -14572,10 +14804,6 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
14572
14804
|
if (fromGoogleMaps != null) {
|
|
14573
14805
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
14574
14806
|
}
|
|
14575
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
14576
|
-
if (fromGoogleSearch != null) {
|
|
14577
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
14578
|
-
}
|
|
14579
14807
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
14580
14808
|
'googleSearchRetrieval',
|
|
14581
14809
|
]);
|
|
@@ -14586,6 +14814,9 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
14586
14814
|
if (fromUrlContext != null) {
|
|
14587
14815
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
14588
14816
|
}
|
|
14817
|
+
if (getValueByPath(fromObject, ['mcpServers']) !== undefined) {
|
|
14818
|
+
throw new Error('mcpServers parameter is not supported in Vertex AI.');
|
|
14819
|
+
}
|
|
14589
14820
|
return toObject;
|
|
14590
14821
|
}
|
|
14591
14822
|
function tunedModelInfoFromMldev(fromObject, _rootObject) {
|
|
@@ -15833,6 +16064,47 @@ class Models extends BaseModule {
|
|
|
15833
16064
|
constructor(apiClient) {
|
|
15834
16065
|
super();
|
|
15835
16066
|
this.apiClient = apiClient;
|
|
16067
|
+
/**
|
|
16068
|
+
* Calculates embeddings for the given contents.
|
|
16069
|
+
*
|
|
16070
|
+
* @param params - The parameters for embedding contents.
|
|
16071
|
+
* @return The response from the API.
|
|
16072
|
+
*
|
|
16073
|
+
* @example
|
|
16074
|
+
* ```ts
|
|
16075
|
+
* const response = await ai.models.embedContent({
|
|
16076
|
+
* model: 'text-embedding-004',
|
|
16077
|
+
* contents: [
|
|
16078
|
+
* 'What is your name?',
|
|
16079
|
+
* 'What is your favorite color?',
|
|
16080
|
+
* ],
|
|
16081
|
+
* config: {
|
|
16082
|
+
* outputDimensionality: 64,
|
|
16083
|
+
* },
|
|
16084
|
+
* });
|
|
16085
|
+
* console.log(response);
|
|
16086
|
+
* ```
|
|
16087
|
+
*/
|
|
16088
|
+
this.embedContent = async (params) => {
|
|
16089
|
+
if (!this.apiClient.isVertexAI()) {
|
|
16090
|
+
return await this.embedContentInternal(params);
|
|
16091
|
+
}
|
|
16092
|
+
const isVertexEmbedContentModel = (params.model.includes('gemini') &&
|
|
16093
|
+
params.model !== 'gemini-embedding-001') ||
|
|
16094
|
+
params.model.includes('maas');
|
|
16095
|
+
if (isVertexEmbedContentModel) {
|
|
16096
|
+
const contents = tContents(params.contents);
|
|
16097
|
+
if (contents.length > 1) {
|
|
16098
|
+
throw new Error('The embedContent API for this model only supports one content at a time.');
|
|
16099
|
+
}
|
|
16100
|
+
const paramsPrivate = Object.assign(Object.assign({}, params), { content: contents[0], embeddingApiType: EmbeddingApiType.EMBED_CONTENT });
|
|
16101
|
+
return await this.embedContentInternal(paramsPrivate);
|
|
16102
|
+
}
|
|
16103
|
+
else {
|
|
16104
|
+
const paramsPrivate = Object.assign(Object.assign({}, params), { embeddingApiType: EmbeddingApiType.PREDICT });
|
|
16105
|
+
return await this.embedContentInternal(paramsPrivate);
|
|
16106
|
+
}
|
|
16107
|
+
};
|
|
15836
16108
|
/**
|
|
15837
16109
|
* Makes an API request to generate content with a given model.
|
|
15838
16110
|
*
|
|
@@ -16520,14 +16792,17 @@ class Models extends BaseModule {
|
|
|
16520
16792
|
* console.log(response);
|
|
16521
16793
|
* ```
|
|
16522
16794
|
*/
|
|
16523
|
-
async
|
|
16795
|
+
async embedContentInternal(params) {
|
|
16524
16796
|
var _a, _b, _c, _d;
|
|
16525
16797
|
let response;
|
|
16526
16798
|
let path = '';
|
|
16527
16799
|
let queryParams = {};
|
|
16528
16800
|
if (this.apiClient.isVertexAI()) {
|
|
16529
|
-
const body =
|
|
16530
|
-
|
|
16801
|
+
const body = embedContentParametersPrivateToVertex(this.apiClient, params, params);
|
|
16802
|
+
const endpointUrl = tIsVertexEmbedContentModel(params.model)
|
|
16803
|
+
? '{model}:embedContent'
|
|
16804
|
+
: '{model}:predict';
|
|
16805
|
+
path = formatMap(endpointUrl, body['_url']);
|
|
16531
16806
|
queryParams = body['_query'];
|
|
16532
16807
|
delete body['_url'];
|
|
16533
16808
|
delete body['_query'];
|
|
@@ -16550,14 +16825,14 @@ class Models extends BaseModule {
|
|
|
16550
16825
|
});
|
|
16551
16826
|
});
|
|
16552
16827
|
return response.then((apiResponse) => {
|
|
16553
|
-
const resp = embedContentResponseFromVertex(apiResponse);
|
|
16828
|
+
const resp = embedContentResponseFromVertex(apiResponse, params);
|
|
16554
16829
|
const typedResp = new EmbedContentResponse();
|
|
16555
16830
|
Object.assign(typedResp, resp);
|
|
16556
16831
|
return typedResp;
|
|
16557
16832
|
});
|
|
16558
16833
|
}
|
|
16559
16834
|
else {
|
|
16560
|
-
const body =
|
|
16835
|
+
const body = embedContentParametersPrivateToMldev(this.apiClient, params);
|
|
16561
16836
|
path = formatMap('{model}:batchEmbedContents', body['_url']);
|
|
16562
16837
|
queryParams = body['_query'];
|
|
16563
16838
|
delete body['_url'];
|
|
@@ -17641,6 +17916,10 @@ function googleMapsToMldev(fromObject) {
|
|
|
17641
17916
|
}
|
|
17642
17917
|
function googleSearchToMldev(fromObject) {
|
|
17643
17918
|
const toObject = {};
|
|
17919
|
+
const fromSearchTypes = getValueByPath(fromObject, ['searchTypes']);
|
|
17920
|
+
if (fromSearchTypes != null) {
|
|
17921
|
+
setValueByPath(toObject, ['searchTypes'], fromSearchTypes);
|
|
17922
|
+
}
|
|
17644
17923
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
17645
17924
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
17646
17925
|
}
|
|
@@ -17864,6 +18143,10 @@ function toolToMldev(fromObject) {
|
|
|
17864
18143
|
if (fromFileSearch != null) {
|
|
17865
18144
|
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
17866
18145
|
}
|
|
18146
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
18147
|
+
if (fromGoogleSearch != null) {
|
|
18148
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
18149
|
+
}
|
|
17867
18150
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
17868
18151
|
'codeExecution',
|
|
17869
18152
|
]);
|
|
@@ -17889,10 +18172,6 @@ function toolToMldev(fromObject) {
|
|
|
17889
18172
|
if (fromGoogleMaps != null) {
|
|
17890
18173
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev(fromGoogleMaps));
|
|
17891
18174
|
}
|
|
17892
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
17893
|
-
if (fromGoogleSearch != null) {
|
|
17894
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
17895
|
-
}
|
|
17896
18175
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
17897
18176
|
'googleSearchRetrieval',
|
|
17898
18177
|
]);
|
|
@@ -17903,6 +18182,16 @@ function toolToMldev(fromObject) {
|
|
|
17903
18182
|
if (fromUrlContext != null) {
|
|
17904
18183
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
17905
18184
|
}
|
|
18185
|
+
const fromMcpServers = getValueByPath(fromObject, ['mcpServers']);
|
|
18186
|
+
if (fromMcpServers != null) {
|
|
18187
|
+
let transformedList = fromMcpServers;
|
|
18188
|
+
if (Array.isArray(transformedList)) {
|
|
18189
|
+
transformedList = transformedList.map((item) => {
|
|
18190
|
+
return item;
|
|
18191
|
+
});
|
|
18192
|
+
}
|
|
18193
|
+
setValueByPath(toObject, ['mcpServers'], transformedList);
|
|
18194
|
+
}
|
|
17906
18195
|
return toObject;
|
|
17907
18196
|
}
|
|
17908
18197
|
|
|
@@ -19514,5 +19803,5 @@ class GoogleGenAI {
|
|
|
19514
19803
|
}
|
|
19515
19804
|
}
|
|
19516
19805
|
|
|
19517
|
-
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 };
|
|
19806
|
+
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 };
|
|
19518
19807
|
//# sourceMappingURL=index.mjs.map
|