@google/genai 1.27.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 +898 -166
- package/dist/index.cjs +1815 -573
- package/dist/index.mjs +1809 -574
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +1927 -655
- package/dist/node/index.mjs +1922 -657
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +898 -166
- package/dist/web/index.mjs +1876 -643
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +898 -166
- package/package.json +12 -7
package/dist/node/index.cjs
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var googleAuthLibrary = require('google-auth-library');
|
|
4
4
|
var fs = require('fs');
|
|
5
|
+
var fs$1 = require('fs/promises');
|
|
5
6
|
var node_stream = require('node:stream');
|
|
7
|
+
var promises = require('node:stream/promises');
|
|
6
8
|
var NodeWs = require('ws');
|
|
7
|
-
var
|
|
9
|
+
var path = require('path');
|
|
8
10
|
|
|
9
11
|
function _interopNamespaceDefault(e) {
|
|
10
12
|
var n = Object.create(null);
|
|
@@ -23,8 +25,9 @@ function _interopNamespaceDefault(e) {
|
|
|
23
25
|
return Object.freeze(n);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
var NodeWs__namespace = /*#__PURE__*/_interopNamespaceDefault(NodeWs);
|
|
27
28
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs$1);
|
|
29
|
+
var NodeWs__namespace = /*#__PURE__*/_interopNamespaceDefault(NodeWs);
|
|
30
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
28
31
|
|
|
29
32
|
/**
|
|
30
33
|
* @license
|
|
@@ -488,6 +491,90 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
488
491
|
}
|
|
489
492
|
return toObject;
|
|
490
493
|
}
|
|
494
|
+
function importFileOperationFromMldev$1(fromObject) {
|
|
495
|
+
const toObject = {};
|
|
496
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
497
|
+
if (fromName != null) {
|
|
498
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
499
|
+
}
|
|
500
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
501
|
+
if (fromMetadata != null) {
|
|
502
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
503
|
+
}
|
|
504
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
505
|
+
if (fromDone != null) {
|
|
506
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
507
|
+
}
|
|
508
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
509
|
+
if (fromError != null) {
|
|
510
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
511
|
+
}
|
|
512
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
513
|
+
if (fromResponse != null) {
|
|
514
|
+
setValueByPath(toObject, ['response'], importFileResponseFromMldev$1(fromResponse));
|
|
515
|
+
}
|
|
516
|
+
return toObject;
|
|
517
|
+
}
|
|
518
|
+
function importFileResponseFromMldev$1(fromObject) {
|
|
519
|
+
const toObject = {};
|
|
520
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
521
|
+
'sdkHttpResponse',
|
|
522
|
+
]);
|
|
523
|
+
if (fromSdkHttpResponse != null) {
|
|
524
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
525
|
+
}
|
|
526
|
+
const fromParent = getValueByPath(fromObject, ['parent']);
|
|
527
|
+
if (fromParent != null) {
|
|
528
|
+
setValueByPath(toObject, ['parent'], fromParent);
|
|
529
|
+
}
|
|
530
|
+
const fromDocumentName = getValueByPath(fromObject, ['documentName']);
|
|
531
|
+
if (fromDocumentName != null) {
|
|
532
|
+
setValueByPath(toObject, ['documentName'], fromDocumentName);
|
|
533
|
+
}
|
|
534
|
+
return toObject;
|
|
535
|
+
}
|
|
536
|
+
function uploadToFileSearchStoreOperationFromMldev(fromObject) {
|
|
537
|
+
const toObject = {};
|
|
538
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
539
|
+
if (fromName != null) {
|
|
540
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
541
|
+
}
|
|
542
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
543
|
+
if (fromMetadata != null) {
|
|
544
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
545
|
+
}
|
|
546
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
547
|
+
if (fromDone != null) {
|
|
548
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
549
|
+
}
|
|
550
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
551
|
+
if (fromError != null) {
|
|
552
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
553
|
+
}
|
|
554
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
555
|
+
if (fromResponse != null) {
|
|
556
|
+
setValueByPath(toObject, ['response'], uploadToFileSearchStoreResponseFromMldev(fromResponse));
|
|
557
|
+
}
|
|
558
|
+
return toObject;
|
|
559
|
+
}
|
|
560
|
+
function uploadToFileSearchStoreResponseFromMldev(fromObject) {
|
|
561
|
+
const toObject = {};
|
|
562
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
563
|
+
'sdkHttpResponse',
|
|
564
|
+
]);
|
|
565
|
+
if (fromSdkHttpResponse != null) {
|
|
566
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
567
|
+
}
|
|
568
|
+
const fromParent = getValueByPath(fromObject, ['parent']);
|
|
569
|
+
if (fromParent != null) {
|
|
570
|
+
setValueByPath(toObject, ['parent'], fromParent);
|
|
571
|
+
}
|
|
572
|
+
const fromDocumentName = getValueByPath(fromObject, ['documentName']);
|
|
573
|
+
if (fromDocumentName != null) {
|
|
574
|
+
setValueByPath(toObject, ['documentName'], fromDocumentName);
|
|
575
|
+
}
|
|
576
|
+
return toObject;
|
|
577
|
+
}
|
|
491
578
|
function videoFromMldev$1(fromObject) {
|
|
492
579
|
const toObject = {};
|
|
493
580
|
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
@@ -528,7 +615,7 @@ function videoFromVertex$1(fromObject) {
|
|
|
528
615
|
* Copyright 2025 Google LLC
|
|
529
616
|
* SPDX-License-Identifier: Apache-2.0
|
|
530
617
|
*/
|
|
531
|
-
/**
|
|
618
|
+
/** Outcome of the code execution. */
|
|
532
619
|
exports.Outcome = void 0;
|
|
533
620
|
(function (Outcome) {
|
|
534
621
|
/**
|
|
@@ -548,7 +635,7 @@ exports.Outcome = void 0;
|
|
|
548
635
|
*/
|
|
549
636
|
Outcome["OUTCOME_DEADLINE_EXCEEDED"] = "OUTCOME_DEADLINE_EXCEEDED";
|
|
550
637
|
})(exports.Outcome || (exports.Outcome = {}));
|
|
551
|
-
/**
|
|
638
|
+
/** Programming language of the `code`. */
|
|
552
639
|
exports.Language = void 0;
|
|
553
640
|
(function (Language) {
|
|
554
641
|
/**
|
|
@@ -580,7 +667,7 @@ exports.FunctionResponseScheduling = void 0;
|
|
|
580
667
|
*/
|
|
581
668
|
FunctionResponseScheduling["INTERRUPT"] = "INTERRUPT";
|
|
582
669
|
})(exports.FunctionResponseScheduling || (exports.FunctionResponseScheduling = {}));
|
|
583
|
-
/**
|
|
670
|
+
/** The type of the data. */
|
|
584
671
|
exports.Type = void 0;
|
|
585
672
|
(function (Type) {
|
|
586
673
|
/**
|
|
@@ -616,7 +703,121 @@ exports.Type = void 0;
|
|
|
616
703
|
*/
|
|
617
704
|
Type["NULL"] = "NULL";
|
|
618
705
|
})(exports.Type || (exports.Type = {}));
|
|
619
|
-
/**
|
|
706
|
+
/** The mode of the predictor to be used in dynamic retrieval. */
|
|
707
|
+
exports.Mode = void 0;
|
|
708
|
+
(function (Mode) {
|
|
709
|
+
/**
|
|
710
|
+
* Always trigger retrieval.
|
|
711
|
+
*/
|
|
712
|
+
Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
713
|
+
/**
|
|
714
|
+
* Run retrieval only when system decides it is necessary.
|
|
715
|
+
*/
|
|
716
|
+
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
717
|
+
})(exports.Mode || (exports.Mode = {}));
|
|
718
|
+
/** The API spec that the external API implements. This enum is not supported in Gemini API. */
|
|
719
|
+
exports.ApiSpec = void 0;
|
|
720
|
+
(function (ApiSpec) {
|
|
721
|
+
/**
|
|
722
|
+
* Unspecified API spec. This value should not be used.
|
|
723
|
+
*/
|
|
724
|
+
ApiSpec["API_SPEC_UNSPECIFIED"] = "API_SPEC_UNSPECIFIED";
|
|
725
|
+
/**
|
|
726
|
+
* Simple search API spec.
|
|
727
|
+
*/
|
|
728
|
+
ApiSpec["SIMPLE_SEARCH"] = "SIMPLE_SEARCH";
|
|
729
|
+
/**
|
|
730
|
+
* Elastic search API spec.
|
|
731
|
+
*/
|
|
732
|
+
ApiSpec["ELASTIC_SEARCH"] = "ELASTIC_SEARCH";
|
|
733
|
+
})(exports.ApiSpec || (exports.ApiSpec = {}));
|
|
734
|
+
/** Type of auth scheme. This enum is not supported in Gemini API. */
|
|
735
|
+
exports.AuthType = void 0;
|
|
736
|
+
(function (AuthType) {
|
|
737
|
+
AuthType["AUTH_TYPE_UNSPECIFIED"] = "AUTH_TYPE_UNSPECIFIED";
|
|
738
|
+
/**
|
|
739
|
+
* No Auth.
|
|
740
|
+
*/
|
|
741
|
+
AuthType["NO_AUTH"] = "NO_AUTH";
|
|
742
|
+
/**
|
|
743
|
+
* API Key Auth.
|
|
744
|
+
*/
|
|
745
|
+
AuthType["API_KEY_AUTH"] = "API_KEY_AUTH";
|
|
746
|
+
/**
|
|
747
|
+
* HTTP Basic Auth.
|
|
748
|
+
*/
|
|
749
|
+
AuthType["HTTP_BASIC_AUTH"] = "HTTP_BASIC_AUTH";
|
|
750
|
+
/**
|
|
751
|
+
* Google Service Account Auth.
|
|
752
|
+
*/
|
|
753
|
+
AuthType["GOOGLE_SERVICE_ACCOUNT_AUTH"] = "GOOGLE_SERVICE_ACCOUNT_AUTH";
|
|
754
|
+
/**
|
|
755
|
+
* OAuth auth.
|
|
756
|
+
*/
|
|
757
|
+
AuthType["OAUTH"] = "OAUTH";
|
|
758
|
+
/**
|
|
759
|
+
* OpenID Connect (OIDC) Auth.
|
|
760
|
+
*/
|
|
761
|
+
AuthType["OIDC_AUTH"] = "OIDC_AUTH";
|
|
762
|
+
})(exports.AuthType || (exports.AuthType = {}));
|
|
763
|
+
/** The location of the API key. This enum is not supported in Gemini API. */
|
|
764
|
+
exports.HttpElementLocation = void 0;
|
|
765
|
+
(function (HttpElementLocation) {
|
|
766
|
+
HttpElementLocation["HTTP_IN_UNSPECIFIED"] = "HTTP_IN_UNSPECIFIED";
|
|
767
|
+
/**
|
|
768
|
+
* Element is in the HTTP request query.
|
|
769
|
+
*/
|
|
770
|
+
HttpElementLocation["HTTP_IN_QUERY"] = "HTTP_IN_QUERY";
|
|
771
|
+
/**
|
|
772
|
+
* Element is in the HTTP request header.
|
|
773
|
+
*/
|
|
774
|
+
HttpElementLocation["HTTP_IN_HEADER"] = "HTTP_IN_HEADER";
|
|
775
|
+
/**
|
|
776
|
+
* Element is in the HTTP request path.
|
|
777
|
+
*/
|
|
778
|
+
HttpElementLocation["HTTP_IN_PATH"] = "HTTP_IN_PATH";
|
|
779
|
+
/**
|
|
780
|
+
* Element is in the HTTP request body.
|
|
781
|
+
*/
|
|
782
|
+
HttpElementLocation["HTTP_IN_BODY"] = "HTTP_IN_BODY";
|
|
783
|
+
/**
|
|
784
|
+
* Element is in the HTTP request cookie.
|
|
785
|
+
*/
|
|
786
|
+
HttpElementLocation["HTTP_IN_COOKIE"] = "HTTP_IN_COOKIE";
|
|
787
|
+
})(exports.HttpElementLocation || (exports.HttpElementLocation = {}));
|
|
788
|
+
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
789
|
+
exports.PhishBlockThreshold = void 0;
|
|
790
|
+
(function (PhishBlockThreshold) {
|
|
791
|
+
/**
|
|
792
|
+
* Defaults to unspecified.
|
|
793
|
+
*/
|
|
794
|
+
PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
795
|
+
/**
|
|
796
|
+
* Blocks Low and above confidence URL that is risky.
|
|
797
|
+
*/
|
|
798
|
+
PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
799
|
+
/**
|
|
800
|
+
* Blocks Medium and above confidence URL that is risky.
|
|
801
|
+
*/
|
|
802
|
+
PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
803
|
+
/**
|
|
804
|
+
* Blocks High and above confidence URL that is risky.
|
|
805
|
+
*/
|
|
806
|
+
PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
|
|
807
|
+
/**
|
|
808
|
+
* Blocks Higher and above confidence URL that is risky.
|
|
809
|
+
*/
|
|
810
|
+
PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
|
|
811
|
+
/**
|
|
812
|
+
* Blocks Very high and above confidence URL that is risky.
|
|
813
|
+
*/
|
|
814
|
+
PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
|
|
815
|
+
/**
|
|
816
|
+
* Blocks Extremely high confidence URL that is risky.
|
|
817
|
+
*/
|
|
818
|
+
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
819
|
+
})(exports.PhishBlockThreshold || (exports.PhishBlockThreshold = {}));
|
|
820
|
+
/** Harm category. */
|
|
620
821
|
exports.HarmCategory = void 0;
|
|
621
822
|
(function (HarmCategory) {
|
|
622
823
|
/**
|
|
@@ -664,7 +865,7 @@ exports.HarmCategory = void 0;
|
|
|
664
865
|
*/
|
|
665
866
|
HarmCategory["HARM_CATEGORY_JAILBREAK"] = "HARM_CATEGORY_JAILBREAK";
|
|
666
867
|
})(exports.HarmCategory || (exports.HarmCategory = {}));
|
|
667
|
-
/**
|
|
868
|
+
/** Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. This enum is not supported in Gemini API. */
|
|
668
869
|
exports.HarmBlockMethod = void 0;
|
|
669
870
|
(function (HarmBlockMethod) {
|
|
670
871
|
/**
|
|
@@ -680,7 +881,7 @@ exports.HarmBlockMethod = void 0;
|
|
|
680
881
|
*/
|
|
681
882
|
HarmBlockMethod["PROBABILITY"] = "PROBABILITY";
|
|
682
883
|
})(exports.HarmBlockMethod || (exports.HarmBlockMethod = {}));
|
|
683
|
-
/**
|
|
884
|
+
/** The harm block threshold. */
|
|
684
885
|
exports.HarmBlockThreshold = void 0;
|
|
685
886
|
(function (HarmBlockThreshold) {
|
|
686
887
|
/**
|
|
@@ -708,87 +909,6 @@ exports.HarmBlockThreshold = void 0;
|
|
|
708
909
|
*/
|
|
709
910
|
HarmBlockThreshold["OFF"] = "OFF";
|
|
710
911
|
})(exports.HarmBlockThreshold || (exports.HarmBlockThreshold = {}));
|
|
711
|
-
/** The mode of the predictor to be used in dynamic retrieval. */
|
|
712
|
-
exports.Mode = void 0;
|
|
713
|
-
(function (Mode) {
|
|
714
|
-
/**
|
|
715
|
-
* Always trigger retrieval.
|
|
716
|
-
*/
|
|
717
|
-
Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
718
|
-
/**
|
|
719
|
-
* Run retrieval only when system decides it is necessary.
|
|
720
|
-
*/
|
|
721
|
-
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
722
|
-
})(exports.Mode || (exports.Mode = {}));
|
|
723
|
-
/** Type of auth scheme. */
|
|
724
|
-
exports.AuthType = void 0;
|
|
725
|
-
(function (AuthType) {
|
|
726
|
-
AuthType["AUTH_TYPE_UNSPECIFIED"] = "AUTH_TYPE_UNSPECIFIED";
|
|
727
|
-
/**
|
|
728
|
-
* No Auth.
|
|
729
|
-
*/
|
|
730
|
-
AuthType["NO_AUTH"] = "NO_AUTH";
|
|
731
|
-
/**
|
|
732
|
-
* API Key Auth.
|
|
733
|
-
*/
|
|
734
|
-
AuthType["API_KEY_AUTH"] = "API_KEY_AUTH";
|
|
735
|
-
/**
|
|
736
|
-
* HTTP Basic Auth.
|
|
737
|
-
*/
|
|
738
|
-
AuthType["HTTP_BASIC_AUTH"] = "HTTP_BASIC_AUTH";
|
|
739
|
-
/**
|
|
740
|
-
* Google Service Account Auth.
|
|
741
|
-
*/
|
|
742
|
-
AuthType["GOOGLE_SERVICE_ACCOUNT_AUTH"] = "GOOGLE_SERVICE_ACCOUNT_AUTH";
|
|
743
|
-
/**
|
|
744
|
-
* OAuth auth.
|
|
745
|
-
*/
|
|
746
|
-
AuthType["OAUTH"] = "OAUTH";
|
|
747
|
-
/**
|
|
748
|
-
* OpenID Connect (OIDC) Auth.
|
|
749
|
-
*/
|
|
750
|
-
AuthType["OIDC_AUTH"] = "OIDC_AUTH";
|
|
751
|
-
})(exports.AuthType || (exports.AuthType = {}));
|
|
752
|
-
/** The API spec that the external API implements. */
|
|
753
|
-
exports.ApiSpec = void 0;
|
|
754
|
-
(function (ApiSpec) {
|
|
755
|
-
/**
|
|
756
|
-
* Unspecified API spec. This value should not be used.
|
|
757
|
-
*/
|
|
758
|
-
ApiSpec["API_SPEC_UNSPECIFIED"] = "API_SPEC_UNSPECIFIED";
|
|
759
|
-
/**
|
|
760
|
-
* Simple search API spec.
|
|
761
|
-
*/
|
|
762
|
-
ApiSpec["SIMPLE_SEARCH"] = "SIMPLE_SEARCH";
|
|
763
|
-
/**
|
|
764
|
-
* Elastic search API spec.
|
|
765
|
-
*/
|
|
766
|
-
ApiSpec["ELASTIC_SEARCH"] = "ELASTIC_SEARCH";
|
|
767
|
-
})(exports.ApiSpec || (exports.ApiSpec = {}));
|
|
768
|
-
/** Status of the url retrieval. */
|
|
769
|
-
exports.UrlRetrievalStatus = void 0;
|
|
770
|
-
(function (UrlRetrievalStatus) {
|
|
771
|
-
/**
|
|
772
|
-
* Default value. This value is unused
|
|
773
|
-
*/
|
|
774
|
-
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_UNSPECIFIED"] = "URL_RETRIEVAL_STATUS_UNSPECIFIED";
|
|
775
|
-
/**
|
|
776
|
-
* Url retrieval is successful.
|
|
777
|
-
*/
|
|
778
|
-
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_SUCCESS"] = "URL_RETRIEVAL_STATUS_SUCCESS";
|
|
779
|
-
/**
|
|
780
|
-
* Url retrieval is failed due to error.
|
|
781
|
-
*/
|
|
782
|
-
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_ERROR"] = "URL_RETRIEVAL_STATUS_ERROR";
|
|
783
|
-
/**
|
|
784
|
-
* Url retrieval is failed because the content is behind paywall.
|
|
785
|
-
*/
|
|
786
|
-
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_PAYWALL"] = "URL_RETRIEVAL_STATUS_PAYWALL";
|
|
787
|
-
/**
|
|
788
|
-
* Url retrieval is failed because the content is unsafe.
|
|
789
|
-
*/
|
|
790
|
-
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_UNSAFE"] = "URL_RETRIEVAL_STATUS_UNSAFE";
|
|
791
|
-
})(exports.UrlRetrievalStatus || (exports.UrlRetrievalStatus = {}));
|
|
792
912
|
/** Output only. The reason why the model stopped generating tokens.
|
|
793
913
|
|
|
794
914
|
If empty, the model has not stopped generating the tokens. */
|
|
@@ -879,7 +999,7 @@ exports.HarmProbability = void 0;
|
|
|
879
999
|
*/
|
|
880
1000
|
HarmProbability["HIGH"] = "HIGH";
|
|
881
1001
|
})(exports.HarmProbability || (exports.HarmProbability = {}));
|
|
882
|
-
/** Output only. Harm severity levels in the content. */
|
|
1002
|
+
/** Output only. Harm severity levels in the content. This enum is not supported in Gemini API. */
|
|
883
1003
|
exports.HarmSeverity = void 0;
|
|
884
1004
|
(function (HarmSeverity) {
|
|
885
1005
|
/**
|
|
@@ -903,6 +1023,30 @@ exports.HarmSeverity = void 0;
|
|
|
903
1023
|
*/
|
|
904
1024
|
HarmSeverity["HARM_SEVERITY_HIGH"] = "HARM_SEVERITY_HIGH";
|
|
905
1025
|
})(exports.HarmSeverity || (exports.HarmSeverity = {}));
|
|
1026
|
+
/** Status of the url retrieval. */
|
|
1027
|
+
exports.UrlRetrievalStatus = void 0;
|
|
1028
|
+
(function (UrlRetrievalStatus) {
|
|
1029
|
+
/**
|
|
1030
|
+
* Default value. This value is unused.
|
|
1031
|
+
*/
|
|
1032
|
+
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_UNSPECIFIED"] = "URL_RETRIEVAL_STATUS_UNSPECIFIED";
|
|
1033
|
+
/**
|
|
1034
|
+
* Url retrieval is successful.
|
|
1035
|
+
*/
|
|
1036
|
+
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_SUCCESS"] = "URL_RETRIEVAL_STATUS_SUCCESS";
|
|
1037
|
+
/**
|
|
1038
|
+
* Url retrieval is failed due to error.
|
|
1039
|
+
*/
|
|
1040
|
+
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_ERROR"] = "URL_RETRIEVAL_STATUS_ERROR";
|
|
1041
|
+
/**
|
|
1042
|
+
* Url retrieval is failed because the content is behind paywall. This enum value is not supported in Vertex AI.
|
|
1043
|
+
*/
|
|
1044
|
+
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_PAYWALL"] = "URL_RETRIEVAL_STATUS_PAYWALL";
|
|
1045
|
+
/**
|
|
1046
|
+
* Url retrieval is failed because the content is unsafe. This enum value is not supported in Vertex AI.
|
|
1047
|
+
*/
|
|
1048
|
+
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_UNSAFE"] = "URL_RETRIEVAL_STATUS_UNSAFE";
|
|
1049
|
+
})(exports.UrlRetrievalStatus || (exports.UrlRetrievalStatus = {}));
|
|
906
1050
|
/** Output only. The reason why the prompt was blocked. */
|
|
907
1051
|
exports.BlockedReason = void 0;
|
|
908
1052
|
(function (BlockedReason) {
|
|
@@ -939,7 +1083,7 @@ exports.BlockedReason = void 0;
|
|
|
939
1083
|
*/
|
|
940
1084
|
BlockedReason["JAILBREAK"] = "JAILBREAK";
|
|
941
1085
|
})(exports.BlockedReason || (exports.BlockedReason = {}));
|
|
942
|
-
/** Output only.
|
|
1086
|
+
/** Output only. The traffic type for this request. This enum is not supported in Gemini API. */
|
|
943
1087
|
exports.TrafficType = void 0;
|
|
944
1088
|
(function (TrafficType) {
|
|
945
1089
|
/**
|
|
@@ -947,7 +1091,7 @@ exports.TrafficType = void 0;
|
|
|
947
1091
|
*/
|
|
948
1092
|
TrafficType["TRAFFIC_TYPE_UNSPECIFIED"] = "TRAFFIC_TYPE_UNSPECIFIED";
|
|
949
1093
|
/**
|
|
950
|
-
*
|
|
1094
|
+
* The request was processed using Pay-As-You-Go quota.
|
|
951
1095
|
*/
|
|
952
1096
|
TrafficType["ON_DEMAND"] = "ON_DEMAND";
|
|
953
1097
|
/**
|
|
@@ -995,13 +1139,61 @@ exports.MediaResolution = void 0;
|
|
|
995
1139
|
*/
|
|
996
1140
|
MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
997
1141
|
})(exports.MediaResolution || (exports.MediaResolution = {}));
|
|
998
|
-
/**
|
|
999
|
-
exports.
|
|
1000
|
-
(function (
|
|
1142
|
+
/** Tuning mode. This enum is not supported in Gemini API. */
|
|
1143
|
+
exports.TuningMode = void 0;
|
|
1144
|
+
(function (TuningMode) {
|
|
1001
1145
|
/**
|
|
1002
|
-
*
|
|
1146
|
+
* Tuning mode is unspecified.
|
|
1003
1147
|
*/
|
|
1004
|
-
|
|
1148
|
+
TuningMode["TUNING_MODE_UNSPECIFIED"] = "TUNING_MODE_UNSPECIFIED";
|
|
1149
|
+
/**
|
|
1150
|
+
* Full fine-tuning mode.
|
|
1151
|
+
*/
|
|
1152
|
+
TuningMode["TUNING_MODE_FULL"] = "TUNING_MODE_FULL";
|
|
1153
|
+
/**
|
|
1154
|
+
* PEFT adapter tuning mode.
|
|
1155
|
+
*/
|
|
1156
|
+
TuningMode["TUNING_MODE_PEFT_ADAPTER"] = "TUNING_MODE_PEFT_ADAPTER";
|
|
1157
|
+
})(exports.TuningMode || (exports.TuningMode = {}));
|
|
1158
|
+
/** Adapter size for tuning. This enum is not supported in Gemini API. */
|
|
1159
|
+
exports.AdapterSize = void 0;
|
|
1160
|
+
(function (AdapterSize) {
|
|
1161
|
+
/**
|
|
1162
|
+
* Adapter size is unspecified.
|
|
1163
|
+
*/
|
|
1164
|
+
AdapterSize["ADAPTER_SIZE_UNSPECIFIED"] = "ADAPTER_SIZE_UNSPECIFIED";
|
|
1165
|
+
/**
|
|
1166
|
+
* Adapter size 1.
|
|
1167
|
+
*/
|
|
1168
|
+
AdapterSize["ADAPTER_SIZE_ONE"] = "ADAPTER_SIZE_ONE";
|
|
1169
|
+
/**
|
|
1170
|
+
* Adapter size 2.
|
|
1171
|
+
*/
|
|
1172
|
+
AdapterSize["ADAPTER_SIZE_TWO"] = "ADAPTER_SIZE_TWO";
|
|
1173
|
+
/**
|
|
1174
|
+
* Adapter size 4.
|
|
1175
|
+
*/
|
|
1176
|
+
AdapterSize["ADAPTER_SIZE_FOUR"] = "ADAPTER_SIZE_FOUR";
|
|
1177
|
+
/**
|
|
1178
|
+
* Adapter size 8.
|
|
1179
|
+
*/
|
|
1180
|
+
AdapterSize["ADAPTER_SIZE_EIGHT"] = "ADAPTER_SIZE_EIGHT";
|
|
1181
|
+
/**
|
|
1182
|
+
* Adapter size 16.
|
|
1183
|
+
*/
|
|
1184
|
+
AdapterSize["ADAPTER_SIZE_SIXTEEN"] = "ADAPTER_SIZE_SIXTEEN";
|
|
1185
|
+
/**
|
|
1186
|
+
* Adapter size 32.
|
|
1187
|
+
*/
|
|
1188
|
+
AdapterSize["ADAPTER_SIZE_THIRTY_TWO"] = "ADAPTER_SIZE_THIRTY_TWO";
|
|
1189
|
+
})(exports.AdapterSize || (exports.AdapterSize = {}));
|
|
1190
|
+
/** Job state. */
|
|
1191
|
+
exports.JobState = void 0;
|
|
1192
|
+
(function (JobState) {
|
|
1193
|
+
/**
|
|
1194
|
+
* The job state is unspecified.
|
|
1195
|
+
*/
|
|
1196
|
+
JobState["JOB_STATE_UNSPECIFIED"] = "JOB_STATE_UNSPECIFIED";
|
|
1005
1197
|
/**
|
|
1006
1198
|
* The job has been just created or resumed and processing has not yet begun.
|
|
1007
1199
|
*/
|
|
@@ -1047,55 +1239,7 @@ exports.JobState = void 0;
|
|
|
1047
1239
|
*/
|
|
1048
1240
|
JobState["JOB_STATE_PARTIALLY_SUCCEEDED"] = "JOB_STATE_PARTIALLY_SUCCEEDED";
|
|
1049
1241
|
})(exports.JobState || (exports.JobState = {}));
|
|
1050
|
-
/**
|
|
1051
|
-
exports.TuningMode = void 0;
|
|
1052
|
-
(function (TuningMode) {
|
|
1053
|
-
/**
|
|
1054
|
-
* Tuning mode is unspecified.
|
|
1055
|
-
*/
|
|
1056
|
-
TuningMode["TUNING_MODE_UNSPECIFIED"] = "TUNING_MODE_UNSPECIFIED";
|
|
1057
|
-
/**
|
|
1058
|
-
* Full fine-tuning mode.
|
|
1059
|
-
*/
|
|
1060
|
-
TuningMode["TUNING_MODE_FULL"] = "TUNING_MODE_FULL";
|
|
1061
|
-
/**
|
|
1062
|
-
* PEFT adapter tuning mode.
|
|
1063
|
-
*/
|
|
1064
|
-
TuningMode["TUNING_MODE_PEFT_ADAPTER"] = "TUNING_MODE_PEFT_ADAPTER";
|
|
1065
|
-
})(exports.TuningMode || (exports.TuningMode = {}));
|
|
1066
|
-
/** Optional. Adapter size for tuning. */
|
|
1067
|
-
exports.AdapterSize = void 0;
|
|
1068
|
-
(function (AdapterSize) {
|
|
1069
|
-
/**
|
|
1070
|
-
* Adapter size is unspecified.
|
|
1071
|
-
*/
|
|
1072
|
-
AdapterSize["ADAPTER_SIZE_UNSPECIFIED"] = "ADAPTER_SIZE_UNSPECIFIED";
|
|
1073
|
-
/**
|
|
1074
|
-
* Adapter size 1.
|
|
1075
|
-
*/
|
|
1076
|
-
AdapterSize["ADAPTER_SIZE_ONE"] = "ADAPTER_SIZE_ONE";
|
|
1077
|
-
/**
|
|
1078
|
-
* Adapter size 2.
|
|
1079
|
-
*/
|
|
1080
|
-
AdapterSize["ADAPTER_SIZE_TWO"] = "ADAPTER_SIZE_TWO";
|
|
1081
|
-
/**
|
|
1082
|
-
* Adapter size 4.
|
|
1083
|
-
*/
|
|
1084
|
-
AdapterSize["ADAPTER_SIZE_FOUR"] = "ADAPTER_SIZE_FOUR";
|
|
1085
|
-
/**
|
|
1086
|
-
* Adapter size 8.
|
|
1087
|
-
*/
|
|
1088
|
-
AdapterSize["ADAPTER_SIZE_EIGHT"] = "ADAPTER_SIZE_EIGHT";
|
|
1089
|
-
/**
|
|
1090
|
-
* Adapter size 16.
|
|
1091
|
-
*/
|
|
1092
|
-
AdapterSize["ADAPTER_SIZE_SIXTEEN"] = "ADAPTER_SIZE_SIXTEEN";
|
|
1093
|
-
/**
|
|
1094
|
-
* Adapter size 32.
|
|
1095
|
-
*/
|
|
1096
|
-
AdapterSize["ADAPTER_SIZE_THIRTY_TWO"] = "ADAPTER_SIZE_THIRTY_TWO";
|
|
1097
|
-
})(exports.AdapterSize || (exports.AdapterSize = {}));
|
|
1098
|
-
/** Optional. The tuning task. Either I2V or T2V. */
|
|
1242
|
+
/** The tuning task. Either I2V or T2V. This enum is not supported in Gemini API. */
|
|
1099
1243
|
exports.TuningTask = void 0;
|
|
1100
1244
|
(function (TuningTask) {
|
|
1101
1245
|
/**
|
|
@@ -1110,6 +1254,10 @@ exports.TuningTask = void 0;
|
|
|
1110
1254
|
* Tuning task for text to video.
|
|
1111
1255
|
*/
|
|
1112
1256
|
TuningTask["TUNING_TASK_T2V"] = "TUNING_TASK_T2V";
|
|
1257
|
+
/**
|
|
1258
|
+
* Tuning task for reference to video.
|
|
1259
|
+
*/
|
|
1260
|
+
TuningTask["TUNING_TASK_R2V"] = "TUNING_TASK_R2V";
|
|
1113
1261
|
})(exports.TuningTask || (exports.TuningTask = {}));
|
|
1114
1262
|
/** Options for feature selection preference. */
|
|
1115
1263
|
exports.FeatureSelectionPreference = void 0;
|
|
@@ -1345,6 +1493,26 @@ exports.VideoCompressionQuality = void 0;
|
|
|
1345
1493
|
*/
|
|
1346
1494
|
VideoCompressionQuality["LOSSLESS"] = "LOSSLESS";
|
|
1347
1495
|
})(exports.VideoCompressionQuality || (exports.VideoCompressionQuality = {}));
|
|
1496
|
+
/** Enum representing the tuning method. */
|
|
1497
|
+
exports.TuningMethod = void 0;
|
|
1498
|
+
(function (TuningMethod) {
|
|
1499
|
+
/**
|
|
1500
|
+
* Supervised fine tuning.
|
|
1501
|
+
*/
|
|
1502
|
+
TuningMethod["SUPERVISED_FINE_TUNING"] = "SUPERVISED_FINE_TUNING";
|
|
1503
|
+
/**
|
|
1504
|
+
* Preference optimization tuning.
|
|
1505
|
+
*/
|
|
1506
|
+
TuningMethod["PREFERENCE_TUNING"] = "PREFERENCE_TUNING";
|
|
1507
|
+
})(exports.TuningMethod || (exports.TuningMethod = {}));
|
|
1508
|
+
/** State for the lifecycle of a Document. */
|
|
1509
|
+
exports.DocumentState = void 0;
|
|
1510
|
+
(function (DocumentState) {
|
|
1511
|
+
DocumentState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
|
|
1512
|
+
DocumentState["STATE_PENDING"] = "STATE_PENDING";
|
|
1513
|
+
DocumentState["STATE_ACTIVE"] = "STATE_ACTIVE";
|
|
1514
|
+
DocumentState["STATE_FAILED"] = "STATE_FAILED";
|
|
1515
|
+
})(exports.DocumentState || (exports.DocumentState = {}));
|
|
1348
1516
|
/** State for the lifecycle of a File. */
|
|
1349
1517
|
exports.FileState = void 0;
|
|
1350
1518
|
(function (FileState) {
|
|
@@ -1772,7 +1940,7 @@ class HttpResponse {
|
|
|
1772
1940
|
/** Content filter results for a prompt sent in the request. Note: This is sent only in the first stream chunk and only if no candidates were generated due to content violations. */
|
|
1773
1941
|
class GenerateContentResponsePromptFeedback {
|
|
1774
1942
|
}
|
|
1775
|
-
/** Usage metadata about response
|
|
1943
|
+
/** Usage metadata about the content generation request and response. This message provides a detailed breakdown of token usage and other relevant metrics. This data type is not supported in Gemini API. */
|
|
1776
1944
|
class GenerateContentResponseUsageMetadata {
|
|
1777
1945
|
}
|
|
1778
1946
|
/** Response message for PredictionService.GenerateContent. */
|
|
@@ -2037,11 +2205,11 @@ class GenerateVideosOperation {
|
|
|
2037
2205
|
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
2038
2206
|
* @internal
|
|
2039
2207
|
*/
|
|
2040
|
-
_fromAPIResponse({ apiResponse,
|
|
2208
|
+
_fromAPIResponse({ apiResponse, _isVertexAI, }) {
|
|
2041
2209
|
const operation = new GenerateVideosOperation();
|
|
2042
2210
|
let response;
|
|
2043
2211
|
const op = apiResponse;
|
|
2044
|
-
if (
|
|
2212
|
+
if (_isVertexAI) {
|
|
2045
2213
|
response = generateVideosOperationFromVertex$1(op);
|
|
2046
2214
|
}
|
|
2047
2215
|
else {
|
|
@@ -2059,6 +2227,32 @@ class DeleteCachedContentResponse {
|
|
|
2059
2227
|
}
|
|
2060
2228
|
class ListCachedContentsResponse {
|
|
2061
2229
|
}
|
|
2230
|
+
/** Config for documents.list return value. */
|
|
2231
|
+
class ListDocumentsResponse {
|
|
2232
|
+
}
|
|
2233
|
+
/** Config for file_search_stores.list return value. */
|
|
2234
|
+
class ListFileSearchStoresResponse {
|
|
2235
|
+
}
|
|
2236
|
+
/** Response for the resumable upload method. */
|
|
2237
|
+
class UploadToFileSearchStoreResumableResponse {
|
|
2238
|
+
}
|
|
2239
|
+
/** Response for ImportFile to import a File API file with a file search store. */
|
|
2240
|
+
class ImportFileResponse {
|
|
2241
|
+
}
|
|
2242
|
+
/** Long-running operation for importing a file to a FileSearchStore. */
|
|
2243
|
+
class ImportFileOperation {
|
|
2244
|
+
/**
|
|
2245
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
2246
|
+
* @internal
|
|
2247
|
+
*/
|
|
2248
|
+
_fromAPIResponse({ apiResponse, _isVertexAI, }) {
|
|
2249
|
+
const operation = new ImportFileOperation();
|
|
2250
|
+
const op = apiResponse;
|
|
2251
|
+
const response = importFileOperationFromMldev$1(op);
|
|
2252
|
+
Object.assign(operation, response);
|
|
2253
|
+
return operation;
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2062
2256
|
/** Response for the list files method. */
|
|
2063
2257
|
class ListFilesResponse {
|
|
2064
2258
|
}
|
|
@@ -2294,6 +2488,23 @@ class LiveMusicServerMessage {
|
|
|
2294
2488
|
return undefined;
|
|
2295
2489
|
}
|
|
2296
2490
|
}
|
|
2491
|
+
/** The response when long-running operation for uploading a file to a FileSearchStore complete. */
|
|
2492
|
+
class UploadToFileSearchStoreResponse {
|
|
2493
|
+
}
|
|
2494
|
+
/** Long-running operation for uploading a file to a FileSearchStore. */
|
|
2495
|
+
class UploadToFileSearchStoreOperation {
|
|
2496
|
+
/**
|
|
2497
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
2498
|
+
* @internal
|
|
2499
|
+
*/
|
|
2500
|
+
_fromAPIResponse({ apiResponse, _isVertexAI, }) {
|
|
2501
|
+
const operation = new UploadToFileSearchStoreOperation();
|
|
2502
|
+
const op = apiResponse;
|
|
2503
|
+
const response = uploadToFileSearchStoreOperationFromMldev(op);
|
|
2504
|
+
Object.assign(operation, response);
|
|
2505
|
+
return operation;
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2297
2508
|
|
|
2298
2509
|
/**
|
|
2299
2510
|
* @license
|
|
@@ -3290,6 +3501,12 @@ function batchJobFromVertex(fromObject) {
|
|
|
3290
3501
|
if (fromDest != null) {
|
|
3291
3502
|
setValueByPath(toObject, ['dest'], batchJobDestinationFromVertex(tRecvBatchJobDestination(fromDest)));
|
|
3292
3503
|
}
|
|
3504
|
+
const fromCompletionStats = getValueByPath(fromObject, [
|
|
3505
|
+
'completionStats',
|
|
3506
|
+
]);
|
|
3507
|
+
if (fromCompletionStats != null) {
|
|
3508
|
+
setValueByPath(toObject, ['completionStats'], fromCompletionStats);
|
|
3509
|
+
}
|
|
3293
3510
|
return toObject;
|
|
3294
3511
|
}
|
|
3295
3512
|
function batchJobSourceFromVertex(fromObject) {
|
|
@@ -3364,13 +3581,13 @@ function batchJobSourceToVertex(fromObject) {
|
|
|
3364
3581
|
}
|
|
3365
3582
|
function blobToMldev$4(fromObject) {
|
|
3366
3583
|
const toObject = {};
|
|
3367
|
-
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
3368
|
-
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
3369
|
-
}
|
|
3370
3584
|
const fromData = getValueByPath(fromObject, ['data']);
|
|
3371
3585
|
if (fromData != null) {
|
|
3372
3586
|
setValueByPath(toObject, ['data'], fromData);
|
|
3373
3587
|
}
|
|
3588
|
+
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
3589
|
+
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
3590
|
+
}
|
|
3374
3591
|
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
3375
3592
|
if (fromMimeType != null) {
|
|
3376
3593
|
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
@@ -3413,12 +3630,6 @@ function candidateFromMldev$1(fromObject) {
|
|
|
3413
3630
|
if (fromFinishReason != null) {
|
|
3414
3631
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
3415
3632
|
}
|
|
3416
|
-
const fromUrlContextMetadata = getValueByPath(fromObject, [
|
|
3417
|
-
'urlContextMetadata',
|
|
3418
|
-
]);
|
|
3419
|
-
if (fromUrlContextMetadata != null) {
|
|
3420
|
-
setValueByPath(toObject, ['urlContextMetadata'], fromUrlContextMetadata);
|
|
3421
|
-
}
|
|
3422
3633
|
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
3423
3634
|
if (fromAvgLogprobs != null) {
|
|
3424
3635
|
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
@@ -3451,6 +3662,12 @@ function candidateFromMldev$1(fromObject) {
|
|
|
3451
3662
|
}
|
|
3452
3663
|
setValueByPath(toObject, ['safetyRatings'], transformedList);
|
|
3453
3664
|
}
|
|
3665
|
+
const fromUrlContextMetadata = getValueByPath(fromObject, [
|
|
3666
|
+
'urlContextMetadata',
|
|
3667
|
+
]);
|
|
3668
|
+
if (fromUrlContextMetadata != null) {
|
|
3669
|
+
setValueByPath(toObject, ['urlContextMetadata'], fromUrlContextMetadata);
|
|
3670
|
+
}
|
|
3454
3671
|
return toObject;
|
|
3455
3672
|
}
|
|
3456
3673
|
function citationMetadataFromMldev$1(fromObject) {
|
|
@@ -3919,15 +4136,18 @@ function googleMapsToMldev$4(fromObject) {
|
|
|
3919
4136
|
}
|
|
3920
4137
|
function googleSearchToMldev$4(fromObject) {
|
|
3921
4138
|
const toObject = {};
|
|
4139
|
+
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
4140
|
+
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
4141
|
+
}
|
|
4142
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
4143
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
4144
|
+
}
|
|
3922
4145
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
3923
4146
|
'timeRangeFilter',
|
|
3924
4147
|
]);
|
|
3925
4148
|
if (fromTimeRangeFilter != null) {
|
|
3926
4149
|
setValueByPath(toObject, ['timeRangeFilter'], fromTimeRangeFilter);
|
|
3927
4150
|
}
|
|
3928
|
-
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
3929
|
-
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
3930
|
-
}
|
|
3931
4151
|
return toObject;
|
|
3932
4152
|
}
|
|
3933
4153
|
function inlinedRequestToMldev(apiClient, fromObject) {
|
|
@@ -4071,30 +4291,6 @@ function listBatchJobsResponseFromVertex(fromObject) {
|
|
|
4071
4291
|
}
|
|
4072
4292
|
function partToMldev$4(fromObject) {
|
|
4073
4293
|
const toObject = {};
|
|
4074
|
-
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
4075
|
-
'videoMetadata',
|
|
4076
|
-
]);
|
|
4077
|
-
if (fromVideoMetadata != null) {
|
|
4078
|
-
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
4079
|
-
}
|
|
4080
|
-
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
4081
|
-
if (fromThought != null) {
|
|
4082
|
-
setValueByPath(toObject, ['thought'], fromThought);
|
|
4083
|
-
}
|
|
4084
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
4085
|
-
if (fromInlineData != null) {
|
|
4086
|
-
setValueByPath(toObject, ['inlineData'], blobToMldev$4(fromInlineData));
|
|
4087
|
-
}
|
|
4088
|
-
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
4089
|
-
if (fromFileData != null) {
|
|
4090
|
-
setValueByPath(toObject, ['fileData'], fileDataToMldev$4(fromFileData));
|
|
4091
|
-
}
|
|
4092
|
-
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
4093
|
-
'thoughtSignature',
|
|
4094
|
-
]);
|
|
4095
|
-
if (fromThoughtSignature != null) {
|
|
4096
|
-
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
4097
|
-
}
|
|
4098
4294
|
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
4099
4295
|
if (fromFunctionCall != null) {
|
|
4100
4296
|
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
@@ -4111,27 +4307,51 @@ function partToMldev$4(fromObject) {
|
|
|
4111
4307
|
if (fromExecutableCode != null) {
|
|
4112
4308
|
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
4113
4309
|
}
|
|
4310
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
4311
|
+
if (fromFileData != null) {
|
|
4312
|
+
setValueByPath(toObject, ['fileData'], fileDataToMldev$4(fromFileData));
|
|
4313
|
+
}
|
|
4114
4314
|
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
4115
4315
|
'functionResponse',
|
|
4116
4316
|
]);
|
|
4117
4317
|
if (fromFunctionResponse != null) {
|
|
4118
4318
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
4119
4319
|
}
|
|
4320
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
4321
|
+
if (fromInlineData != null) {
|
|
4322
|
+
setValueByPath(toObject, ['inlineData'], blobToMldev$4(fromInlineData));
|
|
4323
|
+
}
|
|
4120
4324
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
4121
4325
|
if (fromText != null) {
|
|
4122
4326
|
setValueByPath(toObject, ['text'], fromText);
|
|
4123
4327
|
}
|
|
4328
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
4329
|
+
if (fromThought != null) {
|
|
4330
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
4331
|
+
}
|
|
4332
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
4333
|
+
'thoughtSignature',
|
|
4334
|
+
]);
|
|
4335
|
+
if (fromThoughtSignature != null) {
|
|
4336
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
4337
|
+
}
|
|
4338
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
4339
|
+
'videoMetadata',
|
|
4340
|
+
]);
|
|
4341
|
+
if (fromVideoMetadata != null) {
|
|
4342
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
4343
|
+
}
|
|
4124
4344
|
return toObject;
|
|
4125
4345
|
}
|
|
4126
4346
|
function safetySettingToMldev$1(fromObject) {
|
|
4127
4347
|
const toObject = {};
|
|
4128
|
-
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
4129
|
-
throw new Error('method parameter is not supported in Gemini API.');
|
|
4130
|
-
}
|
|
4131
4348
|
const fromCategory = getValueByPath(fromObject, ['category']);
|
|
4132
4349
|
if (fromCategory != null) {
|
|
4133
4350
|
setValueByPath(toObject, ['category'], fromCategory);
|
|
4134
4351
|
}
|
|
4352
|
+
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
4353
|
+
throw new Error('method parameter is not supported in Gemini API.');
|
|
4354
|
+
}
|
|
4135
4355
|
const fromThreshold = getValueByPath(fromObject, ['threshold']);
|
|
4136
4356
|
if (fromThreshold != null) {
|
|
4137
4357
|
setValueByPath(toObject, ['threshold'], fromThreshold);
|
|
@@ -4155,16 +4375,26 @@ function toolToMldev$4(fromObject) {
|
|
|
4155
4375
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
4156
4376
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
4157
4377
|
}
|
|
4158
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4159
|
-
if (fromGoogleSearch != null) {
|
|
4160
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
4161
|
-
}
|
|
4162
4378
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
4163
4379
|
'googleSearchRetrieval',
|
|
4164
4380
|
]);
|
|
4165
4381
|
if (fromGoogleSearchRetrieval != null) {
|
|
4166
4382
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
4167
4383
|
}
|
|
4384
|
+
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
4385
|
+
if (fromComputerUse != null) {
|
|
4386
|
+
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
4387
|
+
}
|
|
4388
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
4389
|
+
if (fromFileSearch != null) {
|
|
4390
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
4391
|
+
}
|
|
4392
|
+
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4393
|
+
'codeExecution',
|
|
4394
|
+
]);
|
|
4395
|
+
if (fromCodeExecution != null) {
|
|
4396
|
+
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
4397
|
+
}
|
|
4168
4398
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
4169
4399
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
4170
4400
|
}
|
|
@@ -4172,20 +4402,14 @@ function toolToMldev$4(fromObject) {
|
|
|
4172
4402
|
if (fromGoogleMaps != null) {
|
|
4173
4403
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$4(fromGoogleMaps));
|
|
4174
4404
|
}
|
|
4405
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4406
|
+
if (fromGoogleSearch != null) {
|
|
4407
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
|
|
4408
|
+
}
|
|
4175
4409
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
4176
4410
|
if (fromUrlContext != null) {
|
|
4177
4411
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
4178
4412
|
}
|
|
4179
|
-
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
4180
|
-
if (fromComputerUse != null) {
|
|
4181
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
4182
|
-
}
|
|
4183
|
-
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4184
|
-
'codeExecution',
|
|
4185
|
-
]);
|
|
4186
|
-
if (fromCodeExecution != null) {
|
|
4187
|
-
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
4188
|
-
}
|
|
4189
4413
|
return toObject;
|
|
4190
4414
|
}
|
|
4191
4415
|
|
|
@@ -4201,6 +4425,8 @@ exports.PagedItem = void 0;
|
|
|
4201
4425
|
PagedItem["PAGED_ITEM_TUNING_JOBS"] = "tuningJobs";
|
|
4202
4426
|
PagedItem["PAGED_ITEM_FILES"] = "files";
|
|
4203
4427
|
PagedItem["PAGED_ITEM_CACHED_CONTENTS"] = "cachedContents";
|
|
4428
|
+
PagedItem["PAGED_ITEM_FILE_SEARCH_STORES"] = "fileSearchStores";
|
|
4429
|
+
PagedItem["PAGED_ITEM_DOCUMENTS"] = "documents";
|
|
4204
4430
|
})(exports.PagedItem || (exports.PagedItem = {}));
|
|
4205
4431
|
/**
|
|
4206
4432
|
* Pager class for iterating through paginated results.
|
|
@@ -4881,13 +5107,13 @@ class Batches extends BaseModule {
|
|
|
4881
5107
|
*/
|
|
4882
5108
|
function blobToMldev$3(fromObject) {
|
|
4883
5109
|
const toObject = {};
|
|
4884
|
-
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
4885
|
-
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
4886
|
-
}
|
|
4887
5110
|
const fromData = getValueByPath(fromObject, ['data']);
|
|
4888
5111
|
if (fromData != null) {
|
|
4889
5112
|
setValueByPath(toObject, ['data'], fromData);
|
|
4890
5113
|
}
|
|
5114
|
+
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
5115
|
+
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
5116
|
+
}
|
|
4891
5117
|
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
4892
5118
|
if (fromMimeType != null) {
|
|
4893
5119
|
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
@@ -5150,15 +5376,18 @@ function googleMapsToMldev$3(fromObject) {
|
|
|
5150
5376
|
}
|
|
5151
5377
|
function googleSearchToMldev$3(fromObject) {
|
|
5152
5378
|
const toObject = {};
|
|
5379
|
+
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
5380
|
+
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
5381
|
+
}
|
|
5382
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
5383
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
5384
|
+
}
|
|
5153
5385
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
5154
5386
|
'timeRangeFilter',
|
|
5155
5387
|
]);
|
|
5156
5388
|
if (fromTimeRangeFilter != null) {
|
|
5157
5389
|
setValueByPath(toObject, ['timeRangeFilter'], fromTimeRangeFilter);
|
|
5158
5390
|
}
|
|
5159
|
-
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
5160
|
-
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
5161
|
-
}
|
|
5162
5391
|
return toObject;
|
|
5163
5392
|
}
|
|
5164
5393
|
function listCachedContentsConfigToMldev(fromObject, parentObject) {
|
|
@@ -5259,39 +5488,15 @@ function listCachedContentsResponseFromVertex(fromObject) {
|
|
|
5259
5488
|
}
|
|
5260
5489
|
function partToMldev$3(fromObject) {
|
|
5261
5490
|
const toObject = {};
|
|
5262
|
-
const
|
|
5263
|
-
|
|
5491
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
5492
|
+
if (fromFunctionCall != null) {
|
|
5493
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
5494
|
+
}
|
|
5495
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
5496
|
+
'codeExecutionResult',
|
|
5264
5497
|
]);
|
|
5265
|
-
if (
|
|
5266
|
-
setValueByPath(toObject, ['
|
|
5267
|
-
}
|
|
5268
|
-
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
5269
|
-
if (fromThought != null) {
|
|
5270
|
-
setValueByPath(toObject, ['thought'], fromThought);
|
|
5271
|
-
}
|
|
5272
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
5273
|
-
if (fromInlineData != null) {
|
|
5274
|
-
setValueByPath(toObject, ['inlineData'], blobToMldev$3(fromInlineData));
|
|
5275
|
-
}
|
|
5276
|
-
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
5277
|
-
if (fromFileData != null) {
|
|
5278
|
-
setValueByPath(toObject, ['fileData'], fileDataToMldev$3(fromFileData));
|
|
5279
|
-
}
|
|
5280
|
-
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
5281
|
-
'thoughtSignature',
|
|
5282
|
-
]);
|
|
5283
|
-
if (fromThoughtSignature != null) {
|
|
5284
|
-
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
5285
|
-
}
|
|
5286
|
-
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
5287
|
-
if (fromFunctionCall != null) {
|
|
5288
|
-
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
5289
|
-
}
|
|
5290
|
-
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
5291
|
-
'codeExecutionResult',
|
|
5292
|
-
]);
|
|
5293
|
-
if (fromCodeExecutionResult != null) {
|
|
5294
|
-
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
5498
|
+
if (fromCodeExecutionResult != null) {
|
|
5499
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
5295
5500
|
}
|
|
5296
5501
|
const fromExecutableCode = getValueByPath(fromObject, [
|
|
5297
5502
|
'executableCode',
|
|
@@ -5299,16 +5504,40 @@ function partToMldev$3(fromObject) {
|
|
|
5299
5504
|
if (fromExecutableCode != null) {
|
|
5300
5505
|
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
5301
5506
|
}
|
|
5507
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
5508
|
+
if (fromFileData != null) {
|
|
5509
|
+
setValueByPath(toObject, ['fileData'], fileDataToMldev$3(fromFileData));
|
|
5510
|
+
}
|
|
5302
5511
|
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
5303
5512
|
'functionResponse',
|
|
5304
5513
|
]);
|
|
5305
5514
|
if (fromFunctionResponse != null) {
|
|
5306
5515
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
5307
5516
|
}
|
|
5517
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
5518
|
+
if (fromInlineData != null) {
|
|
5519
|
+
setValueByPath(toObject, ['inlineData'], blobToMldev$3(fromInlineData));
|
|
5520
|
+
}
|
|
5308
5521
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
5309
5522
|
if (fromText != null) {
|
|
5310
5523
|
setValueByPath(toObject, ['text'], fromText);
|
|
5311
5524
|
}
|
|
5525
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
5526
|
+
if (fromThought != null) {
|
|
5527
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
5528
|
+
}
|
|
5529
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
5530
|
+
'thoughtSignature',
|
|
5531
|
+
]);
|
|
5532
|
+
if (fromThoughtSignature != null) {
|
|
5533
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
5534
|
+
}
|
|
5535
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
5536
|
+
'videoMetadata',
|
|
5537
|
+
]);
|
|
5538
|
+
if (fromVideoMetadata != null) {
|
|
5539
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
5540
|
+
}
|
|
5312
5541
|
return toObject;
|
|
5313
5542
|
}
|
|
5314
5543
|
function toolToMldev$3(fromObject) {
|
|
@@ -5328,16 +5557,26 @@ function toolToMldev$3(fromObject) {
|
|
|
5328
5557
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
5329
5558
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
5330
5559
|
}
|
|
5331
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5332
|
-
if (fromGoogleSearch != null) {
|
|
5333
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
5334
|
-
}
|
|
5335
5560
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
5336
5561
|
'googleSearchRetrieval',
|
|
5337
5562
|
]);
|
|
5338
5563
|
if (fromGoogleSearchRetrieval != null) {
|
|
5339
5564
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
5340
5565
|
}
|
|
5566
|
+
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
5567
|
+
if (fromComputerUse != null) {
|
|
5568
|
+
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
5569
|
+
}
|
|
5570
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
5571
|
+
if (fromFileSearch != null) {
|
|
5572
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
5573
|
+
}
|
|
5574
|
+
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5575
|
+
'codeExecution',
|
|
5576
|
+
]);
|
|
5577
|
+
if (fromCodeExecution != null) {
|
|
5578
|
+
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
5579
|
+
}
|
|
5341
5580
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
5342
5581
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
5343
5582
|
}
|
|
@@ -5345,20 +5584,14 @@ function toolToMldev$3(fromObject) {
|
|
|
5345
5584
|
if (fromGoogleMaps != null) {
|
|
5346
5585
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$3(fromGoogleMaps));
|
|
5347
5586
|
}
|
|
5587
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5588
|
+
if (fromGoogleSearch != null) {
|
|
5589
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$3(fromGoogleSearch));
|
|
5590
|
+
}
|
|
5348
5591
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
5349
5592
|
if (fromUrlContext != null) {
|
|
5350
5593
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
5351
5594
|
}
|
|
5352
|
-
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
5353
|
-
if (fromComputerUse != null) {
|
|
5354
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
5355
|
-
}
|
|
5356
|
-
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5357
|
-
'codeExecution',
|
|
5358
|
-
]);
|
|
5359
|
-
if (fromCodeExecution != null) {
|
|
5360
|
-
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
5361
|
-
}
|
|
5362
5595
|
return toObject;
|
|
5363
5596
|
}
|
|
5364
5597
|
function toolToVertex$2(fromObject) {
|
|
@@ -5379,16 +5612,25 @@ function toolToVertex$2(fromObject) {
|
|
|
5379
5612
|
if (fromRetrieval != null) {
|
|
5380
5613
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
5381
5614
|
}
|
|
5382
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5383
|
-
if (fromGoogleSearch != null) {
|
|
5384
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
5385
|
-
}
|
|
5386
5615
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
5387
5616
|
'googleSearchRetrieval',
|
|
5388
5617
|
]);
|
|
5389
5618
|
if (fromGoogleSearchRetrieval != null) {
|
|
5390
5619
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
5391
5620
|
}
|
|
5621
|
+
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
5622
|
+
if (fromComputerUse != null) {
|
|
5623
|
+
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
5624
|
+
}
|
|
5625
|
+
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
5626
|
+
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
5627
|
+
}
|
|
5628
|
+
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5629
|
+
'codeExecution',
|
|
5630
|
+
]);
|
|
5631
|
+
if (fromCodeExecution != null) {
|
|
5632
|
+
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
5633
|
+
}
|
|
5392
5634
|
const fromEnterpriseWebSearch = getValueByPath(fromObject, [
|
|
5393
5635
|
'enterpriseWebSearch',
|
|
5394
5636
|
]);
|
|
@@ -5399,20 +5641,14 @@ function toolToVertex$2(fromObject) {
|
|
|
5399
5641
|
if (fromGoogleMaps != null) {
|
|
5400
5642
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
5401
5643
|
}
|
|
5644
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
5645
|
+
if (fromGoogleSearch != null) {
|
|
5646
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
5647
|
+
}
|
|
5402
5648
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
5403
5649
|
if (fromUrlContext != null) {
|
|
5404
5650
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
5405
5651
|
}
|
|
5406
|
-
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
5407
|
-
if (fromComputerUse != null) {
|
|
5408
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
5409
|
-
}
|
|
5410
|
-
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5411
|
-
'codeExecution',
|
|
5412
|
-
]);
|
|
5413
|
-
if (fromCodeExecution != null) {
|
|
5414
|
-
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
5415
|
-
}
|
|
5416
5652
|
return toObject;
|
|
5417
5653
|
}
|
|
5418
5654
|
function updateCachedContentConfigToMldev(fromObject, parentObject) {
|
|
@@ -6621,13 +6857,13 @@ class Files extends BaseModule {
|
|
|
6621
6857
|
*/
|
|
6622
6858
|
function blobToMldev$2(fromObject) {
|
|
6623
6859
|
const toObject = {};
|
|
6624
|
-
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
6625
|
-
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
6626
|
-
}
|
|
6627
6860
|
const fromData = getValueByPath(fromObject, ['data']);
|
|
6628
6861
|
if (fromData != null) {
|
|
6629
6862
|
setValueByPath(toObject, ['data'], fromData);
|
|
6630
6863
|
}
|
|
6864
|
+
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
6865
|
+
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
6866
|
+
}
|
|
6631
6867
|
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
6632
6868
|
if (fromMimeType != null) {
|
|
6633
6869
|
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
@@ -6710,6 +6946,12 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
6710
6946
|
if (fromModelSelectionConfig != null) {
|
|
6711
6947
|
setValueByPath(toObject, ['modelConfig'], fromModelSelectionConfig);
|
|
6712
6948
|
}
|
|
6949
|
+
const fromResponseJsonSchema = getValueByPath(fromObject, [
|
|
6950
|
+
'responseJsonSchema',
|
|
6951
|
+
]);
|
|
6952
|
+
if (fromResponseJsonSchema != null) {
|
|
6953
|
+
setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
|
|
6954
|
+
}
|
|
6713
6955
|
const fromAudioTimestamp = getValueByPath(fromObject, [
|
|
6714
6956
|
'audioTimestamp',
|
|
6715
6957
|
]);
|
|
@@ -6756,12 +6998,6 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
6756
6998
|
if (fromPresencePenalty != null) {
|
|
6757
6999
|
setValueByPath(toObject, ['presencePenalty'], fromPresencePenalty);
|
|
6758
7000
|
}
|
|
6759
|
-
const fromResponseJsonSchema = getValueByPath(fromObject, [
|
|
6760
|
-
'responseJsonSchema',
|
|
6761
|
-
]);
|
|
6762
|
-
if (fromResponseJsonSchema != null) {
|
|
6763
|
-
setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
|
|
6764
|
-
}
|
|
6765
7001
|
const fromResponseLogprobs = getValueByPath(fromObject, [
|
|
6766
7002
|
'responseLogprobs',
|
|
6767
7003
|
]);
|
|
@@ -6843,15 +7079,18 @@ function googleMapsToMldev$2(fromObject) {
|
|
|
6843
7079
|
}
|
|
6844
7080
|
function googleSearchToMldev$2(fromObject) {
|
|
6845
7081
|
const toObject = {};
|
|
7082
|
+
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
7083
|
+
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
7084
|
+
}
|
|
7085
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
7086
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
7087
|
+
}
|
|
6846
7088
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
6847
7089
|
'timeRangeFilter',
|
|
6848
7090
|
]);
|
|
6849
7091
|
if (fromTimeRangeFilter != null) {
|
|
6850
7092
|
setValueByPath(toObject, ['timeRangeFilter'], fromTimeRangeFilter);
|
|
6851
7093
|
}
|
|
6852
|
-
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
6853
|
-
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
6854
|
-
}
|
|
6855
7094
|
return toObject;
|
|
6856
7095
|
}
|
|
6857
7096
|
function liveConnectConfigToMldev$1(fromObject, parentObject) {
|
|
@@ -7252,30 +7491,6 @@ function liveServerMessageFromVertex(fromObject) {
|
|
|
7252
7491
|
}
|
|
7253
7492
|
function partToMldev$2(fromObject) {
|
|
7254
7493
|
const toObject = {};
|
|
7255
|
-
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
7256
|
-
'videoMetadata',
|
|
7257
|
-
]);
|
|
7258
|
-
if (fromVideoMetadata != null) {
|
|
7259
|
-
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
7260
|
-
}
|
|
7261
|
-
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
7262
|
-
if (fromThought != null) {
|
|
7263
|
-
setValueByPath(toObject, ['thought'], fromThought);
|
|
7264
|
-
}
|
|
7265
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
7266
|
-
if (fromInlineData != null) {
|
|
7267
|
-
setValueByPath(toObject, ['inlineData'], blobToMldev$2(fromInlineData));
|
|
7268
|
-
}
|
|
7269
|
-
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
7270
|
-
if (fromFileData != null) {
|
|
7271
|
-
setValueByPath(toObject, ['fileData'], fileDataToMldev$2(fromFileData));
|
|
7272
|
-
}
|
|
7273
|
-
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
7274
|
-
'thoughtSignature',
|
|
7275
|
-
]);
|
|
7276
|
-
if (fromThoughtSignature != null) {
|
|
7277
|
-
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
7278
|
-
}
|
|
7279
7494
|
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
7280
7495
|
if (fromFunctionCall != null) {
|
|
7281
7496
|
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
@@ -7292,16 +7507,40 @@ function partToMldev$2(fromObject) {
|
|
|
7292
7507
|
if (fromExecutableCode != null) {
|
|
7293
7508
|
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
7294
7509
|
}
|
|
7510
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
7511
|
+
if (fromFileData != null) {
|
|
7512
|
+
setValueByPath(toObject, ['fileData'], fileDataToMldev$2(fromFileData));
|
|
7513
|
+
}
|
|
7295
7514
|
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
7296
7515
|
'functionResponse',
|
|
7297
7516
|
]);
|
|
7298
7517
|
if (fromFunctionResponse != null) {
|
|
7299
7518
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
7300
7519
|
}
|
|
7520
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
7521
|
+
if (fromInlineData != null) {
|
|
7522
|
+
setValueByPath(toObject, ['inlineData'], blobToMldev$2(fromInlineData));
|
|
7523
|
+
}
|
|
7301
7524
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
7302
7525
|
if (fromText != null) {
|
|
7303
7526
|
setValueByPath(toObject, ['text'], fromText);
|
|
7304
7527
|
}
|
|
7528
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
7529
|
+
if (fromThought != null) {
|
|
7530
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
7531
|
+
}
|
|
7532
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
7533
|
+
'thoughtSignature',
|
|
7534
|
+
]);
|
|
7535
|
+
if (fromThoughtSignature != null) {
|
|
7536
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
7537
|
+
}
|
|
7538
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
7539
|
+
'videoMetadata',
|
|
7540
|
+
]);
|
|
7541
|
+
if (fromVideoMetadata != null) {
|
|
7542
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
7543
|
+
}
|
|
7305
7544
|
return toObject;
|
|
7306
7545
|
}
|
|
7307
7546
|
function sessionResumptionConfigToMldev$1(fromObject) {
|
|
@@ -7317,6 +7556,10 @@ function sessionResumptionConfigToMldev$1(fromObject) {
|
|
|
7317
7556
|
}
|
|
7318
7557
|
function speechConfigToVertex$1(fromObject) {
|
|
7319
7558
|
const toObject = {};
|
|
7559
|
+
const fromLanguageCode = getValueByPath(fromObject, ['languageCode']);
|
|
7560
|
+
if (fromLanguageCode != null) {
|
|
7561
|
+
setValueByPath(toObject, ['languageCode'], fromLanguageCode);
|
|
7562
|
+
}
|
|
7320
7563
|
const fromVoiceConfig = getValueByPath(fromObject, ['voiceConfig']);
|
|
7321
7564
|
if (fromVoiceConfig != null) {
|
|
7322
7565
|
setValueByPath(toObject, ['voiceConfig'], fromVoiceConfig);
|
|
@@ -7324,10 +7567,6 @@ function speechConfigToVertex$1(fromObject) {
|
|
|
7324
7567
|
if (getValueByPath(fromObject, ['multiSpeakerVoiceConfig']) !== undefined) {
|
|
7325
7568
|
throw new Error('multiSpeakerVoiceConfig parameter is not supported in Vertex AI.');
|
|
7326
7569
|
}
|
|
7327
|
-
const fromLanguageCode = getValueByPath(fromObject, ['languageCode']);
|
|
7328
|
-
if (fromLanguageCode != null) {
|
|
7329
|
-
setValueByPath(toObject, ['languageCode'], fromLanguageCode);
|
|
7330
|
-
}
|
|
7331
7570
|
return toObject;
|
|
7332
7571
|
}
|
|
7333
7572
|
function toolToMldev$2(fromObject) {
|
|
@@ -7347,16 +7586,26 @@ function toolToMldev$2(fromObject) {
|
|
|
7347
7586
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
7348
7587
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
7349
7588
|
}
|
|
7350
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
7351
|
-
if (fromGoogleSearch != null) {
|
|
7352
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
7353
|
-
}
|
|
7354
7589
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
7355
7590
|
'googleSearchRetrieval',
|
|
7356
7591
|
]);
|
|
7357
7592
|
if (fromGoogleSearchRetrieval != null) {
|
|
7358
7593
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
7359
7594
|
}
|
|
7595
|
+
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
7596
|
+
if (fromComputerUse != null) {
|
|
7597
|
+
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
7598
|
+
}
|
|
7599
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
7600
|
+
if (fromFileSearch != null) {
|
|
7601
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
7602
|
+
}
|
|
7603
|
+
const fromCodeExecution = getValueByPath(fromObject, [
|
|
7604
|
+
'codeExecution',
|
|
7605
|
+
]);
|
|
7606
|
+
if (fromCodeExecution != null) {
|
|
7607
|
+
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
7608
|
+
}
|
|
7360
7609
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
7361
7610
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
7362
7611
|
}
|
|
@@ -7364,20 +7613,14 @@ function toolToMldev$2(fromObject) {
|
|
|
7364
7613
|
if (fromGoogleMaps != null) {
|
|
7365
7614
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$2(fromGoogleMaps));
|
|
7366
7615
|
}
|
|
7616
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
7617
|
+
if (fromGoogleSearch != null) {
|
|
7618
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2(fromGoogleSearch));
|
|
7619
|
+
}
|
|
7367
7620
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
7368
7621
|
if (fromUrlContext != null) {
|
|
7369
7622
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
7370
7623
|
}
|
|
7371
|
-
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
7372
|
-
if (fromComputerUse != null) {
|
|
7373
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
7374
|
-
}
|
|
7375
|
-
const fromCodeExecution = getValueByPath(fromObject, [
|
|
7376
|
-
'codeExecution',
|
|
7377
|
-
]);
|
|
7378
|
-
if (fromCodeExecution != null) {
|
|
7379
|
-
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
7380
|
-
}
|
|
7381
7624
|
return toObject;
|
|
7382
7625
|
}
|
|
7383
7626
|
function toolToVertex$1(fromObject) {
|
|
@@ -7398,16 +7641,25 @@ function toolToVertex$1(fromObject) {
|
|
|
7398
7641
|
if (fromRetrieval != null) {
|
|
7399
7642
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
7400
7643
|
}
|
|
7401
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
7402
|
-
if (fromGoogleSearch != null) {
|
|
7403
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
7404
|
-
}
|
|
7405
7644
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
7406
7645
|
'googleSearchRetrieval',
|
|
7407
7646
|
]);
|
|
7408
7647
|
if (fromGoogleSearchRetrieval != null) {
|
|
7409
7648
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
7410
7649
|
}
|
|
7650
|
+
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
7651
|
+
if (fromComputerUse != null) {
|
|
7652
|
+
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
7653
|
+
}
|
|
7654
|
+
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
7655
|
+
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
7656
|
+
}
|
|
7657
|
+
const fromCodeExecution = getValueByPath(fromObject, [
|
|
7658
|
+
'codeExecution',
|
|
7659
|
+
]);
|
|
7660
|
+
if (fromCodeExecution != null) {
|
|
7661
|
+
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
7662
|
+
}
|
|
7411
7663
|
const fromEnterpriseWebSearch = getValueByPath(fromObject, [
|
|
7412
7664
|
'enterpriseWebSearch',
|
|
7413
7665
|
]);
|
|
@@ -7418,20 +7670,14 @@ function toolToVertex$1(fromObject) {
|
|
|
7418
7670
|
if (fromGoogleMaps != null) {
|
|
7419
7671
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
7420
7672
|
}
|
|
7673
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
7674
|
+
if (fromGoogleSearch != null) {
|
|
7675
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
7676
|
+
}
|
|
7421
7677
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
7422
7678
|
if (fromUrlContext != null) {
|
|
7423
7679
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
7424
7680
|
}
|
|
7425
|
-
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
7426
|
-
if (fromComputerUse != null) {
|
|
7427
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
7428
|
-
}
|
|
7429
|
-
const fromCodeExecution = getValueByPath(fromObject, [
|
|
7430
|
-
'codeExecution',
|
|
7431
|
-
]);
|
|
7432
|
-
if (fromCodeExecution != null) {
|
|
7433
|
-
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
7434
|
-
}
|
|
7435
7681
|
return toObject;
|
|
7436
7682
|
}
|
|
7437
7683
|
function usageMetadataFromVertex(fromObject) {
|
|
@@ -7534,13 +7780,13 @@ function usageMetadataFromVertex(fromObject) {
|
|
|
7534
7780
|
*/
|
|
7535
7781
|
function blobToMldev$1(fromObject) {
|
|
7536
7782
|
const toObject = {};
|
|
7537
|
-
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
7538
|
-
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
7539
|
-
}
|
|
7540
7783
|
const fromData = getValueByPath(fromObject, ['data']);
|
|
7541
7784
|
if (fromData != null) {
|
|
7542
7785
|
setValueByPath(toObject, ['data'], fromData);
|
|
7543
7786
|
}
|
|
7787
|
+
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
7788
|
+
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
7789
|
+
}
|
|
7544
7790
|
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
7545
7791
|
if (fromMimeType != null) {
|
|
7546
7792
|
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
@@ -7567,12 +7813,6 @@ function candidateFromMldev(fromObject) {
|
|
|
7567
7813
|
if (fromFinishReason != null) {
|
|
7568
7814
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
7569
7815
|
}
|
|
7570
|
-
const fromUrlContextMetadata = getValueByPath(fromObject, [
|
|
7571
|
-
'urlContextMetadata',
|
|
7572
|
-
]);
|
|
7573
|
-
if (fromUrlContextMetadata != null) {
|
|
7574
|
-
setValueByPath(toObject, ['urlContextMetadata'], fromUrlContextMetadata);
|
|
7575
|
-
}
|
|
7576
7816
|
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
7577
7817
|
if (fromAvgLogprobs != null) {
|
|
7578
7818
|
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
@@ -7605,6 +7845,12 @@ function candidateFromMldev(fromObject) {
|
|
|
7605
7845
|
}
|
|
7606
7846
|
setValueByPath(toObject, ['safetyRatings'], transformedList);
|
|
7607
7847
|
}
|
|
7848
|
+
const fromUrlContextMetadata = getValueByPath(fromObject, [
|
|
7849
|
+
'urlContextMetadata',
|
|
7850
|
+
]);
|
|
7851
|
+
if (fromUrlContextMetadata != null) {
|
|
7852
|
+
setValueByPath(toObject, ['urlContextMetadata'], fromUrlContextMetadata);
|
|
7853
|
+
}
|
|
7608
7854
|
return toObject;
|
|
7609
7855
|
}
|
|
7610
7856
|
function citationMetadataFromMldev(fromObject) {
|
|
@@ -9373,6 +9619,12 @@ function generationConfigToVertex(fromObject) {
|
|
|
9373
9619
|
if (fromModelSelectionConfig != null) {
|
|
9374
9620
|
setValueByPath(toObject, ['modelConfig'], fromModelSelectionConfig);
|
|
9375
9621
|
}
|
|
9622
|
+
const fromResponseJsonSchema = getValueByPath(fromObject, [
|
|
9623
|
+
'responseJsonSchema',
|
|
9624
|
+
]);
|
|
9625
|
+
if (fromResponseJsonSchema != null) {
|
|
9626
|
+
setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
|
|
9627
|
+
}
|
|
9376
9628
|
const fromAudioTimestamp = getValueByPath(fromObject, [
|
|
9377
9629
|
'audioTimestamp',
|
|
9378
9630
|
]);
|
|
@@ -9419,12 +9671,6 @@ function generationConfigToVertex(fromObject) {
|
|
|
9419
9671
|
if (fromPresencePenalty != null) {
|
|
9420
9672
|
setValueByPath(toObject, ['presencePenalty'], fromPresencePenalty);
|
|
9421
9673
|
}
|
|
9422
|
-
const fromResponseJsonSchema = getValueByPath(fromObject, [
|
|
9423
|
-
'responseJsonSchema',
|
|
9424
|
-
]);
|
|
9425
|
-
if (fromResponseJsonSchema != null) {
|
|
9426
|
-
setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
|
|
9427
|
-
}
|
|
9428
9674
|
const fromResponseLogprobs = getValueByPath(fromObject, [
|
|
9429
9675
|
'responseLogprobs',
|
|
9430
9676
|
]);
|
|
@@ -9522,15 +9768,18 @@ function googleMapsToMldev$1(fromObject) {
|
|
|
9522
9768
|
}
|
|
9523
9769
|
function googleSearchToMldev$1(fromObject) {
|
|
9524
9770
|
const toObject = {};
|
|
9771
|
+
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
9772
|
+
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
9773
|
+
}
|
|
9774
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
9775
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
9776
|
+
}
|
|
9525
9777
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
9526
9778
|
'timeRangeFilter',
|
|
9527
9779
|
]);
|
|
9528
9780
|
if (fromTimeRangeFilter != null) {
|
|
9529
9781
|
setValueByPath(toObject, ['timeRangeFilter'], fromTimeRangeFilter);
|
|
9530
9782
|
}
|
|
9531
|
-
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
9532
|
-
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
9533
|
-
}
|
|
9534
9783
|
return toObject;
|
|
9535
9784
|
}
|
|
9536
9785
|
function imageFromMldev(fromObject) {
|
|
@@ -9820,30 +10069,6 @@ function modelFromVertex(fromObject) {
|
|
|
9820
10069
|
}
|
|
9821
10070
|
function partToMldev$1(fromObject) {
|
|
9822
10071
|
const toObject = {};
|
|
9823
|
-
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
9824
|
-
'videoMetadata',
|
|
9825
|
-
]);
|
|
9826
|
-
if (fromVideoMetadata != null) {
|
|
9827
|
-
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
9828
|
-
}
|
|
9829
|
-
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
9830
|
-
if (fromThought != null) {
|
|
9831
|
-
setValueByPath(toObject, ['thought'], fromThought);
|
|
9832
|
-
}
|
|
9833
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
9834
|
-
if (fromInlineData != null) {
|
|
9835
|
-
setValueByPath(toObject, ['inlineData'], blobToMldev$1(fromInlineData));
|
|
9836
|
-
}
|
|
9837
|
-
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
9838
|
-
if (fromFileData != null) {
|
|
9839
|
-
setValueByPath(toObject, ['fileData'], fileDataToMldev$1(fromFileData));
|
|
9840
|
-
}
|
|
9841
|
-
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
9842
|
-
'thoughtSignature',
|
|
9843
|
-
]);
|
|
9844
|
-
if (fromThoughtSignature != null) {
|
|
9845
|
-
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
9846
|
-
}
|
|
9847
10072
|
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
9848
10073
|
if (fromFunctionCall != null) {
|
|
9849
10074
|
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
@@ -9860,16 +10085,40 @@ function partToMldev$1(fromObject) {
|
|
|
9860
10085
|
if (fromExecutableCode != null) {
|
|
9861
10086
|
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
9862
10087
|
}
|
|
10088
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
10089
|
+
if (fromFileData != null) {
|
|
10090
|
+
setValueByPath(toObject, ['fileData'], fileDataToMldev$1(fromFileData));
|
|
10091
|
+
}
|
|
9863
10092
|
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
9864
10093
|
'functionResponse',
|
|
9865
10094
|
]);
|
|
9866
10095
|
if (fromFunctionResponse != null) {
|
|
9867
10096
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
9868
10097
|
}
|
|
10098
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
10099
|
+
if (fromInlineData != null) {
|
|
10100
|
+
setValueByPath(toObject, ['inlineData'], blobToMldev$1(fromInlineData));
|
|
10101
|
+
}
|
|
9869
10102
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
9870
10103
|
if (fromText != null) {
|
|
9871
10104
|
setValueByPath(toObject, ['text'], fromText);
|
|
9872
10105
|
}
|
|
10106
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
10107
|
+
if (fromThought != null) {
|
|
10108
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
10109
|
+
}
|
|
10110
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
10111
|
+
'thoughtSignature',
|
|
10112
|
+
]);
|
|
10113
|
+
if (fromThoughtSignature != null) {
|
|
10114
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
10115
|
+
}
|
|
10116
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
10117
|
+
'videoMetadata',
|
|
10118
|
+
]);
|
|
10119
|
+
if (fromVideoMetadata != null) {
|
|
10120
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
10121
|
+
}
|
|
9873
10122
|
return toObject;
|
|
9874
10123
|
}
|
|
9875
10124
|
function productImageToVertex(fromObject) {
|
|
@@ -10086,13 +10335,13 @@ function safetyAttributesFromVertex(fromObject) {
|
|
|
10086
10335
|
}
|
|
10087
10336
|
function safetySettingToMldev(fromObject) {
|
|
10088
10337
|
const toObject = {};
|
|
10089
|
-
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
10090
|
-
throw new Error('method parameter is not supported in Gemini API.');
|
|
10091
|
-
}
|
|
10092
10338
|
const fromCategory = getValueByPath(fromObject, ['category']);
|
|
10093
10339
|
if (fromCategory != null) {
|
|
10094
10340
|
setValueByPath(toObject, ['category'], fromCategory);
|
|
10095
10341
|
}
|
|
10342
|
+
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
10343
|
+
throw new Error('method parameter is not supported in Gemini API.');
|
|
10344
|
+
}
|
|
10096
10345
|
const fromThreshold = getValueByPath(fromObject, ['threshold']);
|
|
10097
10346
|
if (fromThreshold != null) {
|
|
10098
10347
|
setValueByPath(toObject, ['threshold'], fromThreshold);
|
|
@@ -10191,6 +10440,10 @@ function segmentImageSourceToVertex(fromObject, parentObject) {
|
|
|
10191
10440
|
}
|
|
10192
10441
|
function speechConfigToVertex(fromObject) {
|
|
10193
10442
|
const toObject = {};
|
|
10443
|
+
const fromLanguageCode = getValueByPath(fromObject, ['languageCode']);
|
|
10444
|
+
if (fromLanguageCode != null) {
|
|
10445
|
+
setValueByPath(toObject, ['languageCode'], fromLanguageCode);
|
|
10446
|
+
}
|
|
10194
10447
|
const fromVoiceConfig = getValueByPath(fromObject, ['voiceConfig']);
|
|
10195
10448
|
if (fromVoiceConfig != null) {
|
|
10196
10449
|
setValueByPath(toObject, ['voiceConfig'], fromVoiceConfig);
|
|
@@ -10198,10 +10451,6 @@ function speechConfigToVertex(fromObject) {
|
|
|
10198
10451
|
if (getValueByPath(fromObject, ['multiSpeakerVoiceConfig']) !== undefined) {
|
|
10199
10452
|
throw new Error('multiSpeakerVoiceConfig parameter is not supported in Vertex AI.');
|
|
10200
10453
|
}
|
|
10201
|
-
const fromLanguageCode = getValueByPath(fromObject, ['languageCode']);
|
|
10202
|
-
if (fromLanguageCode != null) {
|
|
10203
|
-
setValueByPath(toObject, ['languageCode'], fromLanguageCode);
|
|
10204
|
-
}
|
|
10205
10454
|
return toObject;
|
|
10206
10455
|
}
|
|
10207
10456
|
function toolToMldev$1(fromObject) {
|
|
@@ -10221,16 +10470,26 @@ function toolToMldev$1(fromObject) {
|
|
|
10221
10470
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
10222
10471
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
10223
10472
|
}
|
|
10224
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
10225
|
-
if (fromGoogleSearch != null) {
|
|
10226
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
10227
|
-
}
|
|
10228
10473
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
10229
10474
|
'googleSearchRetrieval',
|
|
10230
10475
|
]);
|
|
10231
10476
|
if (fromGoogleSearchRetrieval != null) {
|
|
10232
10477
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
10233
10478
|
}
|
|
10479
|
+
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
10480
|
+
if (fromComputerUse != null) {
|
|
10481
|
+
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
10482
|
+
}
|
|
10483
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
10484
|
+
if (fromFileSearch != null) {
|
|
10485
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
10486
|
+
}
|
|
10487
|
+
const fromCodeExecution = getValueByPath(fromObject, [
|
|
10488
|
+
'codeExecution',
|
|
10489
|
+
]);
|
|
10490
|
+
if (fromCodeExecution != null) {
|
|
10491
|
+
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
10492
|
+
}
|
|
10234
10493
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
10235
10494
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
10236
10495
|
}
|
|
@@ -10238,20 +10497,14 @@ function toolToMldev$1(fromObject) {
|
|
|
10238
10497
|
if (fromGoogleMaps != null) {
|
|
10239
10498
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$1(fromGoogleMaps));
|
|
10240
10499
|
}
|
|
10500
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
10501
|
+
if (fromGoogleSearch != null) {
|
|
10502
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1(fromGoogleSearch));
|
|
10503
|
+
}
|
|
10241
10504
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
10242
10505
|
if (fromUrlContext != null) {
|
|
10243
10506
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
10244
10507
|
}
|
|
10245
|
-
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
10246
|
-
if (fromComputerUse != null) {
|
|
10247
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
10248
|
-
}
|
|
10249
|
-
const fromCodeExecution = getValueByPath(fromObject, [
|
|
10250
|
-
'codeExecution',
|
|
10251
|
-
]);
|
|
10252
|
-
if (fromCodeExecution != null) {
|
|
10253
|
-
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
10254
|
-
}
|
|
10255
10508
|
return toObject;
|
|
10256
10509
|
}
|
|
10257
10510
|
function toolToVertex(fromObject) {
|
|
@@ -10272,16 +10525,25 @@ function toolToVertex(fromObject) {
|
|
|
10272
10525
|
if (fromRetrieval != null) {
|
|
10273
10526
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
10274
10527
|
}
|
|
10275
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
10276
|
-
if (fromGoogleSearch != null) {
|
|
10277
|
-
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
10278
|
-
}
|
|
10279
10528
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
10280
10529
|
'googleSearchRetrieval',
|
|
10281
10530
|
]);
|
|
10282
10531
|
if (fromGoogleSearchRetrieval != null) {
|
|
10283
10532
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
10284
10533
|
}
|
|
10534
|
+
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
10535
|
+
if (fromComputerUse != null) {
|
|
10536
|
+
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
10537
|
+
}
|
|
10538
|
+
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
10539
|
+
throw new Error('fileSearch parameter is not supported in Vertex AI.');
|
|
10540
|
+
}
|
|
10541
|
+
const fromCodeExecution = getValueByPath(fromObject, [
|
|
10542
|
+
'codeExecution',
|
|
10543
|
+
]);
|
|
10544
|
+
if (fromCodeExecution != null) {
|
|
10545
|
+
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
10546
|
+
}
|
|
10285
10547
|
const fromEnterpriseWebSearch = getValueByPath(fromObject, [
|
|
10286
10548
|
'enterpriseWebSearch',
|
|
10287
10549
|
]);
|
|
@@ -10292,20 +10554,14 @@ function toolToVertex(fromObject) {
|
|
|
10292
10554
|
if (fromGoogleMaps != null) {
|
|
10293
10555
|
setValueByPath(toObject, ['googleMaps'], fromGoogleMaps);
|
|
10294
10556
|
}
|
|
10557
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
10558
|
+
if (fromGoogleSearch != null) {
|
|
10559
|
+
setValueByPath(toObject, ['googleSearch'], fromGoogleSearch);
|
|
10560
|
+
}
|
|
10295
10561
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
10296
10562
|
if (fromUrlContext != null) {
|
|
10297
10563
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
10298
10564
|
}
|
|
10299
|
-
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
10300
|
-
if (fromComputerUse != null) {
|
|
10301
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
10302
|
-
}
|
|
10303
|
-
const fromCodeExecution = getValueByPath(fromObject, [
|
|
10304
|
-
'codeExecution',
|
|
10305
|
-
]);
|
|
10306
|
-
if (fromCodeExecution != null) {
|
|
10307
|
-
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
10308
|
-
}
|
|
10309
10565
|
return toObject;
|
|
10310
10566
|
}
|
|
10311
10567
|
function tunedModelInfoFromMldev(fromObject) {
|
|
@@ -10409,6 +10665,18 @@ function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
|
|
|
10409
10665
|
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
10410
10666
|
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
10411
10667
|
}
|
|
10668
|
+
const fromSafetyFilterLevel = getValueByPath(fromObject, [
|
|
10669
|
+
'safetyFilterLevel',
|
|
10670
|
+
]);
|
|
10671
|
+
if (parentObject !== undefined && fromSafetyFilterLevel != null) {
|
|
10672
|
+
setValueByPath(parentObject, ['parameters', 'safetySetting'], fromSafetyFilterLevel);
|
|
10673
|
+
}
|
|
10674
|
+
const fromPersonGeneration = getValueByPath(fromObject, [
|
|
10675
|
+
'personGeneration',
|
|
10676
|
+
]);
|
|
10677
|
+
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
10678
|
+
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
10679
|
+
}
|
|
10412
10680
|
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
10413
10681
|
'includeRaiReason',
|
|
10414
10682
|
]);
|
|
@@ -10615,7 +10883,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
10615
10883
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
10616
10884
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
10617
10885
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
10618
|
-
const SDK_VERSION = '1.
|
|
10886
|
+
const SDK_VERSION = '1.29.0'; // x-release-please-version
|
|
10619
10887
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
10620
10888
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
10621
10889
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -10993,13 +11261,22 @@ class ApiClient {
|
|
|
10993
11261
|
await this.clientOptions.auth.addAuthHeaders(headers, url);
|
|
10994
11262
|
return headers;
|
|
10995
11263
|
}
|
|
11264
|
+
getFileName(file) {
|
|
11265
|
+
var _a;
|
|
11266
|
+
let fileName = '';
|
|
11267
|
+
if (typeof file === 'string') {
|
|
11268
|
+
fileName = file.replace(/[/\\]+$/, '');
|
|
11269
|
+
fileName = (_a = fileName.split(/[/\\]/).pop()) !== null && _a !== void 0 ? _a : '';
|
|
11270
|
+
}
|
|
11271
|
+
return fileName;
|
|
11272
|
+
}
|
|
10996
11273
|
/**
|
|
10997
11274
|
* Uploads a file asynchronously using Gemini API only, this is not supported
|
|
10998
11275
|
* in Vertex AI.
|
|
10999
11276
|
*
|
|
11000
11277
|
* @param file The string path to the file to be uploaded or a Blob object.
|
|
11001
11278
|
* @param config Optional parameters specified in the `UploadFileConfig`
|
|
11002
|
-
* interface. @see {@link UploadFileConfig}
|
|
11279
|
+
* interface. @see {@link types.UploadFileConfig}
|
|
11003
11280
|
* @return A promise that resolves to a `File` object.
|
|
11004
11281
|
* @throws An error if called on a Vertex AI client.
|
|
11005
11282
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
@@ -11023,42 +11300,71 @@ class ApiClient {
|
|
|
11023
11300
|
throw new Error('Can not determine mimeType. Please provide mimeType in the config.');
|
|
11024
11301
|
}
|
|
11025
11302
|
fileToUpload.mimeType = mimeType;
|
|
11026
|
-
const
|
|
11303
|
+
const body = {
|
|
11304
|
+
file: fileToUpload,
|
|
11305
|
+
};
|
|
11306
|
+
const fileName = this.getFileName(file);
|
|
11307
|
+
const path = formatMap('upload/v1beta/files', body['_url']);
|
|
11308
|
+
const uploadUrl = await this.fetchUploadUrl(path, fileToUpload.sizeBytes, fileToUpload.mimeType, fileName, body, config === null || config === void 0 ? void 0 : config.httpOptions);
|
|
11027
11309
|
return uploader.upload(file, uploadUrl, this);
|
|
11028
11310
|
}
|
|
11311
|
+
/**
|
|
11312
|
+
* Uploads a file to a given file search store asynchronously using Gemini API only, this is not supported
|
|
11313
|
+
* in Vertex AI.
|
|
11314
|
+
*
|
|
11315
|
+
* @param fileSearchStoreName The name of the file search store to upload the file to.
|
|
11316
|
+
* @param file The string path to the file to be uploaded or a Blob object.
|
|
11317
|
+
* @param config Optional parameters specified in the `UploadFileConfig`
|
|
11318
|
+
* interface. @see {@link UploadFileConfig}
|
|
11319
|
+
* @return A promise that resolves to a `File` object.
|
|
11320
|
+
* @throws An error if called on a Vertex AI client.
|
|
11321
|
+
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
11322
|
+
*/
|
|
11323
|
+
async uploadFileToFileSearchStore(fileSearchStoreName, file, config) {
|
|
11324
|
+
var _a;
|
|
11325
|
+
const uploader = this.clientOptions.uploader;
|
|
11326
|
+
const fileStat = await uploader.stat(file);
|
|
11327
|
+
const sizeBytes = String(fileStat.size);
|
|
11328
|
+
const mimeType = (_a = config === null || config === void 0 ? void 0 : config.mimeType) !== null && _a !== void 0 ? _a : fileStat.type;
|
|
11329
|
+
if (mimeType === undefined || mimeType === '') {
|
|
11330
|
+
throw new Error('Can not determine mimeType. Please provide mimeType in the config.');
|
|
11331
|
+
}
|
|
11332
|
+
const path = `upload/v1beta/${fileSearchStoreName}:uploadToFileSearchStore`;
|
|
11333
|
+
const fileName = this.getFileName(file);
|
|
11334
|
+
const body = {};
|
|
11335
|
+
if (config === null || config === void 0 ? void 0 : config.customMetadata) {
|
|
11336
|
+
body['customMetadata'] = config.customMetadata;
|
|
11337
|
+
}
|
|
11338
|
+
if (config === null || config === void 0 ? void 0 : config.chunkingConfig) {
|
|
11339
|
+
body['chunkingConfig'] = config.chunkingConfig;
|
|
11340
|
+
}
|
|
11341
|
+
const uploadUrl = await this.fetchUploadUrl(path, sizeBytes, mimeType, fileName, body, config === null || config === void 0 ? void 0 : config.httpOptions);
|
|
11342
|
+
return uploader.uploadToFileSearchStore(file, uploadUrl, this);
|
|
11343
|
+
}
|
|
11029
11344
|
/**
|
|
11030
11345
|
* Downloads a file asynchronously to the specified path.
|
|
11031
11346
|
*
|
|
11032
11347
|
* @params params - The parameters for the download request, see {@link
|
|
11033
|
-
* DownloadFileParameters}
|
|
11348
|
+
* types.DownloadFileParameters}
|
|
11034
11349
|
*/
|
|
11035
11350
|
async downloadFile(params) {
|
|
11036
11351
|
const downloader = this.clientOptions.downloader;
|
|
11037
11352
|
await downloader.download(params, this);
|
|
11038
11353
|
}
|
|
11039
|
-
async fetchUploadUrl(
|
|
11354
|
+
async fetchUploadUrl(path, sizeBytes, mimeType, fileName, body, configHttpOptions) {
|
|
11040
11355
|
var _a;
|
|
11041
11356
|
let httpOptions = {};
|
|
11042
|
-
if (
|
|
11043
|
-
httpOptions =
|
|
11357
|
+
if (configHttpOptions) {
|
|
11358
|
+
httpOptions = configHttpOptions;
|
|
11044
11359
|
}
|
|
11045
11360
|
else {
|
|
11046
11361
|
httpOptions = {
|
|
11047
11362
|
apiVersion: '',
|
|
11048
|
-
headers: {
|
|
11049
|
-
'Content-Type': 'application/json',
|
|
11050
|
-
'X-Goog-Upload-Protocol': 'resumable',
|
|
11051
|
-
'X-Goog-Upload-Command': 'start',
|
|
11052
|
-
'X-Goog-Upload-Header-Content-Length': `${file.sizeBytes}`,
|
|
11053
|
-
'X-Goog-Upload-Header-Content-Type': `${file.mimeType}`,
|
|
11054
|
-
},
|
|
11363
|
+
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 } : {})),
|
|
11055
11364
|
};
|
|
11056
11365
|
}
|
|
11057
|
-
const body = {
|
|
11058
|
-
'file': file,
|
|
11059
|
-
};
|
|
11060
11366
|
const httpResponse = await this.request({
|
|
11061
|
-
path
|
|
11367
|
+
path,
|
|
11062
11368
|
body: JSON.stringify(body),
|
|
11063
11369
|
httpMethod: 'POST',
|
|
11064
11370
|
httpOptions,
|
|
@@ -12062,11 +12368,27 @@ function hasCallableTools(params) {
|
|
|
12062
12368
|
var _a, _b, _c;
|
|
12063
12369
|
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;
|
|
12064
12370
|
}
|
|
12065
|
-
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12371
|
+
/**
|
|
12372
|
+
* Returns the indexes of the tools that are not compatible with AFC.
|
|
12373
|
+
*/
|
|
12374
|
+
function findAfcIncompatibleToolIndexes(params) {
|
|
12375
|
+
var _a;
|
|
12376
|
+
// Use number[] for an array of numbers in TypeScript
|
|
12377
|
+
const afcIncompatibleToolIndexes = [];
|
|
12378
|
+
if (!((_a = params === null || params === void 0 ? void 0 : params.config) === null || _a === void 0 ? void 0 : _a.tools)) {
|
|
12379
|
+
return afcIncompatibleToolIndexes;
|
|
12380
|
+
}
|
|
12381
|
+
params.config.tools.forEach((tool, index) => {
|
|
12382
|
+
if (isCallableTool(tool)) {
|
|
12383
|
+
return;
|
|
12384
|
+
}
|
|
12385
|
+
const geminiTool = tool;
|
|
12386
|
+
if (geminiTool.functionDeclarations &&
|
|
12387
|
+
geminiTool.functionDeclarations.length > 0) {
|
|
12388
|
+
afcIncompatibleToolIndexes.push(index);
|
|
12389
|
+
}
|
|
12390
|
+
});
|
|
12391
|
+
return afcIncompatibleToolIndexes;
|
|
12070
12392
|
}
|
|
12071
12393
|
/**
|
|
12072
12394
|
* Returns whether to append automatic function calling history to the
|
|
@@ -12131,8 +12453,12 @@ class Models extends BaseModule {
|
|
|
12131
12453
|
if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
|
|
12132
12454
|
return await this.generateContentInternal(transformedParams);
|
|
12133
12455
|
}
|
|
12134
|
-
|
|
12135
|
-
|
|
12456
|
+
const incompatibleToolIndexes = findAfcIncompatibleToolIndexes(params);
|
|
12457
|
+
if (incompatibleToolIndexes.length > 0) {
|
|
12458
|
+
const formattedIndexes = incompatibleToolIndexes
|
|
12459
|
+
.map((index) => `tools[${index}]`)
|
|
12460
|
+
.join(', ');
|
|
12461
|
+
throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${formattedIndexes}.`);
|
|
12136
12462
|
}
|
|
12137
12463
|
let response;
|
|
12138
12464
|
let functionResponseContent;
|
|
@@ -12219,9 +12545,14 @@ class Models extends BaseModule {
|
|
|
12219
12545
|
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
12220
12546
|
return await this.generateContentStreamInternal(transformedParams);
|
|
12221
12547
|
}
|
|
12222
|
-
|
|
12223
|
-
|
|
12548
|
+
const incompatibleToolIndexes = findAfcIncompatibleToolIndexes(params);
|
|
12549
|
+
if (incompatibleToolIndexes.length > 0) {
|
|
12550
|
+
const formattedIndexes = incompatibleToolIndexes
|
|
12551
|
+
.map((index) => `tools[${index}]`)
|
|
12552
|
+
.join(', ');
|
|
12553
|
+
throw new Error(`Incompatible tools found at ${formattedIndexes}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`);
|
|
12224
12554
|
}
|
|
12555
|
+
return await this.processAfcStream(params);
|
|
12225
12556
|
};
|
|
12226
12557
|
/**
|
|
12227
12558
|
* Generates an image based on a text description and configuration.
|
|
@@ -13617,7 +13948,7 @@ class Operations extends BaseModule {
|
|
|
13617
13948
|
});
|
|
13618
13949
|
return operation._fromAPIResponse({
|
|
13619
13950
|
apiResponse: rawOperation,
|
|
13620
|
-
|
|
13951
|
+
_isVertexAI: true,
|
|
13621
13952
|
});
|
|
13622
13953
|
}
|
|
13623
13954
|
else {
|
|
@@ -13627,7 +13958,7 @@ class Operations extends BaseModule {
|
|
|
13627
13958
|
});
|
|
13628
13959
|
return operation._fromAPIResponse({
|
|
13629
13960
|
apiResponse: rawOperation,
|
|
13630
|
-
|
|
13961
|
+
_isVertexAI: false,
|
|
13631
13962
|
});
|
|
13632
13963
|
}
|
|
13633
13964
|
}
|
|
@@ -13656,7 +13987,7 @@ class Operations extends BaseModule {
|
|
|
13656
13987
|
});
|
|
13657
13988
|
return operation._fromAPIResponse({
|
|
13658
13989
|
apiResponse: rawOperation,
|
|
13659
|
-
|
|
13990
|
+
_isVertexAI: true,
|
|
13660
13991
|
});
|
|
13661
13992
|
}
|
|
13662
13993
|
else {
|
|
@@ -13666,7 +13997,7 @@ class Operations extends BaseModule {
|
|
|
13666
13997
|
});
|
|
13667
13998
|
return operation._fromAPIResponse({
|
|
13668
13999
|
apiResponse: rawOperation,
|
|
13669
|
-
|
|
14000
|
+
_isVertexAI: false,
|
|
13670
14001
|
});
|
|
13671
14002
|
}
|
|
13672
14003
|
}
|
|
@@ -13754,13 +14085,13 @@ class Operations extends BaseModule {
|
|
|
13754
14085
|
*/
|
|
13755
14086
|
function blobToMldev(fromObject) {
|
|
13756
14087
|
const toObject = {};
|
|
13757
|
-
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
13758
|
-
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
13759
|
-
}
|
|
13760
14088
|
const fromData = getValueByPath(fromObject, ['data']);
|
|
13761
14089
|
if (fromData != null) {
|
|
13762
14090
|
setValueByPath(toObject, ['data'], fromData);
|
|
13763
14091
|
}
|
|
14092
|
+
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
14093
|
+
throw new Error('displayName parameter is not supported in Gemini API.');
|
|
14094
|
+
}
|
|
13764
14095
|
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
13765
14096
|
if (fromMimeType != null) {
|
|
13766
14097
|
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
@@ -13851,15 +14182,18 @@ function googleMapsToMldev(fromObject) {
|
|
|
13851
14182
|
}
|
|
13852
14183
|
function googleSearchToMldev(fromObject) {
|
|
13853
14184
|
const toObject = {};
|
|
14185
|
+
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
14186
|
+
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
14187
|
+
}
|
|
14188
|
+
if (getValueByPath(fromObject, ['blockingConfidence']) !== undefined) {
|
|
14189
|
+
throw new Error('blockingConfidence parameter is not supported in Gemini API.');
|
|
14190
|
+
}
|
|
13854
14191
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
13855
14192
|
'timeRangeFilter',
|
|
13856
14193
|
]);
|
|
13857
14194
|
if (fromTimeRangeFilter != null) {
|
|
13858
14195
|
setValueByPath(toObject, ['timeRangeFilter'], fromTimeRangeFilter);
|
|
13859
14196
|
}
|
|
13860
|
-
if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
|
|
13861
|
-
throw new Error('excludeDomains parameter is not supported in Gemini API.');
|
|
13862
|
-
}
|
|
13863
14197
|
return toObject;
|
|
13864
14198
|
}
|
|
13865
14199
|
function liveConnectConfigToMldev(fromObject, parentObject) {
|
|
@@ -13986,30 +14320,6 @@ function liveConnectConstraintsToMldev(apiClient, fromObject) {
|
|
|
13986
14320
|
}
|
|
13987
14321
|
function partToMldev(fromObject) {
|
|
13988
14322
|
const toObject = {};
|
|
13989
|
-
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
13990
|
-
'videoMetadata',
|
|
13991
|
-
]);
|
|
13992
|
-
if (fromVideoMetadata != null) {
|
|
13993
|
-
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
13994
|
-
}
|
|
13995
|
-
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
13996
|
-
if (fromThought != null) {
|
|
13997
|
-
setValueByPath(toObject, ['thought'], fromThought);
|
|
13998
|
-
}
|
|
13999
|
-
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
14000
|
-
if (fromInlineData != null) {
|
|
14001
|
-
setValueByPath(toObject, ['inlineData'], blobToMldev(fromInlineData));
|
|
14002
|
-
}
|
|
14003
|
-
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
14004
|
-
if (fromFileData != null) {
|
|
14005
|
-
setValueByPath(toObject, ['fileData'], fileDataToMldev(fromFileData));
|
|
14006
|
-
}
|
|
14007
|
-
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
14008
|
-
'thoughtSignature',
|
|
14009
|
-
]);
|
|
14010
|
-
if (fromThoughtSignature != null) {
|
|
14011
|
-
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
14012
|
-
}
|
|
14013
14323
|
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
14014
14324
|
if (fromFunctionCall != null) {
|
|
14015
14325
|
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
@@ -14026,25 +14336,49 @@ function partToMldev(fromObject) {
|
|
|
14026
14336
|
if (fromExecutableCode != null) {
|
|
14027
14337
|
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
14028
14338
|
}
|
|
14339
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
14340
|
+
if (fromFileData != null) {
|
|
14341
|
+
setValueByPath(toObject, ['fileData'], fileDataToMldev(fromFileData));
|
|
14342
|
+
}
|
|
14029
14343
|
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
14030
14344
|
'functionResponse',
|
|
14031
14345
|
]);
|
|
14032
14346
|
if (fromFunctionResponse != null) {
|
|
14033
14347
|
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
14034
14348
|
}
|
|
14349
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
14350
|
+
if (fromInlineData != null) {
|
|
14351
|
+
setValueByPath(toObject, ['inlineData'], blobToMldev(fromInlineData));
|
|
14352
|
+
}
|
|
14035
14353
|
const fromText = getValueByPath(fromObject, ['text']);
|
|
14036
14354
|
if (fromText != null) {
|
|
14037
14355
|
setValueByPath(toObject, ['text'], fromText);
|
|
14038
14356
|
}
|
|
14039
|
-
|
|
14040
|
-
|
|
14041
|
-
|
|
14042
|
-
const toObject = {};
|
|
14043
|
-
const fromHandle = getValueByPath(fromObject, ['handle']);
|
|
14044
|
-
if (fromHandle != null) {
|
|
14045
|
-
setValueByPath(toObject, ['handle'], fromHandle);
|
|
14357
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
14358
|
+
if (fromThought != null) {
|
|
14359
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
14046
14360
|
}
|
|
14047
|
-
|
|
14361
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
14362
|
+
'thoughtSignature',
|
|
14363
|
+
]);
|
|
14364
|
+
if (fromThoughtSignature != null) {
|
|
14365
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
14366
|
+
}
|
|
14367
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
14368
|
+
'videoMetadata',
|
|
14369
|
+
]);
|
|
14370
|
+
if (fromVideoMetadata != null) {
|
|
14371
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
14372
|
+
}
|
|
14373
|
+
return toObject;
|
|
14374
|
+
}
|
|
14375
|
+
function sessionResumptionConfigToMldev(fromObject) {
|
|
14376
|
+
const toObject = {};
|
|
14377
|
+
const fromHandle = getValueByPath(fromObject, ['handle']);
|
|
14378
|
+
if (fromHandle != null) {
|
|
14379
|
+
setValueByPath(toObject, ['handle'], fromHandle);
|
|
14380
|
+
}
|
|
14381
|
+
if (getValueByPath(fromObject, ['transparent']) !== undefined) {
|
|
14048
14382
|
throw new Error('transparent parameter is not supported in Gemini API.');
|
|
14049
14383
|
}
|
|
14050
14384
|
return toObject;
|
|
@@ -14066,16 +14400,26 @@ function toolToMldev(fromObject) {
|
|
|
14066
14400
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
14067
14401
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
14068
14402
|
}
|
|
14069
|
-
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
14070
|
-
if (fromGoogleSearch != null) {
|
|
14071
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
14072
|
-
}
|
|
14073
14403
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
14074
14404
|
'googleSearchRetrieval',
|
|
14075
14405
|
]);
|
|
14076
14406
|
if (fromGoogleSearchRetrieval != null) {
|
|
14077
14407
|
setValueByPath(toObject, ['googleSearchRetrieval'], fromGoogleSearchRetrieval);
|
|
14078
14408
|
}
|
|
14409
|
+
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
14410
|
+
if (fromComputerUse != null) {
|
|
14411
|
+
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
14412
|
+
}
|
|
14413
|
+
const fromFileSearch = getValueByPath(fromObject, ['fileSearch']);
|
|
14414
|
+
if (fromFileSearch != null) {
|
|
14415
|
+
setValueByPath(toObject, ['fileSearch'], fromFileSearch);
|
|
14416
|
+
}
|
|
14417
|
+
const fromCodeExecution = getValueByPath(fromObject, [
|
|
14418
|
+
'codeExecution',
|
|
14419
|
+
]);
|
|
14420
|
+
if (fromCodeExecution != null) {
|
|
14421
|
+
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
14422
|
+
}
|
|
14079
14423
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
14080
14424
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
14081
14425
|
}
|
|
@@ -14083,20 +14427,14 @@ function toolToMldev(fromObject) {
|
|
|
14083
14427
|
if (fromGoogleMaps != null) {
|
|
14084
14428
|
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev(fromGoogleMaps));
|
|
14085
14429
|
}
|
|
14430
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
14431
|
+
if (fromGoogleSearch != null) {
|
|
14432
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev(fromGoogleSearch));
|
|
14433
|
+
}
|
|
14086
14434
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
14087
14435
|
if (fromUrlContext != null) {
|
|
14088
14436
|
setValueByPath(toObject, ['urlContext'], fromUrlContext);
|
|
14089
14437
|
}
|
|
14090
|
-
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
14091
|
-
if (fromComputerUse != null) {
|
|
14092
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
14093
|
-
}
|
|
14094
|
-
const fromCodeExecution = getValueByPath(fromObject, [
|
|
14095
|
-
'codeExecution',
|
|
14096
|
-
]);
|
|
14097
|
-
if (fromCodeExecution != null) {
|
|
14098
|
-
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
14099
|
-
}
|
|
14100
14438
|
return toObject;
|
|
14101
14439
|
}
|
|
14102
14440
|
|
|
@@ -14223,139 +14561,883 @@ function convertBidiSetupToTokenSetup(requestDict, config) {
|
|
|
14223
14561
|
}
|
|
14224
14562
|
}
|
|
14225
14563
|
else {
|
|
14226
|
-
// Case 3: "Lock all fields" (meaning, don't send a field_mask, let server
|
|
14227
|
-
// defaults apply or all are mutable). This is hit if:
|
|
14228
|
-
// - `config.lockAdditionalFields` is undefined.
|
|
14229
|
-
// - `config.lockAdditionalFields` is non-empty, BUT
|
|
14230
|
-
// `preExistingFieldMask` is null, not a string, or an empty string.
|
|
14231
|
-
delete requestDict['fieldMask'];
|
|
14564
|
+
// Case 3: "Lock all fields" (meaning, don't send a field_mask, let server
|
|
14565
|
+
// defaults apply or all are mutable). This is hit if:
|
|
14566
|
+
// - `config.lockAdditionalFields` is undefined.
|
|
14567
|
+
// - `config.lockAdditionalFields` is non-empty, BUT
|
|
14568
|
+
// `preExistingFieldMask` is null, not a string, or an empty string.
|
|
14569
|
+
delete requestDict['fieldMask'];
|
|
14570
|
+
}
|
|
14571
|
+
}
|
|
14572
|
+
else {
|
|
14573
|
+
// No valid `bidiGenerateContentSetup` was found or extracted.
|
|
14574
|
+
// "Lock additional null fields if any".
|
|
14575
|
+
if (preExistingFieldMask !== null &&
|
|
14576
|
+
Array.isArray(preExistingFieldMask) &&
|
|
14577
|
+
preExistingFieldMask.length > 0) {
|
|
14578
|
+
// If there's a pre-existing field mask, it's a string, and it's not
|
|
14579
|
+
// empty, then we should lock all fields.
|
|
14580
|
+
requestDict['fieldMask'] = preExistingFieldMask.join(',');
|
|
14581
|
+
}
|
|
14582
|
+
else {
|
|
14583
|
+
delete requestDict['fieldMask'];
|
|
14584
|
+
}
|
|
14585
|
+
}
|
|
14586
|
+
return requestDict;
|
|
14587
|
+
}
|
|
14588
|
+
class Tokens extends BaseModule {
|
|
14589
|
+
constructor(apiClient) {
|
|
14590
|
+
super();
|
|
14591
|
+
this.apiClient = apiClient;
|
|
14592
|
+
}
|
|
14593
|
+
/**
|
|
14594
|
+
* Creates an ephemeral auth token resource.
|
|
14595
|
+
*
|
|
14596
|
+
* @experimental
|
|
14597
|
+
*
|
|
14598
|
+
* @remarks
|
|
14599
|
+
* Ephemeral auth tokens is only supported in the Gemini Developer API.
|
|
14600
|
+
* It can be used for the session connection to the Live constrained API.
|
|
14601
|
+
* Support in v1alpha only.
|
|
14602
|
+
*
|
|
14603
|
+
* @param params - The parameters for the create request.
|
|
14604
|
+
* @return The created auth token.
|
|
14605
|
+
*
|
|
14606
|
+
* @example
|
|
14607
|
+
* ```ts
|
|
14608
|
+
* const ai = new GoogleGenAI({
|
|
14609
|
+
* apiKey: token.name,
|
|
14610
|
+
* httpOptions: { apiVersion: 'v1alpha' } // Support in v1alpha only.
|
|
14611
|
+
* });
|
|
14612
|
+
*
|
|
14613
|
+
* // Case 1: If LiveEphemeralParameters is unset, unlock LiveConnectConfig
|
|
14614
|
+
* // when using the token in Live API sessions. Each session connection can
|
|
14615
|
+
* // use a different configuration.
|
|
14616
|
+
* const config: CreateAuthTokenConfig = {
|
|
14617
|
+
* uses: 3,
|
|
14618
|
+
* expireTime: '2025-05-01T00:00:00Z',
|
|
14619
|
+
* }
|
|
14620
|
+
* const token = await ai.tokens.create(config);
|
|
14621
|
+
*
|
|
14622
|
+
* // Case 2: If LiveEphemeralParameters is set, lock all fields in
|
|
14623
|
+
* // LiveConnectConfig when using the token in Live API sessions. For
|
|
14624
|
+
* // example, changing `outputAudioTranscription` in the Live API
|
|
14625
|
+
* // connection will be ignored by the API.
|
|
14626
|
+
* const config: CreateAuthTokenConfig =
|
|
14627
|
+
* uses: 3,
|
|
14628
|
+
* expireTime: '2025-05-01T00:00:00Z',
|
|
14629
|
+
* LiveEphemeralParameters: {
|
|
14630
|
+
* model: 'gemini-2.0-flash-001',
|
|
14631
|
+
* config: {
|
|
14632
|
+
* 'responseModalities': ['AUDIO'],
|
|
14633
|
+
* 'systemInstruction': 'Always answer in English.',
|
|
14634
|
+
* }
|
|
14635
|
+
* }
|
|
14636
|
+
* }
|
|
14637
|
+
* const token = await ai.tokens.create(config);
|
|
14638
|
+
*
|
|
14639
|
+
* // Case 3: If LiveEphemeralParameters is set and lockAdditionalFields is
|
|
14640
|
+
* // set, lock LiveConnectConfig with set and additional fields (e.g.
|
|
14641
|
+
* // responseModalities, systemInstruction, temperature in this example) when
|
|
14642
|
+
* // using the token in Live API sessions.
|
|
14643
|
+
* const config: CreateAuthTokenConfig =
|
|
14644
|
+
* uses: 3,
|
|
14645
|
+
* expireTime: '2025-05-01T00:00:00Z',
|
|
14646
|
+
* LiveEphemeralParameters: {
|
|
14647
|
+
* model: 'gemini-2.0-flash-001',
|
|
14648
|
+
* config: {
|
|
14649
|
+
* 'responseModalities': ['AUDIO'],
|
|
14650
|
+
* 'systemInstruction': 'Always answer in English.',
|
|
14651
|
+
* }
|
|
14652
|
+
* },
|
|
14653
|
+
* lockAdditionalFields: ['temperature'],
|
|
14654
|
+
* }
|
|
14655
|
+
* const token = await ai.tokens.create(config);
|
|
14656
|
+
*
|
|
14657
|
+
* // Case 4: If LiveEphemeralParameters is set and lockAdditionalFields is
|
|
14658
|
+
* // empty array, lock LiveConnectConfig with set fields (e.g.
|
|
14659
|
+
* // responseModalities, systemInstruction in this example) when using the
|
|
14660
|
+
* // token in Live API sessions.
|
|
14661
|
+
* const config: CreateAuthTokenConfig =
|
|
14662
|
+
* uses: 3,
|
|
14663
|
+
* expireTime: '2025-05-01T00:00:00Z',
|
|
14664
|
+
* LiveEphemeralParameters: {
|
|
14665
|
+
* model: 'gemini-2.0-flash-001',
|
|
14666
|
+
* config: {
|
|
14667
|
+
* 'responseModalities': ['AUDIO'],
|
|
14668
|
+
* 'systemInstruction': 'Always answer in English.',
|
|
14669
|
+
* }
|
|
14670
|
+
* },
|
|
14671
|
+
* lockAdditionalFields: [],
|
|
14672
|
+
* }
|
|
14673
|
+
* const token = await ai.tokens.create(config);
|
|
14674
|
+
* ```
|
|
14675
|
+
*/
|
|
14676
|
+
async create(params) {
|
|
14677
|
+
var _a, _b;
|
|
14678
|
+
let response;
|
|
14679
|
+
let path = '';
|
|
14680
|
+
let queryParams = {};
|
|
14681
|
+
if (this.apiClient.isVertexAI()) {
|
|
14682
|
+
throw new Error('The client.tokens.create method is only supported by the Gemini Developer API.');
|
|
14683
|
+
}
|
|
14684
|
+
else {
|
|
14685
|
+
const body = createAuthTokenParametersToMldev(this.apiClient, params);
|
|
14686
|
+
path = formatMap('auth_tokens', body['_url']);
|
|
14687
|
+
queryParams = body['_query'];
|
|
14688
|
+
delete body['config'];
|
|
14689
|
+
delete body['_url'];
|
|
14690
|
+
delete body['_query'];
|
|
14691
|
+
const transformedBody = convertBidiSetupToTokenSetup(body, params.config);
|
|
14692
|
+
response = this.apiClient
|
|
14693
|
+
.request({
|
|
14694
|
+
path: path,
|
|
14695
|
+
queryParams: queryParams,
|
|
14696
|
+
body: JSON.stringify(transformedBody),
|
|
14697
|
+
httpMethod: 'POST',
|
|
14698
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
14699
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
14700
|
+
})
|
|
14701
|
+
.then((httpResponse) => {
|
|
14702
|
+
return httpResponse.json();
|
|
14703
|
+
});
|
|
14704
|
+
return response.then((resp) => {
|
|
14705
|
+
return resp;
|
|
14706
|
+
});
|
|
14707
|
+
}
|
|
14708
|
+
}
|
|
14709
|
+
}
|
|
14710
|
+
|
|
14711
|
+
/**
|
|
14712
|
+
* @license
|
|
14713
|
+
* Copyright 2025 Google LLC
|
|
14714
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
14715
|
+
*/
|
|
14716
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
14717
|
+
function createFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
14718
|
+
const toObject = {};
|
|
14719
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
14720
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
14721
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
14722
|
+
}
|
|
14723
|
+
return toObject;
|
|
14724
|
+
}
|
|
14725
|
+
function createFileSearchStoreParametersToMldev(fromObject) {
|
|
14726
|
+
const toObject = {};
|
|
14727
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14728
|
+
if (fromConfig != null) {
|
|
14729
|
+
createFileSearchStoreConfigToMldev(fromConfig, toObject);
|
|
14730
|
+
}
|
|
14731
|
+
return toObject;
|
|
14732
|
+
}
|
|
14733
|
+
function deleteFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
14734
|
+
const toObject = {};
|
|
14735
|
+
const fromForce = getValueByPath(fromObject, ['force']);
|
|
14736
|
+
if (parentObject !== undefined && fromForce != null) {
|
|
14737
|
+
setValueByPath(parentObject, ['_query', 'force'], fromForce);
|
|
14738
|
+
}
|
|
14739
|
+
return toObject;
|
|
14740
|
+
}
|
|
14741
|
+
function deleteFileSearchStoreParametersToMldev(fromObject) {
|
|
14742
|
+
const toObject = {};
|
|
14743
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
14744
|
+
if (fromName != null) {
|
|
14745
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
14746
|
+
}
|
|
14747
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14748
|
+
if (fromConfig != null) {
|
|
14749
|
+
deleteFileSearchStoreConfigToMldev(fromConfig, toObject);
|
|
14750
|
+
}
|
|
14751
|
+
return toObject;
|
|
14752
|
+
}
|
|
14753
|
+
function getFileSearchStoreParametersToMldev(fromObject) {
|
|
14754
|
+
const toObject = {};
|
|
14755
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
14756
|
+
if (fromName != null) {
|
|
14757
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
14758
|
+
}
|
|
14759
|
+
return toObject;
|
|
14760
|
+
}
|
|
14761
|
+
function importFileConfigToMldev(fromObject, parentObject) {
|
|
14762
|
+
const toObject = {};
|
|
14763
|
+
const fromCustomMetadata = getValueByPath(fromObject, [
|
|
14764
|
+
'customMetadata',
|
|
14765
|
+
]);
|
|
14766
|
+
if (parentObject !== undefined && fromCustomMetadata != null) {
|
|
14767
|
+
let transformedList = fromCustomMetadata;
|
|
14768
|
+
if (Array.isArray(transformedList)) {
|
|
14769
|
+
transformedList = transformedList.map((item) => {
|
|
14770
|
+
return item;
|
|
14771
|
+
});
|
|
14772
|
+
}
|
|
14773
|
+
setValueByPath(parentObject, ['customMetadata'], transformedList);
|
|
14774
|
+
}
|
|
14775
|
+
const fromChunkingConfig = getValueByPath(fromObject, [
|
|
14776
|
+
'chunkingConfig',
|
|
14777
|
+
]);
|
|
14778
|
+
if (parentObject !== undefined && fromChunkingConfig != null) {
|
|
14779
|
+
setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
|
|
14780
|
+
}
|
|
14781
|
+
return toObject;
|
|
14782
|
+
}
|
|
14783
|
+
function importFileOperationFromMldev(fromObject) {
|
|
14784
|
+
const toObject = {};
|
|
14785
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
14786
|
+
if (fromName != null) {
|
|
14787
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
14788
|
+
}
|
|
14789
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
14790
|
+
if (fromMetadata != null) {
|
|
14791
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
14792
|
+
}
|
|
14793
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
14794
|
+
if (fromDone != null) {
|
|
14795
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
14796
|
+
}
|
|
14797
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
14798
|
+
if (fromError != null) {
|
|
14799
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
14800
|
+
}
|
|
14801
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
14802
|
+
if (fromResponse != null) {
|
|
14803
|
+
setValueByPath(toObject, ['response'], importFileResponseFromMldev(fromResponse));
|
|
14804
|
+
}
|
|
14805
|
+
return toObject;
|
|
14806
|
+
}
|
|
14807
|
+
function importFileParametersToMldev(fromObject) {
|
|
14808
|
+
const toObject = {};
|
|
14809
|
+
const fromFileSearchStoreName = getValueByPath(fromObject, [
|
|
14810
|
+
'fileSearchStoreName',
|
|
14811
|
+
]);
|
|
14812
|
+
if (fromFileSearchStoreName != null) {
|
|
14813
|
+
setValueByPath(toObject, ['_url', 'file_search_store_name'], fromFileSearchStoreName);
|
|
14814
|
+
}
|
|
14815
|
+
const fromFileName = getValueByPath(fromObject, ['fileName']);
|
|
14816
|
+
if (fromFileName != null) {
|
|
14817
|
+
setValueByPath(toObject, ['fileName'], fromFileName);
|
|
14818
|
+
}
|
|
14819
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14820
|
+
if (fromConfig != null) {
|
|
14821
|
+
importFileConfigToMldev(fromConfig, toObject);
|
|
14822
|
+
}
|
|
14823
|
+
return toObject;
|
|
14824
|
+
}
|
|
14825
|
+
function importFileResponseFromMldev(fromObject) {
|
|
14826
|
+
const toObject = {};
|
|
14827
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
14828
|
+
'sdkHttpResponse',
|
|
14829
|
+
]);
|
|
14830
|
+
if (fromSdkHttpResponse != null) {
|
|
14831
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
14832
|
+
}
|
|
14833
|
+
const fromParent = getValueByPath(fromObject, ['parent']);
|
|
14834
|
+
if (fromParent != null) {
|
|
14835
|
+
setValueByPath(toObject, ['parent'], fromParent);
|
|
14836
|
+
}
|
|
14837
|
+
const fromDocumentName = getValueByPath(fromObject, ['documentName']);
|
|
14838
|
+
if (fromDocumentName != null) {
|
|
14839
|
+
setValueByPath(toObject, ['documentName'], fromDocumentName);
|
|
14840
|
+
}
|
|
14841
|
+
return toObject;
|
|
14842
|
+
}
|
|
14843
|
+
function listFileSearchStoresConfigToMldev(fromObject, parentObject) {
|
|
14844
|
+
const toObject = {};
|
|
14845
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
14846
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
14847
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
14848
|
+
}
|
|
14849
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
14850
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
14851
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
14852
|
+
}
|
|
14853
|
+
return toObject;
|
|
14854
|
+
}
|
|
14855
|
+
function listFileSearchStoresParametersToMldev(fromObject) {
|
|
14856
|
+
const toObject = {};
|
|
14857
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14858
|
+
if (fromConfig != null) {
|
|
14859
|
+
listFileSearchStoresConfigToMldev(fromConfig, toObject);
|
|
14860
|
+
}
|
|
14861
|
+
return toObject;
|
|
14862
|
+
}
|
|
14863
|
+
function listFileSearchStoresResponseFromMldev(fromObject) {
|
|
14864
|
+
const toObject = {};
|
|
14865
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
14866
|
+
'sdkHttpResponse',
|
|
14867
|
+
]);
|
|
14868
|
+
if (fromSdkHttpResponse != null) {
|
|
14869
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
14870
|
+
}
|
|
14871
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
14872
|
+
'nextPageToken',
|
|
14873
|
+
]);
|
|
14874
|
+
if (fromNextPageToken != null) {
|
|
14875
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
14876
|
+
}
|
|
14877
|
+
const fromFileSearchStores = getValueByPath(fromObject, [
|
|
14878
|
+
'fileSearchStores',
|
|
14879
|
+
]);
|
|
14880
|
+
if (fromFileSearchStores != null) {
|
|
14881
|
+
let transformedList = fromFileSearchStores;
|
|
14882
|
+
if (Array.isArray(transformedList)) {
|
|
14883
|
+
transformedList = transformedList.map((item) => {
|
|
14884
|
+
return item;
|
|
14885
|
+
});
|
|
14886
|
+
}
|
|
14887
|
+
setValueByPath(toObject, ['fileSearchStores'], transformedList);
|
|
14888
|
+
}
|
|
14889
|
+
return toObject;
|
|
14890
|
+
}
|
|
14891
|
+
function uploadToFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
14892
|
+
const toObject = {};
|
|
14893
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
14894
|
+
if (parentObject !== undefined && fromMimeType != null) {
|
|
14895
|
+
setValueByPath(parentObject, ['mimeType'], fromMimeType);
|
|
14896
|
+
}
|
|
14897
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
14898
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
14899
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
14900
|
+
}
|
|
14901
|
+
const fromCustomMetadata = getValueByPath(fromObject, [
|
|
14902
|
+
'customMetadata',
|
|
14903
|
+
]);
|
|
14904
|
+
if (parentObject !== undefined && fromCustomMetadata != null) {
|
|
14905
|
+
let transformedList = fromCustomMetadata;
|
|
14906
|
+
if (Array.isArray(transformedList)) {
|
|
14907
|
+
transformedList = transformedList.map((item) => {
|
|
14908
|
+
return item;
|
|
14909
|
+
});
|
|
14910
|
+
}
|
|
14911
|
+
setValueByPath(parentObject, ['customMetadata'], transformedList);
|
|
14912
|
+
}
|
|
14913
|
+
const fromChunkingConfig = getValueByPath(fromObject, [
|
|
14914
|
+
'chunkingConfig',
|
|
14915
|
+
]);
|
|
14916
|
+
if (parentObject !== undefined && fromChunkingConfig != null) {
|
|
14917
|
+
setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
|
|
14918
|
+
}
|
|
14919
|
+
return toObject;
|
|
14920
|
+
}
|
|
14921
|
+
function uploadToFileSearchStoreParametersToMldev(fromObject) {
|
|
14922
|
+
const toObject = {};
|
|
14923
|
+
const fromFileSearchStoreName = getValueByPath(fromObject, [
|
|
14924
|
+
'fileSearchStoreName',
|
|
14925
|
+
]);
|
|
14926
|
+
if (fromFileSearchStoreName != null) {
|
|
14927
|
+
setValueByPath(toObject, ['_url', 'file_search_store_name'], fromFileSearchStoreName);
|
|
14928
|
+
}
|
|
14929
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14930
|
+
if (fromConfig != null) {
|
|
14931
|
+
uploadToFileSearchStoreConfigToMldev(fromConfig, toObject);
|
|
14932
|
+
}
|
|
14933
|
+
return toObject;
|
|
14934
|
+
}
|
|
14935
|
+
function uploadToFileSearchStoreResumableResponseFromMldev(fromObject) {
|
|
14936
|
+
const toObject = {};
|
|
14937
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
14938
|
+
'sdkHttpResponse',
|
|
14939
|
+
]);
|
|
14940
|
+
if (fromSdkHttpResponse != null) {
|
|
14941
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
14942
|
+
}
|
|
14943
|
+
return toObject;
|
|
14944
|
+
}
|
|
14945
|
+
|
|
14946
|
+
/**
|
|
14947
|
+
* @license
|
|
14948
|
+
* Copyright 2025 Google LLC
|
|
14949
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
14950
|
+
*/
|
|
14951
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
14952
|
+
function deleteDocumentConfigToMldev(fromObject, parentObject) {
|
|
14953
|
+
const toObject = {};
|
|
14954
|
+
const fromForce = getValueByPath(fromObject, ['force']);
|
|
14955
|
+
if (parentObject !== undefined && fromForce != null) {
|
|
14956
|
+
setValueByPath(parentObject, ['_query', 'force'], fromForce);
|
|
14957
|
+
}
|
|
14958
|
+
return toObject;
|
|
14959
|
+
}
|
|
14960
|
+
function deleteDocumentParametersToMldev(fromObject) {
|
|
14961
|
+
const toObject = {};
|
|
14962
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
14963
|
+
if (fromName != null) {
|
|
14964
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
14965
|
+
}
|
|
14966
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14967
|
+
if (fromConfig != null) {
|
|
14968
|
+
deleteDocumentConfigToMldev(fromConfig, toObject);
|
|
14969
|
+
}
|
|
14970
|
+
return toObject;
|
|
14971
|
+
}
|
|
14972
|
+
function getDocumentParametersToMldev(fromObject) {
|
|
14973
|
+
const toObject = {};
|
|
14974
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
14975
|
+
if (fromName != null) {
|
|
14976
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
14977
|
+
}
|
|
14978
|
+
return toObject;
|
|
14979
|
+
}
|
|
14980
|
+
function listDocumentsConfigToMldev(fromObject, parentObject) {
|
|
14981
|
+
const toObject = {};
|
|
14982
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
14983
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
14984
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
14985
|
+
}
|
|
14986
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
14987
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
14988
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
14989
|
+
}
|
|
14990
|
+
return toObject;
|
|
14991
|
+
}
|
|
14992
|
+
function listDocumentsParametersToMldev(fromObject) {
|
|
14993
|
+
const toObject = {};
|
|
14994
|
+
const fromParent = getValueByPath(fromObject, ['parent']);
|
|
14995
|
+
if (fromParent != null) {
|
|
14996
|
+
setValueByPath(toObject, ['_url', 'parent'], fromParent);
|
|
14997
|
+
}
|
|
14998
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14999
|
+
if (fromConfig != null) {
|
|
15000
|
+
listDocumentsConfigToMldev(fromConfig, toObject);
|
|
15001
|
+
}
|
|
15002
|
+
return toObject;
|
|
15003
|
+
}
|
|
15004
|
+
function listDocumentsResponseFromMldev(fromObject) {
|
|
15005
|
+
const toObject = {};
|
|
15006
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
15007
|
+
'sdkHttpResponse',
|
|
15008
|
+
]);
|
|
15009
|
+
if (fromSdkHttpResponse != null) {
|
|
15010
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
15011
|
+
}
|
|
15012
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
15013
|
+
'nextPageToken',
|
|
15014
|
+
]);
|
|
15015
|
+
if (fromNextPageToken != null) {
|
|
15016
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
15017
|
+
}
|
|
15018
|
+
const fromDocuments = getValueByPath(fromObject, ['documents']);
|
|
15019
|
+
if (fromDocuments != null) {
|
|
15020
|
+
let transformedList = fromDocuments;
|
|
15021
|
+
if (Array.isArray(transformedList)) {
|
|
15022
|
+
transformedList = transformedList.map((item) => {
|
|
15023
|
+
return item;
|
|
15024
|
+
});
|
|
15025
|
+
}
|
|
15026
|
+
setValueByPath(toObject, ['documents'], transformedList);
|
|
15027
|
+
}
|
|
15028
|
+
return toObject;
|
|
15029
|
+
}
|
|
15030
|
+
|
|
15031
|
+
/**
|
|
15032
|
+
* @license
|
|
15033
|
+
* Copyright 2025 Google LLC
|
|
15034
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15035
|
+
*/
|
|
15036
|
+
class Documents extends BaseModule {
|
|
15037
|
+
constructor(apiClient) {
|
|
15038
|
+
super();
|
|
15039
|
+
this.apiClient = apiClient;
|
|
15040
|
+
/**
|
|
15041
|
+
* Lists documents.
|
|
15042
|
+
*
|
|
15043
|
+
* @param params - The parameters for the list request.
|
|
15044
|
+
* @return - A pager of documents.
|
|
15045
|
+
*
|
|
15046
|
+
* @example
|
|
15047
|
+
* ```ts
|
|
15048
|
+
* const documents = await ai.documents.list({config: {'pageSize': 2}});
|
|
15049
|
+
* for await (const document of documents) {
|
|
15050
|
+
* console.log(document);
|
|
15051
|
+
* }
|
|
15052
|
+
* ```
|
|
15053
|
+
*/
|
|
15054
|
+
this.list = async (params) => {
|
|
15055
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_DOCUMENTS, (x) => this.listInternal({
|
|
15056
|
+
parent: params.parent,
|
|
15057
|
+
config: x.config,
|
|
15058
|
+
}), await this.listInternal(params), params);
|
|
15059
|
+
};
|
|
15060
|
+
}
|
|
15061
|
+
/**
|
|
15062
|
+
* Gets a Document.
|
|
15063
|
+
*
|
|
15064
|
+
* @param params - The parameters for getting a document.
|
|
15065
|
+
* @return Document.
|
|
15066
|
+
*/
|
|
15067
|
+
async get(params) {
|
|
15068
|
+
var _a, _b;
|
|
15069
|
+
let response;
|
|
15070
|
+
let path = '';
|
|
15071
|
+
let queryParams = {};
|
|
15072
|
+
if (this.apiClient.isVertexAI()) {
|
|
15073
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15074
|
+
}
|
|
15075
|
+
else {
|
|
15076
|
+
const body = getDocumentParametersToMldev(params);
|
|
15077
|
+
path = formatMap('{name}', body['_url']);
|
|
15078
|
+
queryParams = body['_query'];
|
|
15079
|
+
delete body['_url'];
|
|
15080
|
+
delete body['_query'];
|
|
15081
|
+
response = this.apiClient
|
|
15082
|
+
.request({
|
|
15083
|
+
path: path,
|
|
15084
|
+
queryParams: queryParams,
|
|
15085
|
+
body: JSON.stringify(body),
|
|
15086
|
+
httpMethod: 'GET',
|
|
15087
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15088
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15089
|
+
})
|
|
15090
|
+
.then((httpResponse) => {
|
|
15091
|
+
return httpResponse.json();
|
|
15092
|
+
});
|
|
15093
|
+
return response.then((resp) => {
|
|
15094
|
+
return resp;
|
|
15095
|
+
});
|
|
15096
|
+
}
|
|
15097
|
+
}
|
|
15098
|
+
/**
|
|
15099
|
+
* Deletes a Document.
|
|
15100
|
+
*
|
|
15101
|
+
* @param params - The parameters for deleting a document.
|
|
15102
|
+
*/
|
|
15103
|
+
async delete(params) {
|
|
15104
|
+
var _a, _b;
|
|
15105
|
+
let path = '';
|
|
15106
|
+
let queryParams = {};
|
|
15107
|
+
if (this.apiClient.isVertexAI()) {
|
|
15108
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15109
|
+
}
|
|
15110
|
+
else {
|
|
15111
|
+
const body = deleteDocumentParametersToMldev(params);
|
|
15112
|
+
path = formatMap('{name}', body['_url']);
|
|
15113
|
+
queryParams = body['_query'];
|
|
15114
|
+
delete body['_url'];
|
|
15115
|
+
delete body['_query'];
|
|
15116
|
+
await this.apiClient.request({
|
|
15117
|
+
path: path,
|
|
15118
|
+
queryParams: queryParams,
|
|
15119
|
+
body: JSON.stringify(body),
|
|
15120
|
+
httpMethod: 'DELETE',
|
|
15121
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15122
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15123
|
+
});
|
|
15124
|
+
}
|
|
15125
|
+
}
|
|
15126
|
+
/**
|
|
15127
|
+
* Lists all Documents in a FileSearchStore.
|
|
15128
|
+
*
|
|
15129
|
+
* @param params - The parameters for listing documents.
|
|
15130
|
+
* @return ListDocumentsResponse.
|
|
15131
|
+
*/
|
|
15132
|
+
async listInternal(params) {
|
|
15133
|
+
var _a, _b;
|
|
15134
|
+
let response;
|
|
15135
|
+
let path = '';
|
|
15136
|
+
let queryParams = {};
|
|
15137
|
+
if (this.apiClient.isVertexAI()) {
|
|
15138
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15139
|
+
}
|
|
15140
|
+
else {
|
|
15141
|
+
const body = listDocumentsParametersToMldev(params);
|
|
15142
|
+
path = formatMap('{parent}/documents', body['_url']);
|
|
15143
|
+
queryParams = body['_query'];
|
|
15144
|
+
delete body['_url'];
|
|
15145
|
+
delete body['_query'];
|
|
15146
|
+
response = this.apiClient
|
|
15147
|
+
.request({
|
|
15148
|
+
path: path,
|
|
15149
|
+
queryParams: queryParams,
|
|
15150
|
+
body: JSON.stringify(body),
|
|
15151
|
+
httpMethod: 'GET',
|
|
15152
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15153
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15154
|
+
})
|
|
15155
|
+
.then((httpResponse) => {
|
|
15156
|
+
return httpResponse.json();
|
|
15157
|
+
});
|
|
15158
|
+
return response.then((apiResponse) => {
|
|
15159
|
+
const resp = listDocumentsResponseFromMldev(apiResponse);
|
|
15160
|
+
const typedResp = new ListDocumentsResponse();
|
|
15161
|
+
Object.assign(typedResp, resp);
|
|
15162
|
+
return typedResp;
|
|
15163
|
+
});
|
|
15164
|
+
}
|
|
15165
|
+
}
|
|
15166
|
+
}
|
|
15167
|
+
|
|
15168
|
+
/**
|
|
15169
|
+
* @license
|
|
15170
|
+
* Copyright 2025 Google LLC
|
|
15171
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15172
|
+
*/
|
|
15173
|
+
class FileSearchStores extends BaseModule {
|
|
15174
|
+
constructor(apiClient, documents = new Documents(apiClient)) {
|
|
15175
|
+
super();
|
|
15176
|
+
this.apiClient = apiClient;
|
|
15177
|
+
this.documents = documents;
|
|
15178
|
+
/**
|
|
15179
|
+
* Lists file search stores.
|
|
15180
|
+
*
|
|
15181
|
+
* @param params - The parameters for the list request.
|
|
15182
|
+
* @return - A pager of file search stores.
|
|
15183
|
+
*
|
|
15184
|
+
* @example
|
|
15185
|
+
* ```ts
|
|
15186
|
+
* const fileSearchStores = await ai.fileSearchStores.list({config: {'pageSize': 2}});
|
|
15187
|
+
* for await (const fileSearchStore of fileSearchStores) {
|
|
15188
|
+
* console.log(fileSearchStore);
|
|
15189
|
+
* }
|
|
15190
|
+
* ```
|
|
15191
|
+
*/
|
|
15192
|
+
this.list = async (params = {}) => {
|
|
15193
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_FILE_SEARCH_STORES, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
15194
|
+
};
|
|
15195
|
+
}
|
|
15196
|
+
/**
|
|
15197
|
+
* Uploads a file asynchronously to a given File Search Store.
|
|
15198
|
+
* This method is not available in Vertex AI.
|
|
15199
|
+
* Supported upload sources:
|
|
15200
|
+
* - Node.js: File path (string) or Blob object.
|
|
15201
|
+
* - Browser: Blob object (e.g., File).
|
|
15202
|
+
*
|
|
15203
|
+
* @remarks
|
|
15204
|
+
* The `mimeType` can be specified in the `config` parameter. If omitted:
|
|
15205
|
+
* - For file path (string) inputs, the `mimeType` will be inferred from the
|
|
15206
|
+
* file extension.
|
|
15207
|
+
* - For Blob object inputs, the `mimeType` will be set to the Blob's `type`
|
|
15208
|
+
* property.
|
|
15209
|
+
*
|
|
15210
|
+
* This section can contain multiple paragraphs and code examples.
|
|
15211
|
+
*
|
|
15212
|
+
* @param params - Optional parameters specified in the
|
|
15213
|
+
* `types.UploadToFileSearchStoreParameters` interface.
|
|
15214
|
+
* @see {@link types.UploadToFileSearchStoreParameters#config} for the optional
|
|
15215
|
+
* config in the parameters.
|
|
15216
|
+
* @return A promise that resolves to a long running operation.
|
|
15217
|
+
* @throws An error if called on a Vertex AI client.
|
|
15218
|
+
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
15219
|
+
* the `mimeType` can be provided in the `params.config` parameter.
|
|
15220
|
+
* @throws An error occurs if a suitable upload location cannot be established.
|
|
15221
|
+
*
|
|
15222
|
+
* @example
|
|
15223
|
+
* The following code uploads a file to a given file search store.
|
|
15224
|
+
*
|
|
15225
|
+
* ```ts
|
|
15226
|
+
* const operation = await ai.fileSearchStores.upload({fileSearchStoreName: 'fileSearchStores/foo-bar', file: 'file.txt', config: {
|
|
15227
|
+
* mimeType: 'text/plain',
|
|
15228
|
+
* }});
|
|
15229
|
+
* console.log(operation.name);
|
|
15230
|
+
* ```
|
|
15231
|
+
*/
|
|
15232
|
+
async uploadToFileSearchStore(params) {
|
|
15233
|
+
if (this.apiClient.isVertexAI()) {
|
|
15234
|
+
throw new Error('Vertex AI does not support uploading files to a file search store.');
|
|
15235
|
+
}
|
|
15236
|
+
return this.apiClient.uploadFileToFileSearchStore(params.fileSearchStoreName, params.file, params.config);
|
|
15237
|
+
}
|
|
15238
|
+
/**
|
|
15239
|
+
* Creates a File Search Store.
|
|
15240
|
+
*
|
|
15241
|
+
* @param params - The parameters for creating a File Search Store.
|
|
15242
|
+
* @return FileSearchStore.
|
|
15243
|
+
*/
|
|
15244
|
+
async create(params) {
|
|
15245
|
+
var _a, _b;
|
|
15246
|
+
let response;
|
|
15247
|
+
let path = '';
|
|
15248
|
+
let queryParams = {};
|
|
15249
|
+
if (this.apiClient.isVertexAI()) {
|
|
15250
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15251
|
+
}
|
|
15252
|
+
else {
|
|
15253
|
+
const body = createFileSearchStoreParametersToMldev(params);
|
|
15254
|
+
path = formatMap('fileSearchStores', body['_url']);
|
|
15255
|
+
queryParams = body['_query'];
|
|
15256
|
+
delete body['_url'];
|
|
15257
|
+
delete body['_query'];
|
|
15258
|
+
response = this.apiClient
|
|
15259
|
+
.request({
|
|
15260
|
+
path: path,
|
|
15261
|
+
queryParams: queryParams,
|
|
15262
|
+
body: JSON.stringify(body),
|
|
15263
|
+
httpMethod: 'POST',
|
|
15264
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15265
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15266
|
+
})
|
|
15267
|
+
.then((httpResponse) => {
|
|
15268
|
+
return httpResponse.json();
|
|
15269
|
+
});
|
|
15270
|
+
return response.then((resp) => {
|
|
15271
|
+
return resp;
|
|
15272
|
+
});
|
|
15273
|
+
}
|
|
15274
|
+
}
|
|
15275
|
+
/**
|
|
15276
|
+
* Gets a File Search Store.
|
|
15277
|
+
*
|
|
15278
|
+
* @param params - The parameters for getting a File Search Store.
|
|
15279
|
+
* @return FileSearchStore.
|
|
15280
|
+
*/
|
|
15281
|
+
async get(params) {
|
|
15282
|
+
var _a, _b;
|
|
15283
|
+
let response;
|
|
15284
|
+
let path = '';
|
|
15285
|
+
let queryParams = {};
|
|
15286
|
+
if (this.apiClient.isVertexAI()) {
|
|
15287
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15288
|
+
}
|
|
15289
|
+
else {
|
|
15290
|
+
const body = getFileSearchStoreParametersToMldev(params);
|
|
15291
|
+
path = formatMap('{name}', body['_url']);
|
|
15292
|
+
queryParams = body['_query'];
|
|
15293
|
+
delete body['_url'];
|
|
15294
|
+
delete body['_query'];
|
|
15295
|
+
response = this.apiClient
|
|
15296
|
+
.request({
|
|
15297
|
+
path: path,
|
|
15298
|
+
queryParams: queryParams,
|
|
15299
|
+
body: JSON.stringify(body),
|
|
15300
|
+
httpMethod: 'GET',
|
|
15301
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15302
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15303
|
+
})
|
|
15304
|
+
.then((httpResponse) => {
|
|
15305
|
+
return httpResponse.json();
|
|
15306
|
+
});
|
|
15307
|
+
return response.then((resp) => {
|
|
15308
|
+
return resp;
|
|
15309
|
+
});
|
|
15310
|
+
}
|
|
15311
|
+
}
|
|
15312
|
+
/**
|
|
15313
|
+
* Deletes a File Search Store.
|
|
15314
|
+
*
|
|
15315
|
+
* @param params - The parameters for deleting a File Search Store.
|
|
15316
|
+
*/
|
|
15317
|
+
async delete(params) {
|
|
15318
|
+
var _a, _b;
|
|
15319
|
+
let path = '';
|
|
15320
|
+
let queryParams = {};
|
|
15321
|
+
if (this.apiClient.isVertexAI()) {
|
|
15322
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15323
|
+
}
|
|
15324
|
+
else {
|
|
15325
|
+
const body = deleteFileSearchStoreParametersToMldev(params);
|
|
15326
|
+
path = formatMap('{name}', body['_url']);
|
|
15327
|
+
queryParams = body['_query'];
|
|
15328
|
+
delete body['_url'];
|
|
15329
|
+
delete body['_query'];
|
|
15330
|
+
await this.apiClient.request({
|
|
15331
|
+
path: path,
|
|
15332
|
+
queryParams: queryParams,
|
|
15333
|
+
body: JSON.stringify(body),
|
|
15334
|
+
httpMethod: 'DELETE',
|
|
15335
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15336
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15337
|
+
});
|
|
15338
|
+
}
|
|
15339
|
+
}
|
|
15340
|
+
/**
|
|
15341
|
+
* Lists all FileSearchStore owned by the user.
|
|
15342
|
+
*
|
|
15343
|
+
* @param params - The parameters for listing file search stores.
|
|
15344
|
+
* @return ListFileSearchStoresResponse.
|
|
15345
|
+
*/
|
|
15346
|
+
async listInternal(params) {
|
|
15347
|
+
var _a, _b;
|
|
15348
|
+
let response;
|
|
15349
|
+
let path = '';
|
|
15350
|
+
let queryParams = {};
|
|
15351
|
+
if (this.apiClient.isVertexAI()) {
|
|
15352
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
15353
|
+
}
|
|
15354
|
+
else {
|
|
15355
|
+
const body = listFileSearchStoresParametersToMldev(params);
|
|
15356
|
+
path = formatMap('fileSearchStores', body['_url']);
|
|
15357
|
+
queryParams = body['_query'];
|
|
15358
|
+
delete body['_url'];
|
|
15359
|
+
delete body['_query'];
|
|
15360
|
+
response = this.apiClient
|
|
15361
|
+
.request({
|
|
15362
|
+
path: path,
|
|
15363
|
+
queryParams: queryParams,
|
|
15364
|
+
body: JSON.stringify(body),
|
|
15365
|
+
httpMethod: 'GET',
|
|
15366
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15367
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15368
|
+
})
|
|
15369
|
+
.then((httpResponse) => {
|
|
15370
|
+
return httpResponse.json();
|
|
15371
|
+
});
|
|
15372
|
+
return response.then((apiResponse) => {
|
|
15373
|
+
const resp = listFileSearchStoresResponseFromMldev(apiResponse);
|
|
15374
|
+
const typedResp = new ListFileSearchStoresResponse();
|
|
15375
|
+
Object.assign(typedResp, resp);
|
|
15376
|
+
return typedResp;
|
|
15377
|
+
});
|
|
14232
15378
|
}
|
|
14233
15379
|
}
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
|
|
14241
|
-
// empty, then we should lock all fields.
|
|
14242
|
-
requestDict['fieldMask'] = preExistingFieldMask.join(',');
|
|
15380
|
+
async uploadToFileSearchStoreInternal(params) {
|
|
15381
|
+
var _a, _b;
|
|
15382
|
+
let response;
|
|
15383
|
+
let path = '';
|
|
15384
|
+
let queryParams = {};
|
|
15385
|
+
if (this.apiClient.isVertexAI()) {
|
|
15386
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
14243
15387
|
}
|
|
14244
15388
|
else {
|
|
14245
|
-
|
|
15389
|
+
const body = uploadToFileSearchStoreParametersToMldev(params);
|
|
15390
|
+
path = formatMap('upload/v1beta/{file_search_store_name}:uploadToFileSearchStore', body['_url']);
|
|
15391
|
+
queryParams = body['_query'];
|
|
15392
|
+
delete body['_url'];
|
|
15393
|
+
delete body['_query'];
|
|
15394
|
+
response = this.apiClient
|
|
15395
|
+
.request({
|
|
15396
|
+
path: path,
|
|
15397
|
+
queryParams: queryParams,
|
|
15398
|
+
body: JSON.stringify(body),
|
|
15399
|
+
httpMethod: 'POST',
|
|
15400
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15401
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15402
|
+
})
|
|
15403
|
+
.then((httpResponse) => {
|
|
15404
|
+
return httpResponse.json();
|
|
15405
|
+
});
|
|
15406
|
+
return response.then((apiResponse) => {
|
|
15407
|
+
const resp = uploadToFileSearchStoreResumableResponseFromMldev(apiResponse);
|
|
15408
|
+
const typedResp = new UploadToFileSearchStoreResumableResponse();
|
|
15409
|
+
Object.assign(typedResp, resp);
|
|
15410
|
+
return typedResp;
|
|
15411
|
+
});
|
|
14246
15412
|
}
|
|
14247
15413
|
}
|
|
14248
|
-
return requestDict;
|
|
14249
|
-
}
|
|
14250
|
-
class Tokens extends BaseModule {
|
|
14251
|
-
constructor(apiClient) {
|
|
14252
|
-
super();
|
|
14253
|
-
this.apiClient = apiClient;
|
|
14254
|
-
}
|
|
14255
15414
|
/**
|
|
14256
|
-
*
|
|
14257
|
-
*
|
|
14258
|
-
* @experimental
|
|
14259
|
-
*
|
|
14260
|
-
* @remarks
|
|
14261
|
-
* Ephemeral auth tokens is only supported in the Gemini Developer API.
|
|
14262
|
-
* It can be used for the session connection to the Live constrained API.
|
|
14263
|
-
* Support in v1alpha only.
|
|
14264
|
-
*
|
|
14265
|
-
* @param params - The parameters for the create request.
|
|
14266
|
-
* @return The created auth token.
|
|
14267
|
-
*
|
|
14268
|
-
* @example
|
|
14269
|
-
* ```ts
|
|
14270
|
-
* const ai = new GoogleGenAI({
|
|
14271
|
-
* apiKey: token.name,
|
|
14272
|
-
* httpOptions: { apiVersion: 'v1alpha' } // Support in v1alpha only.
|
|
14273
|
-
* });
|
|
14274
|
-
*
|
|
14275
|
-
* // Case 1: If LiveEphemeralParameters is unset, unlock LiveConnectConfig
|
|
14276
|
-
* // when using the token in Live API sessions. Each session connection can
|
|
14277
|
-
* // use a different configuration.
|
|
14278
|
-
* const config: CreateAuthTokenConfig = {
|
|
14279
|
-
* uses: 3,
|
|
14280
|
-
* expireTime: '2025-05-01T00:00:00Z',
|
|
14281
|
-
* }
|
|
14282
|
-
* const token = await ai.tokens.create(config);
|
|
14283
|
-
*
|
|
14284
|
-
* // Case 2: If LiveEphemeralParameters is set, lock all fields in
|
|
14285
|
-
* // LiveConnectConfig when using the token in Live API sessions. For
|
|
14286
|
-
* // example, changing `outputAudioTranscription` in the Live API
|
|
14287
|
-
* // connection will be ignored by the API.
|
|
14288
|
-
* const config: CreateAuthTokenConfig =
|
|
14289
|
-
* uses: 3,
|
|
14290
|
-
* expireTime: '2025-05-01T00:00:00Z',
|
|
14291
|
-
* LiveEphemeralParameters: {
|
|
14292
|
-
* model: 'gemini-2.0-flash-001',
|
|
14293
|
-
* config: {
|
|
14294
|
-
* 'responseModalities': ['AUDIO'],
|
|
14295
|
-
* 'systemInstruction': 'Always answer in English.',
|
|
14296
|
-
* }
|
|
14297
|
-
* }
|
|
14298
|
-
* }
|
|
14299
|
-
* const token = await ai.tokens.create(config);
|
|
15415
|
+
* Imports a File from File Service to a FileSearchStore.
|
|
14300
15416
|
*
|
|
14301
|
-
*
|
|
14302
|
-
* // set, lock LiveConnectConfig with set and additional fields (e.g.
|
|
14303
|
-
* // responseModalities, systemInstruction, temperature in this example) when
|
|
14304
|
-
* // using the token in Live API sessions.
|
|
14305
|
-
* const config: CreateAuthTokenConfig =
|
|
14306
|
-
* uses: 3,
|
|
14307
|
-
* expireTime: '2025-05-01T00:00:00Z',
|
|
14308
|
-
* LiveEphemeralParameters: {
|
|
14309
|
-
* model: 'gemini-2.0-flash-001',
|
|
14310
|
-
* config: {
|
|
14311
|
-
* 'responseModalities': ['AUDIO'],
|
|
14312
|
-
* 'systemInstruction': 'Always answer in English.',
|
|
14313
|
-
* }
|
|
14314
|
-
* },
|
|
14315
|
-
* lockAdditionalFields: ['temperature'],
|
|
14316
|
-
* }
|
|
14317
|
-
* const token = await ai.tokens.create(config);
|
|
15417
|
+
* This is a long-running operation, see aip.dev/151
|
|
14318
15418
|
*
|
|
14319
|
-
*
|
|
14320
|
-
*
|
|
14321
|
-
* // responseModalities, systemInstruction in this example) when using the
|
|
14322
|
-
* // token in Live API sessions.
|
|
14323
|
-
* const config: CreateAuthTokenConfig =
|
|
14324
|
-
* uses: 3,
|
|
14325
|
-
* expireTime: '2025-05-01T00:00:00Z',
|
|
14326
|
-
* LiveEphemeralParameters: {
|
|
14327
|
-
* model: 'gemini-2.0-flash-001',
|
|
14328
|
-
* config: {
|
|
14329
|
-
* 'responseModalities': ['AUDIO'],
|
|
14330
|
-
* 'systemInstruction': 'Always answer in English.',
|
|
14331
|
-
* }
|
|
14332
|
-
* },
|
|
14333
|
-
* lockAdditionalFields: [],
|
|
14334
|
-
* }
|
|
14335
|
-
* const token = await ai.tokens.create(config);
|
|
14336
|
-
* ```
|
|
15419
|
+
* @param params - The parameters for importing a file to a file search store.
|
|
15420
|
+
* @return ImportFileOperation.
|
|
14337
15421
|
*/
|
|
14338
|
-
async
|
|
15422
|
+
async importFile(params) {
|
|
14339
15423
|
var _a, _b;
|
|
14340
15424
|
let response;
|
|
14341
15425
|
let path = '';
|
|
14342
15426
|
let queryParams = {};
|
|
14343
15427
|
if (this.apiClient.isVertexAI()) {
|
|
14344
|
-
throw new Error('
|
|
15428
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
14345
15429
|
}
|
|
14346
15430
|
else {
|
|
14347
|
-
const body =
|
|
14348
|
-
path = formatMap('
|
|
15431
|
+
const body = importFileParametersToMldev(params);
|
|
15432
|
+
path = formatMap('{file_search_store_name}:importFile', body['_url']);
|
|
14349
15433
|
queryParams = body['_query'];
|
|
14350
|
-
delete body['config'];
|
|
14351
15434
|
delete body['_url'];
|
|
14352
15435
|
delete body['_query'];
|
|
14353
|
-
const transformedBody = convertBidiSetupToTokenSetup(body, params.config);
|
|
14354
15436
|
response = this.apiClient
|
|
14355
15437
|
.request({
|
|
14356
15438
|
path: path,
|
|
14357
15439
|
queryParams: queryParams,
|
|
14358
|
-
body: JSON.stringify(
|
|
15440
|
+
body: JSON.stringify(body),
|
|
14359
15441
|
httpMethod: 'POST',
|
|
14360
15442
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
14361
15443
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
@@ -14363,8 +15445,11 @@ class Tokens extends BaseModule {
|
|
|
14363
15445
|
.then((httpResponse) => {
|
|
14364
15446
|
return httpResponse.json();
|
|
14365
15447
|
});
|
|
14366
|
-
return response.then((
|
|
14367
|
-
|
|
15448
|
+
return response.then((apiResponse) => {
|
|
15449
|
+
const resp = importFileOperationFromMldev(apiResponse);
|
|
15450
|
+
const typedResp = new ImportFileOperation();
|
|
15451
|
+
Object.assign(typedResp, resp);
|
|
15452
|
+
return typedResp;
|
|
14368
15453
|
});
|
|
14369
15454
|
}
|
|
14370
15455
|
}
|
|
@@ -14458,14 +15543,19 @@ class NodeDownloader {
|
|
|
14458
15543
|
const response = await downloadFile(params, apiClient);
|
|
14459
15544
|
if (response instanceof HttpResponse) {
|
|
14460
15545
|
const writer = fs.createWriteStream(params.downloadPath);
|
|
14461
|
-
node_stream.Readable.fromWeb(response.responseInternal.body)
|
|
15546
|
+
const body = node_stream.Readable.fromWeb(response.responseInternal.body);
|
|
15547
|
+
body.pipe(writer);
|
|
15548
|
+
await promises.finished(writer);
|
|
14462
15549
|
}
|
|
14463
15550
|
else {
|
|
14464
|
-
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
}
|
|
14468
|
-
}
|
|
15551
|
+
try {
|
|
15552
|
+
await fs$1.writeFile(params.downloadPath, response, {
|
|
15553
|
+
encoding: 'base64',
|
|
15554
|
+
});
|
|
15555
|
+
}
|
|
15556
|
+
catch (error) {
|
|
15557
|
+
throw new Error(`Failed to write file to ${params.downloadPath}: ${error}`);
|
|
15558
|
+
}
|
|
14469
15559
|
}
|
|
14470
15560
|
}
|
|
14471
15561
|
}
|
|
@@ -14612,15 +15702,35 @@ function createTuningJobConfigToMldev(fromObject, parentObject, _rootObject) {
|
|
|
14612
15702
|
if (getValueByPath(fromObject, ['labels']) !== undefined) {
|
|
14613
15703
|
throw new Error('labels parameter is not supported in Gemini API.');
|
|
14614
15704
|
}
|
|
15705
|
+
if (getValueByPath(fromObject, ['beta']) !== undefined) {
|
|
15706
|
+
throw new Error('beta parameter is not supported in Gemini API.');
|
|
15707
|
+
}
|
|
14615
15708
|
return toObject;
|
|
14616
15709
|
}
|
|
14617
15710
|
function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
|
|
14618
15711
|
const toObject = {};
|
|
14619
|
-
|
|
14620
|
-
'
|
|
15712
|
+
let discriminatorValidationDataset = getValueByPath(rootObject, [
|
|
15713
|
+
'config',
|
|
15714
|
+
'method',
|
|
14621
15715
|
]);
|
|
14622
|
-
if (
|
|
14623
|
-
|
|
15716
|
+
if (discriminatorValidationDataset === undefined) {
|
|
15717
|
+
discriminatorValidationDataset = 'SUPERVISED_FINE_TUNING';
|
|
15718
|
+
}
|
|
15719
|
+
if (discriminatorValidationDataset === 'SUPERVISED_FINE_TUNING') {
|
|
15720
|
+
const fromValidationDataset = getValueByPath(fromObject, [
|
|
15721
|
+
'validationDataset',
|
|
15722
|
+
]);
|
|
15723
|
+
if (parentObject !== undefined && fromValidationDataset != null) {
|
|
15724
|
+
setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(fromValidationDataset));
|
|
15725
|
+
}
|
|
15726
|
+
}
|
|
15727
|
+
else if (discriminatorValidationDataset === 'PREFERENCE_TUNING') {
|
|
15728
|
+
const fromValidationDataset = getValueByPath(fromObject, [
|
|
15729
|
+
'validationDataset',
|
|
15730
|
+
]);
|
|
15731
|
+
if (parentObject !== undefined && fromValidationDataset != null) {
|
|
15732
|
+
setValueByPath(parentObject, ['preferenceOptimizationSpec'], tuningValidationDatasetToVertex(fromValidationDataset));
|
|
15733
|
+
}
|
|
14624
15734
|
}
|
|
14625
15735
|
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
14626
15736
|
'tunedModelDisplayName',
|
|
@@ -14632,25 +15742,90 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
|
|
|
14632
15742
|
if (parentObject !== undefined && fromDescription != null) {
|
|
14633
15743
|
setValueByPath(parentObject, ['description'], fromDescription);
|
|
14634
15744
|
}
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
15745
|
+
let discriminatorEpochCount = getValueByPath(rootObject, [
|
|
15746
|
+
'config',
|
|
15747
|
+
'method',
|
|
15748
|
+
]);
|
|
15749
|
+
if (discriminatorEpochCount === undefined) {
|
|
15750
|
+
discriminatorEpochCount = 'SUPERVISED_FINE_TUNING';
|
|
14638
15751
|
}
|
|
14639
|
-
|
|
14640
|
-
'
|
|
15752
|
+
if (discriminatorEpochCount === 'SUPERVISED_FINE_TUNING') {
|
|
15753
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
15754
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
15755
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
|
|
15756
|
+
}
|
|
15757
|
+
}
|
|
15758
|
+
else if (discriminatorEpochCount === 'PREFERENCE_TUNING') {
|
|
15759
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
15760
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
15761
|
+
setValueByPath(parentObject, ['preferenceOptimizationSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
|
|
15762
|
+
}
|
|
15763
|
+
}
|
|
15764
|
+
let discriminatorLearningRateMultiplier = getValueByPath(rootObject, [
|
|
15765
|
+
'config',
|
|
15766
|
+
'method',
|
|
14641
15767
|
]);
|
|
14642
|
-
if (
|
|
14643
|
-
|
|
15768
|
+
if (discriminatorLearningRateMultiplier === undefined) {
|
|
15769
|
+
discriminatorLearningRateMultiplier = 'SUPERVISED_FINE_TUNING';
|
|
15770
|
+
}
|
|
15771
|
+
if (discriminatorLearningRateMultiplier === 'SUPERVISED_FINE_TUNING') {
|
|
15772
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
15773
|
+
'learningRateMultiplier',
|
|
15774
|
+
]);
|
|
15775
|
+
if (parentObject !== undefined && fromLearningRateMultiplier != null) {
|
|
15776
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
15777
|
+
}
|
|
15778
|
+
}
|
|
15779
|
+
else if (discriminatorLearningRateMultiplier === 'PREFERENCE_TUNING') {
|
|
15780
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
15781
|
+
'learningRateMultiplier',
|
|
15782
|
+
]);
|
|
15783
|
+
if (parentObject !== undefined && fromLearningRateMultiplier != null) {
|
|
15784
|
+
setValueByPath(parentObject, [
|
|
15785
|
+
'preferenceOptimizationSpec',
|
|
15786
|
+
'hyperParameters',
|
|
15787
|
+
'learningRateMultiplier',
|
|
15788
|
+
], fromLearningRateMultiplier);
|
|
15789
|
+
}
|
|
14644
15790
|
}
|
|
14645
|
-
|
|
14646
|
-
|
|
15791
|
+
let discriminatorExportLastCheckpointOnly = getValueByPath(rootObject, ['config', 'method']);
|
|
15792
|
+
if (discriminatorExportLastCheckpointOnly === undefined) {
|
|
15793
|
+
discriminatorExportLastCheckpointOnly = 'SUPERVISED_FINE_TUNING';
|
|
15794
|
+
}
|
|
15795
|
+
if (discriminatorExportLastCheckpointOnly === 'SUPERVISED_FINE_TUNING') {
|
|
15796
|
+
const fromExportLastCheckpointOnly = getValueByPath(fromObject, [
|
|
15797
|
+
'exportLastCheckpointOnly',
|
|
15798
|
+
]);
|
|
15799
|
+
if (parentObject !== undefined && fromExportLastCheckpointOnly != null) {
|
|
15800
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'exportLastCheckpointOnly'], fromExportLastCheckpointOnly);
|
|
15801
|
+
}
|
|
15802
|
+
}
|
|
15803
|
+
else if (discriminatorExportLastCheckpointOnly === 'PREFERENCE_TUNING') {
|
|
15804
|
+
const fromExportLastCheckpointOnly = getValueByPath(fromObject, [
|
|
15805
|
+
'exportLastCheckpointOnly',
|
|
15806
|
+
]);
|
|
15807
|
+
if (parentObject !== undefined && fromExportLastCheckpointOnly != null) {
|
|
15808
|
+
setValueByPath(parentObject, ['preferenceOptimizationSpec', 'exportLastCheckpointOnly'], fromExportLastCheckpointOnly);
|
|
15809
|
+
}
|
|
15810
|
+
}
|
|
15811
|
+
let discriminatorAdapterSize = getValueByPath(rootObject, [
|
|
15812
|
+
'config',
|
|
15813
|
+
'method',
|
|
14647
15814
|
]);
|
|
14648
|
-
if (
|
|
14649
|
-
|
|
15815
|
+
if (discriminatorAdapterSize === undefined) {
|
|
15816
|
+
discriminatorAdapterSize = 'SUPERVISED_FINE_TUNING';
|
|
15817
|
+
}
|
|
15818
|
+
if (discriminatorAdapterSize === 'SUPERVISED_FINE_TUNING') {
|
|
15819
|
+
const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
|
|
15820
|
+
if (parentObject !== undefined && fromAdapterSize != null) {
|
|
15821
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
|
|
15822
|
+
}
|
|
14650
15823
|
}
|
|
14651
|
-
|
|
14652
|
-
|
|
14653
|
-
|
|
15824
|
+
else if (discriminatorAdapterSize === 'PREFERENCE_TUNING') {
|
|
15825
|
+
const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
|
|
15826
|
+
if (parentObject !== undefined && fromAdapterSize != null) {
|
|
15827
|
+
setValueByPath(parentObject, ['preferenceOptimizationSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
|
|
15828
|
+
}
|
|
14654
15829
|
}
|
|
14655
15830
|
if (getValueByPath(fromObject, ['batchSize']) !== undefined) {
|
|
14656
15831
|
throw new Error('batchSize parameter is not supported in Vertex AI.');
|
|
@@ -14662,6 +15837,10 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
|
|
|
14662
15837
|
if (parentObject !== undefined && fromLabels != null) {
|
|
14663
15838
|
setValueByPath(parentObject, ['labels'], fromLabels);
|
|
14664
15839
|
}
|
|
15840
|
+
const fromBeta = getValueByPath(fromObject, ['beta']);
|
|
15841
|
+
if (parentObject !== undefined && fromBeta != null) {
|
|
15842
|
+
setValueByPath(parentObject, ['preferenceOptimizationSpec', 'hyperParameters', 'beta'], fromBeta);
|
|
15843
|
+
}
|
|
14665
15844
|
return toObject;
|
|
14666
15845
|
}
|
|
14667
15846
|
function createTuningJobParametersPrivateToMldev(fromObject, rootObject) {
|
|
@@ -14680,7 +15859,7 @@ function createTuningJobParametersPrivateToMldev(fromObject, rootObject) {
|
|
|
14680
15859
|
'trainingDataset',
|
|
14681
15860
|
]);
|
|
14682
15861
|
if (fromTrainingDataset != null) {
|
|
14683
|
-
|
|
15862
|
+
tuningDatasetToMldev(fromTrainingDataset);
|
|
14684
15863
|
}
|
|
14685
15864
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14686
15865
|
if (fromConfig != null) {
|
|
@@ -14704,11 +15883,11 @@ function createTuningJobParametersPrivateToVertex(fromObject, rootObject) {
|
|
|
14704
15883
|
'trainingDataset',
|
|
14705
15884
|
]);
|
|
14706
15885
|
if (fromTrainingDataset != null) {
|
|
14707
|
-
tuningDatasetToVertex(fromTrainingDataset, toObject);
|
|
15886
|
+
tuningDatasetToVertex(fromTrainingDataset, toObject, rootObject);
|
|
14708
15887
|
}
|
|
14709
15888
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
14710
15889
|
if (fromConfig != null) {
|
|
14711
|
-
createTuningJobConfigToVertex(fromConfig, toObject);
|
|
15890
|
+
createTuningJobConfigToVertex(fromConfig, toObject, rootObject);
|
|
14712
15891
|
}
|
|
14713
15892
|
return toObject;
|
|
14714
15893
|
}
|
|
@@ -14860,17 +16039,49 @@ function tuningDatasetToMldev(fromObject, _rootObject) {
|
|
|
14860
16039
|
}
|
|
14861
16040
|
return toObject;
|
|
14862
16041
|
}
|
|
14863
|
-
function tuningDatasetToVertex(fromObject, parentObject,
|
|
16042
|
+
function tuningDatasetToVertex(fromObject, parentObject, rootObject) {
|
|
14864
16043
|
const toObject = {};
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
16044
|
+
let discriminatorGcsUri = getValueByPath(rootObject, [
|
|
16045
|
+
'config',
|
|
16046
|
+
'method',
|
|
16047
|
+
]);
|
|
16048
|
+
if (discriminatorGcsUri === undefined) {
|
|
16049
|
+
discriminatorGcsUri = 'SUPERVISED_FINE_TUNING';
|
|
14868
16050
|
}
|
|
14869
|
-
|
|
14870
|
-
'
|
|
16051
|
+
if (discriminatorGcsUri === 'SUPERVISED_FINE_TUNING') {
|
|
16052
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
16053
|
+
if (parentObject !== undefined && fromGcsUri != null) {
|
|
16054
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'trainingDatasetUri'], fromGcsUri);
|
|
16055
|
+
}
|
|
16056
|
+
}
|
|
16057
|
+
else if (discriminatorGcsUri === 'PREFERENCE_TUNING') {
|
|
16058
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
16059
|
+
if (parentObject !== undefined && fromGcsUri != null) {
|
|
16060
|
+
setValueByPath(parentObject, ['preferenceOptimizationSpec', 'trainingDatasetUri'], fromGcsUri);
|
|
16061
|
+
}
|
|
16062
|
+
}
|
|
16063
|
+
let discriminatorVertexDatasetResource = getValueByPath(rootObject, [
|
|
16064
|
+
'config',
|
|
16065
|
+
'method',
|
|
14871
16066
|
]);
|
|
14872
|
-
if (
|
|
14873
|
-
|
|
16067
|
+
if (discriminatorVertexDatasetResource === undefined) {
|
|
16068
|
+
discriminatorVertexDatasetResource = 'SUPERVISED_FINE_TUNING';
|
|
16069
|
+
}
|
|
16070
|
+
if (discriminatorVertexDatasetResource === 'SUPERVISED_FINE_TUNING') {
|
|
16071
|
+
const fromVertexDatasetResource = getValueByPath(fromObject, [
|
|
16072
|
+
'vertexDatasetResource',
|
|
16073
|
+
]);
|
|
16074
|
+
if (parentObject !== undefined && fromVertexDatasetResource != null) {
|
|
16075
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'trainingDatasetUri'], fromVertexDatasetResource);
|
|
16076
|
+
}
|
|
16077
|
+
}
|
|
16078
|
+
else if (discriminatorVertexDatasetResource === 'PREFERENCE_TUNING') {
|
|
16079
|
+
const fromVertexDatasetResource = getValueByPath(fromObject, [
|
|
16080
|
+
'vertexDatasetResource',
|
|
16081
|
+
]);
|
|
16082
|
+
if (parentObject !== undefined && fromVertexDatasetResource != null) {
|
|
16083
|
+
setValueByPath(parentObject, ['preferenceOptimizationSpec', 'trainingDatasetUri'], fromVertexDatasetResource);
|
|
16084
|
+
}
|
|
14874
16085
|
}
|
|
14875
16086
|
if (getValueByPath(fromObject, ['examples']) !== undefined) {
|
|
14876
16087
|
throw new Error('examples parameter is not supported in Vertex AI.');
|
|
@@ -14989,6 +16200,12 @@ function tuningJobFromVertex(fromObject, _rootObject) {
|
|
|
14989
16200
|
if (fromSupervisedTuningSpec != null) {
|
|
14990
16201
|
setValueByPath(toObject, ['supervisedTuningSpec'], fromSupervisedTuningSpec);
|
|
14991
16202
|
}
|
|
16203
|
+
const fromPreferenceOptimizationSpec = getValueByPath(fromObject, [
|
|
16204
|
+
'preferenceOptimizationSpec',
|
|
16205
|
+
]);
|
|
16206
|
+
if (fromPreferenceOptimizationSpec != null) {
|
|
16207
|
+
setValueByPath(toObject, ['preferenceOptimizationSpec'], fromPreferenceOptimizationSpec);
|
|
16208
|
+
}
|
|
14992
16209
|
const fromTuningDataStats = getValueByPath(fromObject, [
|
|
14993
16210
|
'tuningDataStats',
|
|
14994
16211
|
]);
|
|
@@ -15355,7 +16572,7 @@ class Tunings extends BaseModule {
|
|
|
15355
16572
|
let path = '';
|
|
15356
16573
|
let queryParams = {};
|
|
15357
16574
|
if (this.apiClient.isVertexAI()) {
|
|
15358
|
-
const body = createTuningJobParametersPrivateToVertex(params);
|
|
16575
|
+
const body = createTuningJobParametersPrivateToVertex(params, params);
|
|
15359
16576
|
path = formatMap('tuningJobs', body['_url']);
|
|
15360
16577
|
queryParams = body['_query'];
|
|
15361
16578
|
delete body['_url'];
|
|
@@ -15433,7 +16650,28 @@ const INITIAL_RETRY_DELAY_MS = 1000;
|
|
|
15433
16650
|
const DELAY_MULTIPLIER = 2;
|
|
15434
16651
|
const X_GOOG_UPLOAD_STATUS_HEADER_FIELD = 'x-goog-upload-status';
|
|
15435
16652
|
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
15436
|
-
var _a
|
|
16653
|
+
var _a;
|
|
16654
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
16655
|
+
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
16656
|
+
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') {
|
|
16657
|
+
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
16658
|
+
}
|
|
16659
|
+
return responseJson['file'];
|
|
16660
|
+
}
|
|
16661
|
+
async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
|
|
16662
|
+
var _a;
|
|
16663
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
16664
|
+
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
16665
|
+
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') {
|
|
16666
|
+
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
16667
|
+
}
|
|
16668
|
+
const resp = uploadToFileSearchStoreOperationFromMldev(responseJson);
|
|
16669
|
+
const typedResp = new UploadToFileSearchStoreOperation();
|
|
16670
|
+
Object.assign(typedResp, resp);
|
|
16671
|
+
return typedResp;
|
|
16672
|
+
}
|
|
16673
|
+
async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
16674
|
+
var _a, _b;
|
|
15437
16675
|
let fileSize = 0;
|
|
15438
16676
|
let offset = 0;
|
|
15439
16677
|
let response = new HttpResponse(new Response());
|
|
@@ -15481,11 +16719,7 @@ async function uploadBlob(file, uploadUrl, apiClient) {
|
|
|
15481
16719
|
throw new Error('All content has been uploaded, but the upload status is not finalized.');
|
|
15482
16720
|
}
|
|
15483
16721
|
}
|
|
15484
|
-
|
|
15485
|
-
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') {
|
|
15486
|
-
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
15487
|
-
}
|
|
15488
|
-
return responseJson['file'];
|
|
16722
|
+
return response;
|
|
15489
16723
|
}
|
|
15490
16724
|
async function getBlobStat(file) {
|
|
15491
16725
|
const fileStat = { size: file.size, type: file.type };
|
|
@@ -15521,6 +16755,14 @@ class NodeUploader {
|
|
|
15521
16755
|
return uploadBlob(file, uploadUrl, apiClient);
|
|
15522
16756
|
}
|
|
15523
16757
|
}
|
|
16758
|
+
async uploadToFileSearchStore(file, uploadUrl, apiClient) {
|
|
16759
|
+
if (typeof file === 'string') {
|
|
16760
|
+
return await this.uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient);
|
|
16761
|
+
}
|
|
16762
|
+
else {
|
|
16763
|
+
return uploadBlobToFileSearchStore(file, uploadUrl, apiClient);
|
|
16764
|
+
}
|
|
16765
|
+
}
|
|
15524
16766
|
/**
|
|
15525
16767
|
* Infers the MIME type of a file based on its extension.
|
|
15526
16768
|
*
|
|
@@ -15612,12 +16854,34 @@ class NodeUploader {
|
|
|
15612
16854
|
return mimeType;
|
|
15613
16855
|
}
|
|
15614
16856
|
async uploadFileFromPath(file, uploadUrl, apiClient) {
|
|
15615
|
-
var _a
|
|
16857
|
+
var _a;
|
|
16858
|
+
const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
|
|
16859
|
+
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
16860
|
+
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') {
|
|
16861
|
+
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
16862
|
+
}
|
|
16863
|
+
return responseJson['file'];
|
|
16864
|
+
}
|
|
16865
|
+
async uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient) {
|
|
16866
|
+
var _a;
|
|
16867
|
+
const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
|
|
16868
|
+
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
16869
|
+
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') {
|
|
16870
|
+
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
16871
|
+
}
|
|
16872
|
+
const resp = uploadToFileSearchStoreOperationFromMldev(responseJson);
|
|
16873
|
+
const typedResp = new UploadToFileSearchStoreOperation();
|
|
16874
|
+
Object.assign(typedResp, resp);
|
|
16875
|
+
return typedResp;
|
|
16876
|
+
}
|
|
16877
|
+
async uploadFileFromPathInternal(file, uploadUrl, apiClient) {
|
|
16878
|
+
var _a, _b;
|
|
15616
16879
|
let fileSize = 0;
|
|
15617
16880
|
let offset = 0;
|
|
15618
16881
|
let response = new HttpResponse(new Response());
|
|
15619
16882
|
let uploadCommand = 'upload';
|
|
15620
16883
|
let fileHandle;
|
|
16884
|
+
const fileName = path__namespace.basename(file);
|
|
15621
16885
|
try {
|
|
15622
16886
|
fileHandle = await fs__namespace.open(file, 'r');
|
|
15623
16887
|
if (!fileHandle) {
|
|
@@ -15649,6 +16913,7 @@ class NodeUploader {
|
|
|
15649
16913
|
'X-Goog-Upload-Command': uploadCommand,
|
|
15650
16914
|
'X-Goog-Upload-Offset': String(offset),
|
|
15651
16915
|
'Content-Length': String(bytesRead),
|
|
16916
|
+
'X-Goog-Upload-File-Name': fileName,
|
|
15652
16917
|
},
|
|
15653
16918
|
},
|
|
15654
16919
|
});
|
|
@@ -15669,11 +16934,7 @@ class NodeUploader {
|
|
|
15669
16934
|
throw new Error('All content has been uploaded, but the upload status is not finalized.');
|
|
15670
16935
|
}
|
|
15671
16936
|
}
|
|
15672
|
-
|
|
15673
|
-
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') {
|
|
15674
|
-
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
15675
|
-
}
|
|
15676
|
-
return responseJson['file'];
|
|
16937
|
+
return response;
|
|
15677
16938
|
}
|
|
15678
16939
|
finally {
|
|
15679
16940
|
// Ensure the file handle is always closed
|
|
@@ -15773,6 +17034,9 @@ class GoogleGenAI {
|
|
|
15773
17034
|
' precedence over the API key from the environment variables.');
|
|
15774
17035
|
this.apiKey = undefined;
|
|
15775
17036
|
}
|
|
17037
|
+
if (!this.location && !this.apiKey) {
|
|
17038
|
+
this.location = 'global';
|
|
17039
|
+
}
|
|
15776
17040
|
}
|
|
15777
17041
|
const baseUrl = getBaseUrl(options.httpOptions, options.vertexai, getEnv('GOOGLE_VERTEX_BASE_URL'), getEnv('GOOGLE_GEMINI_BASE_URL'));
|
|
15778
17042
|
if (baseUrl) {
|
|
@@ -15809,6 +17073,7 @@ class GoogleGenAI {
|
|
|
15809
17073
|
this.operations = new Operations(this.apiClient);
|
|
15810
17074
|
this.authTokens = new Tokens(this.apiClient);
|
|
15811
17075
|
this.tunings = new Tunings(this.apiClient);
|
|
17076
|
+
this.fileSearchStores = new FileSearchStores(this.apiClient);
|
|
15812
17077
|
}
|
|
15813
17078
|
}
|
|
15814
17079
|
function getEnv(env) {
|
|
@@ -15861,10 +17126,14 @@ exports.GenerateVideosOperation = GenerateVideosOperation;
|
|
|
15861
17126
|
exports.GenerateVideosResponse = GenerateVideosResponse;
|
|
15862
17127
|
exports.GoogleGenAI = GoogleGenAI;
|
|
15863
17128
|
exports.HttpResponse = HttpResponse;
|
|
17129
|
+
exports.ImportFileOperation = ImportFileOperation;
|
|
17130
|
+
exports.ImportFileResponse = ImportFileResponse;
|
|
15864
17131
|
exports.InlinedEmbedContentResponse = InlinedEmbedContentResponse;
|
|
15865
17132
|
exports.InlinedResponse = InlinedResponse;
|
|
15866
17133
|
exports.ListBatchJobsResponse = ListBatchJobsResponse;
|
|
15867
17134
|
exports.ListCachedContentsResponse = ListCachedContentsResponse;
|
|
17135
|
+
exports.ListDocumentsResponse = ListDocumentsResponse;
|
|
17136
|
+
exports.ListFileSearchStoresResponse = ListFileSearchStoresResponse;
|
|
15868
17137
|
exports.ListFilesResponse = ListFilesResponse;
|
|
15869
17138
|
exports.ListModelsResponse = ListModelsResponse;
|
|
15870
17139
|
exports.ListTuningJobsResponse = ListTuningJobsResponse;
|
|
@@ -15886,6 +17155,9 @@ exports.SingleEmbedContentResponse = SingleEmbedContentResponse;
|
|
|
15886
17155
|
exports.StyleReferenceImage = StyleReferenceImage;
|
|
15887
17156
|
exports.SubjectReferenceImage = SubjectReferenceImage;
|
|
15888
17157
|
exports.Tokens = Tokens;
|
|
17158
|
+
exports.UploadToFileSearchStoreOperation = UploadToFileSearchStoreOperation;
|
|
17159
|
+
exports.UploadToFileSearchStoreResponse = UploadToFileSearchStoreResponse;
|
|
17160
|
+
exports.UploadToFileSearchStoreResumableResponse = UploadToFileSearchStoreResumableResponse;
|
|
15889
17161
|
exports.UpscaleImageResponse = UpscaleImageResponse;
|
|
15890
17162
|
exports.createFunctionResponsePartFromBase64 = createFunctionResponsePartFromBase64;
|
|
15891
17163
|
exports.createFunctionResponsePartFromUri = createFunctionResponsePartFromUri;
|