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