@google/genai 2.9.0-rc.0 → 2.10.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 +1 -4
- package/dist/genai.d.ts +570 -363
- package/dist/index.cjs +283 -120
- package/dist/index.mjs +284 -121
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +283 -120
- package/dist/node/index.mjs +284 -121
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +570 -363
- package/dist/tokenizer/node.cjs +56 -20
- package/dist/tokenizer/node.d.ts +41 -10
- package/dist/tokenizer/node.mjs +56 -20
- package/dist/tokenizer/node.mjs.map +1 -1
- package/dist/vertex_internal/index.cjs +57 -21
- package/dist/vertex_internal/index.cjs.map +1 -1
- package/dist/vertex_internal/index.d.ts +71 -18
- package/dist/vertex_internal/index.js +57 -21
- package/dist/vertex_internal/index.js.map +1 -1
- package/dist/web/index.mjs +284 -121
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +570 -363
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -704,26 +704,6 @@ exports.Type = void 0;
|
|
|
704
704
|
*/
|
|
705
705
|
Type["NULL"] = "NULL";
|
|
706
706
|
})(exports.Type || (exports.Type = {}));
|
|
707
|
-
/** The environment being operated. */
|
|
708
|
-
exports.Environment = void 0;
|
|
709
|
-
(function (Environment) {
|
|
710
|
-
/**
|
|
711
|
-
* Defaults to browser.
|
|
712
|
-
*/
|
|
713
|
-
Environment["ENVIRONMENT_UNSPECIFIED"] = "ENVIRONMENT_UNSPECIFIED";
|
|
714
|
-
/**
|
|
715
|
-
* Operates in a web browser.
|
|
716
|
-
*/
|
|
717
|
-
Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
|
|
718
|
-
/**
|
|
719
|
-
* Operates in a mobile environment.
|
|
720
|
-
*/
|
|
721
|
-
Environment["ENVIRONMENT_MOBILE"] = "ENVIRONMENT_MOBILE";
|
|
722
|
-
/**
|
|
723
|
-
* Operates in a desktop environment.
|
|
724
|
-
*/
|
|
725
|
-
Environment["ENVIRONMENT_DESKTOP"] = "ENVIRONMENT_DESKTOP";
|
|
726
|
-
})(exports.Environment || (exports.Environment = {}));
|
|
727
707
|
/** Type of auth scheme. This enum is not supported in Gemini API. */
|
|
728
708
|
exports.AuthType = void 0;
|
|
729
709
|
(function (AuthType) {
|
|
@@ -794,6 +774,62 @@ exports.ApiSpec = void 0;
|
|
|
794
774
|
*/
|
|
795
775
|
ApiSpec["ELASTIC_SEARCH"] = "ELASTIC_SEARCH";
|
|
796
776
|
})(exports.ApiSpec || (exports.ApiSpec = {}));
|
|
777
|
+
/** The environment being operated. */
|
|
778
|
+
exports.Environment = void 0;
|
|
779
|
+
(function (Environment) {
|
|
780
|
+
/**
|
|
781
|
+
* Defaults to browser.
|
|
782
|
+
*/
|
|
783
|
+
Environment["ENVIRONMENT_UNSPECIFIED"] = "ENVIRONMENT_UNSPECIFIED";
|
|
784
|
+
/**
|
|
785
|
+
* Operates in a web browser.
|
|
786
|
+
*/
|
|
787
|
+
Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
|
|
788
|
+
/**
|
|
789
|
+
* Operates in a mobile environment.
|
|
790
|
+
*/
|
|
791
|
+
Environment["ENVIRONMENT_MOBILE"] = "ENVIRONMENT_MOBILE";
|
|
792
|
+
/**
|
|
793
|
+
* Operates in a desktop environment.
|
|
794
|
+
*/
|
|
795
|
+
Environment["ENVIRONMENT_DESKTOP"] = "ENVIRONMENT_DESKTOP";
|
|
796
|
+
})(exports.Environment || (exports.Environment = {}));
|
|
797
|
+
/** SafetyPolicy */
|
|
798
|
+
exports.SafetyPolicy = void 0;
|
|
799
|
+
(function (SafetyPolicy) {
|
|
800
|
+
/**
|
|
801
|
+
* Unspecified safety policy.
|
|
802
|
+
*/
|
|
803
|
+
SafetyPolicy["SAFETY_POLICY_UNSPECIFIED"] = "SAFETY_POLICY_UNSPECIFIED";
|
|
804
|
+
/**
|
|
805
|
+
* Safety policy for financial transactions.
|
|
806
|
+
*/
|
|
807
|
+
SafetyPolicy["FINANCIAL_TRANSACTIONS"] = "FINANCIAL_TRANSACTIONS";
|
|
808
|
+
/**
|
|
809
|
+
* Safety policy for sensitive data modification.
|
|
810
|
+
*/
|
|
811
|
+
SafetyPolicy["SENSITIVE_DATA_MODIFICATION"] = "SENSITIVE_DATA_MODIFICATION";
|
|
812
|
+
/**
|
|
813
|
+
* Safety policy for communication tools (e.g. Gmail, Chat, Meet).
|
|
814
|
+
*/
|
|
815
|
+
SafetyPolicy["COMMUNICATION_TOOL"] = "COMMUNICATION_TOOL";
|
|
816
|
+
/**
|
|
817
|
+
* Safety policy for account creation.
|
|
818
|
+
*/
|
|
819
|
+
SafetyPolicy["ACCOUNT_CREATION"] = "ACCOUNT_CREATION";
|
|
820
|
+
/**
|
|
821
|
+
* Safety policy for data modification.
|
|
822
|
+
*/
|
|
823
|
+
SafetyPolicy["DATA_MODIFICATION"] = "DATA_MODIFICATION";
|
|
824
|
+
/**
|
|
825
|
+
* Safety policy for user consent management.
|
|
826
|
+
*/
|
|
827
|
+
SafetyPolicy["USER_CONSENT_MANAGEMENT"] = "USER_CONSENT_MANAGEMENT";
|
|
828
|
+
/**
|
|
829
|
+
* Safety policy for legal terms and agreements.
|
|
830
|
+
*/
|
|
831
|
+
SafetyPolicy["LEGAL_TERMS_AND_AGREEMENTS"] = "LEGAL_TERMS_AND_AGREEMENTS";
|
|
832
|
+
})(exports.SafetyPolicy || (exports.SafetyPolicy = {}));
|
|
797
833
|
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
798
834
|
exports.PhishBlockThreshold = void 0;
|
|
799
835
|
(function (PhishBlockThreshold) {
|
|
@@ -5973,6 +6009,29 @@ function codeExecutionResultToVertex$3(fromObject) {
|
|
|
5973
6009
|
}
|
|
5974
6010
|
return toObject;
|
|
5975
6011
|
}
|
|
6012
|
+
function computerUseToVertex$2(fromObject) {
|
|
6013
|
+
const toObject = {};
|
|
6014
|
+
const fromEnvironment = getValueByPath(fromObject, ['environment']);
|
|
6015
|
+
if (fromEnvironment != null) {
|
|
6016
|
+
setValueByPath(toObject, ['environment'], fromEnvironment);
|
|
6017
|
+
}
|
|
6018
|
+
const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
|
|
6019
|
+
'excludedPredefinedFunctions',
|
|
6020
|
+
]);
|
|
6021
|
+
if (fromExcludedPredefinedFunctions != null) {
|
|
6022
|
+
setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
|
|
6023
|
+
}
|
|
6024
|
+
const fromEnablePromptInjectionDetection = getValueByPath(fromObject, [
|
|
6025
|
+
'enablePromptInjectionDetection',
|
|
6026
|
+
]);
|
|
6027
|
+
if (fromEnablePromptInjectionDetection != null) {
|
|
6028
|
+
setValueByPath(toObject, ['enablePromptInjectionDetection'], fromEnablePromptInjectionDetection);
|
|
6029
|
+
}
|
|
6030
|
+
if (getValueByPath(fromObject, ['disabledSafetyPolicies']) !== undefined) {
|
|
6031
|
+
throw new Error('disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
6032
|
+
}
|
|
6033
|
+
return toObject;
|
|
6034
|
+
}
|
|
5976
6035
|
function contentToMldev$3(fromObject) {
|
|
5977
6036
|
const toObject = {};
|
|
5978
6037
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
@@ -6648,7 +6707,7 @@ function toolToVertex$2(fromObject) {
|
|
|
6648
6707
|
}
|
|
6649
6708
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
6650
6709
|
if (fromComputerUse != null) {
|
|
6651
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
6710
|
+
setValueByPath(toObject, ['computerUse'], computerUseToVertex$2(fromComputerUse));
|
|
6652
6711
|
}
|
|
6653
6712
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
6654
6713
|
throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
@@ -7715,7 +7774,7 @@ class Files extends BaseModule {
|
|
|
7715
7774
|
* file extension.
|
|
7716
7775
|
* - For Blob object inputs, the `mimeType` will be set to the Blob's `type`
|
|
7717
7776
|
* property.
|
|
7718
|
-
*
|
|
7777
|
+
* Some examples for file extension to mimeType mapping:
|
|
7719
7778
|
* .txt -> text/plain
|
|
7720
7779
|
* .json -> application/json
|
|
7721
7780
|
* .jpg -> image/jpeg
|
|
@@ -8003,6 +8062,22 @@ function audioTranscriptionConfigToMldev$1(fromObject) {
|
|
|
8003
8062
|
if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
|
|
8004
8063
|
throw new Error('languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
|
|
8005
8064
|
}
|
|
8065
|
+
const fromLanguageAuto = getValueByPath(fromObject, ['languageAuto']);
|
|
8066
|
+
if (fromLanguageAuto != null) {
|
|
8067
|
+
setValueByPath(toObject, ['languageAuto'], fromLanguageAuto);
|
|
8068
|
+
}
|
|
8069
|
+
const fromLanguageHints = getValueByPath(fromObject, [
|
|
8070
|
+
'languageHints',
|
|
8071
|
+
]);
|
|
8072
|
+
if (fromLanguageHints != null) {
|
|
8073
|
+
setValueByPath(toObject, ['languageHints'], fromLanguageHints);
|
|
8074
|
+
}
|
|
8075
|
+
const fromAdaptationPhrases = getValueByPath(fromObject, [
|
|
8076
|
+
'adaptationPhrases',
|
|
8077
|
+
]);
|
|
8078
|
+
if (fromAdaptationPhrases != null) {
|
|
8079
|
+
setValueByPath(toObject, ['adaptationPhrases'], fromAdaptationPhrases);
|
|
8080
|
+
}
|
|
8006
8081
|
return toObject;
|
|
8007
8082
|
}
|
|
8008
8083
|
function authConfigToMldev$2(fromObject) {
|
|
@@ -8062,6 +8137,29 @@ function codeExecutionResultToVertex$2(fromObject) {
|
|
|
8062
8137
|
}
|
|
8063
8138
|
return toObject;
|
|
8064
8139
|
}
|
|
8140
|
+
function computerUseToVertex$1(fromObject) {
|
|
8141
|
+
const toObject = {};
|
|
8142
|
+
const fromEnvironment = getValueByPath(fromObject, ['environment']);
|
|
8143
|
+
if (fromEnvironment != null) {
|
|
8144
|
+
setValueByPath(toObject, ['environment'], fromEnvironment);
|
|
8145
|
+
}
|
|
8146
|
+
const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
|
|
8147
|
+
'excludedPredefinedFunctions',
|
|
8148
|
+
]);
|
|
8149
|
+
if (fromExcludedPredefinedFunctions != null) {
|
|
8150
|
+
setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
|
|
8151
|
+
}
|
|
8152
|
+
const fromEnablePromptInjectionDetection = getValueByPath(fromObject, [
|
|
8153
|
+
'enablePromptInjectionDetection',
|
|
8154
|
+
]);
|
|
8155
|
+
if (fromEnablePromptInjectionDetection != null) {
|
|
8156
|
+
setValueByPath(toObject, ['enablePromptInjectionDetection'], fromEnablePromptInjectionDetection);
|
|
8157
|
+
}
|
|
8158
|
+
if (getValueByPath(fromObject, ['disabledSafetyPolicies']) !== undefined) {
|
|
8159
|
+
throw new Error('disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
8160
|
+
}
|
|
8161
|
+
return toObject;
|
|
8162
|
+
}
|
|
8065
8163
|
function contentToMldev$2(fromObject) {
|
|
8066
8164
|
const toObject = {};
|
|
8067
8165
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
@@ -9020,7 +9118,7 @@ function toolToVertex$1(fromObject) {
|
|
|
9020
9118
|
}
|
|
9021
9119
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
9022
9120
|
if (fromComputerUse != null) {
|
|
9023
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
9121
|
+
setValueByPath(toObject, ['computerUse'], computerUseToVertex$1(fromComputerUse));
|
|
9024
9122
|
}
|
|
9025
9123
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
9026
9124
|
throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
@@ -9183,6 +9281,10 @@ function voiceActivityFromVertex(fromObject) {
|
|
|
9183
9281
|
if (fromVoiceActivityType != null) {
|
|
9184
9282
|
setValueByPath(toObject, ['voiceActivityType'], fromVoiceActivityType);
|
|
9185
9283
|
}
|
|
9284
|
+
const fromAudioOffset = getValueByPath(fromObject, ['audioOffset']);
|
|
9285
|
+
if (fromAudioOffset != null) {
|
|
9286
|
+
setValueByPath(toObject, ['audioOffset'], fromAudioOffset);
|
|
9287
|
+
}
|
|
9186
9288
|
return toObject;
|
|
9187
9289
|
}
|
|
9188
9290
|
|
|
@@ -9360,6 +9462,29 @@ function computeTokensResponseFromVertex(fromObject, _rootObject) {
|
|
|
9360
9462
|
}
|
|
9361
9463
|
return toObject;
|
|
9362
9464
|
}
|
|
9465
|
+
function computerUseToVertex(fromObject, _rootObject) {
|
|
9466
|
+
const toObject = {};
|
|
9467
|
+
const fromEnvironment = getValueByPath(fromObject, ['environment']);
|
|
9468
|
+
if (fromEnvironment != null) {
|
|
9469
|
+
setValueByPath(toObject, ['environment'], fromEnvironment);
|
|
9470
|
+
}
|
|
9471
|
+
const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
|
|
9472
|
+
'excludedPredefinedFunctions',
|
|
9473
|
+
]);
|
|
9474
|
+
if (fromExcludedPredefinedFunctions != null) {
|
|
9475
|
+
setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
|
|
9476
|
+
}
|
|
9477
|
+
const fromEnablePromptInjectionDetection = getValueByPath(fromObject, [
|
|
9478
|
+
'enablePromptInjectionDetection',
|
|
9479
|
+
]);
|
|
9480
|
+
if (fromEnablePromptInjectionDetection != null) {
|
|
9481
|
+
setValueByPath(toObject, ['enablePromptInjectionDetection'], fromEnablePromptInjectionDetection);
|
|
9482
|
+
}
|
|
9483
|
+
if (getValueByPath(fromObject, ['disabledSafetyPolicies']) !== undefined) {
|
|
9484
|
+
throw new Error('disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
9485
|
+
}
|
|
9486
|
+
return toObject;
|
|
9487
|
+
}
|
|
9363
9488
|
function contentEmbeddingFromVertex(fromObject, rootObject) {
|
|
9364
9489
|
const toObject = {};
|
|
9365
9490
|
const fromValues = getValueByPath(fromObject, ['values']);
|
|
@@ -12438,7 +12563,7 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
12438
12563
|
}
|
|
12439
12564
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
12440
12565
|
if (fromComputerUse != null) {
|
|
12441
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
12566
|
+
setValueByPath(toObject, ['computerUse'], computerUseToVertex(fromComputerUse));
|
|
12442
12567
|
}
|
|
12443
12568
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
12444
12569
|
throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
@@ -13062,7 +13187,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
13062
13187
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
13063
13188
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
13064
13189
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
13065
|
-
const SDK_VERSION = '2.
|
|
13190
|
+
const SDK_VERSION = '2.10.0'; // x-release-please-version
|
|
13066
13191
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
13067
13192
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
13068
13193
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -14776,7 +14901,7 @@ class Models extends BaseModule {
|
|
|
14776
14901
|
this.generateContent = async (params) => {
|
|
14777
14902
|
var _a, _b, _c, _d, _e;
|
|
14778
14903
|
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14779
|
-
this.
|
|
14904
|
+
this.maybeMoveToResponseJsonSchema(params);
|
|
14780
14905
|
if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
|
|
14781
14906
|
return await this.generateContentInternal(transformedParams);
|
|
14782
14907
|
}
|
|
@@ -14868,7 +14993,7 @@ class Models extends BaseModule {
|
|
|
14868
14993
|
*/
|
|
14869
14994
|
this.generateContentStream = async (params) => {
|
|
14870
14995
|
var _a, _b, _c, _d, _e;
|
|
14871
|
-
this.
|
|
14996
|
+
this.maybeMoveToResponseJsonSchema(params);
|
|
14872
14997
|
if (shouldDisableAfc(params.config)) {
|
|
14873
14998
|
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14874
14999
|
return await this.generateContentStreamInternal(transformedParams);
|
|
@@ -15093,7 +15218,7 @@ class Models extends BaseModule {
|
|
|
15093
15218
|
* To maintain backward compatibility, we move the data that was treated as
|
|
15094
15219
|
* JSON schema from the responseSchema field to the responseJsonSchema field.
|
|
15095
15220
|
*/
|
|
15096
|
-
|
|
15221
|
+
maybeMoveToResponseJsonSchema(params) {
|
|
15097
15222
|
if (params.config && params.config.responseSchema) {
|
|
15098
15223
|
if (!params.config.responseJsonSchema) {
|
|
15099
15224
|
if (Object.keys(params.config.responseSchema).includes('$schema')) {
|
|
@@ -15195,7 +15320,7 @@ class Models extends BaseModule {
|
|
|
15195
15320
|
throw new Error('Function call name was not returned by the model.');
|
|
15196
15321
|
}
|
|
15197
15322
|
if (!afcTools.has(part.functionCall.name)) {
|
|
15198
|
-
throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${afcTools.keys()},
|
|
15323
|
+
throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${afcTools.keys()}, missing tool: ${part.functionCall.name}`);
|
|
15199
15324
|
}
|
|
15200
15325
|
else {
|
|
15201
15326
|
const responseParts = yield __await(afcTools
|
|
@@ -16416,6 +16541,22 @@ function audioTranscriptionConfigToMldev(fromObject) {
|
|
|
16416
16541
|
if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
|
|
16417
16542
|
throw new Error('languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
|
|
16418
16543
|
}
|
|
16544
|
+
const fromLanguageAuto = getValueByPath(fromObject, ['languageAuto']);
|
|
16545
|
+
if (fromLanguageAuto != null) {
|
|
16546
|
+
setValueByPath(toObject, ['languageAuto'], fromLanguageAuto);
|
|
16547
|
+
}
|
|
16548
|
+
const fromLanguageHints = getValueByPath(fromObject, [
|
|
16549
|
+
'languageHints',
|
|
16550
|
+
]);
|
|
16551
|
+
if (fromLanguageHints != null) {
|
|
16552
|
+
setValueByPath(toObject, ['languageHints'], fromLanguageHints);
|
|
16553
|
+
}
|
|
16554
|
+
const fromAdaptationPhrases = getValueByPath(fromObject, [
|
|
16555
|
+
'adaptationPhrases',
|
|
16556
|
+
]);
|
|
16557
|
+
if (fromAdaptationPhrases != null) {
|
|
16558
|
+
setValueByPath(toObject, ['adaptationPhrases'], fromAdaptationPhrases);
|
|
16559
|
+
}
|
|
16419
16560
|
return toObject;
|
|
16420
16561
|
}
|
|
16421
16562
|
function authConfigToMldev(fromObject) {
|
|
@@ -18022,15 +18163,6 @@ class GoogleGenAiError extends Error {
|
|
|
18022
18163
|
* g3-prettier-ignore-file
|
|
18023
18164
|
*/
|
|
18024
18165
|
class GeminiNextGenAPIClientError extends Error {
|
|
18025
|
-
static [Symbol.hasInstance](instance) {
|
|
18026
|
-
if (Function.prototype[Symbol.hasInstance].call(this, instance)) {
|
|
18027
|
-
return true;
|
|
18028
|
-
}
|
|
18029
|
-
if (this === GeminiNextGenAPIClientError) {
|
|
18030
|
-
return isKnownLegacyErrorLike(instance);
|
|
18031
|
-
}
|
|
18032
|
-
return isNamedLegacyErrorLike(instance, this.name);
|
|
18033
|
-
}
|
|
18034
18166
|
}
|
|
18035
18167
|
/** General errors raised by the GenAI API. */
|
|
18036
18168
|
class APIError extends GeminiNextGenAPIClientError {
|
|
@@ -18045,6 +18177,7 @@ class APIError extends GeminiNextGenAPIClientError {
|
|
|
18045
18177
|
this.rawResponse = undefined;
|
|
18046
18178
|
this.cause = undefined;
|
|
18047
18179
|
this.name = this.constructor.name;
|
|
18180
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
18048
18181
|
}
|
|
18049
18182
|
static makeMessage(status, error, message) {
|
|
18050
18183
|
var _a;
|
|
@@ -18056,15 +18189,6 @@ class APIError extends GeminiNextGenAPIClientError {
|
|
|
18056
18189
|
const statusText = status ? `${status} ` : "";
|
|
18057
18190
|
return `${statusText}${msg}`;
|
|
18058
18191
|
}
|
|
18059
|
-
static [Symbol.hasInstance](instance) {
|
|
18060
|
-
if (Function.prototype[Symbol.hasInstance].call(this, instance)) {
|
|
18061
|
-
return true;
|
|
18062
|
-
}
|
|
18063
|
-
if (this === APIError) {
|
|
18064
|
-
return isAPIErrorLike(instance);
|
|
18065
|
-
}
|
|
18066
|
-
return isNamedLegacyErrorLike(instance, this.name);
|
|
18067
|
-
}
|
|
18068
18192
|
static generate(status, errorResponse, message, headers) {
|
|
18069
18193
|
if (!status || !headers) {
|
|
18070
18194
|
return new APIConnectionError({
|
|
@@ -18205,57 +18329,12 @@ function stringifyErrorBody(error) {
|
|
|
18205
18329
|
function isPlainObject$2(value) {
|
|
18206
18330
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
18207
18331
|
}
|
|
18208
|
-
function isLegacyErrorLike(value) {
|
|
18209
|
-
if (!(value instanceof Error) || !isPlainObject$2(value)) {
|
|
18210
|
-
return false;
|
|
18211
|
-
}
|
|
18212
|
-
return ("status" in value ||
|
|
18213
|
-
"statusCode" in value ||
|
|
18214
|
-
"error" in value ||
|
|
18215
|
-
"headers" in value);
|
|
18216
|
-
}
|
|
18217
|
-
function isAPIErrorLike(value) {
|
|
18218
|
-
return isLegacyErrorLike(value) && "error" in value;
|
|
18219
|
-
}
|
|
18220
18332
|
function isCompatAPIErrorInstance(value) {
|
|
18333
|
+
// Avoid instanceof here so this guard never depends on Symbol.hasInstance.
|
|
18221
18334
|
return typeof value === "object" && value !== null
|
|
18222
18335
|
? APIError.prototype.isPrototypeOf(value)
|
|
18223
18336
|
: false;
|
|
18224
18337
|
}
|
|
18225
|
-
const knownLegacyErrorNames = [
|
|
18226
|
-
"GeminiNextGenAPIClientError",
|
|
18227
|
-
"APIError",
|
|
18228
|
-
"APIUserAbortError",
|
|
18229
|
-
"APIConnectionError",
|
|
18230
|
-
"APIConnectionTimeoutError",
|
|
18231
|
-
"BadRequestError",
|
|
18232
|
-
"AuthenticationError",
|
|
18233
|
-
"PermissionDeniedError",
|
|
18234
|
-
"NotFoundError",
|
|
18235
|
-
"ConflictError",
|
|
18236
|
-
"UnprocessableEntityError",
|
|
18237
|
-
"RateLimitError",
|
|
18238
|
-
"InternalServerError",
|
|
18239
|
-
];
|
|
18240
|
-
const legacySubclassNamesByBaseName = {
|
|
18241
|
-
GeminiNextGenAPIClientError: knownLegacyErrorNames,
|
|
18242
|
-
APIConnectionError: ["APIConnectionTimeoutError"],
|
|
18243
|
-
};
|
|
18244
|
-
function isKnownLegacyErrorLike(value) {
|
|
18245
|
-
if (!isLegacyErrorLike(value)) {
|
|
18246
|
-
return false;
|
|
18247
|
-
}
|
|
18248
|
-
return knownLegacyErrorNames.includes(value.name);
|
|
18249
|
-
}
|
|
18250
|
-
function isNamedLegacyErrorLike(value, name) {
|
|
18251
|
-
var _a, _b;
|
|
18252
|
-
if (!isLegacyErrorLike(value)) {
|
|
18253
|
-
return false;
|
|
18254
|
-
}
|
|
18255
|
-
const valueName = value.name;
|
|
18256
|
-
return (valueName === name ||
|
|
18257
|
-
((_b = (_a = legacySubclassNamesByBaseName[name]) === null || _a === void 0 ? void 0 : _a.includes(valueName)) !== null && _b !== void 0 ? _b : false));
|
|
18258
|
-
}
|
|
18259
18338
|
function defineReadonly(target, key, value) {
|
|
18260
18339
|
Object.defineProperty(target, key, {
|
|
18261
18340
|
configurable: true,
|
|
@@ -18465,7 +18544,7 @@ function serverURLFromOptions(options) {
|
|
|
18465
18544
|
return new URL(u);
|
|
18466
18545
|
}
|
|
18467
18546
|
const SDK_METADATA = {
|
|
18468
|
-
userAgent: "speakeasy-sdk/typescript 2.4.1-preview.4 2.
|
|
18547
|
+
userAgent: "speakeasy-sdk/typescript 2.4.1-preview.4 2.911.0 v1beta @google/genai",
|
|
18469
18548
|
};
|
|
18470
18549
|
|
|
18471
18550
|
/**
|
|
@@ -19014,14 +19093,19 @@ async function retry(fetchFn, options) {
|
|
|
19014
19093
|
statusCodes: options.statusCodes,
|
|
19015
19094
|
retryConnectionErrors: !!options.config.retryConnectionErrors,
|
|
19016
19095
|
}), (_a = options.config.backoff) !== null && _a !== void 0 ? _a : defaultBackoff);
|
|
19096
|
+
case "attempt-count-backoff":
|
|
19097
|
+
return retryAttemptCountBackoff(wrapFetcher(fetchFn, {
|
|
19098
|
+
statusCodes: options.statusCodes,
|
|
19099
|
+
retryConnectionErrors: !!options.config.retryConnectionErrors,
|
|
19100
|
+
}), Object.assign(Object.assign({}, defaultBackoff), options.config.backoff), options.config);
|
|
19017
19101
|
default:
|
|
19018
|
-
return await fetchFn();
|
|
19102
|
+
return await fetchFn(0);
|
|
19019
19103
|
}
|
|
19020
19104
|
}
|
|
19021
19105
|
function wrapFetcher(fn, options) {
|
|
19022
|
-
return async () => {
|
|
19106
|
+
return async (attempt) => {
|
|
19023
19107
|
try {
|
|
19024
|
-
const res = await fn();
|
|
19108
|
+
const res = await fn(attempt);
|
|
19025
19109
|
if (isRetryableResponse(res, options.statusCodes)) {
|
|
19026
19110
|
throw new TemporaryError("Response failed with retryable status code", res);
|
|
19027
19111
|
}
|
|
@@ -19063,7 +19147,7 @@ async function retryBackoff(fn, strategy) {
|
|
|
19063
19147
|
let x = 0;
|
|
19064
19148
|
while (true) {
|
|
19065
19149
|
try {
|
|
19066
|
-
const res = await fn();
|
|
19150
|
+
const res = await fn(x);
|
|
19067
19151
|
return res;
|
|
19068
19152
|
}
|
|
19069
19153
|
catch (err) {
|
|
@@ -19091,7 +19175,46 @@ async function retryBackoff(fn, strategy) {
|
|
|
19091
19175
|
}
|
|
19092
19176
|
}
|
|
19093
19177
|
}
|
|
19178
|
+
async function retryAttemptCountBackoff(fn, strategy, config) {
|
|
19179
|
+
let attempt = 0;
|
|
19180
|
+
while (true) {
|
|
19181
|
+
try {
|
|
19182
|
+
return await fn(attempt);
|
|
19183
|
+
}
|
|
19184
|
+
catch (err) {
|
|
19185
|
+
if (err instanceof PermanentError) {
|
|
19186
|
+
throw err.cause;
|
|
19187
|
+
}
|
|
19188
|
+
if (attempt >= config.maxRetries) {
|
|
19189
|
+
if (err instanceof TemporaryError) {
|
|
19190
|
+
return err.response;
|
|
19191
|
+
}
|
|
19192
|
+
throw err;
|
|
19193
|
+
}
|
|
19194
|
+
let retryInterval = 0;
|
|
19195
|
+
if (err instanceof TemporaryError) {
|
|
19196
|
+
retryInterval = retryIntervalFromResponse(err.response);
|
|
19197
|
+
}
|
|
19198
|
+
if (retryInterval <= 0) {
|
|
19199
|
+
retryInterval =
|
|
19200
|
+
strategy.initialInterval *
|
|
19201
|
+
Math.pow(strategy.exponent, attempt) *
|
|
19202
|
+
(1 - Math.random() * 0.25);
|
|
19203
|
+
}
|
|
19204
|
+
const d = Math.min(retryInterval, strategy.maxInterval);
|
|
19205
|
+
await delay(d);
|
|
19206
|
+
attempt++;
|
|
19207
|
+
}
|
|
19208
|
+
}
|
|
19209
|
+
}
|
|
19094
19210
|
function retryIntervalFromResponse(res) {
|
|
19211
|
+
const retryAfterMsVal = res.headers.get("retry-after-ms");
|
|
19212
|
+
if (retryAfterMsVal) {
|
|
19213
|
+
const parsedMs = Number(retryAfterMsVal);
|
|
19214
|
+
if (Number.isFinite(parsedMs) && parsedMs >= 0) {
|
|
19215
|
+
return parsedMs;
|
|
19216
|
+
}
|
|
19217
|
+
}
|
|
19095
19218
|
const retryVal = res.headers.get("retry-after") || "";
|
|
19096
19219
|
if (!retryVal) {
|
|
19097
19220
|
return 0;
|
|
@@ -19546,13 +19669,12 @@ class Stream extends ReadableStream {
|
|
|
19546
19669
|
cancel: reason => upstream.cancel(reason),
|
|
19547
19670
|
});
|
|
19548
19671
|
}
|
|
19549
|
-
|
|
19550
|
-
[Symbol.asyncIterator]() {
|
|
19672
|
+
[Symbol.asyncIterator](options) {
|
|
19551
19673
|
const fn = ReadableStream.prototype[Symbol.asyncIterator];
|
|
19552
19674
|
if (typeof fn === "function")
|
|
19553
|
-
return fn.call(this);
|
|
19675
|
+
return fn.call(this, options);
|
|
19554
19676
|
const reader = this.getReader();
|
|
19555
|
-
|
|
19677
|
+
const iterator = {
|
|
19556
19678
|
next: async () => {
|
|
19557
19679
|
const r = await reader.read();
|
|
19558
19680
|
if (r.done) {
|
|
@@ -19575,6 +19697,17 @@ class Stream extends ReadableStream {
|
|
|
19575
19697
|
return this;
|
|
19576
19698
|
},
|
|
19577
19699
|
};
|
|
19700
|
+
const asyncDispose = Symbol.asyncDispose;
|
|
19701
|
+
if (asyncDispose) {
|
|
19702
|
+
iterator[asyncDispose] = async () => {
|
|
19703
|
+
var _a;
|
|
19704
|
+
await ((_a = iterator.return) === null || _a === void 0 ? void 0 : _a.call(iterator));
|
|
19705
|
+
};
|
|
19706
|
+
}
|
|
19707
|
+
return iterator;
|
|
19708
|
+
}
|
|
19709
|
+
values(options) {
|
|
19710
|
+
return this[Symbol.asyncIterator](options);
|
|
19578
19711
|
}
|
|
19579
19712
|
}
|
|
19580
19713
|
const CR = 13;
|
|
@@ -19715,7 +19848,16 @@ function match(...matchers) {
|
|
|
19715
19848
|
switch (encoding) {
|
|
19716
19849
|
case "json":
|
|
19717
19850
|
body = await response.text();
|
|
19718
|
-
|
|
19851
|
+
try {
|
|
19852
|
+
raw = JSON.parse(body);
|
|
19853
|
+
}
|
|
19854
|
+
catch (err) {
|
|
19855
|
+
// Passthrough for malformed error bodies; success bodies must be valid.
|
|
19856
|
+
if (!("err" in matcher)) {
|
|
19857
|
+
throw err;
|
|
19858
|
+
}
|
|
19859
|
+
raw = body;
|
|
19860
|
+
}
|
|
19719
19861
|
break;
|
|
19720
19862
|
case "jsonl":
|
|
19721
19863
|
raw = response.body;
|
|
@@ -20073,7 +20215,7 @@ async function $do$e(client, body, api_version, options) {
|
|
|
20073
20215
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20074
20216
|
|| client._options.retry_config
|
|
20075
20217
|
|| {
|
|
20076
|
-
strategy: "backoff",
|
|
20218
|
+
strategy: "attempt-count-backoff",
|
|
20077
20219
|
backoff: {
|
|
20078
20220
|
initialInterval: 500,
|
|
20079
20221
|
maxInterval: 8000,
|
|
@@ -20081,6 +20223,7 @@ async function $do$e(client, body, api_version, options) {
|
|
|
20081
20223
|
maxElapsedTime: 30000,
|
|
20082
20224
|
},
|
|
20083
20225
|
retryConnectionErrors: true,
|
|
20226
|
+
maxRetries: 4,
|
|
20084
20227
|
}
|
|
20085
20228
|
|| { strategy: "none" },
|
|
20086
20229
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20160,7 +20303,7 @@ async function $do$d(client, id, api_version, options) {
|
|
|
20160
20303
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20161
20304
|
|| client._options.retry_config
|
|
20162
20305
|
|| {
|
|
20163
|
-
strategy: "backoff",
|
|
20306
|
+
strategy: "attempt-count-backoff",
|
|
20164
20307
|
backoff: {
|
|
20165
20308
|
initialInterval: 500,
|
|
20166
20309
|
maxInterval: 8000,
|
|
@@ -20168,6 +20311,7 @@ async function $do$d(client, id, api_version, options) {
|
|
|
20168
20311
|
maxElapsedTime: 30000,
|
|
20169
20312
|
},
|
|
20170
20313
|
retryConnectionErrors: true,
|
|
20314
|
+
maxRetries: 4,
|
|
20171
20315
|
}
|
|
20172
20316
|
|| { strategy: "none" },
|
|
20173
20317
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20247,7 +20391,7 @@ async function $do$c(client, id, api_version, options) {
|
|
|
20247
20391
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20248
20392
|
|| client._options.retry_config
|
|
20249
20393
|
|| {
|
|
20250
|
-
strategy: "backoff",
|
|
20394
|
+
strategy: "attempt-count-backoff",
|
|
20251
20395
|
backoff: {
|
|
20252
20396
|
initialInterval: 500,
|
|
20253
20397
|
maxInterval: 8000,
|
|
@@ -20255,6 +20399,7 @@ async function $do$c(client, id, api_version, options) {
|
|
|
20255
20399
|
maxElapsedTime: 30000,
|
|
20256
20400
|
},
|
|
20257
20401
|
retryConnectionErrors: true,
|
|
20402
|
+
maxRetries: 4,
|
|
20258
20403
|
}
|
|
20259
20404
|
|| { strategy: "none" },
|
|
20260
20405
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20337,7 +20482,7 @@ async function $do$b(client, api_version, page_size, page_token, parent, options
|
|
|
20337
20482
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20338
20483
|
|| client._options.retry_config
|
|
20339
20484
|
|| {
|
|
20340
|
-
strategy: "backoff",
|
|
20485
|
+
strategy: "attempt-count-backoff",
|
|
20341
20486
|
backoff: {
|
|
20342
20487
|
initialInterval: 500,
|
|
20343
20488
|
maxInterval: 8000,
|
|
@@ -20345,6 +20490,7 @@ async function $do$b(client, api_version, page_size, page_token, parent, options
|
|
|
20345
20490
|
maxElapsedTime: 30000,
|
|
20346
20491
|
},
|
|
20347
20492
|
retryConnectionErrors: true,
|
|
20493
|
+
maxRetries: 4,
|
|
20348
20494
|
}
|
|
20349
20495
|
|| { strategy: "none" },
|
|
20350
20496
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20607,7 +20753,7 @@ async function $do$a(client, id, api_version, options) {
|
|
|
20607
20753
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20608
20754
|
|| client._options.retry_config
|
|
20609
20755
|
|| {
|
|
20610
|
-
strategy: "backoff",
|
|
20756
|
+
strategy: "attempt-count-backoff",
|
|
20611
20757
|
backoff: {
|
|
20612
20758
|
initialInterval: 500,
|
|
20613
20759
|
maxInterval: 8000,
|
|
@@ -20615,6 +20761,7 @@ async function $do$a(client, id, api_version, options) {
|
|
|
20615
20761
|
maxElapsedTime: 30000,
|
|
20616
20762
|
},
|
|
20617
20763
|
retryConnectionErrors: true,
|
|
20764
|
+
maxRetries: 4,
|
|
20618
20765
|
}
|
|
20619
20766
|
|| { strategy: "none" },
|
|
20620
20767
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20691,7 +20838,7 @@ async function $do$9(client, body, api_version, options) {
|
|
|
20691
20838
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20692
20839
|
|| client._options.retry_config
|
|
20693
20840
|
|| {
|
|
20694
|
-
strategy: "backoff",
|
|
20841
|
+
strategy: "attempt-count-backoff",
|
|
20695
20842
|
backoff: {
|
|
20696
20843
|
initialInterval: 500,
|
|
20697
20844
|
maxInterval: 8000,
|
|
@@ -20699,6 +20846,7 @@ async function $do$9(client, body, api_version, options) {
|
|
|
20699
20846
|
maxElapsedTime: 30000,
|
|
20700
20847
|
},
|
|
20701
20848
|
retryConnectionErrors: true,
|
|
20849
|
+
maxRetries: 4,
|
|
20702
20850
|
}
|
|
20703
20851
|
|| { strategy: "none" },
|
|
20704
20852
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20787,7 +20935,7 @@ async function $do$8(client, id, api_version, options) {
|
|
|
20787
20935
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20788
20936
|
|| client._options.retry_config
|
|
20789
20937
|
|| {
|
|
20790
|
-
strategy: "backoff",
|
|
20938
|
+
strategy: "attempt-count-backoff",
|
|
20791
20939
|
backoff: {
|
|
20792
20940
|
initialInterval: 500,
|
|
20793
20941
|
maxInterval: 8000,
|
|
@@ -20795,6 +20943,7 @@ async function $do$8(client, id, api_version, options) {
|
|
|
20795
20943
|
maxElapsedTime: 30000,
|
|
20796
20944
|
},
|
|
20797
20945
|
retryConnectionErrors: true,
|
|
20946
|
+
maxRetries: 4,
|
|
20798
20947
|
}
|
|
20799
20948
|
|| { strategy: "none" },
|
|
20800
20949
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20882,7 +21031,7 @@ async function $do$7(client, id, stream, last_event_id, include_input, api_versi
|
|
|
20882
21031
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20883
21032
|
|| client._options.retry_config
|
|
20884
21033
|
|| {
|
|
20885
|
-
strategy: "backoff",
|
|
21034
|
+
strategy: "attempt-count-backoff",
|
|
20886
21035
|
backoff: {
|
|
20887
21036
|
initialInterval: 500,
|
|
20888
21037
|
maxInterval: 8000,
|
|
@@ -20890,6 +21039,7 @@ async function $do$7(client, id, stream, last_event_id, include_input, api_versi
|
|
|
20890
21039
|
maxElapsedTime: 30000,
|
|
20891
21040
|
},
|
|
20892
21041
|
retryConnectionErrors: true,
|
|
21042
|
+
maxRetries: 4,
|
|
20893
21043
|
}
|
|
20894
21044
|
|| { strategy: "none" },
|
|
20895
21045
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21008,7 +21158,7 @@ async function $do$6(client, body, api_version, options) {
|
|
|
21008
21158
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21009
21159
|
|| client._options.retry_config
|
|
21010
21160
|
|| {
|
|
21011
|
-
strategy: "backoff",
|
|
21161
|
+
strategy: "attempt-count-backoff",
|
|
21012
21162
|
backoff: {
|
|
21013
21163
|
initialInterval: 500,
|
|
21014
21164
|
maxInterval: 8000,
|
|
@@ -21016,6 +21166,7 @@ async function $do$6(client, body, api_version, options) {
|
|
|
21016
21166
|
maxElapsedTime: 30000,
|
|
21017
21167
|
},
|
|
21018
21168
|
retryConnectionErrors: true,
|
|
21169
|
+
maxRetries: 4,
|
|
21019
21170
|
}
|
|
21020
21171
|
|| { strategy: "none" },
|
|
21021
21172
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21095,7 +21246,7 @@ async function $do$5(client, id, api_version, options) {
|
|
|
21095
21246
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21096
21247
|
|| client._options.retry_config
|
|
21097
21248
|
|| {
|
|
21098
|
-
strategy: "backoff",
|
|
21249
|
+
strategy: "attempt-count-backoff",
|
|
21099
21250
|
backoff: {
|
|
21100
21251
|
initialInterval: 500,
|
|
21101
21252
|
maxInterval: 8000,
|
|
@@ -21103,6 +21254,7 @@ async function $do$5(client, id, api_version, options) {
|
|
|
21103
21254
|
maxElapsedTime: 30000,
|
|
21104
21255
|
},
|
|
21105
21256
|
retryConnectionErrors: true,
|
|
21257
|
+
maxRetries: 4,
|
|
21106
21258
|
}
|
|
21107
21259
|
|| { strategy: "none" },
|
|
21108
21260
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21182,7 +21334,7 @@ async function $do$4(client, id, api_version, options) {
|
|
|
21182
21334
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21183
21335
|
|| client._options.retry_config
|
|
21184
21336
|
|| {
|
|
21185
|
-
strategy: "backoff",
|
|
21337
|
+
strategy: "attempt-count-backoff",
|
|
21186
21338
|
backoff: {
|
|
21187
21339
|
initialInterval: 500,
|
|
21188
21340
|
maxInterval: 8000,
|
|
@@ -21190,6 +21342,7 @@ async function $do$4(client, id, api_version, options) {
|
|
|
21190
21342
|
maxElapsedTime: 30000,
|
|
21191
21343
|
},
|
|
21192
21344
|
retryConnectionErrors: true,
|
|
21345
|
+
maxRetries: 4,
|
|
21193
21346
|
}
|
|
21194
21347
|
|| { strategy: "none" },
|
|
21195
21348
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21270,7 +21423,7 @@ async function $do$3(client, api_version, page_size, page_token, options) {
|
|
|
21270
21423
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21271
21424
|
|| client._options.retry_config
|
|
21272
21425
|
|| {
|
|
21273
|
-
strategy: "backoff",
|
|
21426
|
+
strategy: "attempt-count-backoff",
|
|
21274
21427
|
backoff: {
|
|
21275
21428
|
initialInterval: 500,
|
|
21276
21429
|
maxInterval: 8000,
|
|
@@ -21278,6 +21431,7 @@ async function $do$3(client, api_version, page_size, page_token, options) {
|
|
|
21278
21431
|
maxElapsedTime: 30000,
|
|
21279
21432
|
},
|
|
21280
21433
|
retryConnectionErrors: true,
|
|
21434
|
+
maxRetries: 4,
|
|
21281
21435
|
}
|
|
21282
21436
|
|| { strategy: "none" },
|
|
21283
21437
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21360,7 +21514,7 @@ async function $do$2(client, id, api_version, body, options) {
|
|
|
21360
21514
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21361
21515
|
|| client._options.retry_config
|
|
21362
21516
|
|| {
|
|
21363
|
-
strategy: "backoff",
|
|
21517
|
+
strategy: "attempt-count-backoff",
|
|
21364
21518
|
backoff: {
|
|
21365
21519
|
initialInterval: 500,
|
|
21366
21520
|
maxInterval: 8000,
|
|
@@ -21368,6 +21522,7 @@ async function $do$2(client, id, api_version, body, options) {
|
|
|
21368
21522
|
maxElapsedTime: 30000,
|
|
21369
21523
|
},
|
|
21370
21524
|
retryConnectionErrors: true,
|
|
21525
|
+
maxRetries: 4,
|
|
21371
21526
|
}
|
|
21372
21527
|
|| { strategy: "none" },
|
|
21373
21528
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21449,7 +21604,7 @@ async function $do$1(client, id, api_version, body, options) {
|
|
|
21449
21604
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21450
21605
|
|| client._options.retry_config
|
|
21451
21606
|
|| {
|
|
21452
|
-
strategy: "backoff",
|
|
21607
|
+
strategy: "attempt-count-backoff",
|
|
21453
21608
|
backoff: {
|
|
21454
21609
|
initialInterval: 500,
|
|
21455
21610
|
maxInterval: 8000,
|
|
@@ -21457,6 +21612,7 @@ async function $do$1(client, id, api_version, body, options) {
|
|
|
21457
21612
|
maxElapsedTime: 30000,
|
|
21458
21613
|
},
|
|
21459
21614
|
retryConnectionErrors: true,
|
|
21615
|
+
maxRetries: 4,
|
|
21460
21616
|
}
|
|
21461
21617
|
|| { strategy: "none" },
|
|
21462
21618
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21542,7 +21698,7 @@ async function $do(client, id, api_version, update_mask, body, options) {
|
|
|
21542
21698
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21543
21699
|
|| client._options.retry_config
|
|
21544
21700
|
|| {
|
|
21545
|
-
strategy: "backoff",
|
|
21701
|
+
strategy: "attempt-count-backoff",
|
|
21546
21702
|
backoff: {
|
|
21547
21703
|
initialInterval: 500,
|
|
21548
21704
|
maxInterval: 8000,
|
|
@@ -21550,6 +21706,7 @@ async function $do(client, id, api_version, update_mask, body, options) {
|
|
|
21550
21706
|
maxElapsedTime: 30000,
|
|
21551
21707
|
},
|
|
21552
21708
|
retryConnectionErrors: true,
|
|
21709
|
+
maxRetries: 4,
|
|
21553
21710
|
}
|
|
21554
21711
|
|| { strategy: "none" },
|
|
21555
21712
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21816,7 +21973,7 @@ function toGoogleGenAIRequestOptions(options, streaming = false) {
|
|
|
21816
21973
|
if (!options && !streaming) {
|
|
21817
21974
|
return undefined;
|
|
21818
21975
|
}
|
|
21819
|
-
const _e = options !== null && options !== void 0 ? options : {}, { timeout, maxRetries
|
|
21976
|
+
const _e = options !== null && options !== void 0 ? options : {}, { timeout, maxRetries, defaultBaseURL, query, body, fetchOptions } = _e, rest = __rest(_e, ["timeout", "maxRetries", "defaultBaseURL", "query", "body", "fetchOptions"]);
|
|
21820
21977
|
const nextOptions = Object.assign({}, rest);
|
|
21821
21978
|
if (isPlainObject(query)) {
|
|
21822
21979
|
nextOptions.extra_query = query;
|
|
@@ -21842,6 +21999,13 @@ function toGoogleGenAIRequestOptions(options, streaming = false) {
|
|
|
21842
21999
|
if (timeout_ms !== undefined) {
|
|
21843
22000
|
nextOptions.timeout_ms = timeout_ms;
|
|
21844
22001
|
}
|
|
22002
|
+
if (maxRetries !== undefined) {
|
|
22003
|
+
nextOptions.retries = {
|
|
22004
|
+
strategy: "attempt-count-backoff",
|
|
22005
|
+
retryConnectionErrors: true,
|
|
22006
|
+
maxRetries,
|
|
22007
|
+
};
|
|
22008
|
+
}
|
|
21845
22009
|
if (streaming) {
|
|
21846
22010
|
const headers = new Headers((_d = nextOptions.headers) !== null && _d !== void 0 ? _d : fetch_options === null || fetch_options === void 0 ? void 0 : fetch_options.headers);
|
|
21847
22011
|
headers.set("Accept", "text/event-stream");
|
|
@@ -24453,7 +24617,6 @@ class GoogleGenAI {
|
|
|
24453
24617
|
if (this._interactions !== undefined) {
|
|
24454
24618
|
return this._interactions;
|
|
24455
24619
|
}
|
|
24456
|
-
console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
|
|
24457
24620
|
this._interactions = new GeminiNextGenInteractions(this.apiClient);
|
|
24458
24621
|
return this._interactions;
|
|
24459
24622
|
}
|