@google/genai 1.28.0 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/genai.d.ts +747 -47
- package/dist/index.cjs +1286 -196
- package/dist/index.mjs +1280 -197
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +1405 -294
- package/dist/node/index.mjs +1398 -295
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +747 -47
- package/dist/web/index.mjs +1291 -210
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +747 -47
- package/package.json +11 -6
package/dist/index.cjs
CHANGED
|
@@ -432,6 +432,90 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
432
432
|
}
|
|
433
433
|
return toObject;
|
|
434
434
|
}
|
|
435
|
+
function importFileOperationFromMldev$1(fromObject) {
|
|
436
|
+
const toObject = {};
|
|
437
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
438
|
+
if (fromName != null) {
|
|
439
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
440
|
+
}
|
|
441
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
442
|
+
if (fromMetadata != null) {
|
|
443
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
444
|
+
}
|
|
445
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
446
|
+
if (fromDone != null) {
|
|
447
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
448
|
+
}
|
|
449
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
450
|
+
if (fromError != null) {
|
|
451
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
452
|
+
}
|
|
453
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
454
|
+
if (fromResponse != null) {
|
|
455
|
+
setValueByPath(toObject, ['response'], importFileResponseFromMldev$1(fromResponse));
|
|
456
|
+
}
|
|
457
|
+
return toObject;
|
|
458
|
+
}
|
|
459
|
+
function importFileResponseFromMldev$1(fromObject) {
|
|
460
|
+
const toObject = {};
|
|
461
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
462
|
+
'sdkHttpResponse',
|
|
463
|
+
]);
|
|
464
|
+
if (fromSdkHttpResponse != null) {
|
|
465
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
466
|
+
}
|
|
467
|
+
const fromParent = getValueByPath(fromObject, ['parent']);
|
|
468
|
+
if (fromParent != null) {
|
|
469
|
+
setValueByPath(toObject, ['parent'], fromParent);
|
|
470
|
+
}
|
|
471
|
+
const fromDocumentName = getValueByPath(fromObject, ['documentName']);
|
|
472
|
+
if (fromDocumentName != null) {
|
|
473
|
+
setValueByPath(toObject, ['documentName'], fromDocumentName);
|
|
474
|
+
}
|
|
475
|
+
return toObject;
|
|
476
|
+
}
|
|
477
|
+
function uploadToFileSearchStoreOperationFromMldev(fromObject) {
|
|
478
|
+
const toObject = {};
|
|
479
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
480
|
+
if (fromName != null) {
|
|
481
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
482
|
+
}
|
|
483
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
484
|
+
if (fromMetadata != null) {
|
|
485
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
486
|
+
}
|
|
487
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
488
|
+
if (fromDone != null) {
|
|
489
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
490
|
+
}
|
|
491
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
492
|
+
if (fromError != null) {
|
|
493
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
494
|
+
}
|
|
495
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
496
|
+
if (fromResponse != null) {
|
|
497
|
+
setValueByPath(toObject, ['response'], uploadToFileSearchStoreResponseFromMldev(fromResponse));
|
|
498
|
+
}
|
|
499
|
+
return toObject;
|
|
500
|
+
}
|
|
501
|
+
function uploadToFileSearchStoreResponseFromMldev(fromObject) {
|
|
502
|
+
const toObject = {};
|
|
503
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
504
|
+
'sdkHttpResponse',
|
|
505
|
+
]);
|
|
506
|
+
if (fromSdkHttpResponse != null) {
|
|
507
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
508
|
+
}
|
|
509
|
+
const fromParent = getValueByPath(fromObject, ['parent']);
|
|
510
|
+
if (fromParent != null) {
|
|
511
|
+
setValueByPath(toObject, ['parent'], fromParent);
|
|
512
|
+
}
|
|
513
|
+
const fromDocumentName = getValueByPath(fromObject, ['documentName']);
|
|
514
|
+
if (fromDocumentName != null) {
|
|
515
|
+
setValueByPath(toObject, ['documentName'], fromDocumentName);
|
|
516
|
+
}
|
|
517
|
+
return toObject;
|
|
518
|
+
}
|
|
435
519
|
function videoFromMldev$1(fromObject) {
|
|
436
520
|
const toObject = {};
|
|
437
521
|
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
@@ -572,6 +656,22 @@ exports.Mode = void 0;
|
|
|
572
656
|
*/
|
|
573
657
|
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
574
658
|
})(exports.Mode || (exports.Mode = {}));
|
|
659
|
+
/** The API spec that the external API implements. This enum is not supported in Gemini API. */
|
|
660
|
+
exports.ApiSpec = void 0;
|
|
661
|
+
(function (ApiSpec) {
|
|
662
|
+
/**
|
|
663
|
+
* Unspecified API spec. This value should not be used.
|
|
664
|
+
*/
|
|
665
|
+
ApiSpec["API_SPEC_UNSPECIFIED"] = "API_SPEC_UNSPECIFIED";
|
|
666
|
+
/**
|
|
667
|
+
* Simple search API spec.
|
|
668
|
+
*/
|
|
669
|
+
ApiSpec["SIMPLE_SEARCH"] = "SIMPLE_SEARCH";
|
|
670
|
+
/**
|
|
671
|
+
* Elastic search API spec.
|
|
672
|
+
*/
|
|
673
|
+
ApiSpec["ELASTIC_SEARCH"] = "ELASTIC_SEARCH";
|
|
674
|
+
})(exports.ApiSpec || (exports.ApiSpec = {}));
|
|
575
675
|
/** Type of auth scheme. This enum is not supported in Gemini API. */
|
|
576
676
|
exports.AuthType = void 0;
|
|
577
677
|
(function (AuthType) {
|
|
@@ -601,22 +701,63 @@ exports.AuthType = void 0;
|
|
|
601
701
|
*/
|
|
602
702
|
AuthType["OIDC_AUTH"] = "OIDC_AUTH";
|
|
603
703
|
})(exports.AuthType || (exports.AuthType = {}));
|
|
604
|
-
/** The
|
|
605
|
-
exports.
|
|
606
|
-
(function (
|
|
704
|
+
/** The location of the API key. This enum is not supported in Gemini API. */
|
|
705
|
+
exports.HttpElementLocation = void 0;
|
|
706
|
+
(function (HttpElementLocation) {
|
|
707
|
+
HttpElementLocation["HTTP_IN_UNSPECIFIED"] = "HTTP_IN_UNSPECIFIED";
|
|
607
708
|
/**
|
|
608
|
-
*
|
|
709
|
+
* Element is in the HTTP request query.
|
|
609
710
|
*/
|
|
610
|
-
|
|
711
|
+
HttpElementLocation["HTTP_IN_QUERY"] = "HTTP_IN_QUERY";
|
|
611
712
|
/**
|
|
612
|
-
*
|
|
713
|
+
* Element is in the HTTP request header.
|
|
613
714
|
*/
|
|
614
|
-
|
|
715
|
+
HttpElementLocation["HTTP_IN_HEADER"] = "HTTP_IN_HEADER";
|
|
615
716
|
/**
|
|
616
|
-
*
|
|
717
|
+
* Element is in the HTTP request path.
|
|
617
718
|
*/
|
|
618
|
-
|
|
619
|
-
|
|
719
|
+
HttpElementLocation["HTTP_IN_PATH"] = "HTTP_IN_PATH";
|
|
720
|
+
/**
|
|
721
|
+
* Element is in the HTTP request body.
|
|
722
|
+
*/
|
|
723
|
+
HttpElementLocation["HTTP_IN_BODY"] = "HTTP_IN_BODY";
|
|
724
|
+
/**
|
|
725
|
+
* Element is in the HTTP request cookie.
|
|
726
|
+
*/
|
|
727
|
+
HttpElementLocation["HTTP_IN_COOKIE"] = "HTTP_IN_COOKIE";
|
|
728
|
+
})(exports.HttpElementLocation || (exports.HttpElementLocation = {}));
|
|
729
|
+
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
730
|
+
exports.PhishBlockThreshold = void 0;
|
|
731
|
+
(function (PhishBlockThreshold) {
|
|
732
|
+
/**
|
|
733
|
+
* Defaults to unspecified.
|
|
734
|
+
*/
|
|
735
|
+
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
736
|
+
/**
|
|
737
|
+
* Blocks Low and above confidence URL that is risky.
|
|
738
|
+
*/
|
|
739
|
+
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
740
|
+
/**
|
|
741
|
+
* Blocks Medium and above confidence URL that is risky.
|
|
742
|
+
*/
|
|
743
|
+
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
744
|
+
/**
|
|
745
|
+
* Blocks High and above confidence URL that is risky.
|
|
746
|
+
*/
|
|
747
|
+
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
748
|
+
/**
|
|
749
|
+
* Blocks Higher and above confidence URL that is risky.
|
|
750
|
+
*/
|
|
751
|
+
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
752
|
+
/**
|
|
753
|
+
* Blocks Very high and above confidence URL that is risky.
|
|
754
|
+
*/
|
|
755
|
+
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
756
|
+
/**
|
|
757
|
+
* Blocks Extremely high confidence URL that is risky.
|
|
758
|
+
*/
|
|
759
|
+
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
760
|
+
})(exports.PhishBlockThreshold || (exports.PhishBlockThreshold = {}));
|
|
620
761
|
/** Harm category. */
|
|
621
762
|
exports.HarmCategory = void 0;
|
|
622
763
|
(function (HarmCategory) {
|
|
@@ -883,7 +1024,7 @@ exports.BlockedReason = void 0;
|
|
|
883
1024
|
*/
|
|
884
1025
|
BlockedReason["JAILBREAK"] = "JAILBREAK";
|
|
885
1026
|
})(exports.BlockedReason || (exports.BlockedReason = {}));
|
|
886
|
-
/** Output only.
|
|
1027
|
+
/** Output only. The traffic type for this request. This enum is not supported in Gemini API. */
|
|
887
1028
|
exports.TrafficType = void 0;
|
|
888
1029
|
(function (TrafficType) {
|
|
889
1030
|
/**
|
|
@@ -891,7 +1032,7 @@ exports.TrafficType = void 0;
|
|
|
891
1032
|
*/
|
|
892
1033
|
TrafficType["TRAFFIC_TYPE_UNSPECIFIED"] = "TRAFFIC_TYPE_UNSPECIFIED";
|
|
893
1034
|
/**
|
|
894
|
-
*
|
|
1035
|
+
* The request was processed using Pay-As-You-Go quota.
|
|
895
1036
|
*/
|
|
896
1037
|
TrafficType["ON_DEMAND"] = "ON_DEMAND";
|
|
897
1038
|
/**
|
|
@@ -1054,6 +1195,10 @@ exports.TuningTask = void 0;
|
|
|
1054
1195
|
* Tuning task for text to video.
|
|
1055
1196
|
*/
|
|
1056
1197
|
TuningTask["TUNING_TASK_T2V"] = "TUNING_TASK_T2V";
|
|
1198
|
+
/**
|
|
1199
|
+
* Tuning task for reference to video.
|
|
1200
|
+
*/
|
|
1201
|
+
TuningTask["TUNING_TASK_R2V"] = "TUNING_TASK_R2V";
|
|
1057
1202
|
})(exports.TuningTask || (exports.TuningTask = {}));
|
|
1058
1203
|
/** Options for feature selection preference. */
|
|
1059
1204
|
exports.FeatureSelectionPreference = void 0;
|
|
@@ -1301,6 +1446,14 @@ exports.TuningMethod = void 0;
|
|
|
1301
1446
|
*/
|
|
1302
1447
|
TuningMethod["PREFERENCE_TUNING"] = "PREFERENCE_TUNING";
|
|
1303
1448
|
})(exports.TuningMethod || (exports.TuningMethod = {}));
|
|
1449
|
+
/** State for the lifecycle of a Document. */
|
|
1450
|
+
exports.DocumentState = void 0;
|
|
1451
|
+
(function (DocumentState) {
|
|
1452
|
+
DocumentState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
|
|
1453
|
+
DocumentState["STATE_PENDING"] = "STATE_PENDING";
|
|
1454
|
+
DocumentState["STATE_ACTIVE"] = "STATE_ACTIVE";
|
|
1455
|
+
DocumentState["STATE_FAILED"] = "STATE_FAILED";
|
|
1456
|
+
})(exports.DocumentState || (exports.DocumentState = {}));
|
|
1304
1457
|
/** State for the lifecycle of a File. */
|
|
1305
1458
|
exports.FileState = void 0;
|
|
1306
1459
|
(function (FileState) {
|
|
@@ -1728,7 +1881,7 @@ class HttpResponse {
|
|
|
1728
1881
|
/** 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. */
|
|
1729
1882
|
class GenerateContentResponsePromptFeedback {
|
|
1730
1883
|
}
|
|
1731
|
-
/** Usage metadata about response
|
|
1884
|
+
/** 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. */
|
|
1732
1885
|
class GenerateContentResponseUsageMetadata {
|
|
1733
1886
|
}
|
|
1734
1887
|
/** Response message for PredictionService.GenerateContent. */
|
|
@@ -1993,11 +2146,11 @@ class GenerateVideosOperation {
|
|
|
1993
2146
|
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1994
2147
|
* @internal
|
|
1995
2148
|
*/
|
|
1996
|
-
_fromAPIResponse({ apiResponse,
|
|
2149
|
+
_fromAPIResponse({ apiResponse, _isVertexAI, }) {
|
|
1997
2150
|
const operation = new GenerateVideosOperation();
|
|
1998
2151
|
let response;
|
|
1999
2152
|
const op = apiResponse;
|
|
2000
|
-
if (
|
|
2153
|
+
if (_isVertexAI) {
|
|
2001
2154
|
response = generateVideosOperationFromVertex$1(op);
|
|
2002
2155
|
}
|
|
2003
2156
|
else {
|
|
@@ -2015,6 +2168,32 @@ class DeleteCachedContentResponse {
|
|
|
2015
2168
|
}
|
|
2016
2169
|
class ListCachedContentsResponse {
|
|
2017
2170
|
}
|
|
2171
|
+
/** Config for documents.list return value. */
|
|
2172
|
+
class ListDocumentsResponse {
|
|
2173
|
+
}
|
|
2174
|
+
/** Config for file_search_stores.list return value. */
|
|
2175
|
+
class ListFileSearchStoresResponse {
|
|
2176
|
+
}
|
|
2177
|
+
/** Response for the resumable upload method. */
|
|
2178
|
+
class UploadToFileSearchStoreResumableResponse {
|
|
2179
|
+
}
|
|
2180
|
+
/** Response for ImportFile to import a File API file with a file search store. */
|
|
2181
|
+
class ImportFileResponse {
|
|
2182
|
+
}
|
|
2183
|
+
/** Long-running operation for importing a file to a FileSearchStore. */
|
|
2184
|
+
class ImportFileOperation {
|
|
2185
|
+
/**
|
|
2186
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
2187
|
+
* @internal
|
|
2188
|
+
*/
|
|
2189
|
+
_fromAPIResponse({ apiResponse, _isVertexAI, }) {
|
|
2190
|
+
const operation = new ImportFileOperation();
|
|
2191
|
+
const op = apiResponse;
|
|
2192
|
+
const response = importFileOperationFromMldev$1(op);
|
|
2193
|
+
Object.assign(operation, response);
|
|
2194
|
+
return operation;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2018
2197
|
/** Response for the list files method. */
|
|
2019
2198
|
class ListFilesResponse {
|
|
2020
2199
|
}
|
|
@@ -2250,6 +2429,23 @@ class LiveMusicServerMessage {
|
|
|
2250
2429
|
return undefined;
|
|
2251
2430
|
}
|
|
2252
2431
|
}
|
|
2432
|
+
/** The response when long-running operation for uploading a file to a FileSearchStore complete. */
|
|
2433
|
+
class UploadToFileSearchStoreResponse {
|
|
2434
|
+
}
|
|
2435
|
+
/** Long-running operation for uploading a file to a FileSearchStore. */
|
|
2436
|
+
class UploadToFileSearchStoreOperation {
|
|
2437
|
+
/**
|
|
2438
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
2439
|
+
* @internal
|
|
2440
|
+
*/
|
|
2441
|
+
_fromAPIResponse({ apiResponse, _isVertexAI, }) {
|
|
2442
|
+
const operation = new UploadToFileSearchStoreOperation();
|
|
2443
|
+
const op = apiResponse;
|
|
2444
|
+
const response = uploadToFileSearchStoreOperationFromMldev(op);
|
|
2445
|
+
Object.assign(operation, response);
|
|
2446
|
+
return operation;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2253
2449
|
|
|
2254
2450
|
/**
|
|
2255
2451
|
* @license
|
|
@@ -3246,6 +3442,12 @@ function batchJobFromVertex(fromObject) {
|
|
|
3246
3442
|
if (fromDest != null) {
|
|
3247
3443
|
setValueByPath(toObject, ['dest'], batchJobDestinationFromVertex(tRecvBatchJobDestination(fromDest)));
|
|
3248
3444
|
}
|
|
3445
|
+
const fromCompletionStats = getValueByPath(fromObject, [
|
|
3446
|
+
'completionStats',
|
|
3447
|
+
]);
|
|
3448
|
+
if (fromCompletionStats != null) {
|
|
3449
|
+
setValueByPath(toObject, ['completionStats'], fromCompletionStats);
|
|
3450
|
+
}
|
|
3249
3451
|
return toObject;
|
|
3250
3452
|
}
|
|
3251
3453
|
function batchJobSourceFromVertex(fromObject) {
|
|
@@ -3878,6 +4080,9 @@ function googleSearchToMldev$4(fromObject) {
|
|
|
3878
4080
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
3879
4081
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
3880
4082
|
}
|
|
4083
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
4084
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
4085
|
+
}
|
|
3881
4086
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
3882
4087
|
'timeRangeFilter',
|
|
3883
4088
|
]);
|
|
@@ -4117,14 +4322,14 @@ function toolToMldev$4(fromObject) {
|
|
|
4117
4322
|
if (fromGoogleSearchRetrieval != null) {
|
|
4118
4323
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
4119
4324
|
}
|
|
4120
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
4121
|
-
if (fromGoogleMaps != null) {
|
|
4122
|
-
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$4(fromGoogleMaps));
|
|
4123
|
-
}
|
|
4124
4325
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
4125
4326
|
if (fromComputerUse != null) {
|
|
4126
4327
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
4127
4328
|
}
|
|
4329
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
4330
|
+
if (fromFileSearch != null) {
|
|
4331
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
4332
|
+
}
|
|
4128
4333
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4129
4334
|
'codeExecution',
|
|
4130
4335
|
]);
|
|
@@ -4134,6 +4339,10 @@ function toolToMldev$4(fromObject) {
|
|
|
4134
4339
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
4135
4340
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
4136
4341
|
}
|
|
4342
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
4343
|
+
if (fromGoogleMaps != null) {
|
|
4344
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$4(fromGoogleMaps));
|
|
4345
|
+
}
|
|
4137
4346
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4138
4347
|
if (fromGoogleSearch != null) {
|
|
4139
4348
|
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
@@ -4157,7 +4366,7 @@ exports.PagedItem = void 0;
|
|
|
4157
4366
|
PagedItem["PAGED_ITEM_TUNING_JOBS"] = "tuningJobs";
|
|
4158
4367
|
PagedItem["PAGED_ITEM_FILES"] = "files";
|
|
4159
4368
|
PagedItem["PAGED_ITEM_CACHED_CONTENTS"] = "cachedContents";
|
|
4160
|
-
PagedItem["
|
|
4369
|
+
PagedItem["PAGED_ITEM_FILE_SEARCH_STORES"] = "fileSearchStores";
|
|
4161
4370
|
PagedItem["PAGED_ITEM_DOCUMENTS"] = "documents";
|
|
4162
4371
|
})(exports.PagedItem || (exports.PagedItem = {}));
|
|
4163
4372
|
/**
|
|
@@ -5111,6 +5320,9 @@ function googleSearchToMldev$3(fromObject) {
|
|
|
5111
5320
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
5112
5321
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
5113
5322
|
}
|
|
5323
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
5324
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
5325
|
+
}
|
|
5114
5326
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
5115
5327
|
'timeRangeFilter',
|
|
5116
5328
|
]);
|
|
@@ -5292,14 +5504,14 @@ function toolToMldev$3(fromObject) {
|
|
|
5292
5504
|
if (fromGoogleSearchRetrieval != null) {
|
|
5293
5505
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
5294
5506
|
}
|
|
5295
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
5296
|
-
if (fromGoogleMaps != null) {
|
|
5297
|
-
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$3(fromGoogleMaps));
|
|
5298
|
-
}
|
|
5299
5507
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
5300
5508
|
if (fromComputerUse != null) {
|
|
5301
5509
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
5302
5510
|
}
|
|
5511
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
5512
|
+
if (fromFileSearch != null) {
|
|
5513
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
5514
|
+
}
|
|
5303
5515
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5304
5516
|
'codeExecution',
|
|
5305
5517
|
]);
|
|
@@ -5309,6 +5521,10 @@ function toolToMldev$3(fromObject) {
|
|
|
5309
5521
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
5310
5522
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
5311
5523
|
}
|
|
5524
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
5525
|
+
if (fromGoogleMaps != null) {
|
|
5526
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$3(fromGoogleMaps));
|
|
5527
|
+
}
|
|
5312
5528
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5313
5529
|
if (fromGoogleSearch != null) {
|
|
5314
5530
|
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
@@ -5343,14 +5559,13 @@ function toolToVertex$2(fromObject) {
|
|
|
5343
5559
|
if (fromGoogleSearchRetrieval != null) {
|
|
5344
5560
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
5345
5561
|
}
|
|
5346
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
5347
|
-
if (fromGoogleMaps != null) {
|
|
5348
|
-
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
5349
|
-
}
|
|
5350
5562
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
5351
5563
|
if (fromComputerUse != null) {
|
|
5352
5564
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
5353
5565
|
}
|
|
5566
|
+
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
5567
|
+
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
5568
|
+
}
|
|
5354
5569
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5355
5570
|
'codeExecution',
|
|
5356
5571
|
]);
|
|
@@ -5363,6 +5578,10 @@ function toolToVertex$2(fromObject) {
|
|
|
5363
5578
|
if (fromEnterpriseWebSearch != null) {
|
|
5364
5579
|
setValueByPath(toObject, ['enterpriseWebSearch'], fromEnterpriseWebSearch);
|
|
5365
5580
|
}
|
|
5581
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
5582
|
+
if (fromGoogleMaps != null) {
|
|
5583
|
+
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
5584
|
+
}
|
|
5366
5585
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5367
5586
|
if (fromGoogleSearch != null) {
|
|
5368
5587
|
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
@@ -6207,7 +6426,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6207
6426
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6208
6427
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6209
6428
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6210
|
-
const SDK_VERSION = '1.
|
|
6429
|
+
const SDK_VERSION = '1.29.0'; // x-release-please-version
|
|
6211
6430
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6212
6431
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6213
6432
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -6585,6 +6804,15 @@ class ApiClient {
|
|
|
6585
6804
|
await this.clientOptions.auth.addAuthHeaders(headers, url);
|
|
6586
6805
|
return headers;
|
|
6587
6806
|
}
|
|
6807
|
+
getFileName(file) {
|
|
6808
|
+
var _a;
|
|
6809
|
+
let fileName = '';
|
|
6810
|
+
if (typeof file === 'string') {
|
|
6811
|
+
fileName = file.replace(/[/\\]+$/, '');
|
|
6812
|
+
fileName = (_a = fileName.split(/[/\\]/).pop()) !== null && _a !== void 0 ? _a : '';
|
|
6813
|
+
}
|
|
6814
|
+
return fileName;
|
|
6815
|
+
}
|
|
6588
6816
|
/**
|
|
6589
6817
|
* Uploads a file asynchronously using Gemini API only, this is not supported
|
|
6590
6818
|
* in Vertex AI.
|
|
@@ -6597,7 +6825,7 @@ class ApiClient {
|
|
|
6597
6825
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
6598
6826
|
*/
|
|
6599
6827
|
async uploadFile(file, config) {
|
|
6600
|
-
var _a
|
|
6828
|
+
var _a;
|
|
6601
6829
|
const fileToUpload = {};
|
|
6602
6830
|
if (config != null) {
|
|
6603
6831
|
fileToUpload.mimeType = config.mimeType;
|
|
@@ -6615,14 +6843,47 @@ class ApiClient {
|
|
|
6615
6843
|
throw new Error('Can not determine mimeType. Please provide mimeType in the config.');
|
|
6616
6844
|
}
|
|
6617
6845
|
fileToUpload.mimeType = mimeType;
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
const uploadUrl = await this.fetchUploadUrl(fileToUpload, fileName, config);
|
|
6846
|
+
const body = {
|
|
6847
|
+
file: fileToUpload,
|
|
6848
|
+
};
|
|
6849
|
+
const fileName = this.getFileName(file);
|
|
6850
|
+
const path = formatMap('upload/v1beta/files', body['_url']);
|
|
6851
|
+
const uploadUrl = await this.fetchUploadUrl(path, fileToUpload.sizeBytes, fileToUpload.mimeType, fileName, body, config === null || config === void 0 ? void 0 : config.httpOptions);
|
|
6624
6852
|
return uploader.upload(file, uploadUrl, this);
|
|
6625
6853
|
}
|
|
6854
|
+
/**
|
|
6855
|
+
* Uploads a file to a given file search store asynchronously using Gemini API only, this is not supported
|
|
6856
|
+
* in Vertex AI.
|
|
6857
|
+
*
|
|
6858
|
+
* @param fileSearchStoreName The name of the file search store to upload the file to.
|
|
6859
|
+
* @param file The string path to the file to be uploaded or a Blob object.
|
|
6860
|
+
* @param config Optional parameters specified in the `UploadFileConfig`
|
|
6861
|
+
* interface. @see {@link UploadFileConfig}
|
|
6862
|
+
* @return A promise that resolves to a `File` object.
|
|
6863
|
+
* @throws An error if called on a Vertex AI client.
|
|
6864
|
+
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
6865
|
+
*/
|
|
6866
|
+
async uploadFileToFileSearchStore(fileSearchStoreName, file, config) {
|
|
6867
|
+
var _a;
|
|
6868
|
+
const uploader = this.clientOptions.uploader;
|
|
6869
|
+
const fileStat = await uploader.stat(file);
|
|
6870
|
+
const sizeBytes = String(fileStat.size);
|
|
6871
|
+
const mimeType = (_a = config === null || config === void 0 ? void 0 : config.mimeType) !== null && _a !== void 0 ? _a : fileStat.type;
|
|
6872
|
+
if (mimeType === undefined || mimeType === '') {
|
|
6873
|
+
throw new Error('Can not determine mimeType. Please provide mimeType in the config.');
|
|
6874
|
+
}
|
|
6875
|
+
const path = `upload/v1beta/${fileSearchStoreName}:uploadToFileSearchStore`;
|
|
6876
|
+
const fileName = this.getFileName(file);
|
|
6877
|
+
const body = {};
|
|
6878
|
+
if (config === null || config === void 0 ? void 0 : config.customMetadata) {
|
|
6879
|
+
body['customMetadata'] = config.customMetadata;
|
|
6880
|
+
}
|
|
6881
|
+
if (config === null || config === void 0 ? void 0 : config.chunkingConfig) {
|
|
6882
|
+
body['chunkingConfig'] = config.chunkingConfig;
|
|
6883
|
+
}
|
|
6884
|
+
const uploadUrl = await this.fetchUploadUrl(path, sizeBytes, mimeType, fileName, body, config === null || config === void 0 ? void 0 : config.httpOptions);
|
|
6885
|
+
return uploader.uploadToFileSearchStore(file, uploadUrl, this);
|
|
6886
|
+
}
|
|
6626
6887
|
/**
|
|
6627
6888
|
* Downloads a file asynchronously to the specified path.
|
|
6628
6889
|
*
|
|
@@ -6633,23 +6894,20 @@ class ApiClient {
|
|
|
6633
6894
|
const downloader = this.clientOptions.downloader;
|
|
6634
6895
|
await downloader.download(params, this);
|
|
6635
6896
|
}
|
|
6636
|
-
async fetchUploadUrl(
|
|
6897
|
+
async fetchUploadUrl(path, sizeBytes, mimeType, fileName, body, configHttpOptions) {
|
|
6637
6898
|
var _a;
|
|
6638
6899
|
let httpOptions = {};
|
|
6639
|
-
if (
|
|
6640
|
-
httpOptions =
|
|
6900
|
+
if (configHttpOptions) {
|
|
6901
|
+
httpOptions = configHttpOptions;
|
|
6641
6902
|
}
|
|
6642
6903
|
else {
|
|
6643
6904
|
httpOptions = {
|
|
6644
6905
|
apiVersion: '',
|
|
6645
|
-
headers: Object.assign({ 'Content-Type': 'application/json', 'X-Goog-Upload-Protocol': 'resumable', 'X-Goog-Upload-Command': 'start', 'X-Goog-Upload-Header-Content-Length': `${
|
|
6906
|
+
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 } : {})),
|
|
6646
6907
|
};
|
|
6647
6908
|
}
|
|
6648
|
-
const body = {
|
|
6649
|
-
'file': file,
|
|
6650
|
-
};
|
|
6651
6909
|
const httpResponse = await this.request({
|
|
6652
|
-
path
|
|
6910
|
+
path,
|
|
6653
6911
|
body: JSON.stringify(body),
|
|
6654
6912
|
httpMethod: 'POST',
|
|
6655
6913
|
httpOptions,
|
|
@@ -6811,6 +7069,14 @@ class CrossUploader {
|
|
|
6811
7069
|
return uploadBlob(file, uploadUrl, apiClient);
|
|
6812
7070
|
}
|
|
6813
7071
|
}
|
|
7072
|
+
async uploadToFileSearchStore(file, uploadUrl, apiClient) {
|
|
7073
|
+
if (typeof file === 'string') {
|
|
7074
|
+
throw crossError();
|
|
7075
|
+
}
|
|
7076
|
+
else {
|
|
7077
|
+
return uploadBlobToFileSearchStore(file, uploadUrl, apiClient);
|
|
7078
|
+
}
|
|
7079
|
+
}
|
|
6814
7080
|
async stat(file) {
|
|
6815
7081
|
if (typeof file === 'string') {
|
|
6816
7082
|
throw crossError();
|
|
@@ -6821,7 +7087,28 @@ class CrossUploader {
|
|
|
6821
7087
|
}
|
|
6822
7088
|
}
|
|
6823
7089
|
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
6824
|
-
var _a
|
|
7090
|
+
var _a;
|
|
7091
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
7092
|
+
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
7093
|
+
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') {
|
|
7094
|
+
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
7095
|
+
}
|
|
7096
|
+
return responseJson['file'];
|
|
7097
|
+
}
|
|
7098
|
+
async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
|
|
7099
|
+
var _a;
|
|
7100
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
7101
|
+
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
7102
|
+
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') {
|
|
7103
|
+
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
7104
|
+
}
|
|
7105
|
+
const resp = uploadToFileSearchStoreOperationFromMldev(responseJson);
|
|
7106
|
+
const typedResp = new UploadToFileSearchStoreOperation();
|
|
7107
|
+
Object.assign(typedResp, resp);
|
|
7108
|
+
return typedResp;
|
|
7109
|
+
}
|
|
7110
|
+
async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
7111
|
+
var _a, _b;
|
|
6825
7112
|
let fileSize = 0;
|
|
6826
7113
|
let offset = 0;
|
|
6827
7114
|
let response = new HttpResponse(new Response());
|
|
@@ -6869,11 +7156,7 @@ async function uploadBlob(file, uploadUrl, apiClient) {
|
|
|
6869
7156
|
throw new Error('All content has been uploaded, but the upload status is not finalized.');
|
|
6870
7157
|
}
|
|
6871
7158
|
}
|
|
6872
|
-
|
|
6873
|
-
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') {
|
|
6874
|
-
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
6875
|
-
}
|
|
6876
|
-
return responseJson['file'];
|
|
7159
|
+
return response;
|
|
6877
7160
|
}
|
|
6878
7161
|
async function getBlobStat(file) {
|
|
6879
7162
|
const fileStat = { size: file.size, type: file.type };
|
|
@@ -7018,11 +7301,743 @@ class Files extends BaseModule {
|
|
|
7018
7301
|
* ```
|
|
7019
7302
|
*/
|
|
7020
7303
|
this.list = async (params = {}) => {
|
|
7021
|
-
return new Pager(exports.PagedItem.PAGED_ITEM_FILES, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
7304
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_FILES, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
7305
|
+
};
|
|
7306
|
+
}
|
|
7307
|
+
/**
|
|
7308
|
+
* Uploads a file asynchronously to the Gemini API.
|
|
7309
|
+
* This method is not available in Vertex AI.
|
|
7310
|
+
* Supported upload sources:
|
|
7311
|
+
* - Node.js: File path (string) or Blob object.
|
|
7312
|
+
* - Browser: Blob object (e.g., File).
|
|
7313
|
+
*
|
|
7314
|
+
* @remarks
|
|
7315
|
+
* The `mimeType` can be specified in the `config` parameter. If omitted:
|
|
7316
|
+
* - For file path (string) inputs, the `mimeType` will be inferred from the
|
|
7317
|
+
* file extension.
|
|
7318
|
+
* - For Blob object inputs, the `mimeType` will be set to the Blob's `type`
|
|
7319
|
+
* property.
|
|
7320
|
+
* Somex eamples for file extension to mimeType mapping:
|
|
7321
|
+
* .txt -> text/plain
|
|
7322
|
+
* .json -> application/json
|
|
7323
|
+
* .jpg -> image/jpeg
|
|
7324
|
+
* .png -> image/png
|
|
7325
|
+
* .mp3 -> audio/mpeg
|
|
7326
|
+
* .mp4 -> video/mp4
|
|
7327
|
+
*
|
|
7328
|
+
* This section can contain multiple paragraphs and code examples.
|
|
7329
|
+
*
|
|
7330
|
+
* @param params - Optional parameters specified in the
|
|
7331
|
+
* `types.UploadFileParameters` interface.
|
|
7332
|
+
* @see {@link types.UploadFileParameters#config} for the optional
|
|
7333
|
+
* config in the parameters.
|
|
7334
|
+
* @return A promise that resolves to a `types.File` object.
|
|
7335
|
+
* @throws An error if called on a Vertex AI client.
|
|
7336
|
+
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
7337
|
+
* the `mimeType` can be provided in the `params.config` parameter.
|
|
7338
|
+
* @throws An error occurs if a suitable upload location cannot be established.
|
|
7339
|
+
*
|
|
7340
|
+
* @example
|
|
7341
|
+
* The following code uploads a file to Gemini API.
|
|
7342
|
+
*
|
|
7343
|
+
* ```ts
|
|
7344
|
+
* const file = await ai.files.upload({file: 'file.txt', config: {
|
|
7345
|
+
* mimeType: 'text/plain',
|
|
7346
|
+
* }});
|
|
7347
|
+
* console.log(file.name);
|
|
7348
|
+
* ```
|
|
7349
|
+
*/
|
|
7350
|
+
async upload(params) {
|
|
7351
|
+
if (this.apiClient.isVertexAI()) {
|
|
7352
|
+
throw new Error('Vertex AI does not support uploading files. You can share files through a GCS bucket.');
|
|
7353
|
+
}
|
|
7354
|
+
return this.apiClient
|
|
7355
|
+
.uploadFile(params.file, params.config)
|
|
7356
|
+
.then((resp) => {
|
|
7357
|
+
return resp;
|
|
7358
|
+
});
|
|
7359
|
+
}
|
|
7360
|
+
/**
|
|
7361
|
+
* Downloads a remotely stored file asynchronously to a location specified in
|
|
7362
|
+
* the `params` object. This method only works on Node environment, to
|
|
7363
|
+
* download files in the browser, use a browser compliant method like an <a>
|
|
7364
|
+
* tag.
|
|
7365
|
+
*
|
|
7366
|
+
* @param params - The parameters for the download request.
|
|
7367
|
+
*
|
|
7368
|
+
* @example
|
|
7369
|
+
* The following code downloads an example file named "files/mehozpxf877d" as
|
|
7370
|
+
* "file.txt".
|
|
7371
|
+
*
|
|
7372
|
+
* ```ts
|
|
7373
|
+
* await ai.files.download({file: file.name, downloadPath: 'file.txt'});
|
|
7374
|
+
* ```
|
|
7375
|
+
*/
|
|
7376
|
+
async download(params) {
|
|
7377
|
+
await this.apiClient.downloadFile(params);
|
|
7378
|
+
}
|
|
7379
|
+
async listInternal(params) {
|
|
7380
|
+
var _a, _b;
|
|
7381
|
+
let response;
|
|
7382
|
+
let path = '';
|
|
7383
|
+
let queryParams = {};
|
|
7384
|
+
if (this.apiClient.isVertexAI()) {
|
|
7385
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
7386
|
+
}
|
|
7387
|
+
else {
|
|
7388
|
+
const body = listFilesParametersToMldev(params);
|
|
7389
|
+
path = formatMap('files', body['_url']);
|
|
7390
|
+
queryParams = body['_query'];
|
|
7391
|
+
delete body['_url'];
|
|
7392
|
+
delete body['_query'];
|
|
7393
|
+
response = this.apiClient
|
|
7394
|
+
.request({
|
|
7395
|
+
path: path,
|
|
7396
|
+
queryParams: queryParams,
|
|
7397
|
+
body: JSON.stringify(body),
|
|
7398
|
+
httpMethod: 'GET',
|
|
7399
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7400
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7401
|
+
})
|
|
7402
|
+
.then((httpResponse) => {
|
|
7403
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
7404
|
+
const response = jsonResponse;
|
|
7405
|
+
response.sdkHttpResponse = {
|
|
7406
|
+
headers: httpResponse.headers,
|
|
7407
|
+
};
|
|
7408
|
+
return response;
|
|
7409
|
+
});
|
|
7410
|
+
});
|
|
7411
|
+
return response.then((apiResponse) => {
|
|
7412
|
+
const resp = listFilesResponseFromMldev(apiResponse);
|
|
7413
|
+
const typedResp = new ListFilesResponse();
|
|
7414
|
+
Object.assign(typedResp, resp);
|
|
7415
|
+
return typedResp;
|
|
7416
|
+
});
|
|
7417
|
+
}
|
|
7418
|
+
}
|
|
7419
|
+
async createInternal(params) {
|
|
7420
|
+
var _a, _b;
|
|
7421
|
+
let response;
|
|
7422
|
+
let path = '';
|
|
7423
|
+
let queryParams = {};
|
|
7424
|
+
if (this.apiClient.isVertexAI()) {
|
|
7425
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
7426
|
+
}
|
|
7427
|
+
else {
|
|
7428
|
+
const body = createFileParametersToMldev(params);
|
|
7429
|
+
path = formatMap('upload/v1beta/files', body['_url']);
|
|
7430
|
+
queryParams = body['_query'];
|
|
7431
|
+
delete body['_url'];
|
|
7432
|
+
delete body['_query'];
|
|
7433
|
+
response = this.apiClient
|
|
7434
|
+
.request({
|
|
7435
|
+
path: path,
|
|
7436
|
+
queryParams: queryParams,
|
|
7437
|
+
body: JSON.stringify(body),
|
|
7438
|
+
httpMethod: 'POST',
|
|
7439
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7440
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7441
|
+
})
|
|
7442
|
+
.then((httpResponse) => {
|
|
7443
|
+
return httpResponse.json();
|
|
7444
|
+
});
|
|
7445
|
+
return response.then((apiResponse) => {
|
|
7446
|
+
const resp = createFileResponseFromMldev(apiResponse);
|
|
7447
|
+
const typedResp = new CreateFileResponse();
|
|
7448
|
+
Object.assign(typedResp, resp);
|
|
7449
|
+
return typedResp;
|
|
7450
|
+
});
|
|
7451
|
+
}
|
|
7452
|
+
}
|
|
7453
|
+
/**
|
|
7454
|
+
* Retrieves the file information from the service.
|
|
7455
|
+
*
|
|
7456
|
+
* @param params - The parameters for the get request
|
|
7457
|
+
* @return The Promise that resolves to the types.File object requested.
|
|
7458
|
+
*
|
|
7459
|
+
* @example
|
|
7460
|
+
* ```ts
|
|
7461
|
+
* const config: GetFileParameters = {
|
|
7462
|
+
* name: fileName,
|
|
7463
|
+
* };
|
|
7464
|
+
* file = await ai.files.get(config);
|
|
7465
|
+
* console.log(file.name);
|
|
7466
|
+
* ```
|
|
7467
|
+
*/
|
|
7468
|
+
async get(params) {
|
|
7469
|
+
var _a, _b;
|
|
7470
|
+
let response;
|
|
7471
|
+
let path = '';
|
|
7472
|
+
let queryParams = {};
|
|
7473
|
+
if (this.apiClient.isVertexAI()) {
|
|
7474
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
7475
|
+
}
|
|
7476
|
+
else {
|
|
7477
|
+
const body = getFileParametersToMldev(params);
|
|
7478
|
+
path = formatMap('files/{file}', body['_url']);
|
|
7479
|
+
queryParams = body['_query'];
|
|
7480
|
+
delete body['_url'];
|
|
7481
|
+
delete body['_query'];
|
|
7482
|
+
response = this.apiClient
|
|
7483
|
+
.request({
|
|
7484
|
+
path: path,
|
|
7485
|
+
queryParams: queryParams,
|
|
7486
|
+
body: JSON.stringify(body),
|
|
7487
|
+
httpMethod: 'GET',
|
|
7488
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7489
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7490
|
+
})
|
|
7491
|
+
.then((httpResponse) => {
|
|
7492
|
+
return httpResponse.json();
|
|
7493
|
+
});
|
|
7494
|
+
return response.then((resp) => {
|
|
7495
|
+
return resp;
|
|
7496
|
+
});
|
|
7497
|
+
}
|
|
7498
|
+
}
|
|
7499
|
+
/**
|
|
7500
|
+
* Deletes a remotely stored file.
|
|
7501
|
+
*
|
|
7502
|
+
* @param params - The parameters for the delete request.
|
|
7503
|
+
* @return The DeleteFileResponse, the response for the delete method.
|
|
7504
|
+
*
|
|
7505
|
+
* @example
|
|
7506
|
+
* The following code deletes an example file named "files/mehozpxf877d".
|
|
7507
|
+
*
|
|
7508
|
+
* ```ts
|
|
7509
|
+
* await ai.files.delete({name: file.name});
|
|
7510
|
+
* ```
|
|
7511
|
+
*/
|
|
7512
|
+
async delete(params) {
|
|
7513
|
+
var _a, _b;
|
|
7514
|
+
let response;
|
|
7515
|
+
let path = '';
|
|
7516
|
+
let queryParams = {};
|
|
7517
|
+
if (this.apiClient.isVertexAI()) {
|
|
7518
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
7519
|
+
}
|
|
7520
|
+
else {
|
|
7521
|
+
const body = deleteFileParametersToMldev(params);
|
|
7522
|
+
path = formatMap('files/{file}', body['_url']);
|
|
7523
|
+
queryParams = body['_query'];
|
|
7524
|
+
delete body['_url'];
|
|
7525
|
+
delete body['_query'];
|
|
7526
|
+
response = this.apiClient
|
|
7527
|
+
.request({
|
|
7528
|
+
path: path,
|
|
7529
|
+
queryParams: queryParams,
|
|
7530
|
+
body: JSON.stringify(body),
|
|
7531
|
+
httpMethod: 'DELETE',
|
|
7532
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7533
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7534
|
+
})
|
|
7535
|
+
.then((httpResponse) => {
|
|
7536
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
7537
|
+
const response = jsonResponse;
|
|
7538
|
+
response.sdkHttpResponse = {
|
|
7539
|
+
headers: httpResponse.headers,
|
|
7540
|
+
};
|
|
7541
|
+
return response;
|
|
7542
|
+
});
|
|
7543
|
+
});
|
|
7544
|
+
return response.then((apiResponse) => {
|
|
7545
|
+
const resp = deleteFileResponseFromMldev(apiResponse);
|
|
7546
|
+
const typedResp = new DeleteFileResponse();
|
|
7547
|
+
Object.assign(typedResp, resp);
|
|
7548
|
+
return typedResp;
|
|
7549
|
+
});
|
|
7550
|
+
}
|
|
7551
|
+
}
|
|
7552
|
+
}
|
|
7553
|
+
|
|
7554
|
+
/**
|
|
7555
|
+
* @license
|
|
7556
|
+
* Copyright 2025 Google LLC
|
|
7557
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7558
|
+
*/
|
|
7559
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
7560
|
+
function createFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
7561
|
+
const toObject = {};
|
|
7562
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
7563
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
7564
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
7565
|
+
}
|
|
7566
|
+
return toObject;
|
|
7567
|
+
}
|
|
7568
|
+
function createFileSearchStoreParametersToMldev(fromObject) {
|
|
7569
|
+
const toObject = {};
|
|
7570
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7571
|
+
if (fromConfig != null) {
|
|
7572
|
+
createFileSearchStoreConfigToMldev(fromConfig, toObject);
|
|
7573
|
+
}
|
|
7574
|
+
return toObject;
|
|
7575
|
+
}
|
|
7576
|
+
function deleteFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
7577
|
+
const toObject = {};
|
|
7578
|
+
const fromForce = getValueByPath(fromObject, ['force']);
|
|
7579
|
+
if (parentObject !== undefined && fromForce != null) {
|
|
7580
|
+
setValueByPath(parentObject, ['_query', 'force'], fromForce);
|
|
7581
|
+
}
|
|
7582
|
+
return toObject;
|
|
7583
|
+
}
|
|
7584
|
+
function deleteFileSearchStoreParametersToMldev(fromObject) {
|
|
7585
|
+
const toObject = {};
|
|
7586
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
7587
|
+
if (fromName != null) {
|
|
7588
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
7589
|
+
}
|
|
7590
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7591
|
+
if (fromConfig != null) {
|
|
7592
|
+
deleteFileSearchStoreConfigToMldev(fromConfig, toObject);
|
|
7593
|
+
}
|
|
7594
|
+
return toObject;
|
|
7595
|
+
}
|
|
7596
|
+
function getFileSearchStoreParametersToMldev(fromObject) {
|
|
7597
|
+
const toObject = {};
|
|
7598
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
7599
|
+
if (fromName != null) {
|
|
7600
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
7601
|
+
}
|
|
7602
|
+
return toObject;
|
|
7603
|
+
}
|
|
7604
|
+
function importFileConfigToMldev(fromObject, parentObject) {
|
|
7605
|
+
const toObject = {};
|
|
7606
|
+
const fromCustomMetadata = getValueByPath(fromObject, [
|
|
7607
|
+
'customMetadata',
|
|
7608
|
+
]);
|
|
7609
|
+
if (parentObject !== undefined && fromCustomMetadata != null) {
|
|
7610
|
+
let transformedList = fromCustomMetadata;
|
|
7611
|
+
if (Array.isArray(transformedList)) {
|
|
7612
|
+
transformedList = transformedList.map((item) => {
|
|
7613
|
+
return item;
|
|
7614
|
+
});
|
|
7615
|
+
}
|
|
7616
|
+
setValueByPath(parentObject, ['customMetadata'], transformedList);
|
|
7617
|
+
}
|
|
7618
|
+
const fromChunkingConfig = getValueByPath(fromObject, [
|
|
7619
|
+
'chunkingConfig',
|
|
7620
|
+
]);
|
|
7621
|
+
if (parentObject !== undefined && fromChunkingConfig != null) {
|
|
7622
|
+
setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
|
|
7623
|
+
}
|
|
7624
|
+
return toObject;
|
|
7625
|
+
}
|
|
7626
|
+
function importFileOperationFromMldev(fromObject) {
|
|
7627
|
+
const toObject = {};
|
|
7628
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
7629
|
+
if (fromName != null) {
|
|
7630
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
7631
|
+
}
|
|
7632
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
7633
|
+
if (fromMetadata != null) {
|
|
7634
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
7635
|
+
}
|
|
7636
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
7637
|
+
if (fromDone != null) {
|
|
7638
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
7639
|
+
}
|
|
7640
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
7641
|
+
if (fromError != null) {
|
|
7642
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
7643
|
+
}
|
|
7644
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
7645
|
+
if (fromResponse != null) {
|
|
7646
|
+
setValueByPath(toObject, ['response'], importFileResponseFromMldev(fromResponse));
|
|
7647
|
+
}
|
|
7648
|
+
return toObject;
|
|
7649
|
+
}
|
|
7650
|
+
function importFileParametersToMldev(fromObject) {
|
|
7651
|
+
const toObject = {};
|
|
7652
|
+
const fromFileSearchStoreName = getValueByPath(fromObject, [
|
|
7653
|
+
'fileSearchStoreName',
|
|
7654
|
+
]);
|
|
7655
|
+
if (fromFileSearchStoreName != null) {
|
|
7656
|
+
setValueByPath(toObject, ['_url', 'file_search_store_name'], fromFileSearchStoreName);
|
|
7657
|
+
}
|
|
7658
|
+
const fromFileName = getValueByPath(fromObject, ['fileName']);
|
|
7659
|
+
if (fromFileName != null) {
|
|
7660
|
+
setValueByPath(toObject, ['fileName'], fromFileName);
|
|
7661
|
+
}
|
|
7662
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7663
|
+
if (fromConfig != null) {
|
|
7664
|
+
importFileConfigToMldev(fromConfig, toObject);
|
|
7665
|
+
}
|
|
7666
|
+
return toObject;
|
|
7667
|
+
}
|
|
7668
|
+
function importFileResponseFromMldev(fromObject) {
|
|
7669
|
+
const toObject = {};
|
|
7670
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
7671
|
+
'sdkHttpResponse',
|
|
7672
|
+
]);
|
|
7673
|
+
if (fromSdkHttpResponse != null) {
|
|
7674
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
7675
|
+
}
|
|
7676
|
+
const fromParent = getValueByPath(fromObject, ['parent']);
|
|
7677
|
+
if (fromParent != null) {
|
|
7678
|
+
setValueByPath(toObject, ['parent'], fromParent);
|
|
7679
|
+
}
|
|
7680
|
+
const fromDocumentName = getValueByPath(fromObject, ['documentName']);
|
|
7681
|
+
if (fromDocumentName != null) {
|
|
7682
|
+
setValueByPath(toObject, ['documentName'], fromDocumentName);
|
|
7683
|
+
}
|
|
7684
|
+
return toObject;
|
|
7685
|
+
}
|
|
7686
|
+
function listFileSearchStoresConfigToMldev(fromObject, parentObject) {
|
|
7687
|
+
const toObject = {};
|
|
7688
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
7689
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
7690
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
7691
|
+
}
|
|
7692
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
7693
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
7694
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
7695
|
+
}
|
|
7696
|
+
return toObject;
|
|
7697
|
+
}
|
|
7698
|
+
function listFileSearchStoresParametersToMldev(fromObject) {
|
|
7699
|
+
const toObject = {};
|
|
7700
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7701
|
+
if (fromConfig != null) {
|
|
7702
|
+
listFileSearchStoresConfigToMldev(fromConfig, toObject);
|
|
7703
|
+
}
|
|
7704
|
+
return toObject;
|
|
7705
|
+
}
|
|
7706
|
+
function listFileSearchStoresResponseFromMldev(fromObject) {
|
|
7707
|
+
const toObject = {};
|
|
7708
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
7709
|
+
'sdkHttpResponse',
|
|
7710
|
+
]);
|
|
7711
|
+
if (fromSdkHttpResponse != null) {
|
|
7712
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
7713
|
+
}
|
|
7714
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
7715
|
+
'nextPageToken',
|
|
7716
|
+
]);
|
|
7717
|
+
if (fromNextPageToken != null) {
|
|
7718
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
7719
|
+
}
|
|
7720
|
+
const fromFileSearchStores = getValueByPath(fromObject, [
|
|
7721
|
+
'fileSearchStores',
|
|
7722
|
+
]);
|
|
7723
|
+
if (fromFileSearchStores != null) {
|
|
7724
|
+
let transformedList = fromFileSearchStores;
|
|
7725
|
+
if (Array.isArray(transformedList)) {
|
|
7726
|
+
transformedList = transformedList.map((item) => {
|
|
7727
|
+
return item;
|
|
7728
|
+
});
|
|
7729
|
+
}
|
|
7730
|
+
setValueByPath(toObject, ['fileSearchStores'], transformedList);
|
|
7731
|
+
}
|
|
7732
|
+
return toObject;
|
|
7733
|
+
}
|
|
7734
|
+
function uploadToFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
7735
|
+
const toObject = {};
|
|
7736
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
7737
|
+
if (parentObject !== undefined && fromMimeType != null) {
|
|
7738
|
+
setValueByPath(parentObject, ['mimeType'], fromMimeType);
|
|
7739
|
+
}
|
|
7740
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
7741
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
7742
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
7743
|
+
}
|
|
7744
|
+
const fromCustomMetadata = getValueByPath(fromObject, [
|
|
7745
|
+
'customMetadata',
|
|
7746
|
+
]);
|
|
7747
|
+
if (parentObject !== undefined && fromCustomMetadata != null) {
|
|
7748
|
+
let transformedList = fromCustomMetadata;
|
|
7749
|
+
if (Array.isArray(transformedList)) {
|
|
7750
|
+
transformedList = transformedList.map((item) => {
|
|
7751
|
+
return item;
|
|
7752
|
+
});
|
|
7753
|
+
}
|
|
7754
|
+
setValueByPath(parentObject, ['customMetadata'], transformedList);
|
|
7755
|
+
}
|
|
7756
|
+
const fromChunkingConfig = getValueByPath(fromObject, [
|
|
7757
|
+
'chunkingConfig',
|
|
7758
|
+
]);
|
|
7759
|
+
if (parentObject !== undefined && fromChunkingConfig != null) {
|
|
7760
|
+
setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
|
|
7761
|
+
}
|
|
7762
|
+
return toObject;
|
|
7763
|
+
}
|
|
7764
|
+
function uploadToFileSearchStoreParametersToMldev(fromObject) {
|
|
7765
|
+
const toObject = {};
|
|
7766
|
+
const fromFileSearchStoreName = getValueByPath(fromObject, [
|
|
7767
|
+
'fileSearchStoreName',
|
|
7768
|
+
]);
|
|
7769
|
+
if (fromFileSearchStoreName != null) {
|
|
7770
|
+
setValueByPath(toObject, ['_url', 'file_search_store_name'], fromFileSearchStoreName);
|
|
7771
|
+
}
|
|
7772
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7773
|
+
if (fromConfig != null) {
|
|
7774
|
+
uploadToFileSearchStoreConfigToMldev(fromConfig, toObject);
|
|
7775
|
+
}
|
|
7776
|
+
return toObject;
|
|
7777
|
+
}
|
|
7778
|
+
function uploadToFileSearchStoreResumableResponseFromMldev(fromObject) {
|
|
7779
|
+
const toObject = {};
|
|
7780
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
7781
|
+
'sdkHttpResponse',
|
|
7782
|
+
]);
|
|
7783
|
+
if (fromSdkHttpResponse != null) {
|
|
7784
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
7785
|
+
}
|
|
7786
|
+
return toObject;
|
|
7787
|
+
}
|
|
7788
|
+
|
|
7789
|
+
/**
|
|
7790
|
+
* @license
|
|
7791
|
+
* Copyright 2025 Google LLC
|
|
7792
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7793
|
+
*/
|
|
7794
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
7795
|
+
function deleteDocumentConfigToMldev(fromObject, parentObject) {
|
|
7796
|
+
const toObject = {};
|
|
7797
|
+
const fromForce = getValueByPath(fromObject, ['force']);
|
|
7798
|
+
if (parentObject !== undefined && fromForce != null) {
|
|
7799
|
+
setValueByPath(parentObject, ['_query', 'force'], fromForce);
|
|
7800
|
+
}
|
|
7801
|
+
return toObject;
|
|
7802
|
+
}
|
|
7803
|
+
function deleteDocumentParametersToMldev(fromObject) {
|
|
7804
|
+
const toObject = {};
|
|
7805
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
7806
|
+
if (fromName != null) {
|
|
7807
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
7808
|
+
}
|
|
7809
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7810
|
+
if (fromConfig != null) {
|
|
7811
|
+
deleteDocumentConfigToMldev(fromConfig, toObject);
|
|
7812
|
+
}
|
|
7813
|
+
return toObject;
|
|
7814
|
+
}
|
|
7815
|
+
function getDocumentParametersToMldev(fromObject) {
|
|
7816
|
+
const toObject = {};
|
|
7817
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
7818
|
+
if (fromName != null) {
|
|
7819
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
7820
|
+
}
|
|
7821
|
+
return toObject;
|
|
7822
|
+
}
|
|
7823
|
+
function listDocumentsConfigToMldev(fromObject, parentObject) {
|
|
7824
|
+
const toObject = {};
|
|
7825
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
7826
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
7827
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
7828
|
+
}
|
|
7829
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
7830
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
7831
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
7832
|
+
}
|
|
7833
|
+
return toObject;
|
|
7834
|
+
}
|
|
7835
|
+
function listDocumentsParametersToMldev(fromObject) {
|
|
7836
|
+
const toObject = {};
|
|
7837
|
+
const fromParent = getValueByPath(fromObject, ['parent']);
|
|
7838
|
+
if (fromParent != null) {
|
|
7839
|
+
setValueByPath(toObject, ['_url', 'parent'], fromParent);
|
|
7840
|
+
}
|
|
7841
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7842
|
+
if (fromConfig != null) {
|
|
7843
|
+
listDocumentsConfigToMldev(fromConfig, toObject);
|
|
7844
|
+
}
|
|
7845
|
+
return toObject;
|
|
7846
|
+
}
|
|
7847
|
+
function listDocumentsResponseFromMldev(fromObject) {
|
|
7848
|
+
const toObject = {};
|
|
7849
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
7850
|
+
'sdkHttpResponse',
|
|
7851
|
+
]);
|
|
7852
|
+
if (fromSdkHttpResponse != null) {
|
|
7853
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
7854
|
+
}
|
|
7855
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
7856
|
+
'nextPageToken',
|
|
7857
|
+
]);
|
|
7858
|
+
if (fromNextPageToken != null) {
|
|
7859
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
7860
|
+
}
|
|
7861
|
+
const fromDocuments = getValueByPath(fromObject, ['documents']);
|
|
7862
|
+
if (fromDocuments != null) {
|
|
7863
|
+
let transformedList = fromDocuments;
|
|
7864
|
+
if (Array.isArray(transformedList)) {
|
|
7865
|
+
transformedList = transformedList.map((item) => {
|
|
7866
|
+
return item;
|
|
7867
|
+
});
|
|
7868
|
+
}
|
|
7869
|
+
setValueByPath(toObject, ['documents'], transformedList);
|
|
7870
|
+
}
|
|
7871
|
+
return toObject;
|
|
7872
|
+
}
|
|
7873
|
+
|
|
7874
|
+
/**
|
|
7875
|
+
* @license
|
|
7876
|
+
* Copyright 2025 Google LLC
|
|
7877
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7878
|
+
*/
|
|
7879
|
+
class Documents extends BaseModule {
|
|
7880
|
+
constructor(apiClient) {
|
|
7881
|
+
super();
|
|
7882
|
+
this.apiClient = apiClient;
|
|
7883
|
+
/**
|
|
7884
|
+
* Lists documents.
|
|
7885
|
+
*
|
|
7886
|
+
* @param params - The parameters for the list request.
|
|
7887
|
+
* @return - A pager of documents.
|
|
7888
|
+
*
|
|
7889
|
+
* @example
|
|
7890
|
+
* ```ts
|
|
7891
|
+
* const documents = await ai.documents.list({config: {'pageSize': 2}});
|
|
7892
|
+
* for await (const document of documents) {
|
|
7893
|
+
* console.log(document);
|
|
7894
|
+
* }
|
|
7895
|
+
* ```
|
|
7896
|
+
*/
|
|
7897
|
+
this.list = async (params) => {
|
|
7898
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_DOCUMENTS, (x) => this.listInternal({
|
|
7899
|
+
parent: params.parent,
|
|
7900
|
+
config: x.config,
|
|
7901
|
+
}), await this.listInternal(params), params);
|
|
7902
|
+
};
|
|
7903
|
+
}
|
|
7904
|
+
/**
|
|
7905
|
+
* Gets a Document.
|
|
7906
|
+
*
|
|
7907
|
+
* @param params - The parameters for getting a document.
|
|
7908
|
+
* @return Document.
|
|
7909
|
+
*/
|
|
7910
|
+
async get(params) {
|
|
7911
|
+
var _a, _b;
|
|
7912
|
+
let response;
|
|
7913
|
+
let path = '';
|
|
7914
|
+
let queryParams = {};
|
|
7915
|
+
if (this.apiClient.isVertexAI()) {
|
|
7916
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
7917
|
+
}
|
|
7918
|
+
else {
|
|
7919
|
+
const body = getDocumentParametersToMldev(params);
|
|
7920
|
+
path = formatMap('{name}', body['_url']);
|
|
7921
|
+
queryParams = body['_query'];
|
|
7922
|
+
delete body['_url'];
|
|
7923
|
+
delete body['_query'];
|
|
7924
|
+
response = this.apiClient
|
|
7925
|
+
.request({
|
|
7926
|
+
path: path,
|
|
7927
|
+
queryParams: queryParams,
|
|
7928
|
+
body: JSON.stringify(body),
|
|
7929
|
+
httpMethod: 'GET',
|
|
7930
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7931
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7932
|
+
})
|
|
7933
|
+
.then((httpResponse) => {
|
|
7934
|
+
return httpResponse.json();
|
|
7935
|
+
});
|
|
7936
|
+
return response.then((resp) => {
|
|
7937
|
+
return resp;
|
|
7938
|
+
});
|
|
7939
|
+
}
|
|
7940
|
+
}
|
|
7941
|
+
/**
|
|
7942
|
+
* Deletes a Document.
|
|
7943
|
+
*
|
|
7944
|
+
* @param params - The parameters for deleting a document.
|
|
7945
|
+
*/
|
|
7946
|
+
async delete(params) {
|
|
7947
|
+
var _a, _b;
|
|
7948
|
+
let path = '';
|
|
7949
|
+
let queryParams = {};
|
|
7950
|
+
if (this.apiClient.isVertexAI()) {
|
|
7951
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
7952
|
+
}
|
|
7953
|
+
else {
|
|
7954
|
+
const body = deleteDocumentParametersToMldev(params);
|
|
7955
|
+
path = formatMap('{name}', body['_url']);
|
|
7956
|
+
queryParams = body['_query'];
|
|
7957
|
+
delete body['_url'];
|
|
7958
|
+
delete body['_query'];
|
|
7959
|
+
await this.apiClient.request({
|
|
7960
|
+
path: path,
|
|
7961
|
+
queryParams: queryParams,
|
|
7962
|
+
body: JSON.stringify(body),
|
|
7963
|
+
httpMethod: 'DELETE',
|
|
7964
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7965
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7966
|
+
});
|
|
7967
|
+
}
|
|
7968
|
+
}
|
|
7969
|
+
/**
|
|
7970
|
+
* Lists all Documents in a FileSearchStore.
|
|
7971
|
+
*
|
|
7972
|
+
* @param params - The parameters for listing documents.
|
|
7973
|
+
* @return ListDocumentsResponse.
|
|
7974
|
+
*/
|
|
7975
|
+
async listInternal(params) {
|
|
7976
|
+
var _a, _b;
|
|
7977
|
+
let response;
|
|
7978
|
+
let path = '';
|
|
7979
|
+
let queryParams = {};
|
|
7980
|
+
if (this.apiClient.isVertexAI()) {
|
|
7981
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
7982
|
+
}
|
|
7983
|
+
else {
|
|
7984
|
+
const body = listDocumentsParametersToMldev(params);
|
|
7985
|
+
path = formatMap('{parent}/documents', body['_url']);
|
|
7986
|
+
queryParams = body['_query'];
|
|
7987
|
+
delete body['_url'];
|
|
7988
|
+
delete body['_query'];
|
|
7989
|
+
response = this.apiClient
|
|
7990
|
+
.request({
|
|
7991
|
+
path: path,
|
|
7992
|
+
queryParams: queryParams,
|
|
7993
|
+
body: JSON.stringify(body),
|
|
7994
|
+
httpMethod: 'GET',
|
|
7995
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7996
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7997
|
+
})
|
|
7998
|
+
.then((httpResponse) => {
|
|
7999
|
+
return httpResponse.json();
|
|
8000
|
+
});
|
|
8001
|
+
return response.then((apiResponse) => {
|
|
8002
|
+
const resp = listDocumentsResponseFromMldev(apiResponse);
|
|
8003
|
+
const typedResp = new ListDocumentsResponse();
|
|
8004
|
+
Object.assign(typedResp, resp);
|
|
8005
|
+
return typedResp;
|
|
8006
|
+
});
|
|
8007
|
+
}
|
|
8008
|
+
}
|
|
8009
|
+
}
|
|
8010
|
+
|
|
8011
|
+
/**
|
|
8012
|
+
* @license
|
|
8013
|
+
* Copyright 2025 Google LLC
|
|
8014
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8015
|
+
*/
|
|
8016
|
+
class FileSearchStores extends BaseModule {
|
|
8017
|
+
constructor(apiClient, documents = new Documents(apiClient)) {
|
|
8018
|
+
super();
|
|
8019
|
+
this.apiClient = apiClient;
|
|
8020
|
+
this.documents = documents;
|
|
8021
|
+
/**
|
|
8022
|
+
* Lists file search stores.
|
|
8023
|
+
*
|
|
8024
|
+
* @param params - The parameters for the list request.
|
|
8025
|
+
* @return - A pager of file search stores.
|
|
8026
|
+
*
|
|
8027
|
+
* @example
|
|
8028
|
+
* ```ts
|
|
8029
|
+
* const fileSearchStores = await ai.fileSearchStores.list({config: {'pageSize': 2}});
|
|
8030
|
+
* for await (const fileSearchStore of fileSearchStores) {
|
|
8031
|
+
* console.log(fileSearchStore);
|
|
8032
|
+
* }
|
|
8033
|
+
* ```
|
|
8034
|
+
*/
|
|
8035
|
+
this.list = async (params = {}) => {
|
|
8036
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_FILE_SEARCH_STORES, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
7022
8037
|
};
|
|
7023
8038
|
}
|
|
7024
8039
|
/**
|
|
7025
|
-
* Uploads a file asynchronously to
|
|
8040
|
+
* Uploads a file asynchronously to a given File Search Store.
|
|
7026
8041
|
* This method is not available in Vertex AI.
|
|
7027
8042
|
* Supported upload sources:
|
|
7028
8043
|
* - Node.js: File path (string) or Blob object.
|
|
@@ -7034,66 +8049,42 @@ class Files extends BaseModule {
|
|
|
7034
8049
|
* file extension.
|
|
7035
8050
|
* - For Blob object inputs, the `mimeType` will be set to the Blob's `type`
|
|
7036
8051
|
* property.
|
|
7037
|
-
* Somex eamples for file extension to mimeType mapping:
|
|
7038
|
-
* .txt -> text/plain
|
|
7039
|
-
* .json -> application/json
|
|
7040
|
-
* .jpg -> image/jpeg
|
|
7041
|
-
* .png -> image/png
|
|
7042
|
-
* .mp3 -> audio/mpeg
|
|
7043
|
-
* .mp4 -> video/mp4
|
|
7044
8052
|
*
|
|
7045
8053
|
* This section can contain multiple paragraphs and code examples.
|
|
7046
8054
|
*
|
|
7047
8055
|
* @param params - Optional parameters specified in the
|
|
7048
|
-
* `types.
|
|
7049
|
-
* @see {@link types.
|
|
8056
|
+
* `types.UploadToFileSearchStoreParameters` interface.
|
|
8057
|
+
* @see {@link types.UploadToFileSearchStoreParameters#config} for the optional
|
|
7050
8058
|
* config in the parameters.
|
|
7051
|
-
* @return A promise that resolves to a
|
|
8059
|
+
* @return A promise that resolves to a long running operation.
|
|
7052
8060
|
* @throws An error if called on a Vertex AI client.
|
|
7053
8061
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
7054
8062
|
* the `mimeType` can be provided in the `params.config` parameter.
|
|
7055
8063
|
* @throws An error occurs if a suitable upload location cannot be established.
|
|
7056
8064
|
*
|
|
7057
8065
|
* @example
|
|
7058
|
-
* The following code uploads a file to
|
|
8066
|
+
* The following code uploads a file to a given file search store.
|
|
7059
8067
|
*
|
|
7060
8068
|
* ```ts
|
|
7061
|
-
* const
|
|
8069
|
+
* const operation = await ai.fileSearchStores.upload({fileSearchStoreName: 'fileSearchStores/foo-bar', file: 'file.txt', config: {
|
|
7062
8070
|
* mimeType: 'text/plain',
|
|
7063
8071
|
* }});
|
|
7064
|
-
* console.log(
|
|
8072
|
+
* console.log(operation.name);
|
|
7065
8073
|
* ```
|
|
7066
8074
|
*/
|
|
7067
|
-
async
|
|
8075
|
+
async uploadToFileSearchStore(params) {
|
|
7068
8076
|
if (this.apiClient.isVertexAI()) {
|
|
7069
|
-
throw new Error('Vertex AI does not support uploading files
|
|
8077
|
+
throw new Error('Vertex AI does not support uploading files to a file search store.');
|
|
7070
8078
|
}
|
|
7071
|
-
return this.apiClient
|
|
7072
|
-
.uploadFile(params.file, params.config)
|
|
7073
|
-
.then((resp) => {
|
|
7074
|
-
return resp;
|
|
7075
|
-
});
|
|
8079
|
+
return this.apiClient.uploadFileToFileSearchStore(params.fileSearchStoreName, params.file, params.config);
|
|
7076
8080
|
}
|
|
7077
8081
|
/**
|
|
7078
|
-
*
|
|
7079
|
-
* the `params` object. This method only works on Node environment, to
|
|
7080
|
-
* download files in the browser, use a browser compliant method like an <a>
|
|
7081
|
-
* tag.
|
|
7082
|
-
*
|
|
7083
|
-
* @param params - The parameters for the download request.
|
|
7084
|
-
*
|
|
7085
|
-
* @example
|
|
7086
|
-
* The following code downloads an example file named "files/mehozpxf877d" as
|
|
7087
|
-
* "file.txt".
|
|
8082
|
+
* Creates a File Search Store.
|
|
7088
8083
|
*
|
|
7089
|
-
*
|
|
7090
|
-
*
|
|
7091
|
-
* ```
|
|
8084
|
+
* @param params - The parameters for creating a File Search Store.
|
|
8085
|
+
* @return FileSearchStore.
|
|
7092
8086
|
*/
|
|
7093
|
-
async
|
|
7094
|
-
await this.apiClient.downloadFile(params);
|
|
7095
|
-
}
|
|
7096
|
-
async listInternal(params) {
|
|
8087
|
+
async create(params) {
|
|
7097
8088
|
var _a, _b;
|
|
7098
8089
|
let response;
|
|
7099
8090
|
let path = '';
|
|
@@ -7102,8 +8093,8 @@ class Files extends BaseModule {
|
|
|
7102
8093
|
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
7103
8094
|
}
|
|
7104
8095
|
else {
|
|
7105
|
-
const body =
|
|
7106
|
-
path = formatMap('
|
|
8096
|
+
const body = createFileSearchStoreParametersToMldev(params);
|
|
8097
|
+
path = formatMap('fileSearchStores', body['_url']);
|
|
7107
8098
|
queryParams = body['_query'];
|
|
7108
8099
|
delete body['_url'];
|
|
7109
8100
|
delete body['_query'];
|
|
@@ -7112,28 +8103,25 @@ class Files extends BaseModule {
|
|
|
7112
8103
|
path: path,
|
|
7113
8104
|
queryParams: queryParams,
|
|
7114
8105
|
body: JSON.stringify(body),
|
|
7115
|
-
httpMethod: '
|
|
8106
|
+
httpMethod: 'POST',
|
|
7116
8107
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7117
8108
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7118
8109
|
})
|
|
7119
8110
|
.then((httpResponse) => {
|
|
7120
|
-
return httpResponse.json()
|
|
7121
|
-
const response = jsonResponse;
|
|
7122
|
-
response.sdkHttpResponse = {
|
|
7123
|
-
headers: httpResponse.headers,
|
|
7124
|
-
};
|
|
7125
|
-
return response;
|
|
7126
|
-
});
|
|
8111
|
+
return httpResponse.json();
|
|
7127
8112
|
});
|
|
7128
|
-
return response.then((
|
|
7129
|
-
|
|
7130
|
-
const typedResp = new ListFilesResponse();
|
|
7131
|
-
Object.assign(typedResp, resp);
|
|
7132
|
-
return typedResp;
|
|
8113
|
+
return response.then((resp) => {
|
|
8114
|
+
return resp;
|
|
7133
8115
|
});
|
|
7134
8116
|
}
|
|
7135
8117
|
}
|
|
7136
|
-
|
|
8118
|
+
/**
|
|
8119
|
+
* Gets a File Search Store.
|
|
8120
|
+
*
|
|
8121
|
+
* @param params - The parameters for getting a File Search Store.
|
|
8122
|
+
* @return FileSearchStore.
|
|
8123
|
+
*/
|
|
8124
|
+
async get(params) {
|
|
7137
8125
|
var _a, _b;
|
|
7138
8126
|
let response;
|
|
7139
8127
|
let path = '';
|
|
@@ -7142,8 +8130,8 @@ class Files extends BaseModule {
|
|
|
7142
8130
|
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
7143
8131
|
}
|
|
7144
8132
|
else {
|
|
7145
|
-
const body =
|
|
7146
|
-
path = formatMap('
|
|
8133
|
+
const body = getFileSearchStoreParametersToMldev(params);
|
|
8134
|
+
path = formatMap('{name}', body['_url']);
|
|
7147
8135
|
queryParams = body['_query'];
|
|
7148
8136
|
delete body['_url'];
|
|
7149
8137
|
delete body['_query'];
|
|
@@ -7152,37 +8140,53 @@ class Files extends BaseModule {
|
|
|
7152
8140
|
path: path,
|
|
7153
8141
|
queryParams: queryParams,
|
|
7154
8142
|
body: JSON.stringify(body),
|
|
7155
|
-
httpMethod: '
|
|
8143
|
+
httpMethod: 'GET',
|
|
7156
8144
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7157
8145
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7158
8146
|
})
|
|
7159
8147
|
.then((httpResponse) => {
|
|
7160
8148
|
return httpResponse.json();
|
|
7161
8149
|
});
|
|
7162
|
-
return response.then((
|
|
7163
|
-
|
|
7164
|
-
const typedResp = new CreateFileResponse();
|
|
7165
|
-
Object.assign(typedResp, resp);
|
|
7166
|
-
return typedResp;
|
|
8150
|
+
return response.then((resp) => {
|
|
8151
|
+
return resp;
|
|
7167
8152
|
});
|
|
7168
8153
|
}
|
|
7169
8154
|
}
|
|
7170
8155
|
/**
|
|
7171
|
-
*
|
|
8156
|
+
* Deletes a File Search Store.
|
|
7172
8157
|
*
|
|
7173
|
-
* @param params - The parameters for
|
|
7174
|
-
|
|
8158
|
+
* @param params - The parameters for deleting a File Search Store.
|
|
8159
|
+
*/
|
|
8160
|
+
async delete(params) {
|
|
8161
|
+
var _a, _b;
|
|
8162
|
+
let path = '';
|
|
8163
|
+
let queryParams = {};
|
|
8164
|
+
if (this.apiClient.isVertexAI()) {
|
|
8165
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
8166
|
+
}
|
|
8167
|
+
else {
|
|
8168
|
+
const body = deleteFileSearchStoreParametersToMldev(params);
|
|
8169
|
+
path = formatMap('{name}', body['_url']);
|
|
8170
|
+
queryParams = body['_query'];
|
|
8171
|
+
delete body['_url'];
|
|
8172
|
+
delete body['_query'];
|
|
8173
|
+
await this.apiClient.request({
|
|
8174
|
+
path: path,
|
|
8175
|
+
queryParams: queryParams,
|
|
8176
|
+
body: JSON.stringify(body),
|
|
8177
|
+
httpMethod: 'DELETE',
|
|
8178
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8179
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8180
|
+
});
|
|
8181
|
+
}
|
|
8182
|
+
}
|
|
8183
|
+
/**
|
|
8184
|
+
* Lists all FileSearchStore owned by the user.
|
|
7175
8185
|
*
|
|
7176
|
-
* @
|
|
7177
|
-
*
|
|
7178
|
-
* const config: GetFileParameters = {
|
|
7179
|
-
* name: fileName,
|
|
7180
|
-
* };
|
|
7181
|
-
* file = await ai.files.get(config);
|
|
7182
|
-
* console.log(file.name);
|
|
7183
|
-
* ```
|
|
8186
|
+
* @param params - The parameters for listing file search stores.
|
|
8187
|
+
* @return ListFileSearchStoresResponse.
|
|
7184
8188
|
*/
|
|
7185
|
-
async
|
|
8189
|
+
async listInternal(params) {
|
|
7186
8190
|
var _a, _b;
|
|
7187
8191
|
let response;
|
|
7188
8192
|
let path = '';
|
|
@@ -7191,8 +8195,8 @@ class Files extends BaseModule {
|
|
|
7191
8195
|
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
7192
8196
|
}
|
|
7193
8197
|
else {
|
|
7194
|
-
const body =
|
|
7195
|
-
path = formatMap('
|
|
8198
|
+
const body = listFileSearchStoresParametersToMldev(params);
|
|
8199
|
+
path = formatMap('fileSearchStores', body['_url']);
|
|
7196
8200
|
queryParams = body['_query'];
|
|
7197
8201
|
delete body['_url'];
|
|
7198
8202
|
delete body['_query'];
|
|
@@ -7208,25 +8212,57 @@ class Files extends BaseModule {
|
|
|
7208
8212
|
.then((httpResponse) => {
|
|
7209
8213
|
return httpResponse.json();
|
|
7210
8214
|
});
|
|
7211
|
-
return response.then((
|
|
7212
|
-
|
|
8215
|
+
return response.then((apiResponse) => {
|
|
8216
|
+
const resp = listFileSearchStoresResponseFromMldev(apiResponse);
|
|
8217
|
+
const typedResp = new ListFileSearchStoresResponse();
|
|
8218
|
+
Object.assign(typedResp, resp);
|
|
8219
|
+
return typedResp;
|
|
8220
|
+
});
|
|
8221
|
+
}
|
|
8222
|
+
}
|
|
8223
|
+
async uploadToFileSearchStoreInternal(params) {
|
|
8224
|
+
var _a, _b;
|
|
8225
|
+
let response;
|
|
8226
|
+
let path = '';
|
|
8227
|
+
let queryParams = {};
|
|
8228
|
+
if (this.apiClient.isVertexAI()) {
|
|
8229
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
8230
|
+
}
|
|
8231
|
+
else {
|
|
8232
|
+
const body = uploadToFileSearchStoreParametersToMldev(params);
|
|
8233
|
+
path = formatMap('upload/v1beta/{file_search_store_name}:uploadToFileSearchStore', body['_url']);
|
|
8234
|
+
queryParams = body['_query'];
|
|
8235
|
+
delete body['_url'];
|
|
8236
|
+
delete body['_query'];
|
|
8237
|
+
response = this.apiClient
|
|
8238
|
+
.request({
|
|
8239
|
+
path: path,
|
|
8240
|
+
queryParams: queryParams,
|
|
8241
|
+
body: JSON.stringify(body),
|
|
8242
|
+
httpMethod: 'POST',
|
|
8243
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8244
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8245
|
+
})
|
|
8246
|
+
.then((httpResponse) => {
|
|
8247
|
+
return httpResponse.json();
|
|
8248
|
+
});
|
|
8249
|
+
return response.then((apiResponse) => {
|
|
8250
|
+
const resp = uploadToFileSearchStoreResumableResponseFromMldev(apiResponse);
|
|
8251
|
+
const typedResp = new UploadToFileSearchStoreResumableResponse();
|
|
8252
|
+
Object.assign(typedResp, resp);
|
|
8253
|
+
return typedResp;
|
|
7213
8254
|
});
|
|
7214
8255
|
}
|
|
7215
8256
|
}
|
|
7216
8257
|
/**
|
|
7217
|
-
*
|
|
7218
|
-
*
|
|
7219
|
-
* @param params - The parameters for the delete request.
|
|
7220
|
-
* @return The DeleteFileResponse, the response for the delete method.
|
|
8258
|
+
* Imports a File from File Service to a FileSearchStore.
|
|
7221
8259
|
*
|
|
7222
|
-
*
|
|
7223
|
-
* The following code deletes an example file named "files/mehozpxf877d".
|
|
8260
|
+
* This is a long-running operation, see aip.dev/151
|
|
7224
8261
|
*
|
|
7225
|
-
*
|
|
7226
|
-
*
|
|
7227
|
-
* ```
|
|
8262
|
+
* @param params - The parameters for importing a file to a file search store.
|
|
8263
|
+
* @return ImportFileOperation.
|
|
7228
8264
|
*/
|
|
7229
|
-
async
|
|
8265
|
+
async importFile(params) {
|
|
7230
8266
|
var _a, _b;
|
|
7231
8267
|
let response;
|
|
7232
8268
|
let path = '';
|
|
@@ -7235,8 +8271,8 @@ class Files extends BaseModule {
|
|
|
7235
8271
|
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
7236
8272
|
}
|
|
7237
8273
|
else {
|
|
7238
|
-
const body =
|
|
7239
|
-
path = formatMap('
|
|
8274
|
+
const body = importFileParametersToMldev(params);
|
|
8275
|
+
path = formatMap('{file_search_store_name}:importFile', body['_url']);
|
|
7240
8276
|
queryParams = body['_query'];
|
|
7241
8277
|
delete body['_url'];
|
|
7242
8278
|
delete body['_query'];
|
|
@@ -7245,22 +8281,16 @@ class Files extends BaseModule {
|
|
|
7245
8281
|
path: path,
|
|
7246
8282
|
queryParams: queryParams,
|
|
7247
8283
|
body: JSON.stringify(body),
|
|
7248
|
-
httpMethod: '
|
|
8284
|
+
httpMethod: 'POST',
|
|
7249
8285
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7250
8286
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7251
8287
|
})
|
|
7252
8288
|
.then((httpResponse) => {
|
|
7253
|
-
return httpResponse.json()
|
|
7254
|
-
const response = jsonResponse;
|
|
7255
|
-
response.sdkHttpResponse = {
|
|
7256
|
-
headers: httpResponse.headers,
|
|
7257
|
-
};
|
|
7258
|
-
return response;
|
|
7259
|
-
});
|
|
8289
|
+
return httpResponse.json();
|
|
7260
8290
|
});
|
|
7261
8291
|
return response.then((apiResponse) => {
|
|
7262
|
-
const resp =
|
|
7263
|
-
const typedResp = new
|
|
8292
|
+
const resp = importFileOperationFromMldev(apiResponse);
|
|
8293
|
+
const typedResp = new ImportFileOperation();
|
|
7264
8294
|
Object.assign(typedResp, resp);
|
|
7265
8295
|
return typedResp;
|
|
7266
8296
|
});
|
|
@@ -7364,6 +8394,12 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
7364
8394
|
if (fromModelSelectionConfig != null) {
|
|
7365
8395
|
setValueByPath(toObject, ['modelConfig'], fromModelSelectionConfig);
|
|
7366
8396
|
}
|
|
8397
|
+
const fromResponseJsonSchema = getValueByPath(fromObject, [
|
|
8398
|
+
'responseJsonSchema',
|
|
8399
|
+
]);
|
|
8400
|
+
if (fromResponseJsonSchema != null) {
|
|
8401
|
+
setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
|
|
8402
|
+
}
|
|
7367
8403
|
const fromAudioTimestamp = getValueByPath(fromObject, [
|
|
7368
8404
|
'audioTimestamp',
|
|
7369
8405
|
]);
|
|
@@ -7410,12 +8446,6 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
7410
8446
|
if (fromPresencePenalty != null) {
|
|
7411
8447
|
setValueByPath(toObject, ['presencePenalty'], fromPresencePenalty);
|
|
7412
8448
|
}
|
|
7413
|
-
const fromResponseJsonSchema = getValueByPath(fromObject, [
|
|
7414
|
-
'responseJsonSchema',
|
|
7415
|
-
]);
|
|
7416
|
-
if (fromResponseJsonSchema != null) {
|
|
7417
|
-
setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
|
|
7418
|
-
}
|
|
7419
8449
|
const fromResponseLogprobs = getValueByPath(fromObject, [
|
|
7420
8450
|
'responseLogprobs',
|
|
7421
8451
|
]);
|
|
@@ -7500,6 +8530,9 @@ function googleSearchToMldev$2(fromObject) {
|
|
|
7500
8530
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
7501
8531
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
7502
8532
|
}
|
|
8533
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
8534
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
8535
|
+
}
|
|
7503
8536
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
7504
8537
|
'timeRangeFilter',
|
|
7505
8538
|
]);
|
|
@@ -8007,14 +9040,14 @@ function toolToMldev$2(fromObject) {
|
|
|
8007
9040
|
if (fromGoogleSearchRetrieval != null) {
|
|
8008
9041
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
8009
9042
|
}
|
|
8010
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
8011
|
-
if (fromGoogleMaps != null) {
|
|
8012
|
-
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$2(fromGoogleMaps));
|
|
8013
|
-
}
|
|
8014
9043
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
8015
9044
|
if (fromComputerUse != null) {
|
|
8016
9045
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
8017
9046
|
}
|
|
9047
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
9048
|
+
if (fromFileSearch != null) {
|
|
9049
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
9050
|
+
}
|
|
8018
9051
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
8019
9052
|
'codeExecution',
|
|
8020
9053
|
]);
|
|
@@ -8024,6 +9057,10 @@ function toolToMldev$2(fromObject) {
|
|
|
8024
9057
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
8025
9058
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
8026
9059
|
}
|
|
9060
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
9061
|
+
if (fromGoogleMaps != null) {
|
|
9062
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$2(fromGoogleMaps));
|
|
9063
|
+
}
|
|
8027
9064
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
8028
9065
|
if (fromGoogleSearch != null) {
|
|
8029
9066
|
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
@@ -8058,14 +9095,13 @@ function toolToVertex$1(fromObject) {
|
|
|
8058
9095
|
if (fromGoogleSearchRetrieval != null) {
|
|
8059
9096
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
8060
9097
|
}
|
|
8061
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
8062
|
-
if (fromGoogleMaps != null) {
|
|
8063
|
-
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
8064
|
-
}
|
|
8065
9098
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
8066
9099
|
if (fromComputerUse != null) {
|
|
8067
9100
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
8068
9101
|
}
|
|
9102
|
+
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
9103
|
+
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
9104
|
+
}
|
|
8069
9105
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
8070
9106
|
'codeExecution',
|
|
8071
9107
|
]);
|
|
@@ -8078,6 +9114,10 @@ function toolToVertex$1(fromObject) {
|
|
|
8078
9114
|
if (fromEnterpriseWebSearch != null) {
|
|
8079
9115
|
setValueByPath(toObject, ['enterpriseWebSearch'], fromEnterpriseWebSearch);
|
|
8080
9116
|
}
|
|
9117
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
9118
|
+
if (fromGoogleMaps != null) {
|
|
9119
|
+
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
9120
|
+
}
|
|
8081
9121
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
8082
9122
|
if (fromGoogleSearch != null) {
|
|
8083
9123
|
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
@@ -10027,6 +11067,12 @@ function generationConfigToVertex(fromObject) {
|
|
|
10027
11067
|
if (fromModelSelectionConfig != null) {
|
|
10028
11068
|
setValueByPath(toObject, ['modelConfig'], fromModelSelectionConfig);
|
|
10029
11069
|
}
|
|
11070
|
+
const fromResponseJsonSchema = getValueByPath(fromObject, [
|
|
11071
|
+
'responseJsonSchema',
|
|
11072
|
+
]);
|
|
11073
|
+
if (fromResponseJsonSchema != null) {
|
|
11074
|
+
setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
|
|
11075
|
+
}
|
|
10030
11076
|
const fromAudioTimestamp = getValueByPath(fromObject, [
|
|
10031
11077
|
'audioTimestamp',
|
|
10032
11078
|
]);
|
|
@@ -10073,12 +11119,6 @@ function generationConfigToVertex(fromObject) {
|
|
|
10073
11119
|
if (fromPresencePenalty != null) {
|
|
10074
11120
|
setValueByPath(toObject, ['presencePenalty'], fromPresencePenalty);
|
|
10075
11121
|
}
|
|
10076
|
-
const fromResponseJsonSchema = getValueByPath(fromObject, [
|
|
10077
|
-
'responseJsonSchema',
|
|
10078
|
-
]);
|
|
10079
|
-
if (fromResponseJsonSchema != null) {
|
|
10080
|
-
setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
|
|
10081
|
-
}
|
|
10082
11122
|
const fromResponseLogprobs = getValueByPath(fromObject, [
|
|
10083
11123
|
'responseLogprobs',
|
|
10084
11124
|
]);
|
|
@@ -10179,6 +11219,9 @@ function googleSearchToMldev$1(fromObject) {
|
|
|
10179
11219
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
10180
11220
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
10181
11221
|
}
|
|
11222
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
11223
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
11224
|
+
}
|
|
10182
11225
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
10183
11226
|
'timeRangeFilter',
|
|
10184
11227
|
]);
|
|
@@ -10881,14 +11924,14 @@ function toolToMldev$1(fromObject) {
|
|
|
10881
11924
|
if (fromGoogleSearchRetrieval != null) {
|
|
10882
11925
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
10883
11926
|
}
|
|
10884
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
10885
|
-
if (fromGoogleMaps != null) {
|
|
10886
|
-
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$1(fromGoogleMaps));
|
|
10887
|
-
}
|
|
10888
11927
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
10889
11928
|
if (fromComputerUse != null) {
|
|
10890
11929
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
10891
11930
|
}
|
|
11931
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
11932
|
+
if (fromFileSearch != null) {
|
|
11933
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
11934
|
+
}
|
|
10892
11935
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
10893
11936
|
'codeExecution',
|
|
10894
11937
|
]);
|
|
@@ -10898,6 +11941,10 @@ function toolToMldev$1(fromObject) {
|
|
|
10898
11941
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
10899
11942
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
10900
11943
|
}
|
|
11944
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
11945
|
+
if (fromGoogleMaps != null) {
|
|
11946
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$1(fromGoogleMaps));
|
|
11947
|
+
}
|
|
10901
11948
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
10902
11949
|
if (fromGoogleSearch != null) {
|
|
10903
11950
|
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
@@ -10932,14 +11979,13 @@ function toolToVertex(fromObject) {
|
|
|
10932
11979
|
if (fromGoogleSearchRetrieval != null) {
|
|
10933
11980
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
10934
11981
|
}
|
|
10935
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
10936
|
-
if (fromGoogleMaps != null) {
|
|
10937
|
-
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
10938
|
-
}
|
|
10939
11982
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
10940
11983
|
if (fromComputerUse != null) {
|
|
10941
11984
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
10942
11985
|
}
|
|
11986
|
+
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
11987
|
+
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
11988
|
+
}
|
|
10943
11989
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
10944
11990
|
'codeExecution',
|
|
10945
11991
|
]);
|
|
@@ -10952,6 +11998,10 @@ function toolToVertex(fromObject) {
|
|
|
10952
11998
|
if (fromEnterpriseWebSearch != null) {
|
|
10953
11999
|
setValueByPath(toObject, ['enterpriseWebSearch'], fromEnterpriseWebSearch);
|
|
10954
12000
|
}
|
|
12001
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
12002
|
+
if (fromGoogleMaps != null) {
|
|
12003
|
+
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
12004
|
+
}
|
|
10955
12005
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
10956
12006
|
if (fromGoogleSearch != null) {
|
|
10957
12007
|
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
@@ -12154,11 +13204,27 @@ function hasCallableTools(params) {
|
|
|
12154
13204
|
var _a, _b, _c;
|
|
12155
13205
|
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;
|
|
12156
13206
|
}
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
13207
|
+
/**
|
|
13208
|
+
* Returns the indexes of the tools that are not compatible with AFC.
|
|
13209
|
+
*/
|
|
13210
|
+
function findAfcIncompatibleToolIndexes(params) {
|
|
13211
|
+
var _a;
|
|
13212
|
+
// Use number[] for an array of numbers in TypeScript
|
|
13213
|
+
const afcIncompatibleToolIndexes = [];
|
|
13214
|
+
if (!((_a = params === null || params === void 0 ? void 0 : params.config) === null || _a === void 0 ? void 0 : _a.tools)) {
|
|
13215
|
+
return afcIncompatibleToolIndexes;
|
|
13216
|
+
}
|
|
13217
|
+
params.config.tools.forEach((tool, index) => {
|
|
13218
|
+
if (isCallableTool(tool)) {
|
|
13219
|
+
return;
|
|
13220
|
+
}
|
|
13221
|
+
const geminiTool = tool;
|
|
13222
|
+
if (geminiTool.functionDeclarations &&
|
|
13223
|
+
geminiTool.functionDeclarations.length > 0) {
|
|
13224
|
+
afcIncompatibleToolIndexes.push(index);
|
|
13225
|
+
}
|
|
13226
|
+
});
|
|
13227
|
+
return afcIncompatibleToolIndexes;
|
|
12162
13228
|
}
|
|
12163
13229
|
/**
|
|
12164
13230
|
* Returns whether to append automatic function calling history to the
|
|
@@ -12223,8 +13289,12 @@ class Models extends BaseModule {
|
|
|
12223
13289
|
if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
|
|
12224
13290
|
return await this.generateContentInternal(transformedParams);
|
|
12225
13291
|
}
|
|
12226
|
-
|
|
12227
|
-
|
|
13292
|
+
const incompatibleToolIndexes = findAfcIncompatibleToolIndexes(params);
|
|
13293
|
+
if (incompatibleToolIndexes.length > 0) {
|
|
13294
|
+
const formattedIndexes = incompatibleToolIndexes
|
|
13295
|
+
.map((index) => `tools[${index}]`)
|
|
13296
|
+
.join(', ');
|
|
13297
|
+
throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${formattedIndexes}.`);
|
|
12228
13298
|
}
|
|
12229
13299
|
let response;
|
|
12230
13300
|
let functionResponseContent;
|
|
@@ -12311,9 +13381,14 @@ class Models extends BaseModule {
|
|
|
12311
13381
|
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
12312
13382
|
return await this.generateContentStreamInternal(transformedParams);
|
|
12313
13383
|
}
|
|
12314
|
-
|
|
12315
|
-
|
|
13384
|
+
const incompatibleToolIndexes = findAfcIncompatibleToolIndexes(params);
|
|
13385
|
+
if (incompatibleToolIndexes.length > 0) {
|
|
13386
|
+
const formattedIndexes = incompatibleToolIndexes
|
|
13387
|
+
.map((index) => `tools[${index}]`)
|
|
13388
|
+
.join(', ');
|
|
13389
|
+
throw new Error(`Incompatible tools found at ${formattedIndexes}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`);
|
|
12316
13390
|
}
|
|
13391
|
+
return await this.processAfcStream(params);
|
|
12317
13392
|
};
|
|
12318
13393
|
/**
|
|
12319
13394
|
* Generates an image based on a text description and configuration.
|
|
@@ -13709,7 +14784,7 @@ class Operations extends BaseModule {
|
|
|
13709
14784
|
});
|
|
13710
14785
|
return operation._fromAPIResponse({
|
|
13711
14786
|
apiResponse: rawOperation,
|
|
13712
|
-
|
|
14787
|
+
_isVertexAI: true,
|
|
13713
14788
|
});
|
|
13714
14789
|
}
|
|
13715
14790
|
else {
|
|
@@ -13719,7 +14794,7 @@ class Operations extends BaseModule {
|
|
|
13719
14794
|
});
|
|
13720
14795
|
return operation._fromAPIResponse({
|
|
13721
14796
|
apiResponse: rawOperation,
|
|
13722
|
-
|
|
14797
|
+
_isVertexAI: false,
|
|
13723
14798
|
});
|
|
13724
14799
|
}
|
|
13725
14800
|
}
|
|
@@ -13748,7 +14823,7 @@ class Operations extends BaseModule {
|
|
|
13748
14823
|
});
|
|
13749
14824
|
return operation._fromAPIResponse({
|
|
13750
14825
|
apiResponse: rawOperation,
|
|
13751
|
-
|
|
14826
|
+
_isVertexAI: true,
|
|
13752
14827
|
});
|
|
13753
14828
|
}
|
|
13754
14829
|
else {
|
|
@@ -13758,7 +14833,7 @@ class Operations extends BaseModule {
|
|
|
13758
14833
|
});
|
|
13759
14834
|
return operation._fromAPIResponse({
|
|
13760
14835
|
apiResponse: rawOperation,
|
|
13761
|
-
|
|
14836
|
+
_isVertexAI: false,
|
|
13762
14837
|
});
|
|
13763
14838
|
}
|
|
13764
14839
|
}
|
|
@@ -13946,6 +15021,9 @@ function googleSearchToMldev(fromObject) {
|
|
|
13946
15021
|
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
13947
15022
|
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
13948
15023
|
}
|
|
15024
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
15025
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
15026
|
+
}
|
|
13949
15027
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
13950
15028
|
'timeRangeFilter',
|
|
13951
15029
|
]);
|
|
@@ -14164,14 +15242,14 @@ function toolToMldev(fromObject) {
|
|
|
14164
15242
|
if (fromGoogleSearchRetrieval != null) {
|
|
14165
15243
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
14166
15244
|
}
|
|
14167
|
-
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
14168
|
-
if (fromGoogleMaps != null) {
|
|
14169
|
-
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev(fromGoogleMaps));
|
|
14170
|
-
}
|
|
14171
15245
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
14172
15246
|
if (fromComputerUse != null) {
|
|
14173
15247
|
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
14174
15248
|
}
|
|
15249
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
15250
|
+
if (fromFileSearch != null) {
|
|
15251
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
15252
|
+
}
|
|
14175
15253
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
14176
15254
|
'codeExecution',
|
|
14177
15255
|
]);
|
|
@@ -14181,6 +15259,10 @@ function toolToMldev(fromObject) {
|
|
|
14181
15259
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
14182
15260
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
14183
15261
|
}
|
|
15262
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
15263
|
+
if (fromGoogleMaps != null) {
|
|
15264
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev(fromGoogleMaps));
|
|
15265
|
+
}
|
|
14184
15266
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
14185
15267
|
if (fromGoogleSearch != null) {
|
|
14186
15268
|
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
@@ -15565,6 +16647,7 @@ class GoogleGenAI {
|
|
|
15565
16647
|
this.operations = new Operations(this.apiClient);
|
|
15566
16648
|
this.authTokens = new Tokens(this.apiClient);
|
|
15567
16649
|
this.tunings = new Tunings(this.apiClient);
|
|
16650
|
+
this.fileSearchStores = new FileSearchStores(this.apiClient);
|
|
15568
16651
|
}
|
|
15569
16652
|
}
|
|
15570
16653
|
|
|
@@ -15596,10 +16679,14 @@ exports.GenerateVideosOperation = GenerateVideosOperation;
|
|
|
15596
16679
|
exports.GenerateVideosResponse = GenerateVideosResponse;
|
|
15597
16680
|
exports.GoogleGenAI = GoogleGenAI;
|
|
15598
16681
|
exports.HttpResponse = HttpResponse;
|
|
16682
|
+
exports.ImportFileOperation = ImportFileOperation;
|
|
16683
|
+
exports.ImportFileResponse = ImportFileResponse;
|
|
15599
16684
|
exports.InlinedEmbedContentResponse = InlinedEmbedContentResponse;
|
|
15600
16685
|
exports.InlinedResponse = InlinedResponse;
|
|
15601
16686
|
exports.ListBatchJobsResponse = ListBatchJobsResponse;
|
|
15602
16687
|
exports.ListCachedContentsResponse = ListCachedContentsResponse;
|
|
16688
|
+
exports.ListDocumentsResponse = ListDocumentsResponse;
|
|
16689
|
+
exports.ListFileSearchStoresResponse = ListFileSearchStoresResponse;
|
|
15603
16690
|
exports.ListFilesResponse = ListFilesResponse;
|
|
15604
16691
|
exports.ListModelsResponse = ListModelsResponse;
|
|
15605
16692
|
exports.ListTuningJobsResponse = ListTuningJobsResponse;
|
|
@@ -15621,6 +16708,9 @@ exports.SingleEmbedContentResponse = SingleEmbedContentResponse;
|
|
|
15621
16708
|
exports.StyleReferenceImage = StyleReferenceImage;
|
|
15622
16709
|
exports.SubjectReferenceImage = SubjectReferenceImage;
|
|
15623
16710
|
exports.Tokens = Tokens;
|
|
16711
|
+
exports.UploadToFileSearchStoreOperation = UploadToFileSearchStoreOperation;
|
|
16712
|
+
exports.UploadToFileSearchStoreResponse = UploadToFileSearchStoreResponse;
|
|
16713
|
+
exports.UploadToFileSearchStoreResumableResponse = UploadToFileSearchStoreResumableResponse;
|
|
15624
16714
|
exports.UpscaleImageResponse = UpscaleImageResponse;
|
|
15625
16715
|
exports.createFunctionResponsePartFromBase64 = createFunctionResponsePartFromBase64;
|
|
15626
16716
|
exports.createFunctionResponsePartFromUri = createFunctionResponsePartFromUri;
|