@google/genai 0.12.0 → 0.14.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/README.md +27 -1
- package/dist/genai.d.ts +468 -23
- package/dist/index.js +1619 -151
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1611 -152
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +1672 -143
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +468 -23
- package/dist/web/index.mjs +1577 -118
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +468 -23
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -491,15 +491,81 @@ function tBytes(apiClient, fromImageBytes) {
|
|
|
491
491
|
// TODO(b/389133914): Remove dummy bytes converter.
|
|
492
492
|
return fromImageBytes;
|
|
493
493
|
}
|
|
494
|
+
function _isFile(origin) {
|
|
495
|
+
return (origin !== null &&
|
|
496
|
+
origin !== undefined &&
|
|
497
|
+
typeof origin === 'object' &&
|
|
498
|
+
'name' in origin);
|
|
499
|
+
}
|
|
500
|
+
function isGeneratedVideo(origin) {
|
|
501
|
+
return (origin !== null &&
|
|
502
|
+
origin !== undefined &&
|
|
503
|
+
typeof origin === 'object' &&
|
|
504
|
+
'video' in origin);
|
|
505
|
+
}
|
|
506
|
+
function isVideo(origin) {
|
|
507
|
+
return (origin !== null &&
|
|
508
|
+
origin !== undefined &&
|
|
509
|
+
typeof origin === 'object' &&
|
|
510
|
+
'uri' in origin);
|
|
511
|
+
}
|
|
494
512
|
function tFileName(apiClient, fromName) {
|
|
495
|
-
|
|
496
|
-
|
|
513
|
+
var _a;
|
|
514
|
+
let name;
|
|
515
|
+
if (_isFile(fromName)) {
|
|
516
|
+
name = fromName.name;
|
|
517
|
+
}
|
|
518
|
+
if (isVideo(fromName)) {
|
|
519
|
+
name = fromName.uri;
|
|
520
|
+
if (name === undefined) {
|
|
521
|
+
return undefined;
|
|
522
|
+
}
|
|
497
523
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
524
|
+
if (isGeneratedVideo(fromName)) {
|
|
525
|
+
name = (_a = fromName.video) === null || _a === void 0 ? void 0 : _a.uri;
|
|
526
|
+
if (name === undefined) {
|
|
527
|
+
return undefined;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
if (typeof fromName === 'string') {
|
|
531
|
+
name = fromName;
|
|
532
|
+
}
|
|
533
|
+
if (name === undefined) {
|
|
534
|
+
throw new Error('Could not extract file name from the provided input.');
|
|
535
|
+
}
|
|
536
|
+
if (name.startsWith('https://')) {
|
|
537
|
+
const suffix = name.split('files/')[1];
|
|
538
|
+
const match = suffix.match(/[a-z0-9]+/);
|
|
539
|
+
if (match === null) {
|
|
540
|
+
throw new Error(`Could not extract file name from URI ${name}`);
|
|
541
|
+
}
|
|
542
|
+
name = match[0];
|
|
543
|
+
}
|
|
544
|
+
else if (name.startsWith('files/')) {
|
|
545
|
+
name = name.split('files/')[1];
|
|
546
|
+
}
|
|
547
|
+
return name;
|
|
548
|
+
}
|
|
549
|
+
function tModelsUrl(apiClient, baseModels) {
|
|
550
|
+
let res;
|
|
551
|
+
if (apiClient.isVertexAI()) {
|
|
552
|
+
res = baseModels ? 'publishers/google/models' : 'models';
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
res = baseModels ? 'models' : 'tunedModels';
|
|
501
556
|
}
|
|
502
|
-
return
|
|
557
|
+
return res;
|
|
558
|
+
}
|
|
559
|
+
function tExtractModels(apiClient, response) {
|
|
560
|
+
for (const key of ['models', 'tunedModels', 'publisherModels']) {
|
|
561
|
+
if (hasField(response, key)) {
|
|
562
|
+
return response[key];
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return [];
|
|
566
|
+
}
|
|
567
|
+
function hasField(data, fieldName) {
|
|
568
|
+
return data !== null && typeof data === 'object' && fieldName in data;
|
|
503
569
|
}
|
|
504
570
|
|
|
505
571
|
/**
|
|
@@ -507,6 +573,21 @@ function tFileName(apiClient, fromName) {
|
|
|
507
573
|
* Copyright 2025 Google LLC
|
|
508
574
|
* SPDX-License-Identifier: Apache-2.0
|
|
509
575
|
*/
|
|
576
|
+
function blobToMldev$2(apiClient, fromObject) {
|
|
577
|
+
const toObject = {};
|
|
578
|
+
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
579
|
+
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
580
|
+
}
|
|
581
|
+
const fromData = getValueByPath(fromObject, ['data']);
|
|
582
|
+
if (fromData != null) {
|
|
583
|
+
setValueByPath(toObject, ['data'], fromData);
|
|
584
|
+
}
|
|
585
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
586
|
+
if (fromMimeType != null) {
|
|
587
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
588
|
+
}
|
|
589
|
+
return toObject;
|
|
590
|
+
}
|
|
510
591
|
function partToMldev$2(apiClient, fromObject) {
|
|
511
592
|
const toObject = {};
|
|
512
593
|
if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
|
|
@@ -516,6 +597,10 @@ function partToMldev$2(apiClient, fromObject) {
|
|
|
516
597
|
if (fromThought != null) {
|
|
517
598
|
setValueByPath(toObject, ['thought'], fromThought);
|
|
518
599
|
}
|
|
600
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
601
|
+
if (fromInlineData != null) {
|
|
602
|
+
setValueByPath(toObject, ['inlineData'], blobToMldev$2(apiClient, fromInlineData));
|
|
603
|
+
}
|
|
519
604
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
520
605
|
'codeExecutionResult',
|
|
521
606
|
]);
|
|
@@ -542,10 +627,6 @@ function partToMldev$2(apiClient, fromObject) {
|
|
|
542
627
|
if (fromFunctionResponse != null) {
|
|
543
628
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
544
629
|
}
|
|
545
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
546
|
-
if (fromInlineData != null) {
|
|
547
|
-
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
548
|
-
}
|
|
549
630
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
550
631
|
if (fromText != null) {
|
|
551
632
|
setValueByPath(toObject, ['text'], fromText);
|
|
@@ -613,6 +694,12 @@ function toolToMldev$2(apiClient, fromObject) {
|
|
|
613
694
|
if (fromGoogleSearchRetrieval != null) {
|
|
614
695
|
setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev$2(apiClient, fromGoogleSearchRetrieval));
|
|
615
696
|
}
|
|
697
|
+
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
698
|
+
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
699
|
+
}
|
|
700
|
+
if (getValueByPath(fromObject, ['googleMaps']) !== undefined) {
|
|
701
|
+
throw new Error('googleMaps parameter is not supported in Gemini API.');
|
|
702
|
+
}
|
|
616
703
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
617
704
|
'codeExecution',
|
|
618
705
|
]);
|
|
@@ -649,6 +736,9 @@ function toolConfigToMldev$1(apiClient, fromObject) {
|
|
|
649
736
|
if (fromFunctionCallingConfig != null) {
|
|
650
737
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(apiClient, fromFunctionCallingConfig));
|
|
651
738
|
}
|
|
739
|
+
if (getValueByPath(fromObject, ['retrievalConfig']) !== undefined) {
|
|
740
|
+
throw new Error('retrievalConfig parameter is not supported in Gemini API.');
|
|
741
|
+
}
|
|
652
742
|
return toObject;
|
|
653
743
|
}
|
|
654
744
|
function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
@@ -777,6 +867,22 @@ function listCachedContentsParametersToMldev(apiClient, fromObject) {
|
|
|
777
867
|
}
|
|
778
868
|
return toObject;
|
|
779
869
|
}
|
|
870
|
+
function blobToVertex$2(apiClient, fromObject) {
|
|
871
|
+
const toObject = {};
|
|
872
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
873
|
+
if (fromDisplayName != null) {
|
|
874
|
+
setValueByPath(toObject, ['displayName'], fromDisplayName);
|
|
875
|
+
}
|
|
876
|
+
const fromData = getValueByPath(fromObject, ['data']);
|
|
877
|
+
if (fromData != null) {
|
|
878
|
+
setValueByPath(toObject, ['data'], fromData);
|
|
879
|
+
}
|
|
880
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
881
|
+
if (fromMimeType != null) {
|
|
882
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
883
|
+
}
|
|
884
|
+
return toObject;
|
|
885
|
+
}
|
|
780
886
|
function partToVertex$2(apiClient, fromObject) {
|
|
781
887
|
const toObject = {};
|
|
782
888
|
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
@@ -789,6 +895,10 @@ function partToVertex$2(apiClient, fromObject) {
|
|
|
789
895
|
if (fromThought != null) {
|
|
790
896
|
setValueByPath(toObject, ['thought'], fromThought);
|
|
791
897
|
}
|
|
898
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
899
|
+
if (fromInlineData != null) {
|
|
900
|
+
setValueByPath(toObject, ['inlineData'], blobToVertex$2(apiClient, fromInlineData));
|
|
901
|
+
}
|
|
792
902
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
793
903
|
'codeExecutionResult',
|
|
794
904
|
]);
|
|
@@ -815,10 +925,6 @@ function partToVertex$2(apiClient, fromObject) {
|
|
|
815
925
|
if (fromFunctionResponse != null) {
|
|
816
926
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
817
927
|
}
|
|
818
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
819
|
-
if (fromInlineData != null) {
|
|
820
|
-
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
821
|
-
}
|
|
822
928
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
823
929
|
if (fromText != null) {
|
|
824
930
|
setValueByPath(toObject, ['text'], fromText);
|
|
@@ -871,6 +977,58 @@ function googleSearchRetrievalToVertex$2(apiClient, fromObject) {
|
|
|
871
977
|
}
|
|
872
978
|
return toObject;
|
|
873
979
|
}
|
|
980
|
+
function enterpriseWebSearchToVertex$2() {
|
|
981
|
+
const toObject = {};
|
|
982
|
+
return toObject;
|
|
983
|
+
}
|
|
984
|
+
function apiKeyConfigToVertex$2(apiClient, fromObject) {
|
|
985
|
+
const toObject = {};
|
|
986
|
+
const fromApiKeyString = getValueByPath(fromObject, ['apiKeyString']);
|
|
987
|
+
if (fromApiKeyString != null) {
|
|
988
|
+
setValueByPath(toObject, ['apiKeyString'], fromApiKeyString);
|
|
989
|
+
}
|
|
990
|
+
return toObject;
|
|
991
|
+
}
|
|
992
|
+
function authConfigToVertex$2(apiClient, fromObject) {
|
|
993
|
+
const toObject = {};
|
|
994
|
+
const fromApiKeyConfig = getValueByPath(fromObject, ['apiKeyConfig']);
|
|
995
|
+
if (fromApiKeyConfig != null) {
|
|
996
|
+
setValueByPath(toObject, ['apiKeyConfig'], apiKeyConfigToVertex$2(apiClient, fromApiKeyConfig));
|
|
997
|
+
}
|
|
998
|
+
const fromAuthType = getValueByPath(fromObject, ['authType']);
|
|
999
|
+
if (fromAuthType != null) {
|
|
1000
|
+
setValueByPath(toObject, ['authType'], fromAuthType);
|
|
1001
|
+
}
|
|
1002
|
+
const fromGoogleServiceAccountConfig = getValueByPath(fromObject, [
|
|
1003
|
+
'googleServiceAccountConfig',
|
|
1004
|
+
]);
|
|
1005
|
+
if (fromGoogleServiceAccountConfig != null) {
|
|
1006
|
+
setValueByPath(toObject, ['googleServiceAccountConfig'], fromGoogleServiceAccountConfig);
|
|
1007
|
+
}
|
|
1008
|
+
const fromHttpBasicAuthConfig = getValueByPath(fromObject, [
|
|
1009
|
+
'httpBasicAuthConfig',
|
|
1010
|
+
]);
|
|
1011
|
+
if (fromHttpBasicAuthConfig != null) {
|
|
1012
|
+
setValueByPath(toObject, ['httpBasicAuthConfig'], fromHttpBasicAuthConfig);
|
|
1013
|
+
}
|
|
1014
|
+
const fromOauthConfig = getValueByPath(fromObject, ['oauthConfig']);
|
|
1015
|
+
if (fromOauthConfig != null) {
|
|
1016
|
+
setValueByPath(toObject, ['oauthConfig'], fromOauthConfig);
|
|
1017
|
+
}
|
|
1018
|
+
const fromOidcConfig = getValueByPath(fromObject, ['oidcConfig']);
|
|
1019
|
+
if (fromOidcConfig != null) {
|
|
1020
|
+
setValueByPath(toObject, ['oidcConfig'], fromOidcConfig);
|
|
1021
|
+
}
|
|
1022
|
+
return toObject;
|
|
1023
|
+
}
|
|
1024
|
+
function googleMapsToVertex$2(apiClient, fromObject) {
|
|
1025
|
+
const toObject = {};
|
|
1026
|
+
const fromAuthConfig = getValueByPath(fromObject, ['authConfig']);
|
|
1027
|
+
if (fromAuthConfig != null) {
|
|
1028
|
+
setValueByPath(toObject, ['authConfig'], authConfigToVertex$2(apiClient, fromAuthConfig));
|
|
1029
|
+
}
|
|
1030
|
+
return toObject;
|
|
1031
|
+
}
|
|
874
1032
|
function toolToVertex$2(apiClient, fromObject) {
|
|
875
1033
|
const toObject = {};
|
|
876
1034
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
@@ -887,6 +1045,16 @@ function toolToVertex$2(apiClient, fromObject) {
|
|
|
887
1045
|
if (fromGoogleSearchRetrieval != null) {
|
|
888
1046
|
setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToVertex$2(apiClient, fromGoogleSearchRetrieval));
|
|
889
1047
|
}
|
|
1048
|
+
const fromEnterpriseWebSearch = getValueByPath(fromObject, [
|
|
1049
|
+
'enterpriseWebSearch',
|
|
1050
|
+
]);
|
|
1051
|
+
if (fromEnterpriseWebSearch != null) {
|
|
1052
|
+
setValueByPath(toObject, ['enterpriseWebSearch'], enterpriseWebSearchToVertex$2());
|
|
1053
|
+
}
|
|
1054
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
1055
|
+
if (fromGoogleMaps != null) {
|
|
1056
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$2(apiClient, fromGoogleMaps));
|
|
1057
|
+
}
|
|
890
1058
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
891
1059
|
'codeExecution',
|
|
892
1060
|
]);
|
|
@@ -915,6 +1083,26 @@ function functionCallingConfigToVertex$1(apiClient, fromObject) {
|
|
|
915
1083
|
}
|
|
916
1084
|
return toObject;
|
|
917
1085
|
}
|
|
1086
|
+
function latLngToVertex$1(apiClient, fromObject) {
|
|
1087
|
+
const toObject = {};
|
|
1088
|
+
const fromLatitude = getValueByPath(fromObject, ['latitude']);
|
|
1089
|
+
if (fromLatitude != null) {
|
|
1090
|
+
setValueByPath(toObject, ['latitude'], fromLatitude);
|
|
1091
|
+
}
|
|
1092
|
+
const fromLongitude = getValueByPath(fromObject, ['longitude']);
|
|
1093
|
+
if (fromLongitude != null) {
|
|
1094
|
+
setValueByPath(toObject, ['longitude'], fromLongitude);
|
|
1095
|
+
}
|
|
1096
|
+
return toObject;
|
|
1097
|
+
}
|
|
1098
|
+
function retrievalConfigToVertex$1(apiClient, fromObject) {
|
|
1099
|
+
const toObject = {};
|
|
1100
|
+
const fromLatLng = getValueByPath(fromObject, ['latLng']);
|
|
1101
|
+
if (fromLatLng != null) {
|
|
1102
|
+
setValueByPath(toObject, ['latLng'], latLngToVertex$1(apiClient, fromLatLng));
|
|
1103
|
+
}
|
|
1104
|
+
return toObject;
|
|
1105
|
+
}
|
|
918
1106
|
function toolConfigToVertex$1(apiClient, fromObject) {
|
|
919
1107
|
const toObject = {};
|
|
920
1108
|
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
@@ -923,6 +1111,12 @@ function toolConfigToVertex$1(apiClient, fromObject) {
|
|
|
923
1111
|
if (fromFunctionCallingConfig != null) {
|
|
924
1112
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToVertex$1(apiClient, fromFunctionCallingConfig));
|
|
925
1113
|
}
|
|
1114
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
1115
|
+
'retrievalConfig',
|
|
1116
|
+
]);
|
|
1117
|
+
if (fromRetrievalConfig != null) {
|
|
1118
|
+
setValueByPath(toObject, ['retrievalConfig'], retrievalConfigToVertex$1(apiClient, fromRetrievalConfig));
|
|
1119
|
+
}
|
|
926
1120
|
return toObject;
|
|
927
1121
|
}
|
|
928
1122
|
function createCachedContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
@@ -1402,6 +1596,17 @@ exports.Mode = void 0;
|
|
|
1402
1596
|
Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
1403
1597
|
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
1404
1598
|
})(exports.Mode || (exports.Mode = {}));
|
|
1599
|
+
/** Type of auth scheme. */
|
|
1600
|
+
exports.AuthType = void 0;
|
|
1601
|
+
(function (AuthType) {
|
|
1602
|
+
AuthType["AUTH_TYPE_UNSPECIFIED"] = "AUTH_TYPE_UNSPECIFIED";
|
|
1603
|
+
AuthType["NO_AUTH"] = "NO_AUTH";
|
|
1604
|
+
AuthType["API_KEY_AUTH"] = "API_KEY_AUTH";
|
|
1605
|
+
AuthType["HTTP_BASIC_AUTH"] = "HTTP_BASIC_AUTH";
|
|
1606
|
+
AuthType["GOOGLE_SERVICE_ACCOUNT_AUTH"] = "GOOGLE_SERVICE_ACCOUNT_AUTH";
|
|
1607
|
+
AuthType["OAUTH"] = "OAUTH";
|
|
1608
|
+
AuthType["OIDC_AUTH"] = "OIDC_AUTH";
|
|
1609
|
+
})(exports.AuthType || (exports.AuthType = {}));
|
|
1405
1610
|
/** Optional. The type of the data. */
|
|
1406
1611
|
exports.Type = void 0;
|
|
1407
1612
|
(function (Type) {
|
|
@@ -1555,21 +1760,6 @@ exports.ImagePromptLanguage = void 0;
|
|
|
1555
1760
|
ImagePromptLanguage["ko"] = "ko";
|
|
1556
1761
|
ImagePromptLanguage["hi"] = "hi";
|
|
1557
1762
|
})(exports.ImagePromptLanguage || (exports.ImagePromptLanguage = {}));
|
|
1558
|
-
/** State for the lifecycle of a File. */
|
|
1559
|
-
exports.FileState = void 0;
|
|
1560
|
-
(function (FileState) {
|
|
1561
|
-
FileState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
|
|
1562
|
-
FileState["PROCESSING"] = "PROCESSING";
|
|
1563
|
-
FileState["ACTIVE"] = "ACTIVE";
|
|
1564
|
-
FileState["FAILED"] = "FAILED";
|
|
1565
|
-
})(exports.FileState || (exports.FileState = {}));
|
|
1566
|
-
/** Source of the File. */
|
|
1567
|
-
exports.FileSource = void 0;
|
|
1568
|
-
(function (FileSource) {
|
|
1569
|
-
FileSource["SOURCE_UNSPECIFIED"] = "SOURCE_UNSPECIFIED";
|
|
1570
|
-
FileSource["UPLOADED"] = "UPLOADED";
|
|
1571
|
-
FileSource["GENERATED"] = "GENERATED";
|
|
1572
|
-
})(exports.FileSource || (exports.FileSource = {}));
|
|
1573
1763
|
/** Enum representing the mask mode of a mask reference image. */
|
|
1574
1764
|
exports.MaskReferenceMode = void 0;
|
|
1575
1765
|
(function (MaskReferenceMode) {
|
|
@@ -1595,6 +1785,33 @@ exports.SubjectReferenceType = void 0;
|
|
|
1595
1785
|
SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
|
|
1596
1786
|
SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
|
|
1597
1787
|
})(exports.SubjectReferenceType || (exports.SubjectReferenceType = {}));
|
|
1788
|
+
/** Enum representing the Imagen 3 Edit mode. */
|
|
1789
|
+
exports.EditMode = void 0;
|
|
1790
|
+
(function (EditMode) {
|
|
1791
|
+
EditMode["EDIT_MODE_DEFAULT"] = "EDIT_MODE_DEFAULT";
|
|
1792
|
+
EditMode["EDIT_MODE_INPAINT_REMOVAL"] = "EDIT_MODE_INPAINT_REMOVAL";
|
|
1793
|
+
EditMode["EDIT_MODE_INPAINT_INSERTION"] = "EDIT_MODE_INPAINT_INSERTION";
|
|
1794
|
+
EditMode["EDIT_MODE_OUTPAINT"] = "EDIT_MODE_OUTPAINT";
|
|
1795
|
+
EditMode["EDIT_MODE_CONTROLLED_EDITING"] = "EDIT_MODE_CONTROLLED_EDITING";
|
|
1796
|
+
EditMode["EDIT_MODE_STYLE"] = "EDIT_MODE_STYLE";
|
|
1797
|
+
EditMode["EDIT_MODE_BGSWAP"] = "EDIT_MODE_BGSWAP";
|
|
1798
|
+
EditMode["EDIT_MODE_PRODUCT_IMAGE"] = "EDIT_MODE_PRODUCT_IMAGE";
|
|
1799
|
+
})(exports.EditMode || (exports.EditMode = {}));
|
|
1800
|
+
/** State for the lifecycle of a File. */
|
|
1801
|
+
exports.FileState = void 0;
|
|
1802
|
+
(function (FileState) {
|
|
1803
|
+
FileState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
|
|
1804
|
+
FileState["PROCESSING"] = "PROCESSING";
|
|
1805
|
+
FileState["ACTIVE"] = "ACTIVE";
|
|
1806
|
+
FileState["FAILED"] = "FAILED";
|
|
1807
|
+
})(exports.FileState || (exports.FileState = {}));
|
|
1808
|
+
/** Source of the File. */
|
|
1809
|
+
exports.FileSource = void 0;
|
|
1810
|
+
(function (FileSource) {
|
|
1811
|
+
FileSource["SOURCE_UNSPECIFIED"] = "SOURCE_UNSPECIFIED";
|
|
1812
|
+
FileSource["UPLOADED"] = "UPLOADED";
|
|
1813
|
+
FileSource["GENERATED"] = "GENERATED";
|
|
1814
|
+
})(exports.FileSource || (exports.FileSource = {}));
|
|
1598
1815
|
/** Server content modalities. */
|
|
1599
1816
|
exports.MediaModality = void 0;
|
|
1600
1817
|
(function (MediaModality) {
|
|
@@ -2009,6 +2226,13 @@ class EmbedContentResponse {
|
|
|
2009
2226
|
/** The output images response. */
|
|
2010
2227
|
class GenerateImagesResponse {
|
|
2011
2228
|
}
|
|
2229
|
+
/** Response for the request to edit an image. */
|
|
2230
|
+
class EditImageResponse {
|
|
2231
|
+
}
|
|
2232
|
+
class UpscaleImageResponse {
|
|
2233
|
+
}
|
|
2234
|
+
class ListModelsResponse {
|
|
2235
|
+
}
|
|
2012
2236
|
class DeleteModelResponse {
|
|
2013
2237
|
}
|
|
2014
2238
|
/** Response for counting tokens. */
|
|
@@ -2056,6 +2280,176 @@ class DeleteFileResponse {
|
|
|
2056
2280
|
/** Represents a single response in a replay. */
|
|
2057
2281
|
class ReplayResponse {
|
|
2058
2282
|
}
|
|
2283
|
+
/** A raw reference image.
|
|
2284
|
+
|
|
2285
|
+
A raw reference image represents the base image to edit, provided by the user.
|
|
2286
|
+
It can optionally be provided in addition to a mask reference image or
|
|
2287
|
+
a style reference image.
|
|
2288
|
+
*/
|
|
2289
|
+
class RawReferenceImage {
|
|
2290
|
+
/** Internal method to convert to ReferenceImageAPIInternal. */
|
|
2291
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2292
|
+
toReferenceImageAPI() {
|
|
2293
|
+
const referenceImageAPI = {
|
|
2294
|
+
referenceType: 'REFERENCE_TYPE_RAW',
|
|
2295
|
+
referenceImage: this.referenceImage,
|
|
2296
|
+
referenceId: this.referenceId,
|
|
2297
|
+
};
|
|
2298
|
+
return referenceImageAPI;
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
/** A mask reference image.
|
|
2302
|
+
|
|
2303
|
+
This encapsulates either a mask image provided by the user and configs for
|
|
2304
|
+
the user provided mask, or only config parameters for the model to generate
|
|
2305
|
+
a mask.
|
|
2306
|
+
|
|
2307
|
+
A mask image is an image whose non-zero values indicate where to edit the base
|
|
2308
|
+
image. If the user provides a mask image, the mask must be in the same
|
|
2309
|
+
dimensions as the raw image.
|
|
2310
|
+
*/
|
|
2311
|
+
class MaskReferenceImage {
|
|
2312
|
+
/** Internal method to convert to ReferenceImageAPIInternal. */
|
|
2313
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2314
|
+
toReferenceImageAPI() {
|
|
2315
|
+
const referenceImageAPI = {
|
|
2316
|
+
referenceType: 'REFERENCE_TYPE_MASK',
|
|
2317
|
+
referenceImage: this.referenceImage,
|
|
2318
|
+
referenceId: this.referenceId,
|
|
2319
|
+
maskImageConfig: this.config,
|
|
2320
|
+
};
|
|
2321
|
+
return referenceImageAPI;
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
/** A control reference image.
|
|
2325
|
+
|
|
2326
|
+
The image of the control reference image is either a control image provided
|
|
2327
|
+
by the user, or a regular image which the backend will use to generate a
|
|
2328
|
+
control image of. In the case of the latter, the
|
|
2329
|
+
enable_control_image_computation field in the config should be set to True.
|
|
2330
|
+
|
|
2331
|
+
A control image is an image that represents a sketch image of areas for the
|
|
2332
|
+
model to fill in based on the prompt.
|
|
2333
|
+
*/
|
|
2334
|
+
class ControlReferenceImage {
|
|
2335
|
+
/** Internal method to convert to ReferenceImageAPIInternal. */
|
|
2336
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2337
|
+
toReferenceImageAPI() {
|
|
2338
|
+
const referenceImageAPI = {
|
|
2339
|
+
referenceType: 'REFERENCE_TYPE_CONTROL',
|
|
2340
|
+
referenceImage: this.referenceImage,
|
|
2341
|
+
referenceId: this.referenceId,
|
|
2342
|
+
controlImageConfig: this.config,
|
|
2343
|
+
};
|
|
2344
|
+
return referenceImageAPI;
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
/** A style reference image.
|
|
2348
|
+
|
|
2349
|
+
This encapsulates a style reference image provided by the user, and
|
|
2350
|
+
additionally optional config parameters for the style reference image.
|
|
2351
|
+
|
|
2352
|
+
A raw reference image can also be provided as a destination for the style to
|
|
2353
|
+
be applied to.
|
|
2354
|
+
*/
|
|
2355
|
+
class StyleReferenceImage {
|
|
2356
|
+
/** Internal method to convert to ReferenceImageAPIInternal. */
|
|
2357
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2358
|
+
toReferenceImageAPI() {
|
|
2359
|
+
const referenceImageAPI = {
|
|
2360
|
+
referenceType: 'REFERENCE_TYPE_STYLE',
|
|
2361
|
+
referenceImage: this.referenceImage,
|
|
2362
|
+
referenceId: this.referenceId,
|
|
2363
|
+
styleImageConfig: this.config,
|
|
2364
|
+
};
|
|
2365
|
+
return referenceImageAPI;
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
/** A subject reference image.
|
|
2369
|
+
|
|
2370
|
+
This encapsulates a subject reference image provided by the user, and
|
|
2371
|
+
additionally optional config parameters for the subject reference image.
|
|
2372
|
+
|
|
2373
|
+
A raw reference image can also be provided as a destination for the subject to
|
|
2374
|
+
be applied to.
|
|
2375
|
+
*/
|
|
2376
|
+
class SubjectReferenceImage {
|
|
2377
|
+
/* Internal method to convert to ReferenceImageAPIInternal. */
|
|
2378
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2379
|
+
toReferenceImageAPI() {
|
|
2380
|
+
const referenceImageAPI = {
|
|
2381
|
+
referenceType: 'REFERENCE_TYPE_SUBJECT',
|
|
2382
|
+
referenceImage: this.referenceImage,
|
|
2383
|
+
referenceId: this.referenceId,
|
|
2384
|
+
subjectImageConfig: this.config,
|
|
2385
|
+
};
|
|
2386
|
+
return referenceImageAPI;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
/** Response message for API call. */
|
|
2390
|
+
class LiveServerMessage {
|
|
2391
|
+
/**
|
|
2392
|
+
* Returns the concatenation of all text parts from the server content if present.
|
|
2393
|
+
*
|
|
2394
|
+
* @remarks
|
|
2395
|
+
* If there are non-text parts in the response, the concatenation of all text
|
|
2396
|
+
* parts will be returned, and a warning will be logged.
|
|
2397
|
+
*/
|
|
2398
|
+
get text() {
|
|
2399
|
+
var _a, _b, _c;
|
|
2400
|
+
let text = '';
|
|
2401
|
+
let anyTextPartFound = false;
|
|
2402
|
+
const nonTextParts = [];
|
|
2403
|
+
for (const part of (_c = (_b = (_a = this.serverContent) === null || _a === void 0 ? void 0 : _a.modelTurn) === null || _b === void 0 ? void 0 : _b.parts) !== null && _c !== void 0 ? _c : []) {
|
|
2404
|
+
for (const [fieldName, fieldValue] of Object.entries(part)) {
|
|
2405
|
+
if (fieldName !== 'text' &&
|
|
2406
|
+
fieldName !== 'thought' &&
|
|
2407
|
+
fieldValue !== null) {
|
|
2408
|
+
nonTextParts.push(fieldName);
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
if (typeof part.text === 'string') {
|
|
2412
|
+
if (typeof part.thought === 'boolean' && part.thought) {
|
|
2413
|
+
continue;
|
|
2414
|
+
}
|
|
2415
|
+
anyTextPartFound = true;
|
|
2416
|
+
text += part.text;
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
if (nonTextParts.length > 0) {
|
|
2420
|
+
console.warn(`there are non-text parts ${nonTextParts} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`);
|
|
2421
|
+
}
|
|
2422
|
+
// part.text === '' is different from part.text is null
|
|
2423
|
+
return anyTextPartFound ? text : undefined;
|
|
2424
|
+
}
|
|
2425
|
+
/**
|
|
2426
|
+
* Returns the concatenation of all inline data parts from the server content if present.
|
|
2427
|
+
*
|
|
2428
|
+
* @remarks
|
|
2429
|
+
* If there are non-inline data parts in the
|
|
2430
|
+
* response, the concatenation of all inline data parts will be returned, and
|
|
2431
|
+
* a warning will be logged.
|
|
2432
|
+
*/
|
|
2433
|
+
get data() {
|
|
2434
|
+
var _a, _b, _c;
|
|
2435
|
+
let data = '';
|
|
2436
|
+
const nonDataParts = [];
|
|
2437
|
+
for (const part of (_c = (_b = (_a = this.serverContent) === null || _a === void 0 ? void 0 : _a.modelTurn) === null || _b === void 0 ? void 0 : _b.parts) !== null && _c !== void 0 ? _c : []) {
|
|
2438
|
+
for (const [fieldName, fieldValue] of Object.entries(part)) {
|
|
2439
|
+
if (fieldName !== 'inlineData' && fieldValue !== null) {
|
|
2440
|
+
nonDataParts.push(fieldName);
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
if (part.inlineData && typeof part.inlineData.data === 'string') {
|
|
2444
|
+
data += atob(part.inlineData.data);
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
if (nonDataParts.length > 0) {
|
|
2448
|
+
console.warn(`there are non-data parts ${nonDataParts} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`);
|
|
2449
|
+
}
|
|
2450
|
+
return data.length > 0 ? btoa(data) : undefined;
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2059
2453
|
/** Client generated response to a `ToolCall` received from the server.
|
|
2060
2454
|
|
|
2061
2455
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2817,7 +3211,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
2817
3211
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
2818
3212
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
2819
3213
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
2820
|
-
const SDK_VERSION = '0.
|
|
3214
|
+
const SDK_VERSION = '0.14.0'; // x-release-please-version
|
|
2821
3215
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
2822
3216
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
2823
3217
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -2864,18 +3258,11 @@ class ApiClient {
|
|
|
2864
3258
|
if (this.clientOptions.vertexai) {
|
|
2865
3259
|
initHttpOptions.apiVersion =
|
|
2866
3260
|
(_a = this.clientOptions.apiVersion) !== null && _a !== void 0 ? _a : VERTEX_AI_API_DEFAULT_VERSION;
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
initHttpOptions.baseUrl = `https://${this.clientOptions.location}-aiplatform.googleapis.com/`;
|
|
2870
|
-
this.clientOptions.apiKey = undefined; // unset API key.
|
|
2871
|
-
}
|
|
2872
|
-
else {
|
|
2873
|
-
initHttpOptions.baseUrl = `https://aiplatform.googleapis.com/`;
|
|
2874
|
-
this.clientOptions.project = undefined; // unset project.
|
|
2875
|
-
this.clientOptions.location = undefined; // unset location.
|
|
2876
|
-
}
|
|
3261
|
+
initHttpOptions.baseUrl = this.baseUrlFromProjectLocation();
|
|
3262
|
+
this.normalizeAuthParameters();
|
|
2877
3263
|
}
|
|
2878
3264
|
else {
|
|
3265
|
+
// Gemini API
|
|
2879
3266
|
initHttpOptions.apiVersion =
|
|
2880
3267
|
(_b = this.clientOptions.apiVersion) !== null && _b !== void 0 ? _b : GOOGLE_AI_API_DEFAULT_VERSION;
|
|
2881
3268
|
initHttpOptions.baseUrl = `https://generativelanguage.googleapis.com/`;
|
|
@@ -2886,6 +3273,39 @@ class ApiClient {
|
|
|
2886
3273
|
this.clientOptions.httpOptions = this.patchHttpOptions(initHttpOptions, opts.httpOptions);
|
|
2887
3274
|
}
|
|
2888
3275
|
}
|
|
3276
|
+
/**
|
|
3277
|
+
* Determines the base URL for Vertex AI based on project and location.
|
|
3278
|
+
* Uses the global endpoint if location is 'global' or if project/location
|
|
3279
|
+
* are not specified (implying API key usage).
|
|
3280
|
+
* @private
|
|
3281
|
+
*/
|
|
3282
|
+
baseUrlFromProjectLocation() {
|
|
3283
|
+
if (this.clientOptions.project &&
|
|
3284
|
+
this.clientOptions.location &&
|
|
3285
|
+
this.clientOptions.location !== 'global') {
|
|
3286
|
+
// Regional endpoint
|
|
3287
|
+
return `https://${this.clientOptions.location}-aiplatform.googleapis.com/`;
|
|
3288
|
+
}
|
|
3289
|
+
// Global endpoint (covers 'global' location and API key usage)
|
|
3290
|
+
return `https://aiplatform.googleapis.com/`;
|
|
3291
|
+
}
|
|
3292
|
+
/**
|
|
3293
|
+
* Normalizes authentication parameters for Vertex AI.
|
|
3294
|
+
* If project and location are provided, API key is cleared.
|
|
3295
|
+
* If project and location are not provided (implying API key usage),
|
|
3296
|
+
* project and location are cleared.
|
|
3297
|
+
* @private
|
|
3298
|
+
*/
|
|
3299
|
+
normalizeAuthParameters() {
|
|
3300
|
+
if (this.clientOptions.project && this.clientOptions.location) {
|
|
3301
|
+
// Using project/location for auth, clear potential API key
|
|
3302
|
+
this.clientOptions.apiKey = undefined;
|
|
3303
|
+
return;
|
|
3304
|
+
}
|
|
3305
|
+
// Using API key for auth (or no auth provided yet), clear project/location
|
|
3306
|
+
this.clientOptions.project = undefined;
|
|
3307
|
+
this.clientOptions.location = undefined;
|
|
3308
|
+
}
|
|
2889
3309
|
isVertexAI() {
|
|
2890
3310
|
var _a;
|
|
2891
3311
|
return (_a = this.clientOptions.vertexai) !== null && _a !== void 0 ? _a : false;
|
|
@@ -3223,6 +3643,16 @@ class ApiClient {
|
|
|
3223
3643
|
const uploadUrl = await this.fetchUploadUrl(fileToUpload, config);
|
|
3224
3644
|
return uploader.upload(file, uploadUrl, this);
|
|
3225
3645
|
}
|
|
3646
|
+
/**
|
|
3647
|
+
* Downloads a file asynchronously to the specified path.
|
|
3648
|
+
*
|
|
3649
|
+
* @params params - The parameters for the download request, see {@link
|
|
3650
|
+
* DownloadFileParameters}
|
|
3651
|
+
*/
|
|
3652
|
+
async downloadFile(params) {
|
|
3653
|
+
const downloader = this.clientOptions.downloader;
|
|
3654
|
+
await downloader.download(params, this);
|
|
3655
|
+
}
|
|
3226
3656
|
async fetchUploadUrl(file, config) {
|
|
3227
3657
|
var _a;
|
|
3228
3658
|
let httpOptions = {};
|
|
@@ -3309,7 +3739,22 @@ function crossError() {
|
|
|
3309
3739
|
`);
|
|
3310
3740
|
}
|
|
3311
3741
|
|
|
3742
|
+
/**
|
|
3743
|
+
* @license
|
|
3744
|
+
* Copyright 2025 Google LLC
|
|
3745
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
3746
|
+
*/
|
|
3747
|
+
class CrossDownloader {
|
|
3748
|
+
async download(_params, _apiClient) {
|
|
3749
|
+
throw crossError();
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
|
|
3312
3753
|
const MAX_CHUNK_SIZE = 1024 * 1024 * 8; // bytes
|
|
3754
|
+
const MAX_RETRY_COUNT = 3;
|
|
3755
|
+
const INITIAL_RETRY_DELAY_MS = 1000;
|
|
3756
|
+
const DELAY_MULTIPLIER = 2;
|
|
3757
|
+
const X_GOOG_UPLOAD_STATUS_HEADER_FIELD = 'x-goog-upload-status';
|
|
3313
3758
|
class CrossUploader {
|
|
3314
3759
|
async upload(file, uploadUrl, apiClient) {
|
|
3315
3760
|
if (typeof file === 'string') {
|
|
@@ -3329,7 +3774,7 @@ class CrossUploader {
|
|
|
3329
3774
|
}
|
|
3330
3775
|
}
|
|
3331
3776
|
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
3332
|
-
var _a, _b;
|
|
3777
|
+
var _a, _b, _c;
|
|
3333
3778
|
let fileSize = 0;
|
|
3334
3779
|
let offset = 0;
|
|
3335
3780
|
let response = new HttpResponse(new Response());
|
|
@@ -3341,24 +3786,34 @@ async function uploadBlob(file, uploadUrl, apiClient) {
|
|
|
3341
3786
|
if (offset + chunkSize >= fileSize) {
|
|
3342
3787
|
uploadCommand += ', finalize';
|
|
3343
3788
|
}
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
'
|
|
3353
|
-
|
|
3354
|
-
|
|
3789
|
+
let retryCount = 0;
|
|
3790
|
+
let currentDelayMs = INITIAL_RETRY_DELAY_MS;
|
|
3791
|
+
while (retryCount < MAX_RETRY_COUNT) {
|
|
3792
|
+
response = await apiClient.request({
|
|
3793
|
+
path: '',
|
|
3794
|
+
body: chunk,
|
|
3795
|
+
httpMethod: 'POST',
|
|
3796
|
+
httpOptions: {
|
|
3797
|
+
apiVersion: '',
|
|
3798
|
+
baseUrl: uploadUrl,
|
|
3799
|
+
headers: {
|
|
3800
|
+
'X-Goog-Upload-Command': uploadCommand,
|
|
3801
|
+
'X-Goog-Upload-Offset': String(offset),
|
|
3802
|
+
'Content-Length': String(chunkSize),
|
|
3803
|
+
},
|
|
3355
3804
|
},
|
|
3356
|
-
}
|
|
3357
|
-
|
|
3805
|
+
});
|
|
3806
|
+
if ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
|
|
3807
|
+
break;
|
|
3808
|
+
}
|
|
3809
|
+
retryCount++;
|
|
3810
|
+
await sleep(currentDelayMs);
|
|
3811
|
+
currentDelayMs = currentDelayMs * DELAY_MULTIPLIER;
|
|
3812
|
+
}
|
|
3358
3813
|
offset += chunkSize;
|
|
3359
3814
|
// The `x-goog-upload-status` header field can be `active`, `final` and
|
|
3360
3815
|
//`cancelled` in resposne.
|
|
3361
|
-
if (((
|
|
3816
|
+
if (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'active') {
|
|
3362
3817
|
break;
|
|
3363
3818
|
}
|
|
3364
3819
|
// TODO(b/401391430) Investigate why the upload status is not finalized
|
|
@@ -3368,7 +3823,7 @@ async function uploadBlob(file, uploadUrl, apiClient) {
|
|
|
3368
3823
|
}
|
|
3369
3824
|
}
|
|
3370
3825
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
3371
|
-
if (((
|
|
3826
|
+
if (((_c = response === null || response === void 0 ? void 0 : response.headers) === null || _c === void 0 ? void 0 : _c[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
|
|
3372
3827
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
3373
3828
|
}
|
|
3374
3829
|
return responseJson['file'];
|
|
@@ -3377,6 +3832,9 @@ async function getBlobStat(file) {
|
|
|
3377
3832
|
const fileStat = { size: file.size, type: file.type };
|
|
3378
3833
|
return fileStat;
|
|
3379
3834
|
}
|
|
3835
|
+
function sleep(ms) {
|
|
3836
|
+
return new Promise((resolvePromise) => setTimeout(resolvePromise, ms));
|
|
3837
|
+
}
|
|
3380
3838
|
|
|
3381
3839
|
/**
|
|
3382
3840
|
* @license
|
|
@@ -3725,11 +4183,30 @@ class Files extends BaseModule {
|
|
|
3725
4183
|
return file;
|
|
3726
4184
|
});
|
|
3727
4185
|
}
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
4186
|
+
/**
|
|
4187
|
+
* Downloads a remotely stored file asynchronously to a location specified in
|
|
4188
|
+
* the `params` object. This method only works on Node environment, to
|
|
4189
|
+
* download files in the browser, use a browser compliant method like an <a>
|
|
4190
|
+
* tag.
|
|
4191
|
+
*
|
|
4192
|
+
* @param params - The parameters for the download request.
|
|
4193
|
+
*
|
|
4194
|
+
* @example
|
|
4195
|
+
* The following code downloads an example file named "files/mehozpxf877d" as
|
|
4196
|
+
* "file.txt".
|
|
4197
|
+
*
|
|
4198
|
+
* ```ts
|
|
4199
|
+
* await ai.files.download({file: file.name, downloadPath: 'file.txt'});
|
|
4200
|
+
* ```
|
|
4201
|
+
*/
|
|
4202
|
+
async download(params) {
|
|
4203
|
+
await this.apiClient.downloadFile(params);
|
|
4204
|
+
}
|
|
4205
|
+
async listInternal(params) {
|
|
4206
|
+
var _a, _b;
|
|
4207
|
+
let response;
|
|
4208
|
+
let path = '';
|
|
4209
|
+
let queryParams = {};
|
|
3733
4210
|
if (this.apiClient.isVertexAI()) {
|
|
3734
4211
|
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
3735
4212
|
}
|
|
@@ -3898,6 +4375,37 @@ class Files extends BaseModule {
|
|
|
3898
4375
|
* Copyright 2025 Google LLC
|
|
3899
4376
|
* SPDX-License-Identifier: Apache-2.0
|
|
3900
4377
|
*/
|
|
4378
|
+
function blobToMldev$1(apiClient, fromObject) {
|
|
4379
|
+
const toObject = {};
|
|
4380
|
+
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
4381
|
+
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
4382
|
+
}
|
|
4383
|
+
const fromData = getValueByPath(fromObject, ['data']);
|
|
4384
|
+
if (fromData != null) {
|
|
4385
|
+
setValueByPath(toObject, ['data'], fromData);
|
|
4386
|
+
}
|
|
4387
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
4388
|
+
if (fromMimeType != null) {
|
|
4389
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
4390
|
+
}
|
|
4391
|
+
return toObject;
|
|
4392
|
+
}
|
|
4393
|
+
function blobToVertex$1(apiClient, fromObject) {
|
|
4394
|
+
const toObject = {};
|
|
4395
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
4396
|
+
if (fromDisplayName != null) {
|
|
4397
|
+
setValueByPath(toObject, ['displayName'], fromDisplayName);
|
|
4398
|
+
}
|
|
4399
|
+
const fromData = getValueByPath(fromObject, ['data']);
|
|
4400
|
+
if (fromData != null) {
|
|
4401
|
+
setValueByPath(toObject, ['data'], fromData);
|
|
4402
|
+
}
|
|
4403
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
4404
|
+
if (fromMimeType != null) {
|
|
4405
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
4406
|
+
}
|
|
4407
|
+
return toObject;
|
|
4408
|
+
}
|
|
3901
4409
|
function partToMldev$1(apiClient, fromObject) {
|
|
3902
4410
|
const toObject = {};
|
|
3903
4411
|
if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
|
|
@@ -3907,6 +4415,10 @@ function partToMldev$1(apiClient, fromObject) {
|
|
|
3907
4415
|
if (fromThought != null) {
|
|
3908
4416
|
setValueByPath(toObject, ['thought'], fromThought);
|
|
3909
4417
|
}
|
|
4418
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
4419
|
+
if (fromInlineData != null) {
|
|
4420
|
+
setValueByPath(toObject, ['inlineData'], blobToMldev$1(apiClient, fromInlineData));
|
|
4421
|
+
}
|
|
3910
4422
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
3911
4423
|
'codeExecutionResult',
|
|
3912
4424
|
]);
|
|
@@ -3933,10 +4445,6 @@ function partToMldev$1(apiClient, fromObject) {
|
|
|
3933
4445
|
if (fromFunctionResponse != null) {
|
|
3934
4446
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
3935
4447
|
}
|
|
3936
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
3937
|
-
if (fromInlineData != null) {
|
|
3938
|
-
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
3939
|
-
}
|
|
3940
4448
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
3941
4449
|
if (fromText != null) {
|
|
3942
4450
|
setValueByPath(toObject, ['text'], fromText);
|
|
@@ -3955,6 +4463,10 @@ function partToVertex$1(apiClient, fromObject) {
|
|
|
3955
4463
|
if (fromThought != null) {
|
|
3956
4464
|
setValueByPath(toObject, ['thought'], fromThought);
|
|
3957
4465
|
}
|
|
4466
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
4467
|
+
if (fromInlineData != null) {
|
|
4468
|
+
setValueByPath(toObject, ['inlineData'], blobToVertex$1(apiClient, fromInlineData));
|
|
4469
|
+
}
|
|
3958
4470
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
3959
4471
|
'codeExecutionResult',
|
|
3960
4472
|
]);
|
|
@@ -3981,10 +4493,6 @@ function partToVertex$1(apiClient, fromObject) {
|
|
|
3981
4493
|
if (fromFunctionResponse != null) {
|
|
3982
4494
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
3983
4495
|
}
|
|
3984
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
3985
|
-
if (fromInlineData != null) {
|
|
3986
|
-
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
3987
|
-
}
|
|
3988
4496
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
3989
4497
|
if (fromText != null) {
|
|
3990
4498
|
setValueByPath(toObject, ['text'], fromText);
|
|
@@ -4083,6 +4591,58 @@ function googleSearchRetrievalToVertex$1(apiClient, fromObject) {
|
|
|
4083
4591
|
}
|
|
4084
4592
|
return toObject;
|
|
4085
4593
|
}
|
|
4594
|
+
function enterpriseWebSearchToVertex$1() {
|
|
4595
|
+
const toObject = {};
|
|
4596
|
+
return toObject;
|
|
4597
|
+
}
|
|
4598
|
+
function apiKeyConfigToVertex$1(apiClient, fromObject) {
|
|
4599
|
+
const toObject = {};
|
|
4600
|
+
const fromApiKeyString = getValueByPath(fromObject, ['apiKeyString']);
|
|
4601
|
+
if (fromApiKeyString != null) {
|
|
4602
|
+
setValueByPath(toObject, ['apiKeyString'], fromApiKeyString);
|
|
4603
|
+
}
|
|
4604
|
+
return toObject;
|
|
4605
|
+
}
|
|
4606
|
+
function authConfigToVertex$1(apiClient, fromObject) {
|
|
4607
|
+
const toObject = {};
|
|
4608
|
+
const fromApiKeyConfig = getValueByPath(fromObject, ['apiKeyConfig']);
|
|
4609
|
+
if (fromApiKeyConfig != null) {
|
|
4610
|
+
setValueByPath(toObject, ['apiKeyConfig'], apiKeyConfigToVertex$1(apiClient, fromApiKeyConfig));
|
|
4611
|
+
}
|
|
4612
|
+
const fromAuthType = getValueByPath(fromObject, ['authType']);
|
|
4613
|
+
if (fromAuthType != null) {
|
|
4614
|
+
setValueByPath(toObject, ['authType'], fromAuthType);
|
|
4615
|
+
}
|
|
4616
|
+
const fromGoogleServiceAccountConfig = getValueByPath(fromObject, [
|
|
4617
|
+
'googleServiceAccountConfig',
|
|
4618
|
+
]);
|
|
4619
|
+
if (fromGoogleServiceAccountConfig != null) {
|
|
4620
|
+
setValueByPath(toObject, ['googleServiceAccountConfig'], fromGoogleServiceAccountConfig);
|
|
4621
|
+
}
|
|
4622
|
+
const fromHttpBasicAuthConfig = getValueByPath(fromObject, [
|
|
4623
|
+
'httpBasicAuthConfig',
|
|
4624
|
+
]);
|
|
4625
|
+
if (fromHttpBasicAuthConfig != null) {
|
|
4626
|
+
setValueByPath(toObject, ['httpBasicAuthConfig'], fromHttpBasicAuthConfig);
|
|
4627
|
+
}
|
|
4628
|
+
const fromOauthConfig = getValueByPath(fromObject, ['oauthConfig']);
|
|
4629
|
+
if (fromOauthConfig != null) {
|
|
4630
|
+
setValueByPath(toObject, ['oauthConfig'], fromOauthConfig);
|
|
4631
|
+
}
|
|
4632
|
+
const fromOidcConfig = getValueByPath(fromObject, ['oidcConfig']);
|
|
4633
|
+
if (fromOidcConfig != null) {
|
|
4634
|
+
setValueByPath(toObject, ['oidcConfig'], fromOidcConfig);
|
|
4635
|
+
}
|
|
4636
|
+
return toObject;
|
|
4637
|
+
}
|
|
4638
|
+
function googleMapsToVertex$1(apiClient, fromObject) {
|
|
4639
|
+
const toObject = {};
|
|
4640
|
+
const fromAuthConfig = getValueByPath(fromObject, ['authConfig']);
|
|
4641
|
+
if (fromAuthConfig != null) {
|
|
4642
|
+
setValueByPath(toObject, ['authConfig'], authConfigToVertex$1(apiClient, fromAuthConfig));
|
|
4643
|
+
}
|
|
4644
|
+
return toObject;
|
|
4645
|
+
}
|
|
4086
4646
|
function toolToMldev$1(apiClient, fromObject) {
|
|
4087
4647
|
const toObject = {};
|
|
4088
4648
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
@@ -4098,6 +4658,12 @@ function toolToMldev$1(apiClient, fromObject) {
|
|
|
4098
4658
|
if (fromGoogleSearchRetrieval != null) {
|
|
4099
4659
|
setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev$1(apiClient, fromGoogleSearchRetrieval));
|
|
4100
4660
|
}
|
|
4661
|
+
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
4662
|
+
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
4663
|
+
}
|
|
4664
|
+
if (getValueByPath(fromObject, ['googleMaps']) !== undefined) {
|
|
4665
|
+
throw new Error('googleMaps parameter is not supported in Gemini API.');
|
|
4666
|
+
}
|
|
4101
4667
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4102
4668
|
'codeExecution',
|
|
4103
4669
|
]);
|
|
@@ -4128,6 +4694,16 @@ function toolToVertex$1(apiClient, fromObject) {
|
|
|
4128
4694
|
if (fromGoogleSearchRetrieval != null) {
|
|
4129
4695
|
setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToVertex$1(apiClient, fromGoogleSearchRetrieval));
|
|
4130
4696
|
}
|
|
4697
|
+
const fromEnterpriseWebSearch = getValueByPath(fromObject, [
|
|
4698
|
+
'enterpriseWebSearch',
|
|
4699
|
+
]);
|
|
4700
|
+
if (fromEnterpriseWebSearch != null) {
|
|
4701
|
+
setValueByPath(toObject, ['enterpriseWebSearch'], enterpriseWebSearchToVertex$1());
|
|
4702
|
+
}
|
|
4703
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
4704
|
+
if (fromGoogleMaps != null) {
|
|
4705
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$1(apiClient, fromGoogleMaps));
|
|
4706
|
+
}
|
|
4131
4707
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4132
4708
|
'codeExecution',
|
|
4133
4709
|
]);
|
|
@@ -4393,8 +4969,11 @@ function liveConnectConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
4393
4969
|
if (parentObject !== undefined && fromSessionResumption != null) {
|
|
4394
4970
|
setValueByPath(parentObject, ['setup', 'sessionResumption'], sessionResumptionConfigToMldev(apiClient, fromSessionResumption));
|
|
4395
4971
|
}
|
|
4396
|
-
|
|
4397
|
-
|
|
4972
|
+
const fromInputAudioTranscription = getValueByPath(fromObject, [
|
|
4973
|
+
'inputAudioTranscription',
|
|
4974
|
+
]);
|
|
4975
|
+
if (parentObject !== undefined && fromInputAudioTranscription != null) {
|
|
4976
|
+
setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev());
|
|
4398
4977
|
}
|
|
4399
4978
|
const fromOutputAudioTranscription = getValueByPath(fromObject, [
|
|
4400
4979
|
'outputAudioTranscription',
|
|
@@ -4627,12 +5206,44 @@ function liveServerSetupCompleteFromVertex() {
|
|
|
4627
5206
|
const toObject = {};
|
|
4628
5207
|
return toObject;
|
|
4629
5208
|
}
|
|
5209
|
+
function blobFromMldev$1(apiClient, fromObject) {
|
|
5210
|
+
const toObject = {};
|
|
5211
|
+
const fromData = getValueByPath(fromObject, ['data']);
|
|
5212
|
+
if (fromData != null) {
|
|
5213
|
+
setValueByPath(toObject, ['data'], fromData);
|
|
5214
|
+
}
|
|
5215
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
5216
|
+
if (fromMimeType != null) {
|
|
5217
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
5218
|
+
}
|
|
5219
|
+
return toObject;
|
|
5220
|
+
}
|
|
5221
|
+
function blobFromVertex$1(apiClient, fromObject) {
|
|
5222
|
+
const toObject = {};
|
|
5223
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5224
|
+
if (fromDisplayName != null) {
|
|
5225
|
+
setValueByPath(toObject, ['displayName'], fromDisplayName);
|
|
5226
|
+
}
|
|
5227
|
+
const fromData = getValueByPath(fromObject, ['data']);
|
|
5228
|
+
if (fromData != null) {
|
|
5229
|
+
setValueByPath(toObject, ['data'], fromData);
|
|
5230
|
+
}
|
|
5231
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
5232
|
+
if (fromMimeType != null) {
|
|
5233
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
5234
|
+
}
|
|
5235
|
+
return toObject;
|
|
5236
|
+
}
|
|
4630
5237
|
function partFromMldev$1(apiClient, fromObject) {
|
|
4631
5238
|
const toObject = {};
|
|
4632
5239
|
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
4633
5240
|
if (fromThought != null) {
|
|
4634
5241
|
setValueByPath(toObject, ['thought'], fromThought);
|
|
4635
5242
|
}
|
|
5243
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
5244
|
+
if (fromInlineData != null) {
|
|
5245
|
+
setValueByPath(toObject, ['inlineData'], blobFromMldev$1(apiClient, fromInlineData));
|
|
5246
|
+
}
|
|
4636
5247
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
4637
5248
|
'codeExecutionResult',
|
|
4638
5249
|
]);
|
|
@@ -4659,10 +5270,6 @@ function partFromMldev$1(apiClient, fromObject) {
|
|
|
4659
5270
|
if (fromFunctionResponse != null) {
|
|
4660
5271
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
4661
5272
|
}
|
|
4662
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
4663
|
-
if (fromInlineData != null) {
|
|
4664
|
-
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
4665
|
-
}
|
|
4666
5273
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
4667
5274
|
if (fromText != null) {
|
|
4668
5275
|
setValueByPath(toObject, ['text'], fromText);
|
|
@@ -4681,6 +5288,10 @@ function partFromVertex$1(apiClient, fromObject) {
|
|
|
4681
5288
|
if (fromThought != null) {
|
|
4682
5289
|
setValueByPath(toObject, ['thought'], fromThought);
|
|
4683
5290
|
}
|
|
5291
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
5292
|
+
if (fromInlineData != null) {
|
|
5293
|
+
setValueByPath(toObject, ['inlineData'], blobFromVertex$1(apiClient, fromInlineData));
|
|
5294
|
+
}
|
|
4684
5295
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
4685
5296
|
'codeExecutionResult',
|
|
4686
5297
|
]);
|
|
@@ -4707,10 +5318,6 @@ function partFromVertex$1(apiClient, fromObject) {
|
|
|
4707
5318
|
if (fromFunctionResponse != null) {
|
|
4708
5319
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
4709
5320
|
}
|
|
4710
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
4711
|
-
if (fromInlineData != null) {
|
|
4712
|
-
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
4713
|
-
}
|
|
4714
5321
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
4715
5322
|
if (fromText != null) {
|
|
4716
5323
|
setValueByPath(toObject, ['text'], fromText);
|
|
@@ -5279,6 +5886,21 @@ function liveServerMessageFromVertex(apiClient, fromObject) {
|
|
|
5279
5886
|
* Copyright 2025 Google LLC
|
|
5280
5887
|
* SPDX-License-Identifier: Apache-2.0
|
|
5281
5888
|
*/
|
|
5889
|
+
function blobToMldev(apiClient, fromObject) {
|
|
5890
|
+
const toObject = {};
|
|
5891
|
+
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
5892
|
+
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
5893
|
+
}
|
|
5894
|
+
const fromData = getValueByPath(fromObject, ['data']);
|
|
5895
|
+
if (fromData != null) {
|
|
5896
|
+
setValueByPath(toObject, ['data'], fromData);
|
|
5897
|
+
}
|
|
5898
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
5899
|
+
if (fromMimeType != null) {
|
|
5900
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
5901
|
+
}
|
|
5902
|
+
return toObject;
|
|
5903
|
+
}
|
|
5282
5904
|
function partToMldev(apiClient, fromObject) {
|
|
5283
5905
|
const toObject = {};
|
|
5284
5906
|
if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
|
|
@@ -5288,6 +5910,10 @@ function partToMldev(apiClient, fromObject) {
|
|
|
5288
5910
|
if (fromThought != null) {
|
|
5289
5911
|
setValueByPath(toObject, ['thought'], fromThought);
|
|
5290
5912
|
}
|
|
5913
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
5914
|
+
if (fromInlineData != null) {
|
|
5915
|
+
setValueByPath(toObject, ['inlineData'], blobToMldev(apiClient, fromInlineData));
|
|
5916
|
+
}
|
|
5291
5917
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
5292
5918
|
'codeExecutionResult',
|
|
5293
5919
|
]);
|
|
@@ -5314,10 +5940,6 @@ function partToMldev(apiClient, fromObject) {
|
|
|
5314
5940
|
if (fromFunctionResponse != null) {
|
|
5315
5941
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
5316
5942
|
}
|
|
5317
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
5318
|
-
if (fromInlineData != null) {
|
|
5319
|
-
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
5320
|
-
}
|
|
5321
5943
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
5322
5944
|
if (fromText != null) {
|
|
5323
5945
|
setValueByPath(toObject, ['text'], fromText);
|
|
@@ -5400,6 +6022,12 @@ function toolToMldev(apiClient, fromObject) {
|
|
|
5400
6022
|
if (fromGoogleSearchRetrieval != null) {
|
|
5401
6023
|
setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev(apiClient, fromGoogleSearchRetrieval));
|
|
5402
6024
|
}
|
|
6025
|
+
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
6026
|
+
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
6027
|
+
}
|
|
6028
|
+
if (getValueByPath(fromObject, ['googleMaps']) !== undefined) {
|
|
6029
|
+
throw new Error('googleMaps parameter is not supported in Gemini API.');
|
|
6030
|
+
}
|
|
5403
6031
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5404
6032
|
'codeExecution',
|
|
5405
6033
|
]);
|
|
@@ -5436,6 +6064,9 @@ function toolConfigToMldev(apiClient, fromObject) {
|
|
|
5436
6064
|
if (fromFunctionCallingConfig != null) {
|
|
5437
6065
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(apiClient, fromFunctionCallingConfig));
|
|
5438
6066
|
}
|
|
6067
|
+
if (getValueByPath(fromObject, ['retrievalConfig']) !== undefined) {
|
|
6068
|
+
throw new Error('retrievalConfig parameter is not supported in Gemini API.');
|
|
6069
|
+
}
|
|
5439
6070
|
return toObject;
|
|
5440
6071
|
}
|
|
5441
6072
|
function prebuiltVoiceConfigToMldev(apiClient, fromObject) {
|
|
@@ -5797,6 +6428,34 @@ function getModelParametersToMldev(apiClient, fromObject) {
|
|
|
5797
6428
|
}
|
|
5798
6429
|
return toObject;
|
|
5799
6430
|
}
|
|
6431
|
+
function listModelsConfigToMldev(apiClient, fromObject, parentObject) {
|
|
6432
|
+
const toObject = {};
|
|
6433
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
6434
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
6435
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
6436
|
+
}
|
|
6437
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
6438
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
6439
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
6440
|
+
}
|
|
6441
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
6442
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
6443
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
6444
|
+
}
|
|
6445
|
+
const fromQueryBase = getValueByPath(fromObject, ['queryBase']);
|
|
6446
|
+
if (parentObject !== undefined && fromQueryBase != null) {
|
|
6447
|
+
setValueByPath(parentObject, ['_url', 'models_url'], tModelsUrl(apiClient, fromQueryBase));
|
|
6448
|
+
}
|
|
6449
|
+
return toObject;
|
|
6450
|
+
}
|
|
6451
|
+
function listModelsParametersToMldev(apiClient, fromObject) {
|
|
6452
|
+
const toObject = {};
|
|
6453
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6454
|
+
if (fromConfig != null) {
|
|
6455
|
+
setValueByPath(toObject, ['config'], listModelsConfigToMldev(apiClient, fromConfig, toObject));
|
|
6456
|
+
}
|
|
6457
|
+
return toObject;
|
|
6458
|
+
}
|
|
5800
6459
|
function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
|
|
5801
6460
|
const toObject = {};
|
|
5802
6461
|
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
@@ -5807,6 +6466,12 @@ function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5807
6466
|
if (parentObject !== undefined && fromDescription != null) {
|
|
5808
6467
|
setValueByPath(parentObject, ['description'], fromDescription);
|
|
5809
6468
|
}
|
|
6469
|
+
const fromDefaultCheckpointId = getValueByPath(fromObject, [
|
|
6470
|
+
'defaultCheckpointId',
|
|
6471
|
+
]);
|
|
6472
|
+
if (parentObject !== undefined && fromDefaultCheckpointId != null) {
|
|
6473
|
+
setValueByPath(parentObject, ['defaultCheckpointId'], fromDefaultCheckpointId);
|
|
6474
|
+
}
|
|
5810
6475
|
return toObject;
|
|
5811
6476
|
}
|
|
5812
6477
|
function updateModelParametersToMldev(apiClient, fromObject) {
|
|
@@ -5953,6 +6618,22 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
5953
6618
|
}
|
|
5954
6619
|
return toObject;
|
|
5955
6620
|
}
|
|
6621
|
+
function blobToVertex(apiClient, fromObject) {
|
|
6622
|
+
const toObject = {};
|
|
6623
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
6624
|
+
if (fromDisplayName != null) {
|
|
6625
|
+
setValueByPath(toObject, ['displayName'], fromDisplayName);
|
|
6626
|
+
}
|
|
6627
|
+
const fromData = getValueByPath(fromObject, ['data']);
|
|
6628
|
+
if (fromData != null) {
|
|
6629
|
+
setValueByPath(toObject, ['data'], fromData);
|
|
6630
|
+
}
|
|
6631
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
6632
|
+
if (fromMimeType != null) {
|
|
6633
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
6634
|
+
}
|
|
6635
|
+
return toObject;
|
|
6636
|
+
}
|
|
5956
6637
|
function partToVertex(apiClient, fromObject) {
|
|
5957
6638
|
const toObject = {};
|
|
5958
6639
|
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
@@ -5965,6 +6646,10 @@ function partToVertex(apiClient, fromObject) {
|
|
|
5965
6646
|
if (fromThought != null) {
|
|
5966
6647
|
setValueByPath(toObject, ['thought'], fromThought);
|
|
5967
6648
|
}
|
|
6649
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
6650
|
+
if (fromInlineData != null) {
|
|
6651
|
+
setValueByPath(toObject, ['inlineData'], blobToVertex(apiClient, fromInlineData));
|
|
6652
|
+
}
|
|
5968
6653
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
5969
6654
|
'codeExecutionResult',
|
|
5970
6655
|
]);
|
|
@@ -5991,10 +6676,6 @@ function partToVertex(apiClient, fromObject) {
|
|
|
5991
6676
|
if (fromFunctionResponse != null) {
|
|
5992
6677
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
5993
6678
|
}
|
|
5994
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
5995
|
-
if (fromInlineData != null) {
|
|
5996
|
-
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
5997
|
-
}
|
|
5998
6679
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
5999
6680
|
if (fromText != null) {
|
|
6000
6681
|
setValueByPath(toObject, ['text'], fromText);
|
|
@@ -6073,6 +6754,58 @@ function googleSearchRetrievalToVertex(apiClient, fromObject) {
|
|
|
6073
6754
|
}
|
|
6074
6755
|
return toObject;
|
|
6075
6756
|
}
|
|
6757
|
+
function enterpriseWebSearchToVertex() {
|
|
6758
|
+
const toObject = {};
|
|
6759
|
+
return toObject;
|
|
6760
|
+
}
|
|
6761
|
+
function apiKeyConfigToVertex(apiClient, fromObject) {
|
|
6762
|
+
const toObject = {};
|
|
6763
|
+
const fromApiKeyString = getValueByPath(fromObject, ['apiKeyString']);
|
|
6764
|
+
if (fromApiKeyString != null) {
|
|
6765
|
+
setValueByPath(toObject, ['apiKeyString'], fromApiKeyString);
|
|
6766
|
+
}
|
|
6767
|
+
return toObject;
|
|
6768
|
+
}
|
|
6769
|
+
function authConfigToVertex(apiClient, fromObject) {
|
|
6770
|
+
const toObject = {};
|
|
6771
|
+
const fromApiKeyConfig = getValueByPath(fromObject, ['apiKeyConfig']);
|
|
6772
|
+
if (fromApiKeyConfig != null) {
|
|
6773
|
+
setValueByPath(toObject, ['apiKeyConfig'], apiKeyConfigToVertex(apiClient, fromApiKeyConfig));
|
|
6774
|
+
}
|
|
6775
|
+
const fromAuthType = getValueByPath(fromObject, ['authType']);
|
|
6776
|
+
if (fromAuthType != null) {
|
|
6777
|
+
setValueByPath(toObject, ['authType'], fromAuthType);
|
|
6778
|
+
}
|
|
6779
|
+
const fromGoogleServiceAccountConfig = getValueByPath(fromObject, [
|
|
6780
|
+
'googleServiceAccountConfig',
|
|
6781
|
+
]);
|
|
6782
|
+
if (fromGoogleServiceAccountConfig != null) {
|
|
6783
|
+
setValueByPath(toObject, ['googleServiceAccountConfig'], fromGoogleServiceAccountConfig);
|
|
6784
|
+
}
|
|
6785
|
+
const fromHttpBasicAuthConfig = getValueByPath(fromObject, [
|
|
6786
|
+
'httpBasicAuthConfig',
|
|
6787
|
+
]);
|
|
6788
|
+
if (fromHttpBasicAuthConfig != null) {
|
|
6789
|
+
setValueByPath(toObject, ['httpBasicAuthConfig'], fromHttpBasicAuthConfig);
|
|
6790
|
+
}
|
|
6791
|
+
const fromOauthConfig = getValueByPath(fromObject, ['oauthConfig']);
|
|
6792
|
+
if (fromOauthConfig != null) {
|
|
6793
|
+
setValueByPath(toObject, ['oauthConfig'], fromOauthConfig);
|
|
6794
|
+
}
|
|
6795
|
+
const fromOidcConfig = getValueByPath(fromObject, ['oidcConfig']);
|
|
6796
|
+
if (fromOidcConfig != null) {
|
|
6797
|
+
setValueByPath(toObject, ['oidcConfig'], fromOidcConfig);
|
|
6798
|
+
}
|
|
6799
|
+
return toObject;
|
|
6800
|
+
}
|
|
6801
|
+
function googleMapsToVertex(apiClient, fromObject) {
|
|
6802
|
+
const toObject = {};
|
|
6803
|
+
const fromAuthConfig = getValueByPath(fromObject, ['authConfig']);
|
|
6804
|
+
if (fromAuthConfig != null) {
|
|
6805
|
+
setValueByPath(toObject, ['authConfig'], authConfigToVertex(apiClient, fromAuthConfig));
|
|
6806
|
+
}
|
|
6807
|
+
return toObject;
|
|
6808
|
+
}
|
|
6076
6809
|
function toolToVertex(apiClient, fromObject) {
|
|
6077
6810
|
const toObject = {};
|
|
6078
6811
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
@@ -6089,6 +6822,16 @@ function toolToVertex(apiClient, fromObject) {
|
|
|
6089
6822
|
if (fromGoogleSearchRetrieval != null) {
|
|
6090
6823
|
setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToVertex(apiClient, fromGoogleSearchRetrieval));
|
|
6091
6824
|
}
|
|
6825
|
+
const fromEnterpriseWebSearch = getValueByPath(fromObject, [
|
|
6826
|
+
'enterpriseWebSearch',
|
|
6827
|
+
]);
|
|
6828
|
+
if (fromEnterpriseWebSearch != null) {
|
|
6829
|
+
setValueByPath(toObject, ['enterpriseWebSearch'], enterpriseWebSearchToVertex());
|
|
6830
|
+
}
|
|
6831
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
6832
|
+
if (fromGoogleMaps != null) {
|
|
6833
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex(apiClient, fromGoogleMaps));
|
|
6834
|
+
}
|
|
6092
6835
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
6093
6836
|
'codeExecution',
|
|
6094
6837
|
]);
|
|
@@ -6117,6 +6860,26 @@ function functionCallingConfigToVertex(apiClient, fromObject) {
|
|
|
6117
6860
|
}
|
|
6118
6861
|
return toObject;
|
|
6119
6862
|
}
|
|
6863
|
+
function latLngToVertex(apiClient, fromObject) {
|
|
6864
|
+
const toObject = {};
|
|
6865
|
+
const fromLatitude = getValueByPath(fromObject, ['latitude']);
|
|
6866
|
+
if (fromLatitude != null) {
|
|
6867
|
+
setValueByPath(toObject, ['latitude'], fromLatitude);
|
|
6868
|
+
}
|
|
6869
|
+
const fromLongitude = getValueByPath(fromObject, ['longitude']);
|
|
6870
|
+
if (fromLongitude != null) {
|
|
6871
|
+
setValueByPath(toObject, ['longitude'], fromLongitude);
|
|
6872
|
+
}
|
|
6873
|
+
return toObject;
|
|
6874
|
+
}
|
|
6875
|
+
function retrievalConfigToVertex(apiClient, fromObject) {
|
|
6876
|
+
const toObject = {};
|
|
6877
|
+
const fromLatLng = getValueByPath(fromObject, ['latLng']);
|
|
6878
|
+
if (fromLatLng != null) {
|
|
6879
|
+
setValueByPath(toObject, ['latLng'], latLngToVertex(apiClient, fromLatLng));
|
|
6880
|
+
}
|
|
6881
|
+
return toObject;
|
|
6882
|
+
}
|
|
6120
6883
|
function toolConfigToVertex(apiClient, fromObject) {
|
|
6121
6884
|
const toObject = {};
|
|
6122
6885
|
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
@@ -6125,6 +6888,12 @@ function toolConfigToVertex(apiClient, fromObject) {
|
|
|
6125
6888
|
if (fromFunctionCallingConfig != null) {
|
|
6126
6889
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToVertex(apiClient, fromFunctionCallingConfig));
|
|
6127
6890
|
}
|
|
6891
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
6892
|
+
'retrievalConfig',
|
|
6893
|
+
]);
|
|
6894
|
+
if (fromRetrievalConfig != null) {
|
|
6895
|
+
setValueByPath(toObject, ['retrievalConfig'], retrievalConfigToVertex(apiClient, fromRetrievalConfig));
|
|
6896
|
+
}
|
|
6128
6897
|
return toObject;
|
|
6129
6898
|
}
|
|
6130
6899
|
function prebuiltVoiceConfigToVertex(apiClient, fromObject) {
|
|
@@ -6491,61 +7260,375 @@ function generateImagesParametersToVertex(apiClient, fromObject) {
|
|
|
6491
7260
|
}
|
|
6492
7261
|
return toObject;
|
|
6493
7262
|
}
|
|
6494
|
-
function
|
|
7263
|
+
function imageToVertex(apiClient, fromObject) {
|
|
6495
7264
|
const toObject = {};
|
|
6496
|
-
const
|
|
6497
|
-
if (
|
|
6498
|
-
setValueByPath(toObject, ['
|
|
7265
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
7266
|
+
if (fromGcsUri != null) {
|
|
7267
|
+
setValueByPath(toObject, ['gcsUri'], fromGcsUri);
|
|
6499
7268
|
}
|
|
6500
|
-
const
|
|
6501
|
-
if (
|
|
6502
|
-
setValueByPath(toObject, ['
|
|
7269
|
+
const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
|
|
7270
|
+
if (fromImageBytes != null) {
|
|
7271
|
+
setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
|
|
7272
|
+
}
|
|
7273
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
7274
|
+
if (fromMimeType != null) {
|
|
7275
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
6503
7276
|
}
|
|
6504
7277
|
return toObject;
|
|
6505
7278
|
}
|
|
6506
|
-
function
|
|
7279
|
+
function maskReferenceConfigToVertex(apiClient, fromObject) {
|
|
6507
7280
|
const toObject = {};
|
|
6508
|
-
const
|
|
6509
|
-
if (
|
|
6510
|
-
setValueByPath(
|
|
7281
|
+
const fromMaskMode = getValueByPath(fromObject, ['maskMode']);
|
|
7282
|
+
if (fromMaskMode != null) {
|
|
7283
|
+
setValueByPath(toObject, ['maskMode'], fromMaskMode);
|
|
6511
7284
|
}
|
|
6512
|
-
const
|
|
6513
|
-
|
|
6514
|
-
|
|
7285
|
+
const fromSegmentationClasses = getValueByPath(fromObject, [
|
|
7286
|
+
'segmentationClasses',
|
|
7287
|
+
]);
|
|
7288
|
+
if (fromSegmentationClasses != null) {
|
|
7289
|
+
setValueByPath(toObject, ['maskClasses'], fromSegmentationClasses);
|
|
7290
|
+
}
|
|
7291
|
+
const fromMaskDilation = getValueByPath(fromObject, ['maskDilation']);
|
|
7292
|
+
if (fromMaskDilation != null) {
|
|
7293
|
+
setValueByPath(toObject, ['dilation'], fromMaskDilation);
|
|
6515
7294
|
}
|
|
6516
7295
|
return toObject;
|
|
6517
7296
|
}
|
|
6518
|
-
function
|
|
7297
|
+
function controlReferenceConfigToVertex(apiClient, fromObject) {
|
|
6519
7298
|
const toObject = {};
|
|
6520
|
-
const
|
|
6521
|
-
if (
|
|
6522
|
-
setValueByPath(toObject, ['
|
|
7299
|
+
const fromControlType = getValueByPath(fromObject, ['controlType']);
|
|
7300
|
+
if (fromControlType != null) {
|
|
7301
|
+
setValueByPath(toObject, ['controlType'], fromControlType);
|
|
6523
7302
|
}
|
|
6524
|
-
const
|
|
6525
|
-
|
|
6526
|
-
|
|
7303
|
+
const fromEnableControlImageComputation = getValueByPath(fromObject, [
|
|
7304
|
+
'enableControlImageComputation',
|
|
7305
|
+
]);
|
|
7306
|
+
if (fromEnableControlImageComputation != null) {
|
|
7307
|
+
setValueByPath(toObject, ['computeControl'], fromEnableControlImageComputation);
|
|
6527
7308
|
}
|
|
6528
7309
|
return toObject;
|
|
6529
7310
|
}
|
|
6530
|
-
function
|
|
7311
|
+
function styleReferenceConfigToVertex(apiClient, fromObject) {
|
|
6531
7312
|
const toObject = {};
|
|
6532
|
-
const
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
if (fromConfig != null) {
|
|
6538
|
-
setValueByPath(toObject, ['config'], fromConfig);
|
|
7313
|
+
const fromStyleDescription = getValueByPath(fromObject, [
|
|
7314
|
+
'styleDescription',
|
|
7315
|
+
]);
|
|
7316
|
+
if (fromStyleDescription != null) {
|
|
7317
|
+
setValueByPath(toObject, ['styleDescription'], fromStyleDescription);
|
|
6539
7318
|
}
|
|
6540
7319
|
return toObject;
|
|
6541
7320
|
}
|
|
6542
|
-
function
|
|
7321
|
+
function subjectReferenceConfigToVertex(apiClient, fromObject) {
|
|
6543
7322
|
const toObject = {};
|
|
6544
|
-
const
|
|
6545
|
-
|
|
7323
|
+
const fromSubjectType = getValueByPath(fromObject, ['subjectType']);
|
|
7324
|
+
if (fromSubjectType != null) {
|
|
7325
|
+
setValueByPath(toObject, ['subjectType'], fromSubjectType);
|
|
7326
|
+
}
|
|
7327
|
+
const fromSubjectDescription = getValueByPath(fromObject, [
|
|
7328
|
+
'subjectDescription',
|
|
6546
7329
|
]);
|
|
6547
|
-
if (
|
|
6548
|
-
setValueByPath(
|
|
7330
|
+
if (fromSubjectDescription != null) {
|
|
7331
|
+
setValueByPath(toObject, ['subjectDescription'], fromSubjectDescription);
|
|
7332
|
+
}
|
|
7333
|
+
return toObject;
|
|
7334
|
+
}
|
|
7335
|
+
function referenceImageAPIInternalToVertex(apiClient, fromObject) {
|
|
7336
|
+
const toObject = {};
|
|
7337
|
+
const fromReferenceImage = getValueByPath(fromObject, [
|
|
7338
|
+
'referenceImage',
|
|
7339
|
+
]);
|
|
7340
|
+
if (fromReferenceImage != null) {
|
|
7341
|
+
setValueByPath(toObject, ['referenceImage'], imageToVertex(apiClient, fromReferenceImage));
|
|
7342
|
+
}
|
|
7343
|
+
const fromReferenceId = getValueByPath(fromObject, ['referenceId']);
|
|
7344
|
+
if (fromReferenceId != null) {
|
|
7345
|
+
setValueByPath(toObject, ['referenceId'], fromReferenceId);
|
|
7346
|
+
}
|
|
7347
|
+
const fromReferenceType = getValueByPath(fromObject, [
|
|
7348
|
+
'referenceType',
|
|
7349
|
+
]);
|
|
7350
|
+
if (fromReferenceType != null) {
|
|
7351
|
+
setValueByPath(toObject, ['referenceType'], fromReferenceType);
|
|
7352
|
+
}
|
|
7353
|
+
const fromMaskImageConfig = getValueByPath(fromObject, [
|
|
7354
|
+
'maskImageConfig',
|
|
7355
|
+
]);
|
|
7356
|
+
if (fromMaskImageConfig != null) {
|
|
7357
|
+
setValueByPath(toObject, ['maskImageConfig'], maskReferenceConfigToVertex(apiClient, fromMaskImageConfig));
|
|
7358
|
+
}
|
|
7359
|
+
const fromControlImageConfig = getValueByPath(fromObject, [
|
|
7360
|
+
'controlImageConfig',
|
|
7361
|
+
]);
|
|
7362
|
+
if (fromControlImageConfig != null) {
|
|
7363
|
+
setValueByPath(toObject, ['controlImageConfig'], controlReferenceConfigToVertex(apiClient, fromControlImageConfig));
|
|
7364
|
+
}
|
|
7365
|
+
const fromStyleImageConfig = getValueByPath(fromObject, [
|
|
7366
|
+
'styleImageConfig',
|
|
7367
|
+
]);
|
|
7368
|
+
if (fromStyleImageConfig != null) {
|
|
7369
|
+
setValueByPath(toObject, ['styleImageConfig'], styleReferenceConfigToVertex(apiClient, fromStyleImageConfig));
|
|
7370
|
+
}
|
|
7371
|
+
const fromSubjectImageConfig = getValueByPath(fromObject, [
|
|
7372
|
+
'subjectImageConfig',
|
|
7373
|
+
]);
|
|
7374
|
+
if (fromSubjectImageConfig != null) {
|
|
7375
|
+
setValueByPath(toObject, ['subjectImageConfig'], subjectReferenceConfigToVertex(apiClient, fromSubjectImageConfig));
|
|
7376
|
+
}
|
|
7377
|
+
return toObject;
|
|
7378
|
+
}
|
|
7379
|
+
function editImageConfigToVertex(apiClient, fromObject, parentObject) {
|
|
7380
|
+
const toObject = {};
|
|
7381
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
7382
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
7383
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
7384
|
+
}
|
|
7385
|
+
const fromNegativePrompt = getValueByPath(fromObject, [
|
|
7386
|
+
'negativePrompt',
|
|
7387
|
+
]);
|
|
7388
|
+
if (parentObject !== undefined && fromNegativePrompt != null) {
|
|
7389
|
+
setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
|
|
7390
|
+
}
|
|
7391
|
+
const fromNumberOfImages = getValueByPath(fromObject, [
|
|
7392
|
+
'numberOfImages',
|
|
7393
|
+
]);
|
|
7394
|
+
if (parentObject !== undefined && fromNumberOfImages != null) {
|
|
7395
|
+
setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
|
|
7396
|
+
}
|
|
7397
|
+
const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
|
|
7398
|
+
if (parentObject !== undefined && fromAspectRatio != null) {
|
|
7399
|
+
setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
|
|
7400
|
+
}
|
|
7401
|
+
const fromGuidanceScale = getValueByPath(fromObject, [
|
|
7402
|
+
'guidanceScale',
|
|
7403
|
+
]);
|
|
7404
|
+
if (parentObject !== undefined && fromGuidanceScale != null) {
|
|
7405
|
+
setValueByPath(parentObject, ['parameters', 'guidanceScale'], fromGuidanceScale);
|
|
7406
|
+
}
|
|
7407
|
+
const fromSeed = getValueByPath(fromObject, ['seed']);
|
|
7408
|
+
if (parentObject !== undefined && fromSeed != null) {
|
|
7409
|
+
setValueByPath(parentObject, ['parameters', 'seed'], fromSeed);
|
|
7410
|
+
}
|
|
7411
|
+
const fromSafetyFilterLevel = getValueByPath(fromObject, [
|
|
7412
|
+
'safetyFilterLevel',
|
|
7413
|
+
]);
|
|
7414
|
+
if (parentObject !== undefined && fromSafetyFilterLevel != null) {
|
|
7415
|
+
setValueByPath(parentObject, ['parameters', 'safetySetting'], fromSafetyFilterLevel);
|
|
7416
|
+
}
|
|
7417
|
+
const fromPersonGeneration = getValueByPath(fromObject, [
|
|
7418
|
+
'personGeneration',
|
|
7419
|
+
]);
|
|
7420
|
+
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
7421
|
+
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
7422
|
+
}
|
|
7423
|
+
const fromIncludeSafetyAttributes = getValueByPath(fromObject, [
|
|
7424
|
+
'includeSafetyAttributes',
|
|
7425
|
+
]);
|
|
7426
|
+
if (parentObject !== undefined && fromIncludeSafetyAttributes != null) {
|
|
7427
|
+
setValueByPath(parentObject, ['parameters', 'includeSafetyAttributes'], fromIncludeSafetyAttributes);
|
|
7428
|
+
}
|
|
7429
|
+
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
7430
|
+
'includeRaiReason',
|
|
7431
|
+
]);
|
|
7432
|
+
if (parentObject !== undefined && fromIncludeRaiReason != null) {
|
|
7433
|
+
setValueByPath(parentObject, ['parameters', 'includeRaiReason'], fromIncludeRaiReason);
|
|
7434
|
+
}
|
|
7435
|
+
const fromLanguage = getValueByPath(fromObject, ['language']);
|
|
7436
|
+
if (parentObject !== undefined && fromLanguage != null) {
|
|
7437
|
+
setValueByPath(parentObject, ['parameters', 'language'], fromLanguage);
|
|
7438
|
+
}
|
|
7439
|
+
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
7440
|
+
'outputMimeType',
|
|
7441
|
+
]);
|
|
7442
|
+
if (parentObject !== undefined && fromOutputMimeType != null) {
|
|
7443
|
+
setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
|
|
7444
|
+
}
|
|
7445
|
+
const fromOutputCompressionQuality = getValueByPath(fromObject, [
|
|
7446
|
+
'outputCompressionQuality',
|
|
7447
|
+
]);
|
|
7448
|
+
if (parentObject !== undefined && fromOutputCompressionQuality != null) {
|
|
7449
|
+
setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
|
|
7450
|
+
}
|
|
7451
|
+
const fromEditMode = getValueByPath(fromObject, ['editMode']);
|
|
7452
|
+
if (parentObject !== undefined && fromEditMode != null) {
|
|
7453
|
+
setValueByPath(parentObject, ['parameters', 'editMode'], fromEditMode);
|
|
7454
|
+
}
|
|
7455
|
+
const fromBaseSteps = getValueByPath(fromObject, ['baseSteps']);
|
|
7456
|
+
if (parentObject !== undefined && fromBaseSteps != null) {
|
|
7457
|
+
setValueByPath(parentObject, ['parameters', 'editConfig', 'baseSteps'], fromBaseSteps);
|
|
7458
|
+
}
|
|
7459
|
+
return toObject;
|
|
7460
|
+
}
|
|
7461
|
+
function editImageParametersInternalToVertex(apiClient, fromObject) {
|
|
7462
|
+
const toObject = {};
|
|
7463
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
7464
|
+
if (fromModel != null) {
|
|
7465
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
7466
|
+
}
|
|
7467
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
7468
|
+
if (fromPrompt != null) {
|
|
7469
|
+
setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
7470
|
+
}
|
|
7471
|
+
const fromReferenceImages = getValueByPath(fromObject, [
|
|
7472
|
+
'referenceImages',
|
|
7473
|
+
]);
|
|
7474
|
+
if (fromReferenceImages != null) {
|
|
7475
|
+
let transformedList = fromReferenceImages;
|
|
7476
|
+
if (Array.isArray(transformedList)) {
|
|
7477
|
+
transformedList = transformedList.map((item) => {
|
|
7478
|
+
return referenceImageAPIInternalToVertex(apiClient, item);
|
|
7479
|
+
});
|
|
7480
|
+
}
|
|
7481
|
+
setValueByPath(toObject, ['instances[0]', 'referenceImages'], transformedList);
|
|
7482
|
+
}
|
|
7483
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7484
|
+
if (fromConfig != null) {
|
|
7485
|
+
setValueByPath(toObject, ['config'], editImageConfigToVertex(apiClient, fromConfig, toObject));
|
|
7486
|
+
}
|
|
7487
|
+
return toObject;
|
|
7488
|
+
}
|
|
7489
|
+
function upscaleImageAPIConfigInternalToVertex(apiClient, fromObject, parentObject) {
|
|
7490
|
+
const toObject = {};
|
|
7491
|
+
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
7492
|
+
'includeRaiReason',
|
|
7493
|
+
]);
|
|
7494
|
+
if (parentObject !== undefined && fromIncludeRaiReason != null) {
|
|
7495
|
+
setValueByPath(parentObject, ['parameters', 'includeRaiReason'], fromIncludeRaiReason);
|
|
7496
|
+
}
|
|
7497
|
+
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
7498
|
+
'outputMimeType',
|
|
7499
|
+
]);
|
|
7500
|
+
if (parentObject !== undefined && fromOutputMimeType != null) {
|
|
7501
|
+
setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
|
|
7502
|
+
}
|
|
7503
|
+
const fromOutputCompressionQuality = getValueByPath(fromObject, [
|
|
7504
|
+
'outputCompressionQuality',
|
|
7505
|
+
]);
|
|
7506
|
+
if (parentObject !== undefined && fromOutputCompressionQuality != null) {
|
|
7507
|
+
setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
|
|
7508
|
+
}
|
|
7509
|
+
const fromNumberOfImages = getValueByPath(fromObject, [
|
|
7510
|
+
'numberOfImages',
|
|
7511
|
+
]);
|
|
7512
|
+
if (parentObject !== undefined && fromNumberOfImages != null) {
|
|
7513
|
+
setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
|
|
7514
|
+
}
|
|
7515
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
7516
|
+
if (parentObject !== undefined && fromMode != null) {
|
|
7517
|
+
setValueByPath(parentObject, ['parameters', 'mode'], fromMode);
|
|
7518
|
+
}
|
|
7519
|
+
return toObject;
|
|
7520
|
+
}
|
|
7521
|
+
function upscaleImageAPIParametersInternalToVertex(apiClient, fromObject) {
|
|
7522
|
+
const toObject = {};
|
|
7523
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
7524
|
+
if (fromModel != null) {
|
|
7525
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
7526
|
+
}
|
|
7527
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
7528
|
+
if (fromImage != null) {
|
|
7529
|
+
setValueByPath(toObject, ['instances[0]', 'image'], imageToVertex(apiClient, fromImage));
|
|
7530
|
+
}
|
|
7531
|
+
const fromUpscaleFactor = getValueByPath(fromObject, [
|
|
7532
|
+
'upscaleFactor',
|
|
7533
|
+
]);
|
|
7534
|
+
if (fromUpscaleFactor != null) {
|
|
7535
|
+
setValueByPath(toObject, ['parameters', 'upscaleConfig', 'upscaleFactor'], fromUpscaleFactor);
|
|
7536
|
+
}
|
|
7537
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7538
|
+
if (fromConfig != null) {
|
|
7539
|
+
setValueByPath(toObject, ['config'], upscaleImageAPIConfigInternalToVertex(apiClient, fromConfig, toObject));
|
|
7540
|
+
}
|
|
7541
|
+
return toObject;
|
|
7542
|
+
}
|
|
7543
|
+
function getModelParametersToVertex(apiClient, fromObject) {
|
|
7544
|
+
const toObject = {};
|
|
7545
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
7546
|
+
if (fromModel != null) {
|
|
7547
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
7548
|
+
}
|
|
7549
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7550
|
+
if (fromConfig != null) {
|
|
7551
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
7552
|
+
}
|
|
7553
|
+
return toObject;
|
|
7554
|
+
}
|
|
7555
|
+
function listModelsConfigToVertex(apiClient, fromObject, parentObject) {
|
|
7556
|
+
const toObject = {};
|
|
7557
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
7558
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
7559
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
7560
|
+
}
|
|
7561
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
7562
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
7563
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
7564
|
+
}
|
|
7565
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
7566
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
7567
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
7568
|
+
}
|
|
7569
|
+
const fromQueryBase = getValueByPath(fromObject, ['queryBase']);
|
|
7570
|
+
if (parentObject !== undefined && fromQueryBase != null) {
|
|
7571
|
+
setValueByPath(parentObject, ['_url', 'models_url'], tModelsUrl(apiClient, fromQueryBase));
|
|
7572
|
+
}
|
|
7573
|
+
return toObject;
|
|
7574
|
+
}
|
|
7575
|
+
function listModelsParametersToVertex(apiClient, fromObject) {
|
|
7576
|
+
const toObject = {};
|
|
7577
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7578
|
+
if (fromConfig != null) {
|
|
7579
|
+
setValueByPath(toObject, ['config'], listModelsConfigToVertex(apiClient, fromConfig, toObject));
|
|
7580
|
+
}
|
|
7581
|
+
return toObject;
|
|
7582
|
+
}
|
|
7583
|
+
function updateModelConfigToVertex(apiClient, fromObject, parentObject) {
|
|
7584
|
+
const toObject = {};
|
|
7585
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
7586
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
7587
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
7588
|
+
}
|
|
7589
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
7590
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
7591
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
7592
|
+
}
|
|
7593
|
+
const fromDefaultCheckpointId = getValueByPath(fromObject, [
|
|
7594
|
+
'defaultCheckpointId',
|
|
7595
|
+
]);
|
|
7596
|
+
if (parentObject !== undefined && fromDefaultCheckpointId != null) {
|
|
7597
|
+
setValueByPath(parentObject, ['defaultCheckpointId'], fromDefaultCheckpointId);
|
|
7598
|
+
}
|
|
7599
|
+
return toObject;
|
|
7600
|
+
}
|
|
7601
|
+
function updateModelParametersToVertex(apiClient, fromObject) {
|
|
7602
|
+
const toObject = {};
|
|
7603
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
7604
|
+
if (fromModel != null) {
|
|
7605
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
7606
|
+
}
|
|
7607
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7608
|
+
if (fromConfig != null) {
|
|
7609
|
+
setValueByPath(toObject, ['config'], updateModelConfigToVertex(apiClient, fromConfig, toObject));
|
|
7610
|
+
}
|
|
7611
|
+
return toObject;
|
|
7612
|
+
}
|
|
7613
|
+
function deleteModelParametersToVertex(apiClient, fromObject) {
|
|
7614
|
+
const toObject = {};
|
|
7615
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
7616
|
+
if (fromModel != null) {
|
|
7617
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
7618
|
+
}
|
|
7619
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7620
|
+
if (fromConfig != null) {
|
|
7621
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
7622
|
+
}
|
|
7623
|
+
return toObject;
|
|
7624
|
+
}
|
|
7625
|
+
function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
7626
|
+
const toObject = {};
|
|
7627
|
+
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
7628
|
+
'systemInstruction',
|
|
7629
|
+
]);
|
|
7630
|
+
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
7631
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex(apiClient, tContent(apiClient, fromSystemInstruction)));
|
|
6549
7632
|
}
|
|
6550
7633
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6551
7634
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -6609,22 +7692,6 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
6609
7692
|
}
|
|
6610
7693
|
return toObject;
|
|
6611
7694
|
}
|
|
6612
|
-
function imageToVertex(apiClient, fromObject) {
|
|
6613
|
-
const toObject = {};
|
|
6614
|
-
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
6615
|
-
if (fromGcsUri != null) {
|
|
6616
|
-
setValueByPath(toObject, ['gcsUri'], fromGcsUri);
|
|
6617
|
-
}
|
|
6618
|
-
const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
|
|
6619
|
-
if (fromImageBytes != null) {
|
|
6620
|
-
setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
|
|
6621
|
-
}
|
|
6622
|
-
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
6623
|
-
if (fromMimeType != null) {
|
|
6624
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
6625
|
-
}
|
|
6626
|
-
return toObject;
|
|
6627
|
-
}
|
|
6628
7695
|
function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
|
|
6629
7696
|
const toObject = {};
|
|
6630
7697
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -6703,12 +7770,28 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
6703
7770
|
}
|
|
6704
7771
|
return toObject;
|
|
6705
7772
|
}
|
|
7773
|
+
function blobFromMldev(apiClient, fromObject) {
|
|
7774
|
+
const toObject = {};
|
|
7775
|
+
const fromData = getValueByPath(fromObject, ['data']);
|
|
7776
|
+
if (fromData != null) {
|
|
7777
|
+
setValueByPath(toObject, ['data'], fromData);
|
|
7778
|
+
}
|
|
7779
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
7780
|
+
if (fromMimeType != null) {
|
|
7781
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
7782
|
+
}
|
|
7783
|
+
return toObject;
|
|
7784
|
+
}
|
|
6706
7785
|
function partFromMldev(apiClient, fromObject) {
|
|
6707
7786
|
const toObject = {};
|
|
6708
7787
|
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
6709
7788
|
if (fromThought != null) {
|
|
6710
7789
|
setValueByPath(toObject, ['thought'], fromThought);
|
|
6711
7790
|
}
|
|
7791
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
7792
|
+
if (fromInlineData != null) {
|
|
7793
|
+
setValueByPath(toObject, ['inlineData'], blobFromMldev(apiClient, fromInlineData));
|
|
7794
|
+
}
|
|
6712
7795
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
6713
7796
|
'codeExecutionResult',
|
|
6714
7797
|
]);
|
|
@@ -6735,10 +7818,6 @@ function partFromMldev(apiClient, fromObject) {
|
|
|
6735
7818
|
if (fromFunctionResponse != null) {
|
|
6736
7819
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
6737
7820
|
}
|
|
6738
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
6739
|
-
if (fromInlineData != null) {
|
|
6740
|
-
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
6741
|
-
}
|
|
6742
7821
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
6743
7822
|
if (fromText != null) {
|
|
6744
7823
|
setValueByPath(toObject, ['text'], fromText);
|
|
@@ -7013,6 +8092,26 @@ function modelFromMldev(apiClient, fromObject) {
|
|
|
7013
8092
|
}
|
|
7014
8093
|
return toObject;
|
|
7015
8094
|
}
|
|
8095
|
+
function listModelsResponseFromMldev(apiClient, fromObject) {
|
|
8096
|
+
const toObject = {};
|
|
8097
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
8098
|
+
'nextPageToken',
|
|
8099
|
+
]);
|
|
8100
|
+
if (fromNextPageToken != null) {
|
|
8101
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
8102
|
+
}
|
|
8103
|
+
const fromModels = getValueByPath(fromObject, ['_self']);
|
|
8104
|
+
if (fromModels != null) {
|
|
8105
|
+
let transformedList = tExtractModels(apiClient, fromModels);
|
|
8106
|
+
if (Array.isArray(transformedList)) {
|
|
8107
|
+
transformedList = transformedList.map((item) => {
|
|
8108
|
+
return modelFromMldev(apiClient, item);
|
|
8109
|
+
});
|
|
8110
|
+
}
|
|
8111
|
+
setValueByPath(toObject, ['models'], transformedList);
|
|
8112
|
+
}
|
|
8113
|
+
return toObject;
|
|
8114
|
+
}
|
|
7016
8115
|
function deleteModelResponseFromMldev() {
|
|
7017
8116
|
const toObject = {};
|
|
7018
8117
|
return toObject;
|
|
@@ -7113,6 +8212,22 @@ function generateVideosOperationFromMldev$1(apiClient, fromObject) {
|
|
|
7113
8212
|
}
|
|
7114
8213
|
return toObject;
|
|
7115
8214
|
}
|
|
8215
|
+
function blobFromVertex(apiClient, fromObject) {
|
|
8216
|
+
const toObject = {};
|
|
8217
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
8218
|
+
if (fromDisplayName != null) {
|
|
8219
|
+
setValueByPath(toObject, ['displayName'], fromDisplayName);
|
|
8220
|
+
}
|
|
8221
|
+
const fromData = getValueByPath(fromObject, ['data']);
|
|
8222
|
+
if (fromData != null) {
|
|
8223
|
+
setValueByPath(toObject, ['data'], fromData);
|
|
8224
|
+
}
|
|
8225
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
8226
|
+
if (fromMimeType != null) {
|
|
8227
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
8228
|
+
}
|
|
8229
|
+
return toObject;
|
|
8230
|
+
}
|
|
7116
8231
|
function partFromVertex(apiClient, fromObject) {
|
|
7117
8232
|
const toObject = {};
|
|
7118
8233
|
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
@@ -7125,6 +8240,10 @@ function partFromVertex(apiClient, fromObject) {
|
|
|
7125
8240
|
if (fromThought != null) {
|
|
7126
8241
|
setValueByPath(toObject, ['thought'], fromThought);
|
|
7127
8242
|
}
|
|
8243
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
8244
|
+
if (fromInlineData != null) {
|
|
8245
|
+
setValueByPath(toObject, ['inlineData'], blobFromVertex(apiClient, fromInlineData));
|
|
8246
|
+
}
|
|
7128
8247
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
7129
8248
|
'codeExecutionResult',
|
|
7130
8249
|
]);
|
|
@@ -7151,10 +8270,6 @@ function partFromVertex(apiClient, fromObject) {
|
|
|
7151
8270
|
if (fromFunctionResponse != null) {
|
|
7152
8271
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
7153
8272
|
}
|
|
7154
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
7155
|
-
if (fromInlineData != null) {
|
|
7156
|
-
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
7157
|
-
}
|
|
7158
8273
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
7159
8274
|
if (fromText != null) {
|
|
7160
8275
|
setValueByPath(toObject, ['text'], fromText);
|
|
@@ -7414,6 +8529,38 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
|
|
|
7414
8529
|
}
|
|
7415
8530
|
return toObject;
|
|
7416
8531
|
}
|
|
8532
|
+
function editImageResponseFromVertex(apiClient, fromObject) {
|
|
8533
|
+
const toObject = {};
|
|
8534
|
+
const fromGeneratedImages = getValueByPath(fromObject, [
|
|
8535
|
+
'predictions',
|
|
8536
|
+
]);
|
|
8537
|
+
if (fromGeneratedImages != null) {
|
|
8538
|
+
let transformedList = fromGeneratedImages;
|
|
8539
|
+
if (Array.isArray(transformedList)) {
|
|
8540
|
+
transformedList = transformedList.map((item) => {
|
|
8541
|
+
return generatedImageFromVertex(apiClient, item);
|
|
8542
|
+
});
|
|
8543
|
+
}
|
|
8544
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
8545
|
+
}
|
|
8546
|
+
return toObject;
|
|
8547
|
+
}
|
|
8548
|
+
function upscaleImageResponseFromVertex(apiClient, fromObject) {
|
|
8549
|
+
const toObject = {};
|
|
8550
|
+
const fromGeneratedImages = getValueByPath(fromObject, [
|
|
8551
|
+
'predictions',
|
|
8552
|
+
]);
|
|
8553
|
+
if (fromGeneratedImages != null) {
|
|
8554
|
+
let transformedList = fromGeneratedImages;
|
|
8555
|
+
if (Array.isArray(transformedList)) {
|
|
8556
|
+
transformedList = transformedList.map((item) => {
|
|
8557
|
+
return generatedImageFromVertex(apiClient, item);
|
|
8558
|
+
});
|
|
8559
|
+
}
|
|
8560
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
8561
|
+
}
|
|
8562
|
+
return toObject;
|
|
8563
|
+
}
|
|
7417
8564
|
function endpointFromVertex(apiClient, fromObject) {
|
|
7418
8565
|
const toObject = {};
|
|
7419
8566
|
const fromName = getValueByPath(fromObject, ['endpoint']);
|
|
@@ -7447,6 +8594,22 @@ function tunedModelInfoFromVertex(apiClient, fromObject) {
|
|
|
7447
8594
|
}
|
|
7448
8595
|
return toObject;
|
|
7449
8596
|
}
|
|
8597
|
+
function checkpointFromVertex(apiClient, fromObject) {
|
|
8598
|
+
const toObject = {};
|
|
8599
|
+
const fromCheckpointId = getValueByPath(fromObject, ['checkpointId']);
|
|
8600
|
+
if (fromCheckpointId != null) {
|
|
8601
|
+
setValueByPath(toObject, ['checkpointId'], fromCheckpointId);
|
|
8602
|
+
}
|
|
8603
|
+
const fromEpoch = getValueByPath(fromObject, ['epoch']);
|
|
8604
|
+
if (fromEpoch != null) {
|
|
8605
|
+
setValueByPath(toObject, ['epoch'], fromEpoch);
|
|
8606
|
+
}
|
|
8607
|
+
const fromStep = getValueByPath(fromObject, ['step']);
|
|
8608
|
+
if (fromStep != null) {
|
|
8609
|
+
setValueByPath(toObject, ['step'], fromStep);
|
|
8610
|
+
}
|
|
8611
|
+
return toObject;
|
|
8612
|
+
}
|
|
7450
8613
|
function modelFromVertex(apiClient, fromObject) {
|
|
7451
8614
|
const toObject = {};
|
|
7452
8615
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
@@ -7483,6 +8646,42 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7483
8646
|
if (fromTunedModelInfo != null) {
|
|
7484
8647
|
setValueByPath(toObject, ['tunedModelInfo'], tunedModelInfoFromVertex(apiClient, fromTunedModelInfo));
|
|
7485
8648
|
}
|
|
8649
|
+
const fromDefaultCheckpointId = getValueByPath(fromObject, [
|
|
8650
|
+
'defaultCheckpointId',
|
|
8651
|
+
]);
|
|
8652
|
+
if (fromDefaultCheckpointId != null) {
|
|
8653
|
+
setValueByPath(toObject, ['defaultCheckpointId'], fromDefaultCheckpointId);
|
|
8654
|
+
}
|
|
8655
|
+
const fromCheckpoints = getValueByPath(fromObject, ['checkpoints']);
|
|
8656
|
+
if (fromCheckpoints != null) {
|
|
8657
|
+
let transformedList = fromCheckpoints;
|
|
8658
|
+
if (Array.isArray(transformedList)) {
|
|
8659
|
+
transformedList = transformedList.map((item) => {
|
|
8660
|
+
return checkpointFromVertex(apiClient, item);
|
|
8661
|
+
});
|
|
8662
|
+
}
|
|
8663
|
+
setValueByPath(toObject, ['checkpoints'], transformedList);
|
|
8664
|
+
}
|
|
8665
|
+
return toObject;
|
|
8666
|
+
}
|
|
8667
|
+
function listModelsResponseFromVertex(apiClient, fromObject) {
|
|
8668
|
+
const toObject = {};
|
|
8669
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
8670
|
+
'nextPageToken',
|
|
8671
|
+
]);
|
|
8672
|
+
if (fromNextPageToken != null) {
|
|
8673
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
8674
|
+
}
|
|
8675
|
+
const fromModels = getValueByPath(fromObject, ['_self']);
|
|
8676
|
+
if (fromModels != null) {
|
|
8677
|
+
let transformedList = tExtractModels(apiClient, fromModels);
|
|
8678
|
+
if (Array.isArray(transformedList)) {
|
|
8679
|
+
transformedList = transformedList.map((item) => {
|
|
8680
|
+
return modelFromVertex(apiClient, item);
|
|
8681
|
+
});
|
|
8682
|
+
}
|
|
8683
|
+
setValueByPath(toObject, ['models'], transformedList);
|
|
8684
|
+
}
|
|
7486
8685
|
return toObject;
|
|
7487
8686
|
}
|
|
7488
8687
|
function deleteModelResponseFromVertex() {
|
|
@@ -7602,7 +8801,7 @@ const FUNCTION_RESPONSE_REQUIRES_ID = 'FunctionResponse request must have an `id
|
|
|
7602
8801
|
* @param event The MessageEvent from the WebSocket.
|
|
7603
8802
|
*/
|
|
7604
8803
|
async function handleWebSocketMessage(apiClient, onmessage, event) {
|
|
7605
|
-
|
|
8804
|
+
const serverMessage = new LiveServerMessage();
|
|
7606
8805
|
let data;
|
|
7607
8806
|
if (event.data instanceof Blob) {
|
|
7608
8807
|
data = JSON.parse(await event.data.text());
|
|
@@ -7611,10 +8810,12 @@ async function handleWebSocketMessage(apiClient, onmessage, event) {
|
|
|
7611
8810
|
data = JSON.parse(event.data);
|
|
7612
8811
|
}
|
|
7613
8812
|
if (apiClient.isVertexAI()) {
|
|
7614
|
-
|
|
8813
|
+
const resp = liveServerMessageFromVertex(apiClient, data);
|
|
8814
|
+
Object.assign(serverMessage, resp);
|
|
7615
8815
|
}
|
|
7616
8816
|
else {
|
|
7617
|
-
|
|
8817
|
+
const resp = liveServerMessageFromMldev(apiClient, data);
|
|
8818
|
+
Object.assign(serverMessage, resp);
|
|
7618
8819
|
}
|
|
7619
8820
|
onmessage(serverMessage);
|
|
7620
8821
|
}
|
|
@@ -8071,9 +9272,7 @@ class Models extends BaseModule {
|
|
|
8071
9272
|
/**
|
|
8072
9273
|
* Generates an image based on a text description and configuration.
|
|
8073
9274
|
*
|
|
8074
|
-
* @param
|
|
8075
|
-
* @param prompt - A text description of the image to generate.
|
|
8076
|
-
* @param [config] - The config for image generation.
|
|
9275
|
+
* @param params - The parameters for generating images.
|
|
8077
9276
|
* @return The response from the API.
|
|
8078
9277
|
*
|
|
8079
9278
|
* @example
|
|
@@ -8121,6 +9320,97 @@ class Models extends BaseModule {
|
|
|
8121
9320
|
return response;
|
|
8122
9321
|
});
|
|
8123
9322
|
};
|
|
9323
|
+
this.list = async (params) => {
|
|
9324
|
+
var _a;
|
|
9325
|
+
const defaultConfig = {
|
|
9326
|
+
queryBase: true,
|
|
9327
|
+
};
|
|
9328
|
+
const actualConfig = Object.assign(Object.assign({}, defaultConfig), params === null || params === void 0 ? void 0 : params.config);
|
|
9329
|
+
const actualParams = {
|
|
9330
|
+
config: actualConfig,
|
|
9331
|
+
};
|
|
9332
|
+
if (this.apiClient.isVertexAI()) {
|
|
9333
|
+
if (!actualParams.config.queryBase) {
|
|
9334
|
+
if ((_a = actualParams.config) === null || _a === void 0 ? void 0 : _a.filter) {
|
|
9335
|
+
throw new Error('Filtering tuned models list for Vertex AI is not currently supported');
|
|
9336
|
+
}
|
|
9337
|
+
else {
|
|
9338
|
+
actualParams.config.filter = 'labels.tune-type:*';
|
|
9339
|
+
}
|
|
9340
|
+
}
|
|
9341
|
+
}
|
|
9342
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_MODELS, (x) => this.listInternal(x), await this.listInternal(actualParams), actualParams);
|
|
9343
|
+
};
|
|
9344
|
+
/**
|
|
9345
|
+
* Edits an image based on a prompt, list of reference images, and configuration.
|
|
9346
|
+
*
|
|
9347
|
+
* @param params - The parameters for editing an image.
|
|
9348
|
+
* @return The response from the API.
|
|
9349
|
+
*
|
|
9350
|
+
* @example
|
|
9351
|
+
* ```ts
|
|
9352
|
+
* const response = await client.models.editImage({
|
|
9353
|
+
* model: 'imagen-3.0-capability-001',
|
|
9354
|
+
* prompt: 'Generate an image containing a mug with the product logo [1] visible on the side of the mug.',
|
|
9355
|
+
* referenceImages: [subjectReferenceImage]
|
|
9356
|
+
* config: {
|
|
9357
|
+
* numberOfImages: 1,
|
|
9358
|
+
* includeRaiReason: true,
|
|
9359
|
+
* },
|
|
9360
|
+
* });
|
|
9361
|
+
* console.log(response?.generatedImages?.[0]?.image?.imageBytes);
|
|
9362
|
+
* ```
|
|
9363
|
+
*/
|
|
9364
|
+
this.editImage = async (params) => {
|
|
9365
|
+
const paramsInternal = {
|
|
9366
|
+
model: params.model,
|
|
9367
|
+
prompt: params.prompt,
|
|
9368
|
+
referenceImages: [],
|
|
9369
|
+
config: params.config,
|
|
9370
|
+
};
|
|
9371
|
+
if (params.referenceImages) {
|
|
9372
|
+
if (params.referenceImages) {
|
|
9373
|
+
paramsInternal.referenceImages = params.referenceImages.map((img) => img.toReferenceImageAPI());
|
|
9374
|
+
}
|
|
9375
|
+
}
|
|
9376
|
+
return await this.editImageInternal(paramsInternal);
|
|
9377
|
+
};
|
|
9378
|
+
/**
|
|
9379
|
+
* Upscales an image based on an image, upscale factor, and configuration.
|
|
9380
|
+
* Only supported in Vertex AI currently.
|
|
9381
|
+
*
|
|
9382
|
+
* @param params - The parameters for upscaling an image.
|
|
9383
|
+
* @return The response from the API.
|
|
9384
|
+
*
|
|
9385
|
+
* @example
|
|
9386
|
+
* ```ts
|
|
9387
|
+
* const response = await client.models.upscaleImage({
|
|
9388
|
+
* model: 'imagen-3.0-generate-002',
|
|
9389
|
+
* image: image,
|
|
9390
|
+
* upscaleFactor: 'x2',
|
|
9391
|
+
* config: {
|
|
9392
|
+
* includeRaiReason: true,
|
|
9393
|
+
* },
|
|
9394
|
+
* });
|
|
9395
|
+
* console.log(response?.generatedImages?.[0]?.image?.imageBytes);
|
|
9396
|
+
* ```
|
|
9397
|
+
*/
|
|
9398
|
+
this.upscaleImage = async (params) => {
|
|
9399
|
+
let apiConfig = {
|
|
9400
|
+
numberOfImages: 1,
|
|
9401
|
+
mode: 'upscale',
|
|
9402
|
+
};
|
|
9403
|
+
if (params.config) {
|
|
9404
|
+
apiConfig = Object.assign(Object.assign({}, apiConfig), params.config);
|
|
9405
|
+
}
|
|
9406
|
+
const apiParams = {
|
|
9407
|
+
model: params.model,
|
|
9408
|
+
image: params.image,
|
|
9409
|
+
upscaleFactor: params.upscaleFactor,
|
|
9410
|
+
config: apiConfig,
|
|
9411
|
+
};
|
|
9412
|
+
return await this.upscaleImageInternal(apiParams);
|
|
9413
|
+
};
|
|
8124
9414
|
}
|
|
8125
9415
|
async generateContentInternal(params) {
|
|
8126
9416
|
var _a, _b, _c, _d;
|
|
@@ -8422,6 +9712,76 @@ class Models extends BaseModule {
|
|
|
8422
9712
|
});
|
|
8423
9713
|
}
|
|
8424
9714
|
}
|
|
9715
|
+
async editImageInternal(params) {
|
|
9716
|
+
var _a, _b;
|
|
9717
|
+
let response;
|
|
9718
|
+
let path = '';
|
|
9719
|
+
let queryParams = {};
|
|
9720
|
+
if (this.apiClient.isVertexAI()) {
|
|
9721
|
+
const body = editImageParametersInternalToVertex(this.apiClient, params);
|
|
9722
|
+
path = formatMap('{model}:predict', body['_url']);
|
|
9723
|
+
queryParams = body['_query'];
|
|
9724
|
+
delete body['config'];
|
|
9725
|
+
delete body['_url'];
|
|
9726
|
+
delete body['_query'];
|
|
9727
|
+
response = this.apiClient
|
|
9728
|
+
.request({
|
|
9729
|
+
path: path,
|
|
9730
|
+
queryParams: queryParams,
|
|
9731
|
+
body: JSON.stringify(body),
|
|
9732
|
+
httpMethod: 'POST',
|
|
9733
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9734
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9735
|
+
})
|
|
9736
|
+
.then((httpResponse) => {
|
|
9737
|
+
return httpResponse.json();
|
|
9738
|
+
});
|
|
9739
|
+
return response.then((apiResponse) => {
|
|
9740
|
+
const resp = editImageResponseFromVertex(this.apiClient, apiResponse);
|
|
9741
|
+
const typedResp = new EditImageResponse();
|
|
9742
|
+
Object.assign(typedResp, resp);
|
|
9743
|
+
return typedResp;
|
|
9744
|
+
});
|
|
9745
|
+
}
|
|
9746
|
+
else {
|
|
9747
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
9748
|
+
}
|
|
9749
|
+
}
|
|
9750
|
+
async upscaleImageInternal(params) {
|
|
9751
|
+
var _a, _b;
|
|
9752
|
+
let response;
|
|
9753
|
+
let path = '';
|
|
9754
|
+
let queryParams = {};
|
|
9755
|
+
if (this.apiClient.isVertexAI()) {
|
|
9756
|
+
const body = upscaleImageAPIParametersInternalToVertex(this.apiClient, params);
|
|
9757
|
+
path = formatMap('{model}:predict', body['_url']);
|
|
9758
|
+
queryParams = body['_query'];
|
|
9759
|
+
delete body['config'];
|
|
9760
|
+
delete body['_url'];
|
|
9761
|
+
delete body['_query'];
|
|
9762
|
+
response = this.apiClient
|
|
9763
|
+
.request({
|
|
9764
|
+
path: path,
|
|
9765
|
+
queryParams: queryParams,
|
|
9766
|
+
body: JSON.stringify(body),
|
|
9767
|
+
httpMethod: 'POST',
|
|
9768
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9769
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9770
|
+
})
|
|
9771
|
+
.then((httpResponse) => {
|
|
9772
|
+
return httpResponse.json();
|
|
9773
|
+
});
|
|
9774
|
+
return response.then((apiResponse) => {
|
|
9775
|
+
const resp = upscaleImageResponseFromVertex(this.apiClient, apiResponse);
|
|
9776
|
+
const typedResp = new UpscaleImageResponse();
|
|
9777
|
+
Object.assign(typedResp, resp);
|
|
9778
|
+
return typedResp;
|
|
9779
|
+
});
|
|
9780
|
+
}
|
|
9781
|
+
else {
|
|
9782
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
9783
|
+
}
|
|
9784
|
+
}
|
|
8425
9785
|
/**
|
|
8426
9786
|
* Fetches information about a model by name.
|
|
8427
9787
|
*
|
|
@@ -8484,6 +9844,64 @@ class Models extends BaseModule {
|
|
|
8484
9844
|
});
|
|
8485
9845
|
}
|
|
8486
9846
|
}
|
|
9847
|
+
async listInternal(params) {
|
|
9848
|
+
var _a, _b, _c, _d;
|
|
9849
|
+
let response;
|
|
9850
|
+
let path = '';
|
|
9851
|
+
let queryParams = {};
|
|
9852
|
+
if (this.apiClient.isVertexAI()) {
|
|
9853
|
+
const body = listModelsParametersToVertex(this.apiClient, params);
|
|
9854
|
+
path = formatMap('{models_url}', body['_url']);
|
|
9855
|
+
queryParams = body['_query'];
|
|
9856
|
+
delete body['config'];
|
|
9857
|
+
delete body['_url'];
|
|
9858
|
+
delete body['_query'];
|
|
9859
|
+
response = this.apiClient
|
|
9860
|
+
.request({
|
|
9861
|
+
path: path,
|
|
9862
|
+
queryParams: queryParams,
|
|
9863
|
+
body: JSON.stringify(body),
|
|
9864
|
+
httpMethod: 'GET',
|
|
9865
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9866
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9867
|
+
})
|
|
9868
|
+
.then((httpResponse) => {
|
|
9869
|
+
return httpResponse.json();
|
|
9870
|
+
});
|
|
9871
|
+
return response.then((apiResponse) => {
|
|
9872
|
+
const resp = listModelsResponseFromVertex(this.apiClient, apiResponse);
|
|
9873
|
+
const typedResp = new ListModelsResponse();
|
|
9874
|
+
Object.assign(typedResp, resp);
|
|
9875
|
+
return typedResp;
|
|
9876
|
+
});
|
|
9877
|
+
}
|
|
9878
|
+
else {
|
|
9879
|
+
const body = listModelsParametersToMldev(this.apiClient, params);
|
|
9880
|
+
path = formatMap('{models_url}', body['_url']);
|
|
9881
|
+
queryParams = body['_query'];
|
|
9882
|
+
delete body['config'];
|
|
9883
|
+
delete body['_url'];
|
|
9884
|
+
delete body['_query'];
|
|
9885
|
+
response = this.apiClient
|
|
9886
|
+
.request({
|
|
9887
|
+
path: path,
|
|
9888
|
+
queryParams: queryParams,
|
|
9889
|
+
body: JSON.stringify(body),
|
|
9890
|
+
httpMethod: 'GET',
|
|
9891
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9892
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9893
|
+
})
|
|
9894
|
+
.then((httpResponse) => {
|
|
9895
|
+
return httpResponse.json();
|
|
9896
|
+
});
|
|
9897
|
+
return response.then((apiResponse) => {
|
|
9898
|
+
const resp = listModelsResponseFromMldev(this.apiClient, apiResponse);
|
|
9899
|
+
const typedResp = new ListModelsResponse();
|
|
9900
|
+
Object.assign(typedResp, resp);
|
|
9901
|
+
return typedResp;
|
|
9902
|
+
});
|
|
9903
|
+
}
|
|
9904
|
+
}
|
|
8487
9905
|
/**
|
|
8488
9906
|
* Updates a tuned model by its name.
|
|
8489
9907
|
*
|
|
@@ -9264,6 +10682,10 @@ function createTuningJobConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
9264
10682
|
if (fromLearningRateMultiplier != null) {
|
|
9265
10683
|
setValueByPath(toObject, ['tuningTask', 'hyperparameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9266
10684
|
}
|
|
10685
|
+
if (getValueByPath(fromObject, ['exportLastCheckpointOnly']) !==
|
|
10686
|
+
undefined) {
|
|
10687
|
+
throw new Error('exportLastCheckpointOnly parameter is not supported in Gemini API.');
|
|
10688
|
+
}
|
|
9267
10689
|
if (getValueByPath(fromObject, ['adapterSize']) !== undefined) {
|
|
9268
10690
|
throw new Error('adapterSize parameter is not supported in Gemini API.');
|
|
9269
10691
|
}
|
|
@@ -9378,6 +10800,12 @@ function createTuningJobConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
9378
10800
|
if (parentObject !== undefined && fromLearningRateMultiplier != null) {
|
|
9379
10801
|
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9380
10802
|
}
|
|
10803
|
+
const fromExportLastCheckpointOnly = getValueByPath(fromObject, [
|
|
10804
|
+
'exportLastCheckpointOnly',
|
|
10805
|
+
]);
|
|
10806
|
+
if (parentObject !== undefined && fromExportLastCheckpointOnly != null) {
|
|
10807
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'exportLastCheckpointOnly'], fromExportLastCheckpointOnly);
|
|
10808
|
+
}
|
|
9381
10809
|
const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
|
|
9382
10810
|
if (parentObject !== undefined && fromAdapterSize != null) {
|
|
9383
10811
|
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
|
|
@@ -9530,6 +10958,26 @@ function operationFromMldev(apiClient, fromObject) {
|
|
|
9530
10958
|
}
|
|
9531
10959
|
return toObject;
|
|
9532
10960
|
}
|
|
10961
|
+
function tunedModelCheckpointFromVertex(apiClient, fromObject) {
|
|
10962
|
+
const toObject = {};
|
|
10963
|
+
const fromCheckpointId = getValueByPath(fromObject, ['checkpointId']);
|
|
10964
|
+
if (fromCheckpointId != null) {
|
|
10965
|
+
setValueByPath(toObject, ['checkpointId'], fromCheckpointId);
|
|
10966
|
+
}
|
|
10967
|
+
const fromEpoch = getValueByPath(fromObject, ['epoch']);
|
|
10968
|
+
if (fromEpoch != null) {
|
|
10969
|
+
setValueByPath(toObject, ['epoch'], fromEpoch);
|
|
10970
|
+
}
|
|
10971
|
+
const fromStep = getValueByPath(fromObject, ['step']);
|
|
10972
|
+
if (fromStep != null) {
|
|
10973
|
+
setValueByPath(toObject, ['step'], fromStep);
|
|
10974
|
+
}
|
|
10975
|
+
const fromEndpoint = getValueByPath(fromObject, ['endpoint']);
|
|
10976
|
+
if (fromEndpoint != null) {
|
|
10977
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
10978
|
+
}
|
|
10979
|
+
return toObject;
|
|
10980
|
+
}
|
|
9533
10981
|
function tunedModelFromVertex(apiClient, fromObject) {
|
|
9534
10982
|
const toObject = {};
|
|
9535
10983
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
@@ -9540,6 +10988,16 @@ function tunedModelFromVertex(apiClient, fromObject) {
|
|
|
9540
10988
|
if (fromEndpoint != null) {
|
|
9541
10989
|
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9542
10990
|
}
|
|
10991
|
+
const fromCheckpoints = getValueByPath(fromObject, ['checkpoints']);
|
|
10992
|
+
if (fromCheckpoints != null) {
|
|
10993
|
+
let transformedList = fromCheckpoints;
|
|
10994
|
+
if (Array.isArray(transformedList)) {
|
|
10995
|
+
transformedList = transformedList.map((item) => {
|
|
10996
|
+
return tunedModelCheckpointFromVertex(apiClient, item);
|
|
10997
|
+
});
|
|
10998
|
+
}
|
|
10999
|
+
setValueByPath(toObject, ['checkpoints'], transformedList);
|
|
11000
|
+
}
|
|
9543
11001
|
return toObject;
|
|
9544
11002
|
}
|
|
9545
11003
|
function tuningJobFromVertex(apiClient, fromObject) {
|
|
@@ -9974,6 +11432,7 @@ class GoogleGenAI {
|
|
|
9974
11432
|
httpOptions: options.httpOptions,
|
|
9975
11433
|
userAgentExtra: LANGUAGE_LABEL_PREFIX + 'cross',
|
|
9976
11434
|
uploader: new CrossUploader(),
|
|
11435
|
+
downloader: new CrossDownloader(),
|
|
9977
11436
|
});
|
|
9978
11437
|
this.models = new Models(this.apiClient);
|
|
9979
11438
|
this.live = new Live(this.apiClient, auth, new CrossWebSocketFactory());
|
|
@@ -9989,11 +11448,13 @@ exports.Caches = Caches;
|
|
|
9989
11448
|
exports.Chat = Chat;
|
|
9990
11449
|
exports.Chats = Chats;
|
|
9991
11450
|
exports.ComputeTokensResponse = ComputeTokensResponse;
|
|
11451
|
+
exports.ControlReferenceImage = ControlReferenceImage;
|
|
9992
11452
|
exports.CountTokensResponse = CountTokensResponse;
|
|
9993
11453
|
exports.CreateFileResponse = CreateFileResponse;
|
|
9994
11454
|
exports.DeleteCachedContentResponse = DeleteCachedContentResponse;
|
|
9995
11455
|
exports.DeleteFileResponse = DeleteFileResponse;
|
|
9996
11456
|
exports.DeleteModelResponse = DeleteModelResponse;
|
|
11457
|
+
exports.EditImageResponse = EditImageResponse;
|
|
9997
11458
|
exports.EmbedContentResponse = EmbedContentResponse;
|
|
9998
11459
|
exports.Files = Files;
|
|
9999
11460
|
exports.FunctionResponse = FunctionResponse;
|
|
@@ -10006,15 +11467,22 @@ exports.GoogleGenAI = GoogleGenAI;
|
|
|
10006
11467
|
exports.HttpResponse = HttpResponse;
|
|
10007
11468
|
exports.ListCachedContentsResponse = ListCachedContentsResponse;
|
|
10008
11469
|
exports.ListFilesResponse = ListFilesResponse;
|
|
11470
|
+
exports.ListModelsResponse = ListModelsResponse;
|
|
10009
11471
|
exports.ListTuningJobsResponse = ListTuningJobsResponse;
|
|
10010
11472
|
exports.Live = Live;
|
|
10011
11473
|
exports.LiveClientToolResponse = LiveClientToolResponse;
|
|
10012
11474
|
exports.LiveSendToolResponseParameters = LiveSendToolResponseParameters;
|
|
11475
|
+
exports.LiveServerMessage = LiveServerMessage;
|
|
11476
|
+
exports.MaskReferenceImage = MaskReferenceImage;
|
|
10013
11477
|
exports.Models = Models;
|
|
10014
11478
|
exports.Operations = Operations;
|
|
10015
11479
|
exports.Pager = Pager;
|
|
11480
|
+
exports.RawReferenceImage = RawReferenceImage;
|
|
10016
11481
|
exports.ReplayResponse = ReplayResponse;
|
|
10017
11482
|
exports.Session = Session;
|
|
11483
|
+
exports.StyleReferenceImage = StyleReferenceImage;
|
|
11484
|
+
exports.SubjectReferenceImage = SubjectReferenceImage;
|
|
11485
|
+
exports.UpscaleImageResponse = UpscaleImageResponse;
|
|
10018
11486
|
exports.createModelContent = createModelContent;
|
|
10019
11487
|
exports.createPartFromBase64 = createPartFromBase64;
|
|
10020
11488
|
exports.createPartFromCodeExecutionResult = createPartFromCodeExecutionResult;
|