@google/genai 1.28.0 → 1.29.1
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 +4 -4
- package/dist/genai.d.ts +769 -47
- package/dist/index.cjs +1281 -165
- package/dist/index.mjs +1275 -166
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +1429 -292
- package/dist/node/index.mjs +1422 -293
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +769 -47
- package/dist/web/index.mjs +1306 -199
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +769 -47
- package/package.json +11 -6
package/dist/node/index.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var fs$1 = require('fs/promises');
|
|
|
6
6
|
var node_stream = require('node:stream');
|
|
7
7
|
var promises = require('node:stream/promises');
|
|
8
8
|
var NodeWs = require('ws');
|
|
9
|
+
var path = require('path');
|
|
9
10
|
|
|
10
11
|
function _interopNamespaceDefault(e) {
|
|
11
12
|
var n = Object.create(null);
|
|
@@ -26,6 +27,7 @@ function _interopNamespaceDefault(e) {
|
|
|
26
27
|
|
|
27
28
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs$1);
|
|
28
29
|
var NodeWs__namespace = /*#__PURE__*/_interopNamespaceDefault(NodeWs);
|
|
30
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* @license
|
|
@@ -489,6 +491,90 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
489
491
|
}
|
|
490
492
|
return toObject;
|
|
491
493
|
}
|
|
494
|
+
function importFileOperationFromMldev$1(fromObject) {
|
|
495
|
+
const toObject = {};
|
|
496
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
497
|
+
if (fromName != null) {
|
|
498
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
499
|
+
}
|
|
500
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
501
|
+
if (fromMetadata != null) {
|
|
502
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
503
|
+
}
|
|
504
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
505
|
+
if (fromDone != null) {
|
|
506
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
507
|
+
}
|
|
508
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
509
|
+
if (fromError != null) {
|
|
510
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
511
|
+
}
|
|
512
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
513
|
+
if (fromResponse != null) {
|
|
514
|
+
setValueByPath(toObject, ['response'], importFileResponseFromMldev$1(fromResponse));
|
|
515
|
+
}
|
|
516
|
+
return toObject;
|
|
517
|
+
}
|
|
518
|
+
function importFileResponseFromMldev$1(fromObject) {
|
|
519
|
+
const toObject = {};
|
|
520
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
521
|
+
'sdkHttpResponse',
|
|
522
|
+
]);
|
|
523
|
+
if (fromSdkHttpResponse != null) {
|
|
524
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
525
|
+
}
|
|
526
|
+
const fromParent = getValueByPath(fromObject, ['parent']);
|
|
527
|
+
if (fromParent != null) {
|
|
528
|
+
setValueByPath(toObject, ['parent'], fromParent);
|
|
529
|
+
}
|
|
530
|
+
const fromDocumentName = getValueByPath(fromObject, ['documentName']);
|
|
531
|
+
if (fromDocumentName != null) {
|
|
532
|
+
setValueByPath(toObject, ['documentName'], fromDocumentName);
|
|
533
|
+
}
|
|
534
|
+
return toObject;
|
|
535
|
+
}
|
|
536
|
+
function uploadToFileSearchStoreOperationFromMldev(fromObject) {
|
|
537
|
+
const toObject = {};
|
|
538
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
539
|
+
if (fromName != null) {
|
|
540
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
541
|
+
}
|
|
542
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
543
|
+
if (fromMetadata != null) {
|
|
544
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
545
|
+
}
|
|
546
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
547
|
+
if (fromDone != null) {
|
|
548
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
549
|
+
}
|
|
550
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
551
|
+
if (fromError != null) {
|
|
552
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
553
|
+
}
|
|
554
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
555
|
+
if (fromResponse != null) {
|
|
556
|
+
setValueByPath(toObject, ['response'], uploadToFileSearchStoreResponseFromMldev(fromResponse));
|
|
557
|
+
}
|
|
558
|
+
return toObject;
|
|
559
|
+
}
|
|
560
|
+
function uploadToFileSearchStoreResponseFromMldev(fromObject) {
|
|
561
|
+
const toObject = {};
|
|
562
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
563
|
+
'sdkHttpResponse',
|
|
564
|
+
]);
|
|
565
|
+
if (fromSdkHttpResponse != null) {
|
|
566
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
567
|
+
}
|
|
568
|
+
const fromParent = getValueByPath(fromObject, ['parent']);
|
|
569
|
+
if (fromParent != null) {
|
|
570
|
+
setValueByPath(toObject, ['parent'], fromParent);
|
|
571
|
+
}
|
|
572
|
+
const fromDocumentName = getValueByPath(fromObject, ['documentName']);
|
|
573
|
+
if (fromDocumentName != null) {
|
|
574
|
+
setValueByPath(toObject, ['documentName'], fromDocumentName);
|
|
575
|
+
}
|
|
576
|
+
return toObject;
|
|
577
|
+
}
|
|
492
578
|
function videoFromMldev$1(fromObject) {
|
|
493
579
|
const toObject = {};
|
|
494
580
|
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
@@ -629,6 +715,22 @@ exports.Mode = void 0;
|
|
|
629
715
|
*/
|
|
630
716
|
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
631
717
|
})(exports.Mode || (exports.Mode = {}));
|
|
718
|
+
/** The API spec that the external API implements. This enum is not supported in Gemini API. */
|
|
719
|
+
exports.ApiSpec = void 0;
|
|
720
|
+
(function (ApiSpec) {
|
|
721
|
+
/**
|
|
722
|
+
* Unspecified API spec. This value should not be used.
|
|
723
|
+
*/
|
|
724
|
+
ApiSpec["API_SPEC_UNSPECIFIED"] = "API_SPEC_UNSPECIFIED";
|
|
725
|
+
/**
|
|
726
|
+
* Simple search API spec.
|
|
727
|
+
*/
|
|
728
|
+
ApiSpec["SIMPLE_SEARCH"] = "SIMPLE_SEARCH";
|
|
729
|
+
/**
|
|
730
|
+
* Elastic search API spec.
|
|
731
|
+
*/
|
|
732
|
+
ApiSpec["ELASTIC_SEARCH"] = "ELASTIC_SEARCH";
|
|
733
|
+
})(exports.ApiSpec || (exports.ApiSpec = {}));
|
|
632
734
|
/** Type of auth scheme. This enum is not supported in Gemini API. */
|
|
633
735
|
exports.AuthType = void 0;
|
|
634
736
|
(function (AuthType) {
|
|
@@ -658,22 +760,63 @@ exports.AuthType = void 0;
|
|
|
658
760
|
*/
|
|
659
761
|
AuthType["OIDC_AUTH"] = "OIDC_AUTH";
|
|
660
762
|
})(exports.AuthType || (exports.AuthType = {}));
|
|
661
|
-
/** The
|
|
662
|
-
exports.
|
|
663
|
-
(function (
|
|
763
|
+
/** The location of the API key. This enum is not supported in Gemini API. */
|
|
764
|
+
exports.HttpElementLocation = void 0;
|
|
765
|
+
(function (HttpElementLocation) {
|
|
766
|
+
HttpElementLocation["HTTP_IN_UNSPECIFIED"] = "HTTP_IN_UNSPECIFIED";
|
|
664
767
|
/**
|
|
665
|
-
*
|
|
768
|
+
* Element is in the HTTP request query.
|
|
666
769
|
*/
|
|
667
|
-
|
|
770
|
+
HttpElementLocation["HTTP_IN_QUERY"] = "HTTP_IN_QUERY";
|
|
668
771
|
/**
|
|
669
|
-
*
|
|
772
|
+
* Element is in the HTTP request header.
|
|
670
773
|
*/
|
|
671
|
-
|
|
774
|
+
HttpElementLocation["HTTP_IN_HEADER"] = "HTTP_IN_HEADER";
|
|
672
775
|
/**
|
|
673
|
-
*
|
|
776
|
+
* Element is in the HTTP request path.
|
|
674
777
|
*/
|
|
675
|
-
|
|
676
|
-
|
|
778
|
+
HttpElementLocation["HTTP_IN_PATH"] = "HTTP_IN_PATH";
|
|
779
|
+
/**
|
|
780
|
+
* Element is in the HTTP request body.
|
|
781
|
+
*/
|
|
782
|
+
HttpElementLocation["HTTP_IN_BODY"] = "HTTP_IN_BODY";
|
|
783
|
+
/**
|
|
784
|
+
* Element is in the HTTP request cookie.
|
|
785
|
+
*/
|
|
786
|
+
HttpElementLocation["HTTP_IN_COOKIE"] = "HTTP_IN_COOKIE";
|
|
787
|
+
})(exports.HttpElementLocation || (exports.HttpElementLocation = {}));
|
|
788
|
+
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
789
|
+
exports.PhishBlockThreshold = void 0;
|
|
790
|
+
(function (PhishBlockThreshold) {
|
|
791
|
+
/**
|
|
792
|
+
* Defaults to unspecified.
|
|
793
|
+
*/
|
|
794
|
+
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
795
|
+
/**
|
|
796
|
+
* Blocks Low and above confidence URL that is risky.
|
|
797
|
+
*/
|
|
798
|
+
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
799
|
+
/**
|
|
800
|
+
* Blocks Medium and above confidence URL that is risky.
|
|
801
|
+
*/
|
|
802
|
+
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
803
|
+
/**
|
|
804
|
+
* Blocks High and above confidence URL that is risky.
|
|
805
|
+
*/
|
|
806
|
+
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
807
|
+
/**
|
|
808
|
+
* Blocks Higher and above confidence URL that is risky.
|
|
809
|
+
*/
|
|
810
|
+
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
811
|
+
/**
|
|
812
|
+
* Blocks Very high and above confidence URL that is risky.
|
|
813
|
+
*/
|
|
814
|
+
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
815
|
+
/**
|
|
816
|
+
* Blocks Extremely high confidence URL that is risky.
|
|
817
|
+
*/
|
|
818
|
+
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
819
|
+
})(exports.PhishBlockThreshold || (exports.PhishBlockThreshold = {}));
|
|
677
820
|
/** Harm category. */
|
|
678
821
|
exports.HarmCategory = void 0;
|
|
679
822
|
(function (HarmCategory) {
|
|
@@ -940,7 +1083,7 @@ exports.BlockedReason = void 0;
|
|
|
940
1083
|
*/
|
|
941
1084
|
BlockedReason["JAILBREAK"] = "JAILBREAK";
|
|
942
1085
|
})(exports.BlockedReason || (exports.BlockedReason = {}));
|
|
943
|
-
/** Output only.
|
|
1086
|
+
/** Output only. The traffic type for this request. This enum is not supported in Gemini API. */
|
|
944
1087
|
exports.TrafficType = void 0;
|
|
945
1088
|
(function (TrafficType) {
|
|
946
1089
|
/**
|
|
@@ -948,7 +1091,7 @@ exports.TrafficType = void 0;
|
|
|
948
1091
|
*/
|
|
949
1092
|
TrafficType["TRAFFIC_TYPE_UNSPECIFIED"] = "TRAFFIC_TYPE_UNSPECIFIED";
|
|
950
1093
|
/**
|
|
951
|
-
*
|
|
1094
|
+
* The request was processed using Pay-As-You-Go quota.
|
|
952
1095
|
*/
|
|
953
1096
|
TrafficType["ON_DEMAND"] = "ON_DEMAND";
|
|
954
1097
|
/**
|
|
@@ -1111,6 +1254,10 @@ exports.TuningTask = void 0;
|
|
|
1111
1254
|
* Tuning task for text to video.
|
|
1112
1255
|
*/
|
|
1113
1256
|
TuningTask["TUNING_TASK_T2V"] = "TUNING_TASK_T2V";
|
|
1257
|
+
/**
|
|
1258
|
+
* Tuning task for reference to video.
|
|
1259
|
+
*/
|
|
1260
|
+
TuningTask["TUNING_TASK_R2V"] = "TUNING_TASK_R2V";
|
|
1114
1261
|
})(exports.TuningTask || (exports.TuningTask = {}));
|
|
1115
1262
|
/** Options for feature selection preference. */
|
|
1116
1263
|
exports.FeatureSelectionPreference = void 0;
|
|
@@ -1358,6 +1505,14 @@ exports.TuningMethod = void 0;
|
|
|
1358
1505
|
*/
|
|
1359
1506
|
TuningMethod["PREFERENCE_TUNING"] = "PREFERENCE_TUNING";
|
|
1360
1507
|
})(exports.TuningMethod || (exports.TuningMethod = {}));
|
|
1508
|
+
/** State for the lifecycle of a Document. */
|
|
1509
|
+
exports.DocumentState = void 0;
|
|
1510
|
+
(function (DocumentState) {
|
|
1511
|
+
DocumentState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
|
|
1512
|
+
DocumentState["STATE_PENDING"] = "STATE_PENDING";
|
|
1513
|
+
DocumentState["STATE_ACTIVE"] = "STATE_ACTIVE";
|
|
1514
|
+
DocumentState["STATE_FAILED"] = "STATE_FAILED";
|
|
1515
|
+
})(exports.DocumentState || (exports.DocumentState = {}));
|
|
1361
1516
|
/** State for the lifecycle of a File. */
|
|
1362
1517
|
exports.FileState = void 0;
|
|
1363
1518
|
(function (FileState) {
|
|
@@ -1785,7 +1940,7 @@ class HttpResponse {
|
|
|
1785
1940
|
/** Content filter results for a prompt sent in the request. Note: This is sent only in the first stream chunk and only if no candidates were generated due to content violations. */
|
|
1786
1941
|
class GenerateContentResponsePromptFeedback {
|
|
1787
1942
|
}
|
|
1788
|
-
/** Usage metadata about response
|
|
1943
|
+
/** Usage metadata about the content generation request and response. This message provides a detailed breakdown of token usage and other relevant metrics. This data type is not supported in Gemini API. */
|
|
1789
1944
|
class GenerateContentResponseUsageMetadata {
|
|
1790
1945
|
}
|
|
1791
1946
|
/** Response message for PredictionService.GenerateContent. */
|
|
@@ -1827,6 +1982,7 @@ class GenerateContentResponse {
|
|
|
1827
1982
|
for (const [fieldName, fieldValue] of Object.entries(part)) {
|
|
1828
1983
|
if (fieldName !== 'text' &&
|
|
1829
1984
|
fieldName !== 'thought' &&
|
|
1985
|
+
fieldName !== 'thoughtSignature' &&
|
|
1830
1986
|
(fieldValue !== null || fieldValue !== undefined)) {
|
|
1831
1987
|
nonTextParts.push(fieldName);
|
|
1832
1988
|
}
|
|
@@ -2050,11 +2206,11 @@ class GenerateVideosOperation {
|
|
|
2050
2206
|
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
2051
2207
|
* @internal
|
|
2052
2208
|
*/
|
|
2053
|
-
_fromAPIResponse({ apiResponse,
|
|
2209
|
+
_fromAPIResponse({ apiResponse, _isVertexAI, }) {
|
|
2054
2210
|
const operation = new GenerateVideosOperation();
|
|
2055
2211
|
let response;
|
|
2056
2212
|
const op = apiResponse;
|
|
2057
|
-
if (
|
|
2213
|
+
if (_isVertexAI) {
|
|
2058
2214
|
response = generateVideosOperationFromVertex$1(op);
|
|
2059
2215
|
}
|
|
2060
2216
|
else {
|
|
@@ -2072,6 +2228,32 @@ class DeleteCachedContentResponse {
|
|
|
2072
2228
|
}
|
|
2073
2229
|
class ListCachedContentsResponse {
|
|
2074
2230
|
}
|
|
2231
|
+
/** Config for documents.list return value. */
|
|
2232
|
+
class ListDocumentsResponse {
|
|
2233
|
+
}
|
|
2234
|
+
/** Config for file_search_stores.list return value. */
|
|
2235
|
+
class ListFileSearchStoresResponse {
|
|
2236
|
+
}
|
|
2237
|
+
/** Response for the resumable upload method. */
|
|
2238
|
+
class UploadToFileSearchStoreResumableResponse {
|
|
2239
|
+
}
|
|
2240
|
+
/** Response for ImportFile to import a File API file with a file search store. */
|
|
2241
|
+
class ImportFileResponse {
|
|
2242
|
+
}
|
|
2243
|
+
/** Long-running operation for importing a file to a FileSearchStore. */
|
|
2244
|
+
class ImportFileOperation {
|
|
2245
|
+
/**
|
|
2246
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
2247
|
+
* @internal
|
|
2248
|
+
*/
|
|
2249
|
+
_fromAPIResponse({ apiResponse, _isVertexAI, }) {
|
|
2250
|
+
const operation = new ImportFileOperation();
|
|
2251
|
+
const op = apiResponse;
|
|
2252
|
+
const response = importFileOperationFromMldev$1(op);
|
|
2253
|
+
Object.assign(operation, response);
|
|
2254
|
+
return operation;
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2075
2257
|
/** Response for the list files method. */
|
|
2076
2258
|
class ListFilesResponse {
|
|
2077
2259
|
}
|
|
@@ -2307,6 +2489,23 @@ class LiveMusicServerMessage {
|
|
|
2307
2489
|
return undefined;
|
|
2308
2490
|
}
|
|
2309
2491
|
}
|
|
2492
|
+
/** The response when long-running operation for uploading a file to a FileSearchStore complete. */
|
|
2493
|
+
class UploadToFileSearchStoreResponse {
|
|
2494
|
+
}
|
|
2495
|
+
/** Long-running operation for uploading a file to a FileSearchStore. */
|
|
2496
|
+
class UploadToFileSearchStoreOperation {
|
|
2497
|
+
/**
|
|
2498
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
2499
|
+
* @internal
|
|
2500
|
+
*/
|
|
2501
|
+
_fromAPIResponse({ apiResponse, _isVertexAI, }) {
|
|
2502
|
+
const operation = new UploadToFileSearchStoreOperation();
|
|
2503
|
+
const op = apiResponse;
|
|
2504
|
+
const response = uploadToFileSearchStoreOperationFromMldev(op);
|
|
2505
|
+
Object.assign(operation, response);
|
|
2506
|
+
return operation;
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2310
2509
|
|
|
2311
2510
|
/**
|
|
2312
2511
|
* @license
|
|
@@ -2317,6 +2516,9 @@ function tModel(apiClient, model) {
|
|
|
2317
2516
|
if (!model || typeof model !== 'string') {
|
|
2318
2517
|
throw new Error('model is required and must be a string');
|
|
2319
2518
|
}
|
|
2519
|
+
if (model.includes('..') || model.includes('?') || model.includes('&')) {
|
|
2520
|
+
throw new Error('invalid model parameter');
|
|
2521
|
+
}
|
|
2320
2522
|
if (apiClient.isVertexAI()) {
|
|
2321
2523
|
if (model.startsWith('publishers/') ||
|
|
2322
2524
|
model.startsWith('projects/') ||
|
|
@@ -3303,6 +3505,12 @@ function batchJobFromVertex(fromObject) {
|
|
|
3303
3505
|
if (fromDest != null) {
|
|
3304
3506
|
setValueByPath(toObject, ['dest'], batchJobDestinationFromVertex(tRecvBatchJobDestination(fromDest)));
|
|
3305
3507
|
}
|
|
3508
|
+
const fromCompletionStats = getValueByPath(fromObject, [
|
|
3509
|
+
'completionStats',
|
|
3510
|
+
]);
|
|
3511
|
+
if (fromCompletionStats != null) {
|
|
3512
|
+
setValueByPath(toObject, ['completionStats'], fromCompletionStats);
|
|
3513
|
+
}
|
|
3306
3514
|
return toObject;
|
|
3307
3515
|
}
|
|
3308
3516
|
function batchJobSourceFromVertex(fromObject) {
|
|
@@ -3935,6 +4143,9 @@ function googleSearchToMldev$4(fromObject) {
|
|
|
3935
4143
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
3936
4144
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
3937
4145
|
}
|
|
4146
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
4147
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
4148
|
+
}
|
|
3938
4149
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
3939
4150
|
'timeRangeFilter',
|
|
3940
4151
|
]);
|
|
@@ -4174,14 +4385,14 @@ function toolToMldev$4(fromObject) {
|
|
|
4174
4385
|
if (fromGoogleSearchRetrieval != null) {
|
|
4175
4386
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
4176
4387
|
}
|
|
4177
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
4178
|
-
if (fromGoogleMaps != null) {
|
|
4179
|
-
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$4(fromGoogleMaps));
|
|
4180
|
-
}
|
|
4181
4388
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
4182
4389
|
if (fromComputerUse != null) {
|
|
4183
4390
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
4184
4391
|
}
|
|
4392
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
4393
|
+
if (fromFileSearch != null) {
|
|
4394
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
4395
|
+
}
|
|
4185
4396
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4186
4397
|
'codeExecution',
|
|
4187
4398
|
]);
|
|
@@ -4191,6 +4402,10 @@ function toolToMldev$4(fromObject) {
|
|
|
4191
4402
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
4192
4403
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
4193
4404
|
}
|
|
4405
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
4406
|
+
if (fromGoogleMaps != null) {
|
|
4407
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$4(fromGoogleMaps));
|
|
4408
|
+
}
|
|
4194
4409
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4195
4410
|
if (fromGoogleSearch != null) {
|
|
4196
4411
|
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
@@ -4214,7 +4429,7 @@ exports.PagedItem = void 0;
|
|
|
4214
4429
|
PagedItem["PAGED_ITEM_TUNING_JOBS"] = "tuningJobs";
|
|
4215
4430
|
PagedItem["PAGED_ITEM_FILES"] = "files";
|
|
4216
4431
|
PagedItem["PAGED_ITEM_CACHED_CONTENTS"] = "cachedContents";
|
|
4217
|
-
PagedItem["
|
|
4432
|
+
PagedItem["PAGED_ITEM_FILE_SEARCH_STORES"] = "fileSearchStores";
|
|
4218
4433
|
PagedItem["PAGED_ITEM_DOCUMENTS"] = "documents";
|
|
4219
4434
|
})(exports.PagedItem || (exports.PagedItem = {}));
|
|
4220
4435
|
/**
|
|
@@ -5168,6 +5383,9 @@ function googleSearchToMldev$3(fromObject) {
|
|
|
5168
5383
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
5169
5384
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
5170
5385
|
}
|
|
5386
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
5387
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
5388
|
+
}
|
|
5171
5389
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
5172
5390
|
'timeRangeFilter',
|
|
5173
5391
|
]);
|
|
@@ -5349,14 +5567,14 @@ function toolToMldev$3(fromObject) {
|
|
|
5349
5567
|
if (fromGoogleSearchRetrieval != null) {
|
|
5350
5568
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
5351
5569
|
}
|
|
5352
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
5353
|
-
if (fromGoogleMaps != null) {
|
|
5354
|
-
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$3(fromGoogleMaps));
|
|
5355
|
-
}
|
|
5356
5570
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
5357
5571
|
if (fromComputerUse != null) {
|
|
5358
5572
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
5359
5573
|
}
|
|
5574
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
5575
|
+
if (fromFileSearch != null) {
|
|
5576
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
5577
|
+
}
|
|
5360
5578
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5361
5579
|
'codeExecution',
|
|
5362
5580
|
]);
|
|
@@ -5366,6 +5584,10 @@ function toolToMldev$3(fromObject) {
|
|
|
5366
5584
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
5367
5585
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
5368
5586
|
}
|
|
5587
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
5588
|
+
if (fromGoogleMaps != null) {
|
|
5589
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$3(fromGoogleMaps));
|
|
5590
|
+
}
|
|
5369
5591
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5370
5592
|
if (fromGoogleSearch != null) {
|
|
5371
5593
|
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
@@ -5400,14 +5622,13 @@ function toolToVertex$2(fromObject) {
|
|
|
5400
5622
|
if (fromGoogleSearchRetrieval != null) {
|
|
5401
5623
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
5402
5624
|
}
|
|
5403
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
5404
|
-
if (fromGoogleMaps != null) {
|
|
5405
|
-
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
5406
|
-
}
|
|
5407
5625
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
5408
5626
|
if (fromComputerUse != null) {
|
|
5409
5627
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
5410
5628
|
}
|
|
5629
|
+
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
5630
|
+
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
5631
|
+
}
|
|
5411
5632
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5412
5633
|
'codeExecution',
|
|
5413
5634
|
]);
|
|
@@ -5420,6 +5641,10 @@ function toolToVertex$2(fromObject) {
|
|
|
5420
5641
|
if (fromEnterpriseWebSearch != null) {
|
|
5421
5642
|
setValueByPath(toObject, ['enterpriseWebSearch'], fromEnterpriseWebSearch);
|
|
5422
5643
|
}
|
|
5644
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
5645
|
+
if (fromGoogleMaps != null) {
|
|
5646
|
+
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
5647
|
+
}
|
|
5423
5648
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5424
5649
|
if (fromGoogleSearch != null) {
|
|
5425
5650
|
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
@@ -6725,6 +6950,12 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
6725
6950
|
if (fromModelSelectionConfig != null) {
|
|
6726
6951
|
setValueByPath(toObject, ['modelConfig'], fromModelSelectionConfig);
|
|
6727
6952
|
}
|
|
6953
|
+
const fromResponseJsonSchema = getValueByPath(fromObject, [
|
|
6954
|
+
'responseJsonSchema',
|
|
6955
|
+
]);
|
|
6956
|
+
if (fromResponseJsonSchema != null) {
|
|
6957
|
+
setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
|
|
6958
|
+
}
|
|
6728
6959
|
const fromAudioTimestamp = getValueByPath(fromObject, [
|
|
6729
6960
|
'audioTimestamp',
|
|
6730
6961
|
]);
|
|
@@ -6771,12 +7002,6 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
6771
7002
|
if (fromPresencePenalty != null) {
|
|
6772
7003
|
setValueByPath(toObject, ['presencePenalty'], fromPresencePenalty);
|
|
6773
7004
|
}
|
|
6774
|
-
const fromResponseJsonSchema = getValueByPath(fromObject, [
|
|
6775
|
-
'responseJsonSchema',
|
|
6776
|
-
]);
|
|
6777
|
-
if (fromResponseJsonSchema != null) {
|
|
6778
|
-
setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
|
|
6779
|
-
}
|
|
6780
7005
|
const fromResponseLogprobs = getValueByPath(fromObject, [
|
|
6781
7006
|
'responseLogprobs',
|
|
6782
7007
|
]);
|
|
@@ -6861,6 +7086,9 @@ function googleSearchToMldev$2(fromObject) {
|
|
|
6861
7086
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
6862
7087
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
6863
7088
|
}
|
|
7089
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
7090
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
7091
|
+
}
|
|
6864
7092
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
6865
7093
|
'timeRangeFilter',
|
|
6866
7094
|
]);
|
|
@@ -7368,14 +7596,14 @@ function toolToMldev$2(fromObject) {
|
|
|
7368
7596
|
if (fromGoogleSearchRetrieval != null) {
|
|
7369
7597
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
7370
7598
|
}
|
|
7371
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
7372
|
-
if (fromGoogleMaps != null) {
|
|
7373
|
-
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$2(fromGoogleMaps));
|
|
7374
|
-
}
|
|
7375
7599
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
7376
7600
|
if (fromComputerUse != null) {
|
|
7377
7601
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
7378
7602
|
}
|
|
7603
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
7604
|
+
if (fromFileSearch != null) {
|
|
7605
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
7606
|
+
}
|
|
7379
7607
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
7380
7608
|
'codeExecution',
|
|
7381
7609
|
]);
|
|
@@ -7385,6 +7613,10 @@ function toolToMldev$2(fromObject) {
|
|
|
7385
7613
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
7386
7614
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
7387
7615
|
}
|
|
7616
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
7617
|
+
if (fromGoogleMaps != null) {
|
|
7618
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$2(fromGoogleMaps));
|
|
7619
|
+
}
|
|
7388
7620
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
7389
7621
|
if (fromGoogleSearch != null) {
|
|
7390
7622
|
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
@@ -7419,14 +7651,13 @@ function toolToVertex$1(fromObject) {
|
|
|
7419
7651
|
if (fromGoogleSearchRetrieval != null) {
|
|
7420
7652
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
7421
7653
|
}
|
|
7422
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
7423
|
-
if (fromGoogleMaps != null) {
|
|
7424
|
-
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
7425
|
-
}
|
|
7426
7654
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
7427
7655
|
if (fromComputerUse != null) {
|
|
7428
7656
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
7429
7657
|
}
|
|
7658
|
+
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
7659
|
+
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
7660
|
+
}
|
|
7430
7661
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
7431
7662
|
'codeExecution',
|
|
7432
7663
|
]);
|
|
@@ -7439,6 +7670,10 @@ function toolToVertex$1(fromObject) {
|
|
|
7439
7670
|
if (fromEnterpriseWebSearch != null) {
|
|
7440
7671
|
setValueByPath(toObject, ['enterpriseWebSearch'], fromEnterpriseWebSearch);
|
|
7441
7672
|
}
|
|
7673
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
7674
|
+
if (fromGoogleMaps != null) {
|
|
7675
|
+
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
7676
|
+
}
|
|
7442
7677
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
7443
7678
|
if (fromGoogleSearch != null) {
|
|
7444
7679
|
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
@@ -9388,6 +9623,12 @@ function generationConfigToVertex(fromObject) {
|
|
|
9388
9623
|
if (fromModelSelectionConfig != null) {
|
|
9389
9624
|
setValueByPath(toObject, ['modelConfig'], fromModelSelectionConfig);
|
|
9390
9625
|
}
|
|
9626
|
+
const fromResponseJsonSchema = getValueByPath(fromObject, [
|
|
9627
|
+
'responseJsonSchema',
|
|
9628
|
+
]);
|
|
9629
|
+
if (fromResponseJsonSchema != null) {
|
|
9630
|
+
setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
|
|
9631
|
+
}
|
|
9391
9632
|
const fromAudioTimestamp = getValueByPath(fromObject, [
|
|
9392
9633
|
'audioTimestamp',
|
|
9393
9634
|
]);
|
|
@@ -9434,12 +9675,6 @@ function generationConfigToVertex(fromObject) {
|
|
|
9434
9675
|
if (fromPresencePenalty != null) {
|
|
9435
9676
|
setValueByPath(toObject, ['presencePenalty'], fromPresencePenalty);
|
|
9436
9677
|
}
|
|
9437
|
-
const fromResponseJsonSchema = getValueByPath(fromObject, [
|
|
9438
|
-
'responseJsonSchema',
|
|
9439
|
-
]);
|
|
9440
|
-
if (fromResponseJsonSchema != null) {
|
|
9441
|
-
setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
|
|
9442
|
-
}
|
|
9443
9678
|
const fromResponseLogprobs = getValueByPath(fromObject, [
|
|
9444
9679
|
'responseLogprobs',
|
|
9445
9680
|
]);
|
|
@@ -9540,6 +9775,9 @@ function googleSearchToMldev$1(fromObject) {
|
|
|
9540
9775
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
9541
9776
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
9542
9777
|
}
|
|
9778
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
9779
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
9780
|
+
}
|
|
9543
9781
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
9544
9782
|
'timeRangeFilter',
|
|
9545
9783
|
]);
|
|
@@ -9777,6 +10015,28 @@ function modelFromMldev(fromObject) {
|
|
|
9777
10015
|
if (fromSupportedActions != null) {
|
|
9778
10016
|
setValueByPath(toObject, ['supportedActions'], fromSupportedActions);
|
|
9779
10017
|
}
|
|
10018
|
+
const fromTemperature = getValueByPath(fromObject, ['temperature']);
|
|
10019
|
+
if (fromTemperature != null) {
|
|
10020
|
+
setValueByPath(toObject, ['temperature'], fromTemperature);
|
|
10021
|
+
}
|
|
10022
|
+
const fromMaxTemperature = getValueByPath(fromObject, [
|
|
10023
|
+
'maxTemperature',
|
|
10024
|
+
]);
|
|
10025
|
+
if (fromMaxTemperature != null) {
|
|
10026
|
+
setValueByPath(toObject, ['maxTemperature'], fromMaxTemperature);
|
|
10027
|
+
}
|
|
10028
|
+
const fromTopP = getValueByPath(fromObject, ['topP']);
|
|
10029
|
+
if (fromTopP != null) {
|
|
10030
|
+
setValueByPath(toObject, ['topP'], fromTopP);
|
|
10031
|
+
}
|
|
10032
|
+
const fromTopK = getValueByPath(fromObject, ['topK']);
|
|
10033
|
+
if (fromTopK != null) {
|
|
10034
|
+
setValueByPath(toObject, ['topK'], fromTopK);
|
|
10035
|
+
}
|
|
10036
|
+
const fromThinking = getValueByPath(fromObject, ['thinking']);
|
|
10037
|
+
if (fromThinking != null) {
|
|
10038
|
+
setValueByPath(toObject, ['thinking'], fromThinking);
|
|
10039
|
+
}
|
|
9780
10040
|
return toObject;
|
|
9781
10041
|
}
|
|
9782
10042
|
function modelFromVertex(fromObject) {
|
|
@@ -9905,7 +10165,7 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
|
9905
10165
|
}
|
|
9906
10166
|
const fromBaseSteps = getValueByPath(fromObject, ['baseSteps']);
|
|
9907
10167
|
if (parentObject !== undefined && fromBaseSteps != null) {
|
|
9908
|
-
setValueByPath(parentObject, ['parameters', '
|
|
10168
|
+
setValueByPath(parentObject, ['parameters', 'baseSteps'], fromBaseSteps);
|
|
9909
10169
|
}
|
|
9910
10170
|
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
9911
10171
|
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
@@ -10242,14 +10502,14 @@ function toolToMldev$1(fromObject) {
|
|
|
10242
10502
|
if (fromGoogleSearchRetrieval != null) {
|
|
10243
10503
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
10244
10504
|
}
|
|
10245
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
10246
|
-
if (fromGoogleMaps != null) {
|
|
10247
|
-
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$1(fromGoogleMaps));
|
|
10248
|
-
}
|
|
10249
10505
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
10250
10506
|
if (fromComputerUse != null) {
|
|
10251
10507
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
10252
10508
|
}
|
|
10509
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
10510
|
+
if (fromFileSearch != null) {
|
|
10511
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
10512
|
+
}
|
|
10253
10513
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
10254
10514
|
'codeExecution',
|
|
10255
10515
|
]);
|
|
@@ -10259,6 +10519,10 @@ function toolToMldev$1(fromObject) {
|
|
|
10259
10519
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
10260
10520
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
10261
10521
|
}
|
|
10522
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
10523
|
+
if (fromGoogleMaps != null) {
|
|
10524
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$1(fromGoogleMaps));
|
|
10525
|
+
}
|
|
10262
10526
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
10263
10527
|
if (fromGoogleSearch != null) {
|
|
10264
10528
|
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
@@ -10293,14 +10557,13 @@ function toolToVertex(fromObject) {
|
|
|
10293
10557
|
if (fromGoogleSearchRetrieval != null) {
|
|
10294
10558
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
10295
10559
|
}
|
|
10296
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
10297
|
-
if (fromGoogleMaps != null) {
|
|
10298
|
-
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
10299
|
-
}
|
|
10300
10560
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
10301
10561
|
if (fromComputerUse != null) {
|
|
10302
10562
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
10303
10563
|
}
|
|
10564
|
+
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
10565
|
+
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
10566
|
+
}
|
|
10304
10567
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
10305
10568
|
'codeExecution',
|
|
10306
10569
|
]);
|
|
@@ -10313,6 +10576,10 @@ function toolToVertex(fromObject) {
|
|
|
10313
10576
|
if (fromEnterpriseWebSearch != null) {
|
|
10314
10577
|
setValueByPath(toObject, ['enterpriseWebSearch'], fromEnterpriseWebSearch);
|
|
10315
10578
|
}
|
|
10579
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
10580
|
+
if (fromGoogleMaps != null) {
|
|
10581
|
+
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
10582
|
+
}
|
|
10316
10583
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
10317
10584
|
if (fromGoogleSearch != null) {
|
|
10318
10585
|
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
@@ -10642,7 +10909,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
10642
10909
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
10643
10910
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
10644
10911
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
10645
|
-
const SDK_VERSION = '1.
|
|
10912
|
+
const SDK_VERSION = '1.29.1'; // x-release-please-version
|
|
10646
10913
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
10647
10914
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
10648
10915
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -11020,6 +11287,15 @@ class ApiClient {
|
|
|
11020
11287
|
await this.clientOptions.auth.addAuthHeaders(headers, url);
|
|
11021
11288
|
return headers;
|
|
11022
11289
|
}
|
|
11290
|
+
getFileName(file) {
|
|
11291
|
+
var _a;
|
|
11292
|
+
let fileName = '';
|
|
11293
|
+
if (typeof file === 'string') {
|
|
11294
|
+
fileName = file.replace(/[/\\]+$/, '');
|
|
11295
|
+
fileName = (_a = fileName.split(/[/\\]/).pop()) !== null && _a !== void 0 ? _a : '';
|
|
11296
|
+
}
|
|
11297
|
+
return fileName;
|
|
11298
|
+
}
|
|
11023
11299
|
/**
|
|
11024
11300
|
* Uploads a file asynchronously using Gemini API only, this is not supported
|
|
11025
11301
|
* in Vertex AI.
|
|
@@ -11032,7 +11308,7 @@ class ApiClient {
|
|
|
11032
11308
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
11033
11309
|
*/
|
|
11034
11310
|
async uploadFile(file, config) {
|
|
11035
|
-
var _a
|
|
11311
|
+
var _a;
|
|
11036
11312
|
const fileToUpload = {};
|
|
11037
11313
|
if (config != null) {
|
|
11038
11314
|
fileToUpload.mimeType = config.mimeType;
|
|
@@ -11050,14 +11326,47 @@ class ApiClient {
|
|
|
11050
11326
|
throw new Error('Can not determine mimeType. Please provide mimeType in the config.');
|
|
11051
11327
|
}
|
|
11052
11328
|
fileToUpload.mimeType = mimeType;
|
|
11053
|
-
|
|
11054
|
-
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
|
|
11058
|
-
const uploadUrl = await this.fetchUploadUrl(fileToUpload, fileName, config);
|
|
11329
|
+
const body = {
|
|
11330
|
+
file: fileToUpload,
|
|
11331
|
+
};
|
|
11332
|
+
const fileName = this.getFileName(file);
|
|
11333
|
+
const path = formatMap('upload/v1beta/files', body['_url']);
|
|
11334
|
+
const uploadUrl = await this.fetchUploadUrl(path, fileToUpload.sizeBytes, fileToUpload.mimeType, fileName, body, config === null || config === void 0 ? void 0 : config.httpOptions);
|
|
11059
11335
|
return uploader.upload(file, uploadUrl, this);
|
|
11060
11336
|
}
|
|
11337
|
+
/**
|
|
11338
|
+
* Uploads a file to a given file search store asynchronously using Gemini API only, this is not supported
|
|
11339
|
+
* in Vertex AI.
|
|
11340
|
+
*
|
|
11341
|
+
* @param fileSearchStoreName The name of the file search store to upload the file to.
|
|
11342
|
+
* @param file The string path to the file to be uploaded or a Blob object.
|
|
11343
|
+
* @param config Optional parameters specified in the `UploadFileConfig`
|
|
11344
|
+
* interface. @see {@link UploadFileConfig}
|
|
11345
|
+
* @return A promise that resolves to a `File` object.
|
|
11346
|
+
* @throws An error if called on a Vertex AI client.
|
|
11347
|
+
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
11348
|
+
*/
|
|
11349
|
+
async uploadFileToFileSearchStore(fileSearchStoreName, file, config) {
|
|
11350
|
+
var _a;
|
|
11351
|
+
const uploader = this.clientOptions.uploader;
|
|
11352
|
+
const fileStat = await uploader.stat(file);
|
|
11353
|
+
const sizeBytes = String(fileStat.size);
|
|
11354
|
+
const mimeType = (_a = config === null || config === void 0 ? void 0 : config.mimeType) !== null && _a !== void 0 ? _a : fileStat.type;
|
|
11355
|
+
if (mimeType === undefined || mimeType === '') {
|
|
11356
|
+
throw new Error('Can not determine mimeType. Please provide mimeType in the config.');
|
|
11357
|
+
}
|
|
11358
|
+
const path = `upload/v1beta/${fileSearchStoreName}:uploadToFileSearchStore`;
|
|
11359
|
+
const fileName = this.getFileName(file);
|
|
11360
|
+
const body = {};
|
|
11361
|
+
if (config === null || config === void 0 ? void 0 : config.customMetadata) {
|
|
11362
|
+
body['customMetadata'] = config.customMetadata;
|
|
11363
|
+
}
|
|
11364
|
+
if (config === null || config === void 0 ? void 0 : config.chunkingConfig) {
|
|
11365
|
+
body['chunkingConfig'] = config.chunkingConfig;
|
|
11366
|
+
}
|
|
11367
|
+
const uploadUrl = await this.fetchUploadUrl(path, sizeBytes, mimeType, fileName, body, config === null || config === void 0 ? void 0 : config.httpOptions);
|
|
11368
|
+
return uploader.uploadToFileSearchStore(file, uploadUrl, this);
|
|
11369
|
+
}
|
|
11061
11370
|
/**
|
|
11062
11371
|
* Downloads a file asynchronously to the specified path.
|
|
11063
11372
|
*
|
|
@@ -11068,23 +11377,20 @@ class ApiClient {
|
|
|
11068
11377
|
const downloader = this.clientOptions.downloader;
|
|
11069
11378
|
await downloader.download(params, this);
|
|
11070
11379
|
}
|
|
11071
|
-
async fetchUploadUrl(
|
|
11380
|
+
async fetchUploadUrl(path, sizeBytes, mimeType, fileName, body, configHttpOptions) {
|
|
11072
11381
|
var _a;
|
|
11073
11382
|
let httpOptions = {};
|
|
11074
|
-
if (
|
|
11075
|
-
httpOptions =
|
|
11383
|
+
if (configHttpOptions) {
|
|
11384
|
+
httpOptions = configHttpOptions;
|
|
11076
11385
|
}
|
|
11077
11386
|
else {
|
|
11078
11387
|
httpOptions = {
|
|
11079
11388
|
apiVersion: '',
|
|
11080
|
-
headers: Object.assign({ 'Content-Type': 'application/json', 'X-Goog-Upload-Protocol': 'resumable', 'X-Goog-Upload-Command': 'start', 'X-Goog-Upload-Header-Content-Length': `${
|
|
11389
|
+
headers: Object.assign({ 'Content-Type': 'application/json', 'X-Goog-Upload-Protocol': 'resumable', 'X-Goog-Upload-Command': 'start', 'X-Goog-Upload-Header-Content-Length': `${sizeBytes}`, 'X-Goog-Upload-Header-Content-Type': `${mimeType}` }, (fileName ? { 'X-Goog-Upload-File-Name': fileName } : {})),
|
|
11081
11390
|
};
|
|
11082
11391
|
}
|
|
11083
|
-
const body = {
|
|
11084
|
-
'file': file,
|
|
11085
|
-
};
|
|
11086
11392
|
const httpResponse = await this.request({
|
|
11087
|
-
path
|
|
11393
|
+
path,
|
|
11088
11394
|
body: JSON.stringify(body),
|
|
11089
11395
|
httpMethod: 'POST',
|
|
11090
11396
|
httpOptions,
|
|
@@ -12088,11 +12394,27 @@ function hasCallableTools(params) {
|
|
|
12088
12394
|
var _a, _b, _c;
|
|
12089
12395
|
return (_c = (_b = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools) === null || _b === void 0 ? void 0 : _b.some((tool) => isCallableTool(tool))) !== null && _c !== void 0 ? _c : false;
|
|
12090
12396
|
}
|
|
12091
|
-
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
|
|
12397
|
+
/**
|
|
12398
|
+
* Returns the indexes of the tools that are not compatible with AFC.
|
|
12399
|
+
*/
|
|
12400
|
+
function findAfcIncompatibleToolIndexes(params) {
|
|
12401
|
+
var _a;
|
|
12402
|
+
// Use number[] for an array of numbers in TypeScript
|
|
12403
|
+
const afcIncompatibleToolIndexes = [];
|
|
12404
|
+
if (!((_a = params === null || params === void 0 ? void 0 : params.config) === null || _a === void 0 ? void 0 : _a.tools)) {
|
|
12405
|
+
return afcIncompatibleToolIndexes;
|
|
12406
|
+
}
|
|
12407
|
+
params.config.tools.forEach((tool, index) => {
|
|
12408
|
+
if (isCallableTool(tool)) {
|
|
12409
|
+
return;
|
|
12410
|
+
}
|
|
12411
|
+
const geminiTool = tool;
|
|
12412
|
+
if (geminiTool.functionDeclarations &&
|
|
12413
|
+
geminiTool.functionDeclarations.length > 0) {
|
|
12414
|
+
afcIncompatibleToolIndexes.push(index);
|
|
12415
|
+
}
|
|
12416
|
+
});
|
|
12417
|
+
return afcIncompatibleToolIndexes;
|
|
12096
12418
|
}
|
|
12097
12419
|
/**
|
|
12098
12420
|
* Returns whether to append automatic function calling history to the
|
|
@@ -12157,8 +12479,12 @@ class Models extends BaseModule {
|
|
|
12157
12479
|
if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
|
|
12158
12480
|
return await this.generateContentInternal(transformedParams);
|
|
12159
12481
|
}
|
|
12160
|
-
|
|
12161
|
-
|
|
12482
|
+
const incompatibleToolIndexes = findAfcIncompatibleToolIndexes(params);
|
|
12483
|
+
if (incompatibleToolIndexes.length > 0) {
|
|
12484
|
+
const formattedIndexes = incompatibleToolIndexes
|
|
12485
|
+
.map((index) => `tools[${index}]`)
|
|
12486
|
+
.join(', ');
|
|
12487
|
+
throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${formattedIndexes}.`);
|
|
12162
12488
|
}
|
|
12163
12489
|
let response;
|
|
12164
12490
|
let functionResponseContent;
|
|
@@ -12245,9 +12571,14 @@ class Models extends BaseModule {
|
|
|
12245
12571
|
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
12246
12572
|
return await this.generateContentStreamInternal(transformedParams);
|
|
12247
12573
|
}
|
|
12248
|
-
|
|
12249
|
-
|
|
12574
|
+
const incompatibleToolIndexes = findAfcIncompatibleToolIndexes(params);
|
|
12575
|
+
if (incompatibleToolIndexes.length > 0) {
|
|
12576
|
+
const formattedIndexes = incompatibleToolIndexes
|
|
12577
|
+
.map((index) => `tools[${index}]`)
|
|
12578
|
+
.join(', ');
|
|
12579
|
+
throw new Error(`Incompatible tools found at ${formattedIndexes}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`);
|
|
12250
12580
|
}
|
|
12581
|
+
return await this.processAfcStream(params);
|
|
12251
12582
|
};
|
|
12252
12583
|
/**
|
|
12253
12584
|
* Generates an image based on a text description and configuration.
|
|
@@ -13643,7 +13974,7 @@ class Operations extends BaseModule {
|
|
|
13643
13974
|
});
|
|
13644
13975
|
return operation._fromAPIResponse({
|
|
13645
13976
|
apiResponse: rawOperation,
|
|
13646
|
-
|
|
13977
|
+
_isVertexAI: true,
|
|
13647
13978
|
});
|
|
13648
13979
|
}
|
|
13649
13980
|
else {
|
|
@@ -13653,7 +13984,7 @@ class Operations extends BaseModule {
|
|
|
13653
13984
|
});
|
|
13654
13985
|
return operation._fromAPIResponse({
|
|
13655
13986
|
apiResponse: rawOperation,
|
|
13656
|
-
|
|
13987
|
+
_isVertexAI: false,
|
|
13657
13988
|
});
|
|
13658
13989
|
}
|
|
13659
13990
|
}
|
|
@@ -13682,7 +14013,7 @@ class Operations extends BaseModule {
|
|
|
13682
14013
|
});
|
|
13683
14014
|
return operation._fromAPIResponse({
|
|
13684
14015
|
apiResponse: rawOperation,
|
|
13685
|
-
|
|
14016
|
+
_isVertexAI: true,
|
|
13686
14017
|
});
|
|
13687
14018
|
}
|
|
13688
14019
|
else {
|
|
@@ -13692,7 +14023,7 @@ class Operations extends BaseModule {
|
|
|
13692
14023
|
});
|
|
13693
14024
|
return operation._fromAPIResponse({
|
|
13694
14025
|
apiResponse: rawOperation,
|
|
13695
|
-
|
|
14026
|
+
_isVertexAI: false,
|
|
13696
14027
|
});
|
|
13697
14028
|
}
|
|
13698
14029
|
}
|
|
@@ -13880,6 +14211,9 @@ function googleSearchToMldev(fromObject) {
|
|
|
13880
14211
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
13881
14212
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
13882
14213
|
}
|
|
14214
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
14215
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
14216
|
+
}
|
|
13883
14217
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
13884
14218
|
'timeRangeFilter',
|
|
13885
14219
|
]);
|
|
@@ -14098,14 +14432,14 @@ function toolToMldev(fromObject) {
|
|
|
14098
14432
|
if (fromGoogleSearchRetrieval != null) {
|
|
14099
14433
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
14100
14434
|
}
|
|
14101
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
14102
|
-
if (fromGoogleMaps != null) {
|
|
14103
|
-
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev(fromGoogleMaps));
|
|
14104
|
-
}
|
|
14105
14435
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
14106
14436
|
if (fromComputerUse != null) {
|
|
14107
14437
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
14108
14438
|
}
|
|
14439
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
14440
|
+
if (fromFileSearch != null) {
|
|
14441
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
14442
|
+
}
|
|
14109
14443
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
14110
14444
|
'codeExecution',
|
|
14111
14445
|
]);
|
|
@@ -14115,6 +14449,10 @@ function toolToMldev(fromObject) {
|
|
|
14115
14449
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
14116
14450
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
14117
14451
|
}
|
|
14452
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
14453
|
+
if (fromGoogleMaps != null) {
|
|
14454
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev(fromGoogleMaps));
|
|
14455
|
+
}
|
|
14118
14456
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
14119
14457
|
if (fromGoogleSearch != null) {
|
|
14120
14458
|
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
@@ -14401,195 +14739,44 @@ class Tokens extends BaseModule {
|
|
|
14401
14739
|
* Copyright 2025 Google LLC
|
|
14402
14740
|
* SPDX-License-Identifier: Apache-2.0
|
|
14403
14741
|
*/
|
|
14404
|
-
|
|
14405
|
-
|
|
14406
|
-
|
|
14407
|
-
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
return;
|
|
14411
|
-
}
|
|
14412
|
-
const vertexAuthOptions = buildGoogleAuthOptions(opts.googleAuthOptions);
|
|
14413
|
-
this.googleAuth = new googleAuthLibrary.GoogleAuth(vertexAuthOptions);
|
|
14414
|
-
}
|
|
14415
|
-
async addAuthHeaders(headers, url) {
|
|
14416
|
-
if (this.apiKey !== undefined) {
|
|
14417
|
-
if (this.apiKey.startsWith('auth_tokens/')) {
|
|
14418
|
-
throw new Error('Ephemeral tokens are only supported by the live API.');
|
|
14419
|
-
}
|
|
14420
|
-
this.addKeyHeader(headers);
|
|
14421
|
-
return;
|
|
14422
|
-
}
|
|
14423
|
-
return this.addGoogleAuthHeaders(headers, url);
|
|
14424
|
-
}
|
|
14425
|
-
addKeyHeader(headers) {
|
|
14426
|
-
if (headers.get(GOOGLE_API_KEY_HEADER) !== null) {
|
|
14427
|
-
return;
|
|
14428
|
-
}
|
|
14429
|
-
if (this.apiKey === undefined) {
|
|
14430
|
-
// This should never happen, this method is only called
|
|
14431
|
-
// when apiKey is set.
|
|
14432
|
-
throw new Error('Trying to set API key header but apiKey is not set');
|
|
14433
|
-
}
|
|
14434
|
-
headers.append(GOOGLE_API_KEY_HEADER, this.apiKey);
|
|
14435
|
-
}
|
|
14436
|
-
async addGoogleAuthHeaders(headers, url) {
|
|
14437
|
-
if (this.googleAuth === undefined) {
|
|
14438
|
-
// This should never happen, addGoogleAuthHeaders should only be
|
|
14439
|
-
// called when there is no apiKey set and in these cases googleAuth
|
|
14440
|
-
// is set.
|
|
14441
|
-
throw new Error('Trying to set google-auth headers but googleAuth is unset');
|
|
14442
|
-
}
|
|
14443
|
-
const authHeaders = await this.googleAuth.getRequestHeaders(url);
|
|
14444
|
-
for (const [key, value] of authHeaders) {
|
|
14445
|
-
if (headers.get(key) !== null) {
|
|
14446
|
-
continue;
|
|
14447
|
-
}
|
|
14448
|
-
headers.append(key, value);
|
|
14449
|
-
}
|
|
14450
|
-
}
|
|
14451
|
-
}
|
|
14452
|
-
function buildGoogleAuthOptions(googleAuthOptions) {
|
|
14453
|
-
let authOptions;
|
|
14454
|
-
if (!googleAuthOptions) {
|
|
14455
|
-
authOptions = {
|
|
14456
|
-
scopes: [REQUIRED_VERTEX_AI_SCOPE],
|
|
14457
|
-
};
|
|
14458
|
-
return authOptions;
|
|
14459
|
-
}
|
|
14460
|
-
else {
|
|
14461
|
-
authOptions = googleAuthOptions;
|
|
14462
|
-
if (!authOptions.scopes) {
|
|
14463
|
-
authOptions.scopes = [REQUIRED_VERTEX_AI_SCOPE];
|
|
14464
|
-
return authOptions;
|
|
14465
|
-
}
|
|
14466
|
-
else if ((typeof authOptions.scopes === 'string' &&
|
|
14467
|
-
authOptions.scopes !== REQUIRED_VERTEX_AI_SCOPE) ||
|
|
14468
|
-
(Array.isArray(authOptions.scopes) &&
|
|
14469
|
-
authOptions.scopes.indexOf(REQUIRED_VERTEX_AI_SCOPE) < 0)) {
|
|
14470
|
-
throw new Error(`Invalid auth scopes. Scopes must include: ${REQUIRED_VERTEX_AI_SCOPE}`);
|
|
14471
|
-
}
|
|
14472
|
-
return authOptions;
|
|
14473
|
-
}
|
|
14474
|
-
}
|
|
14475
|
-
|
|
14476
|
-
/**
|
|
14477
|
-
* @license
|
|
14478
|
-
* Copyright 2025 Google LLC
|
|
14479
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
14480
|
-
*/
|
|
14481
|
-
class NodeDownloader {
|
|
14482
|
-
async download(params, apiClient) {
|
|
14483
|
-
if (params.downloadPath) {
|
|
14484
|
-
const response = await downloadFile(params, apiClient);
|
|
14485
|
-
if (response instanceof HttpResponse) {
|
|
14486
|
-
const writer = fs.createWriteStream(params.downloadPath);
|
|
14487
|
-
const body = node_stream.Readable.fromWeb(response.responseInternal.body);
|
|
14488
|
-
body.pipe(writer);
|
|
14489
|
-
await promises.finished(writer);
|
|
14490
|
-
}
|
|
14491
|
-
else {
|
|
14492
|
-
try {
|
|
14493
|
-
await fs$1.writeFile(params.downloadPath, response, {
|
|
14494
|
-
encoding: 'base64',
|
|
14495
|
-
});
|
|
14496
|
-
}
|
|
14497
|
-
catch (error) {
|
|
14498
|
-
throw new Error(`Failed to write file to ${params.downloadPath}: ${error}`);
|
|
14499
|
-
}
|
|
14500
|
-
}
|
|
14501
|
-
}
|
|
14502
|
-
}
|
|
14503
|
-
}
|
|
14504
|
-
async function downloadFile(params, apiClient) {
|
|
14505
|
-
var _a, _b, _c;
|
|
14506
|
-
const name = tFileName(params.file);
|
|
14507
|
-
if (name !== undefined) {
|
|
14508
|
-
return await apiClient.request({
|
|
14509
|
-
path: `files/${name}:download`,
|
|
14510
|
-
httpMethod: 'GET',
|
|
14511
|
-
queryParams: {
|
|
14512
|
-
'alt': 'media',
|
|
14513
|
-
},
|
|
14514
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
14515
|
-
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
14516
|
-
});
|
|
14517
|
-
}
|
|
14518
|
-
else if (isGeneratedVideo(params.file)) {
|
|
14519
|
-
const videoBytes = (_c = params.file.video) === null || _c === void 0 ? void 0 : _c.videoBytes;
|
|
14520
|
-
if (typeof videoBytes === 'string') {
|
|
14521
|
-
return videoBytes;
|
|
14522
|
-
}
|
|
14523
|
-
else {
|
|
14524
|
-
throw new Error('Failed to download generated video, Uri or videoBytes not found.');
|
|
14525
|
-
}
|
|
14526
|
-
}
|
|
14527
|
-
else if (isVideo(params.file)) {
|
|
14528
|
-
const videoBytes = params.file.videoBytes;
|
|
14529
|
-
if (typeof videoBytes === 'string') {
|
|
14530
|
-
return videoBytes;
|
|
14531
|
-
}
|
|
14532
|
-
else {
|
|
14533
|
-
throw new Error('Failed to download video, Uri or videoBytes not found.');
|
|
14534
|
-
}
|
|
14535
|
-
}
|
|
14536
|
-
else {
|
|
14537
|
-
throw new Error('Unsupported file type');
|
|
14742
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
14743
|
+
function createFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
14744
|
+
const toObject = {};
|
|
14745
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
14746
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
14747
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
14538
14748
|
}
|
|
14749
|
+
return toObject;
|
|
14539
14750
|
}
|
|
14540
|
-
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
|
|
14544
|
-
|
|
14545
|
-
*/
|
|
14546
|
-
class NodeWebSocketFactory {
|
|
14547
|
-
create(url, headers, callbacks) {
|
|
14548
|
-
return new NodeWebSocket(url, headers, callbacks);
|
|
14751
|
+
function createFileSearchStoreParametersToMldev(fromObject) {
|
|
14752
|
+
const toObject = {};
|
|
14753
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14754
|
+
if (fromConfig != null) {
|
|
14755
|
+
createFileSearchStoreConfigToMldev(fromConfig, toObject);
|
|
14549
14756
|
}
|
|
14757
|
+
return toObject;
|
|
14550
14758
|
}
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14555
|
-
|
|
14556
|
-
}
|
|
14557
|
-
connect() {
|
|
14558
|
-
this.ws = new NodeWs__namespace.WebSocket(this.url, { headers: this.headers });
|
|
14559
|
-
this.ws.onopen = this.callbacks.onopen;
|
|
14560
|
-
this.ws.onerror = this.callbacks.onerror;
|
|
14561
|
-
this.ws.onclose = this.callbacks.onclose;
|
|
14562
|
-
this.ws.onmessage = this.callbacks.onmessage;
|
|
14563
|
-
}
|
|
14564
|
-
send(message) {
|
|
14565
|
-
if (this.ws === undefined) {
|
|
14566
|
-
throw new Error('WebSocket is not connected');
|
|
14567
|
-
}
|
|
14568
|
-
this.ws.send(message);
|
|
14569
|
-
}
|
|
14570
|
-
close() {
|
|
14571
|
-
if (this.ws === undefined) {
|
|
14572
|
-
throw new Error('WebSocket is not connected');
|
|
14573
|
-
}
|
|
14574
|
-
this.ws.close();
|
|
14759
|
+
function deleteFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
14760
|
+
const toObject = {};
|
|
14761
|
+
const fromForce = getValueByPath(fromObject, ['force']);
|
|
14762
|
+
if (parentObject !== undefined && fromForce != null) {
|
|
14763
|
+
setValueByPath(parentObject, ['_query', 'force'], fromForce);
|
|
14575
14764
|
}
|
|
14765
|
+
return toObject;
|
|
14576
14766
|
}
|
|
14577
|
-
|
|
14578
|
-
/**
|
|
14579
|
-
* @license
|
|
14580
|
-
* Copyright 2025 Google LLC
|
|
14581
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
14582
|
-
*/
|
|
14583
|
-
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
14584
|
-
function cancelTuningJobParametersToMldev(fromObject, _rootObject) {
|
|
14767
|
+
function deleteFileSearchStoreParametersToMldev(fromObject) {
|
|
14585
14768
|
const toObject = {};
|
|
14586
14769
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
14587
14770
|
if (fromName != null) {
|
|
14588
14771
|
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
14589
14772
|
}
|
|
14773
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14774
|
+
if (fromConfig != null) {
|
|
14775
|
+
deleteFileSearchStoreConfigToMldev(fromConfig, toObject);
|
|
14776
|
+
}
|
|
14590
14777
|
return toObject;
|
|
14591
14778
|
}
|
|
14592
|
-
function
|
|
14779
|
+
function getFileSearchStoreParametersToMldev(fromObject) {
|
|
14593
14780
|
const toObject = {};
|
|
14594
14781
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
14595
14782
|
if (fromName != null) {
|
|
@@ -14597,23 +14784,921 @@ function cancelTuningJobParametersToVertex(fromObject, _rootObject) {
|
|
|
14597
14784
|
}
|
|
14598
14785
|
return toObject;
|
|
14599
14786
|
}
|
|
14600
|
-
function
|
|
14787
|
+
function importFileConfigToMldev(fromObject, parentObject) {
|
|
14601
14788
|
const toObject = {};
|
|
14602
|
-
|
|
14603
|
-
|
|
14604
|
-
}
|
|
14605
|
-
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
14606
|
-
'tunedModelDisplayName',
|
|
14789
|
+
const fromCustomMetadata = getValueByPath(fromObject, [
|
|
14790
|
+
'customMetadata',
|
|
14607
14791
|
]);
|
|
14608
|
-
if (parentObject !== undefined &&
|
|
14609
|
-
|
|
14610
|
-
|
|
14611
|
-
|
|
14612
|
-
|
|
14792
|
+
if (parentObject !== undefined && fromCustomMetadata != null) {
|
|
14793
|
+
let transformedList = fromCustomMetadata;
|
|
14794
|
+
if (Array.isArray(transformedList)) {
|
|
14795
|
+
transformedList = transformedList.map((item) => {
|
|
14796
|
+
return item;
|
|
14797
|
+
});
|
|
14798
|
+
}
|
|
14799
|
+
setValueByPath(parentObject, ['customMetadata'], transformedList);
|
|
14613
14800
|
}
|
|
14614
|
-
const
|
|
14615
|
-
|
|
14616
|
-
|
|
14801
|
+
const fromChunkingConfig = getValueByPath(fromObject, [
|
|
14802
|
+
'chunkingConfig',
|
|
14803
|
+
]);
|
|
14804
|
+
if (parentObject !== undefined && fromChunkingConfig != null) {
|
|
14805
|
+
setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
|
|
14806
|
+
}
|
|
14807
|
+
return toObject;
|
|
14808
|
+
}
|
|
14809
|
+
function importFileOperationFromMldev(fromObject) {
|
|
14810
|
+
const toObject = {};
|
|
14811
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
14812
|
+
if (fromName != null) {
|
|
14813
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
14814
|
+
}
|
|
14815
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
14816
|
+
if (fromMetadata != null) {
|
|
14817
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
14818
|
+
}
|
|
14819
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
14820
|
+
if (fromDone != null) {
|
|
14821
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
14822
|
+
}
|
|
14823
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
14824
|
+
if (fromError != null) {
|
|
14825
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
14826
|
+
}
|
|
14827
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
14828
|
+
if (fromResponse != null) {
|
|
14829
|
+
setValueByPath(toObject, ['response'], importFileResponseFromMldev(fromResponse));
|
|
14830
|
+
}
|
|
14831
|
+
return toObject;
|
|
14832
|
+
}
|
|
14833
|
+
function importFileParametersToMldev(fromObject) {
|
|
14834
|
+
const toObject = {};
|
|
14835
|
+
const fromFileSearchStoreName = getValueByPath(fromObject, [
|
|
14836
|
+
'fileSearchStoreName',
|
|
14837
|
+
]);
|
|
14838
|
+
if (fromFileSearchStoreName != null) {
|
|
14839
|
+
setValueByPath(toObject, ['_url', 'file_search_store_name'], fromFileSearchStoreName);
|
|
14840
|
+
}
|
|
14841
|
+
const fromFileName = getValueByPath(fromObject, ['fileName']);
|
|
14842
|
+
if (fromFileName != null) {
|
|
14843
|
+
setValueByPath(toObject, ['fileName'], fromFileName);
|
|
14844
|
+
}
|
|
14845
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14846
|
+
if (fromConfig != null) {
|
|
14847
|
+
importFileConfigToMldev(fromConfig, toObject);
|
|
14848
|
+
}
|
|
14849
|
+
return toObject;
|
|
14850
|
+
}
|
|
14851
|
+
function importFileResponseFromMldev(fromObject) {
|
|
14852
|
+
const toObject = {};
|
|
14853
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
14854
|
+
'sdkHttpResponse',
|
|
14855
|
+
]);
|
|
14856
|
+
if (fromSdkHttpResponse != null) {
|
|
14857
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
14858
|
+
}
|
|
14859
|
+
const fromParent = getValueByPath(fromObject, ['parent']);
|
|
14860
|
+
if (fromParent != null) {
|
|
14861
|
+
setValueByPath(toObject, ['parent'], fromParent);
|
|
14862
|
+
}
|
|
14863
|
+
const fromDocumentName = getValueByPath(fromObject, ['documentName']);
|
|
14864
|
+
if (fromDocumentName != null) {
|
|
14865
|
+
setValueByPath(toObject, ['documentName'], fromDocumentName);
|
|
14866
|
+
}
|
|
14867
|
+
return toObject;
|
|
14868
|
+
}
|
|
14869
|
+
function listFileSearchStoresConfigToMldev(fromObject, parentObject) {
|
|
14870
|
+
const toObject = {};
|
|
14871
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
14872
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
14873
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
14874
|
+
}
|
|
14875
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
14876
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
14877
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
14878
|
+
}
|
|
14879
|
+
return toObject;
|
|
14880
|
+
}
|
|
14881
|
+
function listFileSearchStoresParametersToMldev(fromObject) {
|
|
14882
|
+
const toObject = {};
|
|
14883
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14884
|
+
if (fromConfig != null) {
|
|
14885
|
+
listFileSearchStoresConfigToMldev(fromConfig, toObject);
|
|
14886
|
+
}
|
|
14887
|
+
return toObject;
|
|
14888
|
+
}
|
|
14889
|
+
function listFileSearchStoresResponseFromMldev(fromObject) {
|
|
14890
|
+
const toObject = {};
|
|
14891
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
14892
|
+
'sdkHttpResponse',
|
|
14893
|
+
]);
|
|
14894
|
+
if (fromSdkHttpResponse != null) {
|
|
14895
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
14896
|
+
}
|
|
14897
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
14898
|
+
'nextPageToken',
|
|
14899
|
+
]);
|
|
14900
|
+
if (fromNextPageToken != null) {
|
|
14901
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
14902
|
+
}
|
|
14903
|
+
const fromFileSearchStores = getValueByPath(fromObject, [
|
|
14904
|
+
'fileSearchStores',
|
|
14905
|
+
]);
|
|
14906
|
+
if (fromFileSearchStores != null) {
|
|
14907
|
+
let transformedList = fromFileSearchStores;
|
|
14908
|
+
if (Array.isArray(transformedList)) {
|
|
14909
|
+
transformedList = transformedList.map((item) => {
|
|
14910
|
+
return item;
|
|
14911
|
+
});
|
|
14912
|
+
}
|
|
14913
|
+
setValueByPath(toObject, ['fileSearchStores'], transformedList);
|
|
14914
|
+
}
|
|
14915
|
+
return toObject;
|
|
14916
|
+
}
|
|
14917
|
+
function uploadToFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
14918
|
+
const toObject = {};
|
|
14919
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
14920
|
+
if (parentObject !== undefined && fromMimeType != null) {
|
|
14921
|
+
setValueByPath(parentObject, ['mimeType'], fromMimeType);
|
|
14922
|
+
}
|
|
14923
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
14924
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
14925
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
14926
|
+
}
|
|
14927
|
+
const fromCustomMetadata = getValueByPath(fromObject, [
|
|
14928
|
+
'customMetadata',
|
|
14929
|
+
]);
|
|
14930
|
+
if (parentObject !== undefined && fromCustomMetadata != null) {
|
|
14931
|
+
let transformedList = fromCustomMetadata;
|
|
14932
|
+
if (Array.isArray(transformedList)) {
|
|
14933
|
+
transformedList = transformedList.map((item) => {
|
|
14934
|
+
return item;
|
|
14935
|
+
});
|
|
14936
|
+
}
|
|
14937
|
+
setValueByPath(parentObject, ['customMetadata'], transformedList);
|
|
14938
|
+
}
|
|
14939
|
+
const fromChunkingConfig = getValueByPath(fromObject, [
|
|
14940
|
+
'chunkingConfig',
|
|
14941
|
+
]);
|
|
14942
|
+
if (parentObject !== undefined && fromChunkingConfig != null) {
|
|
14943
|
+
setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
|
|
14944
|
+
}
|
|
14945
|
+
return toObject;
|
|
14946
|
+
}
|
|
14947
|
+
function uploadToFileSearchStoreParametersToMldev(fromObject) {
|
|
14948
|
+
const toObject = {};
|
|
14949
|
+
const fromFileSearchStoreName = getValueByPath(fromObject, [
|
|
14950
|
+
'fileSearchStoreName',
|
|
14951
|
+
]);
|
|
14952
|
+
if (fromFileSearchStoreName != null) {
|
|
14953
|
+
setValueByPath(toObject, ['_url', 'file_search_store_name'], fromFileSearchStoreName);
|
|
14954
|
+
}
|
|
14955
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14956
|
+
if (fromConfig != null) {
|
|
14957
|
+
uploadToFileSearchStoreConfigToMldev(fromConfig, toObject);
|
|
14958
|
+
}
|
|
14959
|
+
return toObject;
|
|
14960
|
+
}
|
|
14961
|
+
function uploadToFileSearchStoreResumableResponseFromMldev(fromObject) {
|
|
14962
|
+
const toObject = {};
|
|
14963
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
14964
|
+
'sdkHttpResponse',
|
|
14965
|
+
]);
|
|
14966
|
+
if (fromSdkHttpResponse != null) {
|
|
14967
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
14968
|
+
}
|
|
14969
|
+
return toObject;
|
|
14970
|
+
}
|
|
14971
|
+
|
|
14972
|
+
/**
|
|
14973
|
+
* @license
|
|
14974
|
+
* Copyright 2025 Google LLC
|
|
14975
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
14976
|
+
*/
|
|
14977
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
14978
|
+
function deleteDocumentConfigToMldev(fromObject, parentObject) {
|
|
14979
|
+
const toObject = {};
|
|
14980
|
+
const fromForce = getValueByPath(fromObject, ['force']);
|
|
14981
|
+
if (parentObject !== undefined && fromForce != null) {
|
|
14982
|
+
setValueByPath(parentObject, ['_query', 'force'], fromForce);
|
|
14983
|
+
}
|
|
14984
|
+
return toObject;
|
|
14985
|
+
}
|
|
14986
|
+
function deleteDocumentParametersToMldev(fromObject) {
|
|
14987
|
+
const toObject = {};
|
|
14988
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
14989
|
+
if (fromName != null) {
|
|
14990
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
14991
|
+
}
|
|
14992
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14993
|
+
if (fromConfig != null) {
|
|
14994
|
+
deleteDocumentConfigToMldev(fromConfig, toObject);
|
|
14995
|
+
}
|
|
14996
|
+
return toObject;
|
|
14997
|
+
}
|
|
14998
|
+
function getDocumentParametersToMldev(fromObject) {
|
|
14999
|
+
const toObject = {};
|
|
15000
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
15001
|
+
if (fromName != null) {
|
|
15002
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
15003
|
+
}
|
|
15004
|
+
return toObject;
|
|
15005
|
+
}
|
|
15006
|
+
function listDocumentsConfigToMldev(fromObject, parentObject) {
|
|
15007
|
+
const toObject = {};
|
|
15008
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
15009
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
15010
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
15011
|
+
}
|
|
15012
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
15013
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
15014
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
15015
|
+
}
|
|
15016
|
+
return toObject;
|
|
15017
|
+
}
|
|
15018
|
+
function listDocumentsParametersToMldev(fromObject) {
|
|
15019
|
+
const toObject = {};
|
|
15020
|
+
const fromParent = getValueByPath(fromObject, ['parent']);
|
|
15021
|
+
if (fromParent != null) {
|
|
15022
|
+
setValueByPath(toObject, ['_url', 'parent'], fromParent);
|
|
15023
|
+
}
|
|
15024
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
15025
|
+
if (fromConfig != null) {
|
|
15026
|
+
listDocumentsConfigToMldev(fromConfig, toObject);
|
|
15027
|
+
}
|
|
15028
|
+
return toObject;
|
|
15029
|
+
}
|
|
15030
|
+
function listDocumentsResponseFromMldev(fromObject) {
|
|
15031
|
+
const toObject = {};
|
|
15032
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
15033
|
+
'sdkHttpResponse',
|
|
15034
|
+
]);
|
|
15035
|
+
if (fromSdkHttpResponse != null) {
|
|
15036
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
15037
|
+
}
|
|
15038
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
15039
|
+
'nextPageToken',
|
|
15040
|
+
]);
|
|
15041
|
+
if (fromNextPageToken != null) {
|
|
15042
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
15043
|
+
}
|
|
15044
|
+
const fromDocuments = getValueByPath(fromObject, ['documents']);
|
|
15045
|
+
if (fromDocuments != null) {
|
|
15046
|
+
let transformedList = fromDocuments;
|
|
15047
|
+
if (Array.isArray(transformedList)) {
|
|
15048
|
+
transformedList = transformedList.map((item) => {
|
|
15049
|
+
return item;
|
|
15050
|
+
});
|
|
15051
|
+
}
|
|
15052
|
+
setValueByPath(toObject, ['documents'], transformedList);
|
|
15053
|
+
}
|
|
15054
|
+
return toObject;
|
|
15055
|
+
}
|
|
15056
|
+
|
|
15057
|
+
/**
|
|
15058
|
+
* @license
|
|
15059
|
+
* Copyright 2025 Google LLC
|
|
15060
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15061
|
+
*/
|
|
15062
|
+
class Documents extends BaseModule {
|
|
15063
|
+
constructor(apiClient) {
|
|
15064
|
+
super();
|
|
15065
|
+
this.apiClient = apiClient;
|
|
15066
|
+
/**
|
|
15067
|
+
* Lists documents.
|
|
15068
|
+
*
|
|
15069
|
+
* @param params - The parameters for the list request.
|
|
15070
|
+
* @return - A pager of documents.
|
|
15071
|
+
*
|
|
15072
|
+
* @example
|
|
15073
|
+
* ```ts
|
|
15074
|
+
* const documents = await ai.documents.list({config: {'pageSize': 2}});
|
|
15075
|
+
* for await (const document of documents) {
|
|
15076
|
+
* console.log(document);
|
|
15077
|
+
* }
|
|
15078
|
+
* ```
|
|
15079
|
+
*/
|
|
15080
|
+
this.list = async (params) => {
|
|
15081
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_DOCUMENTS, (x) => this.listInternal({
|
|
15082
|
+
parent: params.parent,
|
|
15083
|
+
config: x.config,
|
|
15084
|
+
}), await this.listInternal(params), params);
|
|
15085
|
+
};
|
|
15086
|
+
}
|
|
15087
|
+
/**
|
|
15088
|
+
* Gets a Document.
|
|
15089
|
+
*
|
|
15090
|
+
* @param params - The parameters for getting a document.
|
|
15091
|
+
* @return Document.
|
|
15092
|
+
*/
|
|
15093
|
+
async get(params) {
|
|
15094
|
+
var _a, _b;
|
|
15095
|
+
let response;
|
|
15096
|
+
let path = '';
|
|
15097
|
+
let queryParams = {};
|
|
15098
|
+
if (this.apiClient.isVertexAI()) {
|
|
15099
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15100
|
+
}
|
|
15101
|
+
else {
|
|
15102
|
+
const body = getDocumentParametersToMldev(params);
|
|
15103
|
+
path = formatMap('{name}', body['_url']);
|
|
15104
|
+
queryParams = body['_query'];
|
|
15105
|
+
delete body['_url'];
|
|
15106
|
+
delete body['_query'];
|
|
15107
|
+
response = this.apiClient
|
|
15108
|
+
.request({
|
|
15109
|
+
path: path,
|
|
15110
|
+
queryParams: queryParams,
|
|
15111
|
+
body: JSON.stringify(body),
|
|
15112
|
+
httpMethod: 'GET',
|
|
15113
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15114
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15115
|
+
})
|
|
15116
|
+
.then((httpResponse) => {
|
|
15117
|
+
return httpResponse.json();
|
|
15118
|
+
});
|
|
15119
|
+
return response.then((resp) => {
|
|
15120
|
+
return resp;
|
|
15121
|
+
});
|
|
15122
|
+
}
|
|
15123
|
+
}
|
|
15124
|
+
/**
|
|
15125
|
+
* Deletes a Document.
|
|
15126
|
+
*
|
|
15127
|
+
* @param params - The parameters for deleting a document.
|
|
15128
|
+
*/
|
|
15129
|
+
async delete(params) {
|
|
15130
|
+
var _a, _b;
|
|
15131
|
+
let path = '';
|
|
15132
|
+
let queryParams = {};
|
|
15133
|
+
if (this.apiClient.isVertexAI()) {
|
|
15134
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15135
|
+
}
|
|
15136
|
+
else {
|
|
15137
|
+
const body = deleteDocumentParametersToMldev(params);
|
|
15138
|
+
path = formatMap('{name}', body['_url']);
|
|
15139
|
+
queryParams = body['_query'];
|
|
15140
|
+
delete body['_url'];
|
|
15141
|
+
delete body['_query'];
|
|
15142
|
+
await this.apiClient.request({
|
|
15143
|
+
path: path,
|
|
15144
|
+
queryParams: queryParams,
|
|
15145
|
+
body: JSON.stringify(body),
|
|
15146
|
+
httpMethod: 'DELETE',
|
|
15147
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15148
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15149
|
+
});
|
|
15150
|
+
}
|
|
15151
|
+
}
|
|
15152
|
+
/**
|
|
15153
|
+
* Lists all Documents in a FileSearchStore.
|
|
15154
|
+
*
|
|
15155
|
+
* @param params - The parameters for listing documents.
|
|
15156
|
+
* @return ListDocumentsResponse.
|
|
15157
|
+
*/
|
|
15158
|
+
async listInternal(params) {
|
|
15159
|
+
var _a, _b;
|
|
15160
|
+
let response;
|
|
15161
|
+
let path = '';
|
|
15162
|
+
let queryParams = {};
|
|
15163
|
+
if (this.apiClient.isVertexAI()) {
|
|
15164
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15165
|
+
}
|
|
15166
|
+
else {
|
|
15167
|
+
const body = listDocumentsParametersToMldev(params);
|
|
15168
|
+
path = formatMap('{parent}/documents', body['_url']);
|
|
15169
|
+
queryParams = body['_query'];
|
|
15170
|
+
delete body['_url'];
|
|
15171
|
+
delete body['_query'];
|
|
15172
|
+
response = this.apiClient
|
|
15173
|
+
.request({
|
|
15174
|
+
path: path,
|
|
15175
|
+
queryParams: queryParams,
|
|
15176
|
+
body: JSON.stringify(body),
|
|
15177
|
+
httpMethod: 'GET',
|
|
15178
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15179
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15180
|
+
})
|
|
15181
|
+
.then((httpResponse) => {
|
|
15182
|
+
return httpResponse.json();
|
|
15183
|
+
});
|
|
15184
|
+
return response.then((apiResponse) => {
|
|
15185
|
+
const resp = listDocumentsResponseFromMldev(apiResponse);
|
|
15186
|
+
const typedResp = new ListDocumentsResponse();
|
|
15187
|
+
Object.assign(typedResp, resp);
|
|
15188
|
+
return typedResp;
|
|
15189
|
+
});
|
|
15190
|
+
}
|
|
15191
|
+
}
|
|
15192
|
+
}
|
|
15193
|
+
|
|
15194
|
+
/**
|
|
15195
|
+
* @license
|
|
15196
|
+
* Copyright 2025 Google LLC
|
|
15197
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15198
|
+
*/
|
|
15199
|
+
class FileSearchStores extends BaseModule {
|
|
15200
|
+
constructor(apiClient, documents = new Documents(apiClient)) {
|
|
15201
|
+
super();
|
|
15202
|
+
this.apiClient = apiClient;
|
|
15203
|
+
this.documents = documents;
|
|
15204
|
+
/**
|
|
15205
|
+
* Lists file search stores.
|
|
15206
|
+
*
|
|
15207
|
+
* @param params - The parameters for the list request.
|
|
15208
|
+
* @return - A pager of file search stores.
|
|
15209
|
+
*
|
|
15210
|
+
* @example
|
|
15211
|
+
* ```ts
|
|
15212
|
+
* const fileSearchStores = await ai.fileSearchStores.list({config: {'pageSize': 2}});
|
|
15213
|
+
* for await (const fileSearchStore of fileSearchStores) {
|
|
15214
|
+
* console.log(fileSearchStore);
|
|
15215
|
+
* }
|
|
15216
|
+
* ```
|
|
15217
|
+
*/
|
|
15218
|
+
this.list = async (params = {}) => {
|
|
15219
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_FILE_SEARCH_STORES, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
15220
|
+
};
|
|
15221
|
+
}
|
|
15222
|
+
/**
|
|
15223
|
+
* Uploads a file asynchronously to a given File Search Store.
|
|
15224
|
+
* This method is not available in Vertex AI.
|
|
15225
|
+
* Supported upload sources:
|
|
15226
|
+
* - Node.js: File path (string) or Blob object.
|
|
15227
|
+
* - Browser: Blob object (e.g., File).
|
|
15228
|
+
*
|
|
15229
|
+
* @remarks
|
|
15230
|
+
* The `mimeType` can be specified in the `config` parameter. If omitted:
|
|
15231
|
+
* - For file path (string) inputs, the `mimeType` will be inferred from the
|
|
15232
|
+
* file extension.
|
|
15233
|
+
* - For Blob object inputs, the `mimeType` will be set to the Blob's `type`
|
|
15234
|
+
* property.
|
|
15235
|
+
*
|
|
15236
|
+
* This section can contain multiple paragraphs and code examples.
|
|
15237
|
+
*
|
|
15238
|
+
* @param params - Optional parameters specified in the
|
|
15239
|
+
* `types.UploadToFileSearchStoreParameters` interface.
|
|
15240
|
+
* @see {@link types.UploadToFileSearchStoreParameters#config} for the optional
|
|
15241
|
+
* config in the parameters.
|
|
15242
|
+
* @return A promise that resolves to a long running operation.
|
|
15243
|
+
* @throws An error if called on a Vertex AI client.
|
|
15244
|
+
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
15245
|
+
* the `mimeType` can be provided in the `params.config` parameter.
|
|
15246
|
+
* @throws An error occurs if a suitable upload location cannot be established.
|
|
15247
|
+
*
|
|
15248
|
+
* @example
|
|
15249
|
+
* The following code uploads a file to a given file search store.
|
|
15250
|
+
*
|
|
15251
|
+
* ```ts
|
|
15252
|
+
* const operation = await ai.fileSearchStores.upload({fileSearchStoreName: 'fileSearchStores/foo-bar', file: 'file.txt', config: {
|
|
15253
|
+
* mimeType: 'text/plain',
|
|
15254
|
+
* }});
|
|
15255
|
+
* console.log(operation.name);
|
|
15256
|
+
* ```
|
|
15257
|
+
*/
|
|
15258
|
+
async uploadToFileSearchStore(params) {
|
|
15259
|
+
if (this.apiClient.isVertexAI()) {
|
|
15260
|
+
throw new Error('Vertex AI does not support uploading files to a file search store.');
|
|
15261
|
+
}
|
|
15262
|
+
return this.apiClient.uploadFileToFileSearchStore(params.fileSearchStoreName, params.file, params.config);
|
|
15263
|
+
}
|
|
15264
|
+
/**
|
|
15265
|
+
* Creates a File Search Store.
|
|
15266
|
+
*
|
|
15267
|
+
* @param params - The parameters for creating a File Search Store.
|
|
15268
|
+
* @return FileSearchStore.
|
|
15269
|
+
*/
|
|
15270
|
+
async create(params) {
|
|
15271
|
+
var _a, _b;
|
|
15272
|
+
let response;
|
|
15273
|
+
let path = '';
|
|
15274
|
+
let queryParams = {};
|
|
15275
|
+
if (this.apiClient.isVertexAI()) {
|
|
15276
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15277
|
+
}
|
|
15278
|
+
else {
|
|
15279
|
+
const body = createFileSearchStoreParametersToMldev(params);
|
|
15280
|
+
path = formatMap('fileSearchStores', body['_url']);
|
|
15281
|
+
queryParams = body['_query'];
|
|
15282
|
+
delete body['_url'];
|
|
15283
|
+
delete body['_query'];
|
|
15284
|
+
response = this.apiClient
|
|
15285
|
+
.request({
|
|
15286
|
+
path: path,
|
|
15287
|
+
queryParams: queryParams,
|
|
15288
|
+
body: JSON.stringify(body),
|
|
15289
|
+
httpMethod: 'POST',
|
|
15290
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15291
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15292
|
+
})
|
|
15293
|
+
.then((httpResponse) => {
|
|
15294
|
+
return httpResponse.json();
|
|
15295
|
+
});
|
|
15296
|
+
return response.then((resp) => {
|
|
15297
|
+
return resp;
|
|
15298
|
+
});
|
|
15299
|
+
}
|
|
15300
|
+
}
|
|
15301
|
+
/**
|
|
15302
|
+
* Gets a File Search Store.
|
|
15303
|
+
*
|
|
15304
|
+
* @param params - The parameters for getting a File Search Store.
|
|
15305
|
+
* @return FileSearchStore.
|
|
15306
|
+
*/
|
|
15307
|
+
async get(params) {
|
|
15308
|
+
var _a, _b;
|
|
15309
|
+
let response;
|
|
15310
|
+
let path = '';
|
|
15311
|
+
let queryParams = {};
|
|
15312
|
+
if (this.apiClient.isVertexAI()) {
|
|
15313
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15314
|
+
}
|
|
15315
|
+
else {
|
|
15316
|
+
const body = getFileSearchStoreParametersToMldev(params);
|
|
15317
|
+
path = formatMap('{name}', body['_url']);
|
|
15318
|
+
queryParams = body['_query'];
|
|
15319
|
+
delete body['_url'];
|
|
15320
|
+
delete body['_query'];
|
|
15321
|
+
response = this.apiClient
|
|
15322
|
+
.request({
|
|
15323
|
+
path: path,
|
|
15324
|
+
queryParams: queryParams,
|
|
15325
|
+
body: JSON.stringify(body),
|
|
15326
|
+
httpMethod: 'GET',
|
|
15327
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15328
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15329
|
+
})
|
|
15330
|
+
.then((httpResponse) => {
|
|
15331
|
+
return httpResponse.json();
|
|
15332
|
+
});
|
|
15333
|
+
return response.then((resp) => {
|
|
15334
|
+
return resp;
|
|
15335
|
+
});
|
|
15336
|
+
}
|
|
15337
|
+
}
|
|
15338
|
+
/**
|
|
15339
|
+
* Deletes a File Search Store.
|
|
15340
|
+
*
|
|
15341
|
+
* @param params - The parameters for deleting a File Search Store.
|
|
15342
|
+
*/
|
|
15343
|
+
async delete(params) {
|
|
15344
|
+
var _a, _b;
|
|
15345
|
+
let path = '';
|
|
15346
|
+
let queryParams = {};
|
|
15347
|
+
if (this.apiClient.isVertexAI()) {
|
|
15348
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15349
|
+
}
|
|
15350
|
+
else {
|
|
15351
|
+
const body = deleteFileSearchStoreParametersToMldev(params);
|
|
15352
|
+
path = formatMap('{name}', body['_url']);
|
|
15353
|
+
queryParams = body['_query'];
|
|
15354
|
+
delete body['_url'];
|
|
15355
|
+
delete body['_query'];
|
|
15356
|
+
await this.apiClient.request({
|
|
15357
|
+
path: path,
|
|
15358
|
+
queryParams: queryParams,
|
|
15359
|
+
body: JSON.stringify(body),
|
|
15360
|
+
httpMethod: 'DELETE',
|
|
15361
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15362
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15363
|
+
});
|
|
15364
|
+
}
|
|
15365
|
+
}
|
|
15366
|
+
/**
|
|
15367
|
+
* Lists all FileSearchStore owned by the user.
|
|
15368
|
+
*
|
|
15369
|
+
* @param params - The parameters for listing file search stores.
|
|
15370
|
+
* @return ListFileSearchStoresResponse.
|
|
15371
|
+
*/
|
|
15372
|
+
async listInternal(params) {
|
|
15373
|
+
var _a, _b;
|
|
15374
|
+
let response;
|
|
15375
|
+
let path = '';
|
|
15376
|
+
let queryParams = {};
|
|
15377
|
+
if (this.apiClient.isVertexAI()) {
|
|
15378
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15379
|
+
}
|
|
15380
|
+
else {
|
|
15381
|
+
const body = listFileSearchStoresParametersToMldev(params);
|
|
15382
|
+
path = formatMap('fileSearchStores', body['_url']);
|
|
15383
|
+
queryParams = body['_query'];
|
|
15384
|
+
delete body['_url'];
|
|
15385
|
+
delete body['_query'];
|
|
15386
|
+
response = this.apiClient
|
|
15387
|
+
.request({
|
|
15388
|
+
path: path,
|
|
15389
|
+
queryParams: queryParams,
|
|
15390
|
+
body: JSON.stringify(body),
|
|
15391
|
+
httpMethod: 'GET',
|
|
15392
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15393
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15394
|
+
})
|
|
15395
|
+
.then((httpResponse) => {
|
|
15396
|
+
return httpResponse.json();
|
|
15397
|
+
});
|
|
15398
|
+
return response.then((apiResponse) => {
|
|
15399
|
+
const resp = listFileSearchStoresResponseFromMldev(apiResponse);
|
|
15400
|
+
const typedResp = new ListFileSearchStoresResponse();
|
|
15401
|
+
Object.assign(typedResp, resp);
|
|
15402
|
+
return typedResp;
|
|
15403
|
+
});
|
|
15404
|
+
}
|
|
15405
|
+
}
|
|
15406
|
+
async uploadToFileSearchStoreInternal(params) {
|
|
15407
|
+
var _a, _b;
|
|
15408
|
+
let response;
|
|
15409
|
+
let path = '';
|
|
15410
|
+
let queryParams = {};
|
|
15411
|
+
if (this.apiClient.isVertexAI()) {
|
|
15412
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15413
|
+
}
|
|
15414
|
+
else {
|
|
15415
|
+
const body = uploadToFileSearchStoreParametersToMldev(params);
|
|
15416
|
+
path = formatMap('upload/v1beta/{file_search_store_name}:uploadToFileSearchStore', body['_url']);
|
|
15417
|
+
queryParams = body['_query'];
|
|
15418
|
+
delete body['_url'];
|
|
15419
|
+
delete body['_query'];
|
|
15420
|
+
response = this.apiClient
|
|
15421
|
+
.request({
|
|
15422
|
+
path: path,
|
|
15423
|
+
queryParams: queryParams,
|
|
15424
|
+
body: JSON.stringify(body),
|
|
15425
|
+
httpMethod: 'POST',
|
|
15426
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15427
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15428
|
+
})
|
|
15429
|
+
.then((httpResponse) => {
|
|
15430
|
+
return httpResponse.json();
|
|
15431
|
+
});
|
|
15432
|
+
return response.then((apiResponse) => {
|
|
15433
|
+
const resp = uploadToFileSearchStoreResumableResponseFromMldev(apiResponse);
|
|
15434
|
+
const typedResp = new UploadToFileSearchStoreResumableResponse();
|
|
15435
|
+
Object.assign(typedResp, resp);
|
|
15436
|
+
return typedResp;
|
|
15437
|
+
});
|
|
15438
|
+
}
|
|
15439
|
+
}
|
|
15440
|
+
/**
|
|
15441
|
+
* Imports a File from File Service to a FileSearchStore.
|
|
15442
|
+
*
|
|
15443
|
+
* This is a long-running operation, see aip.dev/151
|
|
15444
|
+
*
|
|
15445
|
+
* @param params - The parameters for importing a file to a file search store.
|
|
15446
|
+
* @return ImportFileOperation.
|
|
15447
|
+
*/
|
|
15448
|
+
async importFile(params) {
|
|
15449
|
+
var _a, _b;
|
|
15450
|
+
let response;
|
|
15451
|
+
let path = '';
|
|
15452
|
+
let queryParams = {};
|
|
15453
|
+
if (this.apiClient.isVertexAI()) {
|
|
15454
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15455
|
+
}
|
|
15456
|
+
else {
|
|
15457
|
+
const body = importFileParametersToMldev(params);
|
|
15458
|
+
path = formatMap('{file_search_store_name}:importFile', body['_url']);
|
|
15459
|
+
queryParams = body['_query'];
|
|
15460
|
+
delete body['_url'];
|
|
15461
|
+
delete body['_query'];
|
|
15462
|
+
response = this.apiClient
|
|
15463
|
+
.request({
|
|
15464
|
+
path: path,
|
|
15465
|
+
queryParams: queryParams,
|
|
15466
|
+
body: JSON.stringify(body),
|
|
15467
|
+
httpMethod: 'POST',
|
|
15468
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15469
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15470
|
+
})
|
|
15471
|
+
.then((httpResponse) => {
|
|
15472
|
+
return httpResponse.json();
|
|
15473
|
+
});
|
|
15474
|
+
return response.then((apiResponse) => {
|
|
15475
|
+
const resp = importFileOperationFromMldev(apiResponse);
|
|
15476
|
+
const typedResp = new ImportFileOperation();
|
|
15477
|
+
Object.assign(typedResp, resp);
|
|
15478
|
+
return typedResp;
|
|
15479
|
+
});
|
|
15480
|
+
}
|
|
15481
|
+
}
|
|
15482
|
+
}
|
|
15483
|
+
|
|
15484
|
+
/**
|
|
15485
|
+
* @license
|
|
15486
|
+
* Copyright 2025 Google LLC
|
|
15487
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15488
|
+
*/
|
|
15489
|
+
const GOOGLE_API_KEY_HEADER = 'x-goog-api-key';
|
|
15490
|
+
const REQUIRED_VERTEX_AI_SCOPE = 'https://www.googleapis.com/auth/cloud-platform';
|
|
15491
|
+
class NodeAuth {
|
|
15492
|
+
constructor(opts) {
|
|
15493
|
+
if (opts.apiKey !== undefined) {
|
|
15494
|
+
this.apiKey = opts.apiKey;
|
|
15495
|
+
return;
|
|
15496
|
+
}
|
|
15497
|
+
const vertexAuthOptions = buildGoogleAuthOptions(opts.googleAuthOptions);
|
|
15498
|
+
this.googleAuth = new googleAuthLibrary.GoogleAuth(vertexAuthOptions);
|
|
15499
|
+
}
|
|
15500
|
+
async addAuthHeaders(headers, url) {
|
|
15501
|
+
if (this.apiKey !== undefined) {
|
|
15502
|
+
if (this.apiKey.startsWith('auth_tokens/')) {
|
|
15503
|
+
throw new Error('Ephemeral tokens are only supported by the live API.');
|
|
15504
|
+
}
|
|
15505
|
+
this.addKeyHeader(headers);
|
|
15506
|
+
return;
|
|
15507
|
+
}
|
|
15508
|
+
return this.addGoogleAuthHeaders(headers, url);
|
|
15509
|
+
}
|
|
15510
|
+
addKeyHeader(headers) {
|
|
15511
|
+
if (headers.get(GOOGLE_API_KEY_HEADER) !== null) {
|
|
15512
|
+
return;
|
|
15513
|
+
}
|
|
15514
|
+
if (this.apiKey === undefined) {
|
|
15515
|
+
// This should never happen, this method is only called
|
|
15516
|
+
// when apiKey is set.
|
|
15517
|
+
throw new Error('Trying to set API key header but apiKey is not set');
|
|
15518
|
+
}
|
|
15519
|
+
headers.append(GOOGLE_API_KEY_HEADER, this.apiKey);
|
|
15520
|
+
}
|
|
15521
|
+
async addGoogleAuthHeaders(headers, url) {
|
|
15522
|
+
if (this.googleAuth === undefined) {
|
|
15523
|
+
// This should never happen, addGoogleAuthHeaders should only be
|
|
15524
|
+
// called when there is no apiKey set and in these cases googleAuth
|
|
15525
|
+
// is set.
|
|
15526
|
+
throw new Error('Trying to set google-auth headers but googleAuth is unset');
|
|
15527
|
+
}
|
|
15528
|
+
const authHeaders = await this.googleAuth.getRequestHeaders(url);
|
|
15529
|
+
for (const [key, value] of authHeaders) {
|
|
15530
|
+
if (headers.get(key) !== null) {
|
|
15531
|
+
continue;
|
|
15532
|
+
}
|
|
15533
|
+
headers.append(key, value);
|
|
15534
|
+
}
|
|
15535
|
+
}
|
|
15536
|
+
}
|
|
15537
|
+
function buildGoogleAuthOptions(googleAuthOptions) {
|
|
15538
|
+
let authOptions;
|
|
15539
|
+
if (!googleAuthOptions) {
|
|
15540
|
+
authOptions = {
|
|
15541
|
+
scopes: [REQUIRED_VERTEX_AI_SCOPE],
|
|
15542
|
+
};
|
|
15543
|
+
return authOptions;
|
|
15544
|
+
}
|
|
15545
|
+
else {
|
|
15546
|
+
authOptions = googleAuthOptions;
|
|
15547
|
+
if (!authOptions.scopes) {
|
|
15548
|
+
authOptions.scopes = [REQUIRED_VERTEX_AI_SCOPE];
|
|
15549
|
+
return authOptions;
|
|
15550
|
+
}
|
|
15551
|
+
else if ((typeof authOptions.scopes === 'string' &&
|
|
15552
|
+
authOptions.scopes !== REQUIRED_VERTEX_AI_SCOPE) ||
|
|
15553
|
+
(Array.isArray(authOptions.scopes) &&
|
|
15554
|
+
authOptions.scopes.indexOf(REQUIRED_VERTEX_AI_SCOPE) < 0)) {
|
|
15555
|
+
throw new Error(`Invalid auth scopes. Scopes must include: ${REQUIRED_VERTEX_AI_SCOPE}`);
|
|
15556
|
+
}
|
|
15557
|
+
return authOptions;
|
|
15558
|
+
}
|
|
15559
|
+
}
|
|
15560
|
+
|
|
15561
|
+
/**
|
|
15562
|
+
* @license
|
|
15563
|
+
* Copyright 2025 Google LLC
|
|
15564
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15565
|
+
*/
|
|
15566
|
+
class NodeDownloader {
|
|
15567
|
+
async download(params, apiClient) {
|
|
15568
|
+
if (params.downloadPath) {
|
|
15569
|
+
const response = await downloadFile(params, apiClient);
|
|
15570
|
+
if (response instanceof HttpResponse) {
|
|
15571
|
+
const writer = fs.createWriteStream(params.downloadPath);
|
|
15572
|
+
const body = node_stream.Readable.fromWeb(response.responseInternal.body);
|
|
15573
|
+
body.pipe(writer);
|
|
15574
|
+
await promises.finished(writer);
|
|
15575
|
+
}
|
|
15576
|
+
else {
|
|
15577
|
+
try {
|
|
15578
|
+
await fs$1.writeFile(params.downloadPath, response, {
|
|
15579
|
+
encoding: 'base64',
|
|
15580
|
+
});
|
|
15581
|
+
}
|
|
15582
|
+
catch (error) {
|
|
15583
|
+
throw new Error(`Failed to write file to ${params.downloadPath}: ${error}`);
|
|
15584
|
+
}
|
|
15585
|
+
}
|
|
15586
|
+
}
|
|
15587
|
+
}
|
|
15588
|
+
}
|
|
15589
|
+
async function downloadFile(params, apiClient) {
|
|
15590
|
+
var _a, _b, _c;
|
|
15591
|
+
const name = tFileName(params.file);
|
|
15592
|
+
if (name !== undefined) {
|
|
15593
|
+
return await apiClient.request({
|
|
15594
|
+
path: `files/${name}:download`,
|
|
15595
|
+
httpMethod: 'GET',
|
|
15596
|
+
queryParams: {
|
|
15597
|
+
'alt': 'media',
|
|
15598
|
+
},
|
|
15599
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15600
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15601
|
+
});
|
|
15602
|
+
}
|
|
15603
|
+
else if (isGeneratedVideo(params.file)) {
|
|
15604
|
+
const videoBytes = (_c = params.file.video) === null || _c === void 0 ? void 0 : _c.videoBytes;
|
|
15605
|
+
if (typeof videoBytes === 'string') {
|
|
15606
|
+
return videoBytes;
|
|
15607
|
+
}
|
|
15608
|
+
else {
|
|
15609
|
+
throw new Error('Failed to download generated video, Uri or videoBytes not found.');
|
|
15610
|
+
}
|
|
15611
|
+
}
|
|
15612
|
+
else if (isVideo(params.file)) {
|
|
15613
|
+
const videoBytes = params.file.videoBytes;
|
|
15614
|
+
if (typeof videoBytes === 'string') {
|
|
15615
|
+
return videoBytes;
|
|
15616
|
+
}
|
|
15617
|
+
else {
|
|
15618
|
+
throw new Error('Failed to download video, Uri or videoBytes not found.');
|
|
15619
|
+
}
|
|
15620
|
+
}
|
|
15621
|
+
else {
|
|
15622
|
+
throw new Error('Unsupported file type');
|
|
15623
|
+
}
|
|
15624
|
+
}
|
|
15625
|
+
|
|
15626
|
+
/**
|
|
15627
|
+
* @license
|
|
15628
|
+
* Copyright 2025 Google LLC
|
|
15629
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15630
|
+
*/
|
|
15631
|
+
class NodeWebSocketFactory {
|
|
15632
|
+
create(url, headers, callbacks) {
|
|
15633
|
+
return new NodeWebSocket(url, headers, callbacks);
|
|
15634
|
+
}
|
|
15635
|
+
}
|
|
15636
|
+
class NodeWebSocket {
|
|
15637
|
+
constructor(url, headers, callbacks) {
|
|
15638
|
+
this.url = url;
|
|
15639
|
+
this.headers = headers;
|
|
15640
|
+
this.callbacks = callbacks;
|
|
15641
|
+
}
|
|
15642
|
+
connect() {
|
|
15643
|
+
this.ws = new NodeWs__namespace.WebSocket(this.url, { headers: this.headers });
|
|
15644
|
+
this.ws.onopen = this.callbacks.onopen;
|
|
15645
|
+
this.ws.onerror = this.callbacks.onerror;
|
|
15646
|
+
this.ws.onclose = this.callbacks.onclose;
|
|
15647
|
+
this.ws.onmessage = this.callbacks.onmessage;
|
|
15648
|
+
}
|
|
15649
|
+
send(message) {
|
|
15650
|
+
if (this.ws === undefined) {
|
|
15651
|
+
throw new Error('WebSocket is not connected');
|
|
15652
|
+
}
|
|
15653
|
+
this.ws.send(message);
|
|
15654
|
+
}
|
|
15655
|
+
close() {
|
|
15656
|
+
if (this.ws === undefined) {
|
|
15657
|
+
throw new Error('WebSocket is not connected');
|
|
15658
|
+
}
|
|
15659
|
+
this.ws.close();
|
|
15660
|
+
}
|
|
15661
|
+
}
|
|
15662
|
+
|
|
15663
|
+
/**
|
|
15664
|
+
* @license
|
|
15665
|
+
* Copyright 2025 Google LLC
|
|
15666
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15667
|
+
*/
|
|
15668
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
15669
|
+
function cancelTuningJobParametersToMldev(fromObject, _rootObject) {
|
|
15670
|
+
const toObject = {};
|
|
15671
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
15672
|
+
if (fromName != null) {
|
|
15673
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
15674
|
+
}
|
|
15675
|
+
return toObject;
|
|
15676
|
+
}
|
|
15677
|
+
function cancelTuningJobParametersToVertex(fromObject, _rootObject) {
|
|
15678
|
+
const toObject = {};
|
|
15679
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
15680
|
+
if (fromName != null) {
|
|
15681
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
15682
|
+
}
|
|
15683
|
+
return toObject;
|
|
15684
|
+
}
|
|
15685
|
+
function createTuningJobConfigToMldev(fromObject, parentObject, _rootObject) {
|
|
15686
|
+
const toObject = {};
|
|
15687
|
+
if (getValueByPath(fromObject, ['validationDataset']) !== undefined) {
|
|
15688
|
+
throw new Error('validationDataset parameter is not supported in Gemini API.');
|
|
15689
|
+
}
|
|
15690
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
15691
|
+
'tunedModelDisplayName',
|
|
15692
|
+
]);
|
|
15693
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
15694
|
+
setValueByPath(parentObject, ['displayName'], fromTunedModelDisplayName);
|
|
15695
|
+
}
|
|
15696
|
+
if (getValueByPath(fromObject, ['description']) !== undefined) {
|
|
15697
|
+
throw new Error('description parameter is not supported in Gemini API.');
|
|
15698
|
+
}
|
|
15699
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
15700
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
15701
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'epochCount'], fromEpochCount);
|
|
14617
15702
|
}
|
|
14618
15703
|
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
14619
15704
|
'learningRateMultiplier',
|
|
@@ -15591,7 +16676,28 @@ const INITIAL_RETRY_DELAY_MS = 1000;
|
|
|
15591
16676
|
const DELAY_MULTIPLIER = 2;
|
|
15592
16677
|
const X_GOOG_UPLOAD_STATUS_HEADER_FIELD = 'x-goog-upload-status';
|
|
15593
16678
|
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
15594
|
-
var _a
|
|
16679
|
+
var _a;
|
|
16680
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
16681
|
+
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
16682
|
+
if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
|
|
16683
|
+
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
16684
|
+
}
|
|
16685
|
+
return responseJson['file'];
|
|
16686
|
+
}
|
|
16687
|
+
async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
|
|
16688
|
+
var _a;
|
|
16689
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
16690
|
+
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
16691
|
+
if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
|
|
16692
|
+
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
16693
|
+
}
|
|
16694
|
+
const resp = uploadToFileSearchStoreOperationFromMldev(responseJson);
|
|
16695
|
+
const typedResp = new UploadToFileSearchStoreOperation();
|
|
16696
|
+
Object.assign(typedResp, resp);
|
|
16697
|
+
return typedResp;
|
|
16698
|
+
}
|
|
16699
|
+
async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
16700
|
+
var _a, _b;
|
|
15595
16701
|
let fileSize = 0;
|
|
15596
16702
|
let offset = 0;
|
|
15597
16703
|
let response = new HttpResponse(new Response());
|
|
@@ -15639,11 +16745,7 @@ async function uploadBlob(file, uploadUrl, apiClient) {
|
|
|
15639
16745
|
throw new Error('All content has been uploaded, but the upload status is not finalized.');
|
|
15640
16746
|
}
|
|
15641
16747
|
}
|
|
15642
|
-
|
|
15643
|
-
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') {
|
|
15644
|
-
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
15645
|
-
}
|
|
15646
|
-
return responseJson['file'];
|
|
16748
|
+
return response;
|
|
15647
16749
|
}
|
|
15648
16750
|
async function getBlobStat(file) {
|
|
15649
16751
|
const fileStat = { size: file.size, type: file.type };
|
|
@@ -15679,6 +16781,14 @@ class NodeUploader {
|
|
|
15679
16781
|
return uploadBlob(file, uploadUrl, apiClient);
|
|
15680
16782
|
}
|
|
15681
16783
|
}
|
|
16784
|
+
async uploadToFileSearchStore(file, uploadUrl, apiClient) {
|
|
16785
|
+
if (typeof file === 'string') {
|
|
16786
|
+
return await this.uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient);
|
|
16787
|
+
}
|
|
16788
|
+
else {
|
|
16789
|
+
return uploadBlobToFileSearchStore(file, uploadUrl, apiClient);
|
|
16790
|
+
}
|
|
16791
|
+
}
|
|
15682
16792
|
/**
|
|
15683
16793
|
* Infers the MIME type of a file based on its extension.
|
|
15684
16794
|
*
|
|
@@ -15770,12 +16880,34 @@ class NodeUploader {
|
|
|
15770
16880
|
return mimeType;
|
|
15771
16881
|
}
|
|
15772
16882
|
async uploadFileFromPath(file, uploadUrl, apiClient) {
|
|
15773
|
-
var _a
|
|
16883
|
+
var _a;
|
|
16884
|
+
const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
|
|
16885
|
+
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
16886
|
+
if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
|
|
16887
|
+
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
16888
|
+
}
|
|
16889
|
+
return responseJson['file'];
|
|
16890
|
+
}
|
|
16891
|
+
async uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient) {
|
|
16892
|
+
var _a;
|
|
16893
|
+
const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
|
|
16894
|
+
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
16895
|
+
if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
|
|
16896
|
+
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
16897
|
+
}
|
|
16898
|
+
const resp = uploadToFileSearchStoreOperationFromMldev(responseJson);
|
|
16899
|
+
const typedResp = new UploadToFileSearchStoreOperation();
|
|
16900
|
+
Object.assign(typedResp, resp);
|
|
16901
|
+
return typedResp;
|
|
16902
|
+
}
|
|
16903
|
+
async uploadFileFromPathInternal(file, uploadUrl, apiClient) {
|
|
16904
|
+
var _a, _b;
|
|
15774
16905
|
let fileSize = 0;
|
|
15775
16906
|
let offset = 0;
|
|
15776
16907
|
let response = new HttpResponse(new Response());
|
|
15777
16908
|
let uploadCommand = 'upload';
|
|
15778
16909
|
let fileHandle;
|
|
16910
|
+
const fileName = path__namespace.basename(file);
|
|
15779
16911
|
try {
|
|
15780
16912
|
fileHandle = await fs__namespace.open(file, 'r');
|
|
15781
16913
|
if (!fileHandle) {
|
|
@@ -15807,6 +16939,7 @@ class NodeUploader {
|
|
|
15807
16939
|
'X-Goog-Upload-Command': uploadCommand,
|
|
15808
16940
|
'X-Goog-Upload-Offset': String(offset),
|
|
15809
16941
|
'Content-Length': String(bytesRead),
|
|
16942
|
+
'X-Goog-Upload-File-Name': fileName,
|
|
15810
16943
|
},
|
|
15811
16944
|
},
|
|
15812
16945
|
});
|
|
@@ -15827,11 +16960,7 @@ class NodeUploader {
|
|
|
15827
16960
|
throw new Error('All content has been uploaded, but the upload status is not finalized.');
|
|
15828
16961
|
}
|
|
15829
16962
|
}
|
|
15830
|
-
|
|
15831
|
-
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') {
|
|
15832
|
-
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
15833
|
-
}
|
|
15834
|
-
return responseJson['file'];
|
|
16963
|
+
return response;
|
|
15835
16964
|
}
|
|
15836
16965
|
finally {
|
|
15837
16966
|
// Ensure the file handle is always closed
|
|
@@ -15970,6 +17099,7 @@ class GoogleGenAI {
|
|
|
15970
17099
|
this.operations = new Operations(this.apiClient);
|
|
15971
17100
|
this.authTokens = new Tokens(this.apiClient);
|
|
15972
17101
|
this.tunings = new Tunings(this.apiClient);
|
|
17102
|
+
this.fileSearchStores = new FileSearchStores(this.apiClient);
|
|
15973
17103
|
}
|
|
15974
17104
|
}
|
|
15975
17105
|
function getEnv(env) {
|
|
@@ -16022,10 +17152,14 @@ exports.GenerateVideosOperation = GenerateVideosOperation;
|
|
|
16022
17152
|
exports.GenerateVideosResponse = GenerateVideosResponse;
|
|
16023
17153
|
exports.GoogleGenAI = GoogleGenAI;
|
|
16024
17154
|
exports.HttpResponse = HttpResponse;
|
|
17155
|
+
exports.ImportFileOperation = ImportFileOperation;
|
|
17156
|
+
exports.ImportFileResponse = ImportFileResponse;
|
|
16025
17157
|
exports.InlinedEmbedContentResponse = InlinedEmbedContentResponse;
|
|
16026
17158
|
exports.InlinedResponse = InlinedResponse;
|
|
16027
17159
|
exports.ListBatchJobsResponse = ListBatchJobsResponse;
|
|
16028
17160
|
exports.ListCachedContentsResponse = ListCachedContentsResponse;
|
|
17161
|
+
exports.ListDocumentsResponse = ListDocumentsResponse;
|
|
17162
|
+
exports.ListFileSearchStoresResponse = ListFileSearchStoresResponse;
|
|
16029
17163
|
exports.ListFilesResponse = ListFilesResponse;
|
|
16030
17164
|
exports.ListModelsResponse = ListModelsResponse;
|
|
16031
17165
|
exports.ListTuningJobsResponse = ListTuningJobsResponse;
|
|
@@ -16047,6 +17181,9 @@ exports.SingleEmbedContentResponse = SingleEmbedContentResponse;
|
|
|
16047
17181
|
exports.StyleReferenceImage = StyleReferenceImage;
|
|
16048
17182
|
exports.SubjectReferenceImage = SubjectReferenceImage;
|
|
16049
17183
|
exports.Tokens = Tokens;
|
|
17184
|
+
exports.UploadToFileSearchStoreOperation = UploadToFileSearchStoreOperation;
|
|
17185
|
+
exports.UploadToFileSearchStoreResponse = UploadToFileSearchStoreResponse;
|
|
17186
|
+
exports.UploadToFileSearchStoreResumableResponse = UploadToFileSearchStoreResumableResponse;
|
|
16050
17187
|
exports.UpscaleImageResponse = UpscaleImageResponse;
|
|
16051
17188
|
exports.createFunctionResponsePartFromBase64 = createFunctionResponsePartFromBase64;
|
|
16052
17189
|
exports.createFunctionResponsePartFromUri = createFunctionResponsePartFromUri;
|