@google/genai 1.44.0 → 1.46.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/dist/genai.d.ts +401 -125
- package/dist/index.cjs +480 -68
- package/dist/index.mjs +480 -69
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +502 -88
- package/dist/node/index.mjs +502 -89
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +401 -125
- package/dist/tokenizer/node.cjs +40 -12
- package/dist/tokenizer/node.d.ts +74 -2
- package/dist/tokenizer/node.mjs +40 -12
- package/dist/tokenizer/node.mjs.map +1 -1
- package/dist/vertex_internal/index.cjs +3013 -0
- package/dist/vertex_internal/index.cjs.map +1 -0
- package/dist/vertex_internal/index.d.ts +8038 -0
- package/dist/vertex_internal/index.js +2984 -0
- package/dist/vertex_internal/index.js.map +1 -0
- package/dist/web/index.mjs +480 -69
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +401 -125
- package/package.json +10 -2
package/dist/web/index.mjs
CHANGED
|
@@ -586,6 +586,18 @@ function videoFromVertex$1(fromObject) {
|
|
|
586
586
|
* Copyright 2025 Google LLC
|
|
587
587
|
* SPDX-License-Identifier: Apache-2.0
|
|
588
588
|
*/
|
|
589
|
+
/** Programming language of the `code`. */
|
|
590
|
+
var Language;
|
|
591
|
+
(function (Language) {
|
|
592
|
+
/**
|
|
593
|
+
* Unspecified language. This value should not be used.
|
|
594
|
+
*/
|
|
595
|
+
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
596
|
+
/**
|
|
597
|
+
* Python >= 3.10, with numpy and simpy available.
|
|
598
|
+
*/
|
|
599
|
+
Language["PYTHON"] = "PYTHON";
|
|
600
|
+
})(Language || (Language = {}));
|
|
589
601
|
/** Outcome of the code execution. */
|
|
590
602
|
var Outcome;
|
|
591
603
|
(function (Outcome) {
|
|
@@ -606,18 +618,6 @@ var Outcome;
|
|
|
606
618
|
*/
|
|
607
619
|
Outcome["OUTCOME_DEADLINE_EXCEEDED"] = "OUTCOME_DEADLINE_EXCEEDED";
|
|
608
620
|
})(Outcome || (Outcome = {}));
|
|
609
|
-
/** Programming language of the `code`. */
|
|
610
|
-
var Language;
|
|
611
|
-
(function (Language) {
|
|
612
|
-
/**
|
|
613
|
-
* Unspecified language. This value should not be used.
|
|
614
|
-
*/
|
|
615
|
-
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
616
|
-
/**
|
|
617
|
-
* Python >= 3.10, with numpy and simpy available.
|
|
618
|
-
*/
|
|
619
|
-
Language["PYTHON"] = "PYTHON";
|
|
620
|
-
})(Language || (Language = {}));
|
|
621
621
|
/** Specifies how the response should be scheduled in the conversation. */
|
|
622
622
|
var FunctionResponseScheduling;
|
|
623
623
|
(function (FunctionResponseScheduling) {
|
|
@@ -1446,6 +1446,34 @@ var PartMediaResolutionLevel;
|
|
|
1446
1446
|
*/
|
|
1447
1447
|
PartMediaResolutionLevel["MEDIA_RESOLUTION_ULTRA_HIGH"] = "MEDIA_RESOLUTION_ULTRA_HIGH";
|
|
1448
1448
|
})(PartMediaResolutionLevel || (PartMediaResolutionLevel = {}));
|
|
1449
|
+
/** The type of tool in the function call. */
|
|
1450
|
+
var ToolType;
|
|
1451
|
+
(function (ToolType) {
|
|
1452
|
+
/**
|
|
1453
|
+
* Unspecified tool type.
|
|
1454
|
+
*/
|
|
1455
|
+
ToolType["TOOL_TYPE_UNSPECIFIED"] = "TOOL_TYPE_UNSPECIFIED";
|
|
1456
|
+
/**
|
|
1457
|
+
* Google search tool, maps to Tool.google_search.search_types.web_search.
|
|
1458
|
+
*/
|
|
1459
|
+
ToolType["GOOGLE_SEARCH_WEB"] = "GOOGLE_SEARCH_WEB";
|
|
1460
|
+
/**
|
|
1461
|
+
* Image search tool, maps to Tool.google_search.search_types.image_search.
|
|
1462
|
+
*/
|
|
1463
|
+
ToolType["GOOGLE_SEARCH_IMAGE"] = "GOOGLE_SEARCH_IMAGE";
|
|
1464
|
+
/**
|
|
1465
|
+
* URL context tool, maps to Tool.url_context.
|
|
1466
|
+
*/
|
|
1467
|
+
ToolType["URL_CONTEXT"] = "URL_CONTEXT";
|
|
1468
|
+
/**
|
|
1469
|
+
* Google maps tool, maps to Tool.google_maps.
|
|
1470
|
+
*/
|
|
1471
|
+
ToolType["GOOGLE_MAPS"] = "GOOGLE_MAPS";
|
|
1472
|
+
/**
|
|
1473
|
+
* File search tool, maps to Tool.file_search.
|
|
1474
|
+
*/
|
|
1475
|
+
ToolType["FILE_SEARCH"] = "FILE_SEARCH";
|
|
1476
|
+
})(ToolType || (ToolType = {}));
|
|
1449
1477
|
/** Resource scope. */
|
|
1450
1478
|
var ResourceScope;
|
|
1451
1479
|
(function (ResourceScope) {
|
|
@@ -1941,6 +1969,14 @@ var LiveMusicPlaybackControl;
|
|
|
1941
1969
|
*/
|
|
1942
1970
|
LiveMusicPlaybackControl["RESET_CONTEXT"] = "RESET_CONTEXT";
|
|
1943
1971
|
})(LiveMusicPlaybackControl || (LiveMusicPlaybackControl = {}));
|
|
1972
|
+
/** The output from a server-side `ToolCall` execution.
|
|
1973
|
+
|
|
1974
|
+
This message contains the results of a tool invocation that was initiated by a
|
|
1975
|
+
`ToolCall` from the model. The client should pass this `ToolResponse` back to
|
|
1976
|
+
the API in a subsequent turn within a `Content` message, along with the
|
|
1977
|
+
corresponding `ToolCall`. */
|
|
1978
|
+
class ToolResponse {
|
|
1979
|
+
}
|
|
1944
1980
|
/** Raw media bytes for function response.
|
|
1945
1981
|
|
|
1946
1982
|
Text should not be sent as raw bytes, use the FunctionResponse.response
|
|
@@ -4669,6 +4705,14 @@ function partToMldev$4(fromObject) {
|
|
|
4669
4705
|
if (fromVideoMetadata != null) {
|
|
4670
4706
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
4671
4707
|
}
|
|
4708
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
4709
|
+
if (fromToolCall != null) {
|
|
4710
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
4711
|
+
}
|
|
4712
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
4713
|
+
if (fromToolResponse != null) {
|
|
4714
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
4715
|
+
}
|
|
4672
4716
|
return toObject;
|
|
4673
4717
|
}
|
|
4674
4718
|
function safetySettingToMldev$1(fromObject) {
|
|
@@ -4700,6 +4744,10 @@ function toolConfigToMldev$2(fromObject) {
|
|
|
4700
4744
|
if (fromFunctionCallingConfig != null) {
|
|
4701
4745
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$2(fromFunctionCallingConfig));
|
|
4702
4746
|
}
|
|
4747
|
+
const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
|
|
4748
|
+
if (fromIncludeServerSideToolInvocations != null) {
|
|
4749
|
+
setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
|
|
4750
|
+
}
|
|
4703
4751
|
return toObject;
|
|
4704
4752
|
}
|
|
4705
4753
|
function toolToMldev$4(fromObject) {
|
|
@@ -5522,6 +5570,24 @@ function contentToMldev$3(fromObject) {
|
|
|
5522
5570
|
}
|
|
5523
5571
|
return toObject;
|
|
5524
5572
|
}
|
|
5573
|
+
function contentToVertex$2(fromObject) {
|
|
5574
|
+
const toObject = {};
|
|
5575
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5576
|
+
if (fromParts != null) {
|
|
5577
|
+
let transformedList = fromParts;
|
|
5578
|
+
if (Array.isArray(transformedList)) {
|
|
5579
|
+
transformedList = transformedList.map((item) => {
|
|
5580
|
+
return partToVertex$2(item);
|
|
5581
|
+
});
|
|
5582
|
+
}
|
|
5583
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5584
|
+
}
|
|
5585
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5586
|
+
if (fromRole != null) {
|
|
5587
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
5588
|
+
}
|
|
5589
|
+
return toObject;
|
|
5590
|
+
}
|
|
5525
5591
|
function createCachedContentConfigToMldev(fromObject, parentObject) {
|
|
5526
5592
|
const toObject = {};
|
|
5527
5593
|
const fromTtl = getValueByPath(fromObject, ['ttl']);
|
|
@@ -5590,7 +5656,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
|
|
|
5590
5656
|
let transformedList = tContents(fromContents);
|
|
5591
5657
|
if (Array.isArray(transformedList)) {
|
|
5592
5658
|
transformedList = transformedList.map((item) => {
|
|
5593
|
-
return item;
|
|
5659
|
+
return contentToVertex$2(item);
|
|
5594
5660
|
});
|
|
5595
5661
|
}
|
|
5596
5662
|
setValueByPath(parentObject, ['contents'], transformedList);
|
|
@@ -5599,7 +5665,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
|
|
|
5599
5665
|
'systemInstruction',
|
|
5600
5666
|
]);
|
|
5601
5667
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
5602
|
-
setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
|
|
5668
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex$2(tContent(fromSystemInstruction)));
|
|
5603
5669
|
}
|
|
5604
5670
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
5605
5671
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -5613,7 +5679,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
|
|
|
5613
5679
|
}
|
|
5614
5680
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
5615
5681
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
5616
|
-
setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
|
|
5682
|
+
setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex$1(fromToolConfig));
|
|
5617
5683
|
}
|
|
5618
5684
|
const fromKmsKeyName = getValueByPath(fromObject, ['kmsKeyName']);
|
|
5619
5685
|
if (parentObject !== undefined && fromKmsKeyName != null) {
|
|
@@ -5973,6 +6039,80 @@ function partToMldev$3(fromObject) {
|
|
|
5973
6039
|
if (fromVideoMetadata != null) {
|
|
5974
6040
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
5975
6041
|
}
|
|
6042
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
6043
|
+
if (fromToolCall != null) {
|
|
6044
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
6045
|
+
}
|
|
6046
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
6047
|
+
if (fromToolResponse != null) {
|
|
6048
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
6049
|
+
}
|
|
6050
|
+
return toObject;
|
|
6051
|
+
}
|
|
6052
|
+
function partToVertex$2(fromObject) {
|
|
6053
|
+
const toObject = {};
|
|
6054
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
6055
|
+
'mediaResolution',
|
|
6056
|
+
]);
|
|
6057
|
+
if (fromMediaResolution != null) {
|
|
6058
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
6059
|
+
}
|
|
6060
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
6061
|
+
'codeExecutionResult',
|
|
6062
|
+
]);
|
|
6063
|
+
if (fromCodeExecutionResult != null) {
|
|
6064
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
6065
|
+
}
|
|
6066
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
6067
|
+
'executableCode',
|
|
6068
|
+
]);
|
|
6069
|
+
if (fromExecutableCode != null) {
|
|
6070
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
6071
|
+
}
|
|
6072
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
6073
|
+
if (fromFileData != null) {
|
|
6074
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
6075
|
+
}
|
|
6076
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
6077
|
+
if (fromFunctionCall != null) {
|
|
6078
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
6079
|
+
}
|
|
6080
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
6081
|
+
'functionResponse',
|
|
6082
|
+
]);
|
|
6083
|
+
if (fromFunctionResponse != null) {
|
|
6084
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
6085
|
+
}
|
|
6086
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
6087
|
+
if (fromInlineData != null) {
|
|
6088
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
6089
|
+
}
|
|
6090
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
6091
|
+
if (fromText != null) {
|
|
6092
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
6093
|
+
}
|
|
6094
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
6095
|
+
if (fromThought != null) {
|
|
6096
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
6097
|
+
}
|
|
6098
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
6099
|
+
'thoughtSignature',
|
|
6100
|
+
]);
|
|
6101
|
+
if (fromThoughtSignature != null) {
|
|
6102
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
6103
|
+
}
|
|
6104
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
6105
|
+
'videoMetadata',
|
|
6106
|
+
]);
|
|
6107
|
+
if (fromVideoMetadata != null) {
|
|
6108
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
6109
|
+
}
|
|
6110
|
+
if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
|
|
6111
|
+
throw new Error('toolCall parameter is not supported in Vertex AI.');
|
|
6112
|
+
}
|
|
6113
|
+
if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
|
|
6114
|
+
throw new Error('toolResponse parameter is not supported in Vertex AI.');
|
|
6115
|
+
}
|
|
5976
6116
|
return toObject;
|
|
5977
6117
|
}
|
|
5978
6118
|
function toolConfigToMldev$1(fromObject) {
|
|
@@ -5989,6 +6129,30 @@ function toolConfigToMldev$1(fromObject) {
|
|
|
5989
6129
|
if (fromFunctionCallingConfig != null) {
|
|
5990
6130
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(fromFunctionCallingConfig));
|
|
5991
6131
|
}
|
|
6132
|
+
const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
|
|
6133
|
+
if (fromIncludeServerSideToolInvocations != null) {
|
|
6134
|
+
setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
|
|
6135
|
+
}
|
|
6136
|
+
return toObject;
|
|
6137
|
+
}
|
|
6138
|
+
function toolConfigToVertex$1(fromObject) {
|
|
6139
|
+
const toObject = {};
|
|
6140
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
6141
|
+
'retrievalConfig',
|
|
6142
|
+
]);
|
|
6143
|
+
if (fromRetrievalConfig != null) {
|
|
6144
|
+
setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
|
|
6145
|
+
}
|
|
6146
|
+
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
6147
|
+
'functionCallingConfig',
|
|
6148
|
+
]);
|
|
6149
|
+
if (fromFunctionCallingConfig != null) {
|
|
6150
|
+
setValueByPath(toObject, ['functionCallingConfig'], fromFunctionCallingConfig);
|
|
6151
|
+
}
|
|
6152
|
+
if (getValueByPath(fromObject, ['includeServerSideToolInvocations']) !==
|
|
6153
|
+
undefined) {
|
|
6154
|
+
throw new Error('includeServerSideToolInvocations parameter is not supported in Vertex AI.');
|
|
6155
|
+
}
|
|
5992
6156
|
return toObject;
|
|
5993
6157
|
}
|
|
5994
6158
|
function toolToMldev$3(fromObject) {
|
|
@@ -7409,6 +7573,13 @@ class Files extends BaseModule {
|
|
|
7409
7573
|
* Copyright 2025 Google LLC
|
|
7410
7574
|
* SPDX-License-Identifier: Apache-2.0
|
|
7411
7575
|
*/
|
|
7576
|
+
function audioTranscriptionConfigToMldev$1(fromObject) {
|
|
7577
|
+
const toObject = {};
|
|
7578
|
+
if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
|
|
7579
|
+
throw new Error('languageCodes parameter is not supported in Gemini API.');
|
|
7580
|
+
}
|
|
7581
|
+
return toObject;
|
|
7582
|
+
}
|
|
7412
7583
|
function authConfigToMldev$2(fromObject) {
|
|
7413
7584
|
const toObject = {};
|
|
7414
7585
|
const fromApiKey = getValueByPath(fromObject, ['apiKey']);
|
|
@@ -7469,6 +7640,24 @@ function contentToMldev$2(fromObject) {
|
|
|
7469
7640
|
}
|
|
7470
7641
|
return toObject;
|
|
7471
7642
|
}
|
|
7643
|
+
function contentToVertex$1(fromObject) {
|
|
7644
|
+
const toObject = {};
|
|
7645
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
7646
|
+
if (fromParts != null) {
|
|
7647
|
+
let transformedList = fromParts;
|
|
7648
|
+
if (Array.isArray(transformedList)) {
|
|
7649
|
+
transformedList = transformedList.map((item) => {
|
|
7650
|
+
return partToVertex$1(item);
|
|
7651
|
+
});
|
|
7652
|
+
}
|
|
7653
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
7654
|
+
}
|
|
7655
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
7656
|
+
if (fromRole != null) {
|
|
7657
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
7658
|
+
}
|
|
7659
|
+
return toObject;
|
|
7660
|
+
}
|
|
7472
7661
|
function fileDataToMldev$2(fromObject) {
|
|
7473
7662
|
const toObject = {};
|
|
7474
7663
|
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
@@ -7785,13 +7974,13 @@ function liveConnectConfigToMldev$1(fromObject, parentObject) {
|
|
|
7785
7974
|
'inputAudioTranscription',
|
|
7786
7975
|
]);
|
|
7787
7976
|
if (parentObject !== undefined && fromInputAudioTranscription != null) {
|
|
7788
|
-
setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
|
|
7977
|
+
setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromInputAudioTranscription));
|
|
7789
7978
|
}
|
|
7790
7979
|
const fromOutputAudioTranscription = getValueByPath(fromObject, [
|
|
7791
7980
|
'outputAudioTranscription',
|
|
7792
7981
|
]);
|
|
7793
7982
|
if (parentObject !== undefined && fromOutputAudioTranscription != null) {
|
|
7794
|
-
setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
|
|
7983
|
+
setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromOutputAudioTranscription));
|
|
7795
7984
|
}
|
|
7796
7985
|
const fromRealtimeInputConfig = getValueByPath(fromObject, [
|
|
7797
7986
|
'realtimeInputConfig',
|
|
@@ -7876,7 +8065,7 @@ function liveConnectConfigToVertex(fromObject, parentObject) {
|
|
|
7876
8065
|
'systemInstruction',
|
|
7877
8066
|
]);
|
|
7878
8067
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
7879
|
-
setValueByPath(parentObject, ['setup', 'systemInstruction'], tContent(fromSystemInstruction));
|
|
8068
|
+
setValueByPath(parentObject, ['setup', 'systemInstruction'], contentToVertex$1(tContent(fromSystemInstruction)));
|
|
7880
8069
|
}
|
|
7881
8070
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
7882
8071
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -8176,6 +8365,80 @@ function partToMldev$2(fromObject) {
|
|
|
8176
8365
|
if (fromVideoMetadata != null) {
|
|
8177
8366
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
8178
8367
|
}
|
|
8368
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
8369
|
+
if (fromToolCall != null) {
|
|
8370
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
8371
|
+
}
|
|
8372
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
8373
|
+
if (fromToolResponse != null) {
|
|
8374
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
8375
|
+
}
|
|
8376
|
+
return toObject;
|
|
8377
|
+
}
|
|
8378
|
+
function partToVertex$1(fromObject) {
|
|
8379
|
+
const toObject = {};
|
|
8380
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
8381
|
+
'mediaResolution',
|
|
8382
|
+
]);
|
|
8383
|
+
if (fromMediaResolution != null) {
|
|
8384
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
8385
|
+
}
|
|
8386
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
8387
|
+
'codeExecutionResult',
|
|
8388
|
+
]);
|
|
8389
|
+
if (fromCodeExecutionResult != null) {
|
|
8390
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
8391
|
+
}
|
|
8392
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
8393
|
+
'executableCode',
|
|
8394
|
+
]);
|
|
8395
|
+
if (fromExecutableCode != null) {
|
|
8396
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
8397
|
+
}
|
|
8398
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
8399
|
+
if (fromFileData != null) {
|
|
8400
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
8401
|
+
}
|
|
8402
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
8403
|
+
if (fromFunctionCall != null) {
|
|
8404
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
8405
|
+
}
|
|
8406
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
8407
|
+
'functionResponse',
|
|
8408
|
+
]);
|
|
8409
|
+
if (fromFunctionResponse != null) {
|
|
8410
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
8411
|
+
}
|
|
8412
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
8413
|
+
if (fromInlineData != null) {
|
|
8414
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
8415
|
+
}
|
|
8416
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
8417
|
+
if (fromText != null) {
|
|
8418
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
8419
|
+
}
|
|
8420
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
8421
|
+
if (fromThought != null) {
|
|
8422
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
8423
|
+
}
|
|
8424
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
8425
|
+
'thoughtSignature',
|
|
8426
|
+
]);
|
|
8427
|
+
if (fromThoughtSignature != null) {
|
|
8428
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
8429
|
+
}
|
|
8430
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
8431
|
+
'videoMetadata',
|
|
8432
|
+
]);
|
|
8433
|
+
if (fromVideoMetadata != null) {
|
|
8434
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
8435
|
+
}
|
|
8436
|
+
if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
|
|
8437
|
+
throw new Error('toolCall parameter is not supported in Vertex AI.');
|
|
8438
|
+
}
|
|
8439
|
+
if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
|
|
8440
|
+
throw new Error('toolResponse parameter is not supported in Vertex AI.');
|
|
8441
|
+
}
|
|
8179
8442
|
return toObject;
|
|
8180
8443
|
}
|
|
8181
8444
|
function sessionResumptionConfigToMldev$1(fromObject) {
|
|
@@ -8544,7 +8807,7 @@ function citationMetadataFromMldev(fromObject, _rootObject) {
|
|
|
8544
8807
|
}
|
|
8545
8808
|
return toObject;
|
|
8546
8809
|
}
|
|
8547
|
-
function computeTokensParametersToVertex(apiClient, fromObject,
|
|
8810
|
+
function computeTokensParametersToVertex(apiClient, fromObject, rootObject) {
|
|
8548
8811
|
const toObject = {};
|
|
8549
8812
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
8550
8813
|
if (fromModel != null) {
|
|
@@ -8555,7 +8818,7 @@ function computeTokensParametersToVertex(apiClient, fromObject, _rootObject) {
|
|
|
8555
8818
|
let transformedList = tContents(fromContents);
|
|
8556
8819
|
if (Array.isArray(transformedList)) {
|
|
8557
8820
|
transformedList = transformedList.map((item) => {
|
|
8558
|
-
return item;
|
|
8821
|
+
return contentToVertex(item);
|
|
8559
8822
|
});
|
|
8560
8823
|
}
|
|
8561
8824
|
setValueByPath(toObject, ['contents'], transformedList);
|
|
@@ -8624,6 +8887,24 @@ function contentToMldev$1(fromObject, rootObject) {
|
|
|
8624
8887
|
}
|
|
8625
8888
|
return toObject;
|
|
8626
8889
|
}
|
|
8890
|
+
function contentToVertex(fromObject, rootObject) {
|
|
8891
|
+
const toObject = {};
|
|
8892
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
8893
|
+
if (fromParts != null) {
|
|
8894
|
+
let transformedList = fromParts;
|
|
8895
|
+
if (Array.isArray(transformedList)) {
|
|
8896
|
+
transformedList = transformedList.map((item) => {
|
|
8897
|
+
return partToVertex(item);
|
|
8898
|
+
});
|
|
8899
|
+
}
|
|
8900
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
8901
|
+
}
|
|
8902
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
8903
|
+
if (fromRole != null) {
|
|
8904
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
8905
|
+
}
|
|
8906
|
+
return toObject;
|
|
8907
|
+
}
|
|
8627
8908
|
function controlReferenceConfigToVertex(fromObject, _rootObject) {
|
|
8628
8909
|
const toObject = {};
|
|
8629
8910
|
const fromControlType = getValueByPath(fromObject, ['controlType']);
|
|
@@ -8657,7 +8938,7 @@ function countTokensConfigToVertex(fromObject, parentObject, rootObject) {
|
|
|
8657
8938
|
'systemInstruction',
|
|
8658
8939
|
]);
|
|
8659
8940
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
8660
|
-
setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
|
|
8941
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
|
|
8661
8942
|
}
|
|
8662
8943
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
8663
8944
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -8710,7 +8991,7 @@ function countTokensParametersToVertex(apiClient, fromObject, rootObject) {
|
|
|
8710
8991
|
let transformedList = tContents(fromContents);
|
|
8711
8992
|
if (Array.isArray(transformedList)) {
|
|
8712
8993
|
transformedList = transformedList.map((item) => {
|
|
8713
|
-
return item;
|
|
8994
|
+
return contentToVertex(item);
|
|
8714
8995
|
});
|
|
8715
8996
|
}
|
|
8716
8997
|
setValueByPath(toObject, ['contents'], transformedList);
|
|
@@ -9114,7 +9395,7 @@ function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject
|
|
|
9114
9395
|
if (discriminatorContent === 'EMBED_CONTENT') {
|
|
9115
9396
|
const fromContent = getValueByPath(fromObject, ['content']);
|
|
9116
9397
|
if (fromContent != null) {
|
|
9117
|
-
setValueByPath(toObject, ['content'], tContent(fromContent));
|
|
9398
|
+
setValueByPath(toObject, ['content'], contentToVertex(tContent(fromContent)));
|
|
9118
9399
|
}
|
|
9119
9400
|
}
|
|
9120
9401
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
@@ -9465,7 +9746,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
|
|
|
9465
9746
|
'systemInstruction',
|
|
9466
9747
|
]);
|
|
9467
9748
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
9468
|
-
setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
|
|
9749
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
|
|
9469
9750
|
}
|
|
9470
9751
|
const fromTemperature = getValueByPath(fromObject, ['temperature']);
|
|
9471
9752
|
if (fromTemperature != null) {
|
|
@@ -9577,7 +9858,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
|
|
|
9577
9858
|
}
|
|
9578
9859
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
9579
9860
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
9580
|
-
setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
|
|
9861
|
+
setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex(fromToolConfig));
|
|
9581
9862
|
}
|
|
9582
9863
|
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9583
9864
|
if (parentObject !== undefined && fromLabels != null) {
|
|
@@ -9666,7 +9947,7 @@ function generateContentParametersToVertex(apiClient, fromObject, rootObject) {
|
|
|
9666
9947
|
let transformedList = tContents(fromContents);
|
|
9667
9948
|
if (Array.isArray(transformedList)) {
|
|
9668
9949
|
transformedList = transformedList.map((item) => {
|
|
9669
|
-
return item;
|
|
9950
|
+
return contentToVertex(item);
|
|
9670
9951
|
});
|
|
9671
9952
|
}
|
|
9672
9953
|
setValueByPath(toObject, ['contents'], transformedList);
|
|
@@ -11070,6 +11351,80 @@ function partToMldev$1(fromObject, rootObject) {
|
|
|
11070
11351
|
if (fromVideoMetadata != null) {
|
|
11071
11352
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
11072
11353
|
}
|
|
11354
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
11355
|
+
if (fromToolCall != null) {
|
|
11356
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
11357
|
+
}
|
|
11358
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
11359
|
+
if (fromToolResponse != null) {
|
|
11360
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
11361
|
+
}
|
|
11362
|
+
return toObject;
|
|
11363
|
+
}
|
|
11364
|
+
function partToVertex(fromObject, _rootObject) {
|
|
11365
|
+
const toObject = {};
|
|
11366
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
11367
|
+
'mediaResolution',
|
|
11368
|
+
]);
|
|
11369
|
+
if (fromMediaResolution != null) {
|
|
11370
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
11371
|
+
}
|
|
11372
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
11373
|
+
'codeExecutionResult',
|
|
11374
|
+
]);
|
|
11375
|
+
if (fromCodeExecutionResult != null) {
|
|
11376
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
11377
|
+
}
|
|
11378
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
11379
|
+
'executableCode',
|
|
11380
|
+
]);
|
|
11381
|
+
if (fromExecutableCode != null) {
|
|
11382
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
11383
|
+
}
|
|
11384
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
11385
|
+
if (fromFileData != null) {
|
|
11386
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
11387
|
+
}
|
|
11388
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
11389
|
+
if (fromFunctionCall != null) {
|
|
11390
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
11391
|
+
}
|
|
11392
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
11393
|
+
'functionResponse',
|
|
11394
|
+
]);
|
|
11395
|
+
if (fromFunctionResponse != null) {
|
|
11396
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
11397
|
+
}
|
|
11398
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
11399
|
+
if (fromInlineData != null) {
|
|
11400
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
11401
|
+
}
|
|
11402
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
11403
|
+
if (fromText != null) {
|
|
11404
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
11405
|
+
}
|
|
11406
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
11407
|
+
if (fromThought != null) {
|
|
11408
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
11409
|
+
}
|
|
11410
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
11411
|
+
'thoughtSignature',
|
|
11412
|
+
]);
|
|
11413
|
+
if (fromThoughtSignature != null) {
|
|
11414
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
11415
|
+
}
|
|
11416
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
11417
|
+
'videoMetadata',
|
|
11418
|
+
]);
|
|
11419
|
+
if (fromVideoMetadata != null) {
|
|
11420
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
11421
|
+
}
|
|
11422
|
+
if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
|
|
11423
|
+
throw new Error('toolCall parameter is not supported in Vertex AI.');
|
|
11424
|
+
}
|
|
11425
|
+
if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
|
|
11426
|
+
throw new Error('toolResponse parameter is not supported in Vertex AI.');
|
|
11427
|
+
}
|
|
11073
11428
|
return toObject;
|
|
11074
11429
|
}
|
|
11075
11430
|
function productImageToVertex(fromObject, rootObject) {
|
|
@@ -11403,6 +11758,30 @@ function toolConfigToMldev(fromObject, rootObject) {
|
|
|
11403
11758
|
if (fromFunctionCallingConfig != null) {
|
|
11404
11759
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(fromFunctionCallingConfig));
|
|
11405
11760
|
}
|
|
11761
|
+
const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
|
|
11762
|
+
if (fromIncludeServerSideToolInvocations != null) {
|
|
11763
|
+
setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
|
|
11764
|
+
}
|
|
11765
|
+
return toObject;
|
|
11766
|
+
}
|
|
11767
|
+
function toolConfigToVertex(fromObject, _rootObject) {
|
|
11768
|
+
const toObject = {};
|
|
11769
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
11770
|
+
'retrievalConfig',
|
|
11771
|
+
]);
|
|
11772
|
+
if (fromRetrievalConfig != null) {
|
|
11773
|
+
setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
|
|
11774
|
+
}
|
|
11775
|
+
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
11776
|
+
'functionCallingConfig',
|
|
11777
|
+
]);
|
|
11778
|
+
if (fromFunctionCallingConfig != null) {
|
|
11779
|
+
setValueByPath(toObject, ['functionCallingConfig'], fromFunctionCallingConfig);
|
|
11780
|
+
}
|
|
11781
|
+
if (getValueByPath(fromObject, ['includeServerSideToolInvocations']) !==
|
|
11782
|
+
undefined) {
|
|
11783
|
+
throw new Error('includeServerSideToolInvocations parameter is not supported in Vertex AI.');
|
|
11784
|
+
}
|
|
11406
11785
|
return toObject;
|
|
11407
11786
|
}
|
|
11408
11787
|
function toolToMldev$1(fromObject, rootObject) {
|
|
@@ -12092,7 +12471,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12092
12471
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12093
12472
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12094
12473
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12095
|
-
const SDK_VERSION = '1.
|
|
12474
|
+
const SDK_VERSION = '1.46.0'; // x-release-please-version
|
|
12096
12475
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12097
12476
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12098
12477
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13451,7 +13830,7 @@ class Session {
|
|
|
13451
13830
|
}
|
|
13452
13831
|
}
|
|
13453
13832
|
const clientMessage = {
|
|
13454
|
-
toolResponse: { functionResponses: functionResponses },
|
|
13833
|
+
toolResponse: { 'functionResponses': functionResponses },
|
|
13455
13834
|
};
|
|
13456
13835
|
return clientMessage;
|
|
13457
13836
|
}
|
|
@@ -15424,6 +15803,13 @@ class Operations extends BaseModule {
|
|
|
15424
15803
|
* Copyright 2025 Google LLC
|
|
15425
15804
|
* SPDX-License-Identifier: Apache-2.0
|
|
15426
15805
|
*/
|
|
15806
|
+
function audioTranscriptionConfigToMldev(fromObject) {
|
|
15807
|
+
const toObject = {};
|
|
15808
|
+
if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
|
|
15809
|
+
throw new Error('languageCodes parameter is not supported in Gemini API.');
|
|
15810
|
+
}
|
|
15811
|
+
return toObject;
|
|
15812
|
+
}
|
|
15427
15813
|
function authConfigToMldev(fromObject) {
|
|
15428
15814
|
const toObject = {};
|
|
15429
15815
|
const fromApiKey = getValueByPath(fromObject, ['apiKey']);
|
|
@@ -15675,13 +16061,13 @@ function liveConnectConfigToMldev(fromObject, parentObject) {
|
|
|
15675
16061
|
'inputAudioTranscription',
|
|
15676
16062
|
]);
|
|
15677
16063
|
if (parentObject !== undefined && fromInputAudioTranscription != null) {
|
|
15678
|
-
setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
|
|
16064
|
+
setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev(fromInputAudioTranscription));
|
|
15679
16065
|
}
|
|
15680
16066
|
const fromOutputAudioTranscription = getValueByPath(fromObject, [
|
|
15681
16067
|
'outputAudioTranscription',
|
|
15682
16068
|
]);
|
|
15683
16069
|
if (parentObject !== undefined && fromOutputAudioTranscription != null) {
|
|
15684
|
-
setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
|
|
16070
|
+
setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev(fromOutputAudioTranscription));
|
|
15685
16071
|
}
|
|
15686
16072
|
const fromRealtimeInputConfig = getValueByPath(fromObject, [
|
|
15687
16073
|
'realtimeInputConfig',
|
|
@@ -15774,6 +16160,14 @@ function partToMldev(fromObject) {
|
|
|
15774
16160
|
if (fromVideoMetadata != null) {
|
|
15775
16161
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
15776
16162
|
}
|
|
16163
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
16164
|
+
if (fromToolCall != null) {
|
|
16165
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
16166
|
+
}
|
|
16167
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
16168
|
+
if (fromToolResponse != null) {
|
|
16169
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
16170
|
+
}
|
|
15777
16171
|
return toObject;
|
|
15778
16172
|
}
|
|
15779
16173
|
function sessionResumptionConfigToMldev(fromObject) {
|
|
@@ -16943,6 +17337,30 @@ const FallbackEncoder = ({ headers, body }) => {
|
|
|
16943
17337
|
};
|
|
16944
17338
|
};
|
|
16945
17339
|
|
|
17340
|
+
/**
|
|
17341
|
+
* @license
|
|
17342
|
+
* Copyright 2025 Google LLC
|
|
17343
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
17344
|
+
*/
|
|
17345
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
17346
|
+
/**
|
|
17347
|
+
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
17348
|
+
*/
|
|
17349
|
+
function stringifyQuery(query) {
|
|
17350
|
+
return Object.entries(query)
|
|
17351
|
+
.filter(([_, value]) => typeof value !== 'undefined')
|
|
17352
|
+
.map(([key, value]) => {
|
|
17353
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
17354
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
17355
|
+
}
|
|
17356
|
+
if (value === null) {
|
|
17357
|
+
return `${encodeURIComponent(key)}=`;
|
|
17358
|
+
}
|
|
17359
|
+
throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
17360
|
+
})
|
|
17361
|
+
.join('&');
|
|
17362
|
+
}
|
|
17363
|
+
|
|
16946
17364
|
/**
|
|
16947
17365
|
* @license
|
|
16948
17366
|
* Copyright 2025 Google LLC
|
|
@@ -18086,18 +18504,7 @@ class BaseGeminiNextGenAPIClient {
|
|
|
18086
18504
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
18087
18505
|
*/
|
|
18088
18506
|
stringifyQuery(query) {
|
|
18089
|
-
return
|
|
18090
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
18091
|
-
.map(([key, value]) => {
|
|
18092
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
18093
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
18094
|
-
}
|
|
18095
|
-
if (value === null) {
|
|
18096
|
-
return `${encodeURIComponent(key)}=`;
|
|
18097
|
-
}
|
|
18098
|
-
throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
18099
|
-
})
|
|
18100
|
-
.join('&');
|
|
18507
|
+
return stringifyQuery(query);
|
|
18101
18508
|
}
|
|
18102
18509
|
getUserAgent() {
|
|
18103
18510
|
return `${this.constructor.name}/JS ${VERSION}`;
|
|
@@ -18114,8 +18521,9 @@ class BaseGeminiNextGenAPIClient {
|
|
|
18114
18521
|
new URL(path)
|
|
18115
18522
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
18116
18523
|
const defaultQuery = this.defaultQuery();
|
|
18117
|
-
|
|
18118
|
-
|
|
18524
|
+
const pathQuery = Object.fromEntries(url.searchParams);
|
|
18525
|
+
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
|
|
18526
|
+
query = Object.assign(Object.assign(Object.assign({}, pathQuery), defaultQuery), query);
|
|
18119
18527
|
}
|
|
18120
18528
|
if (typeof query === 'object' && query && !Array.isArray(query)) {
|
|
18121
18529
|
url.search = this.stringifyQuery(query);
|
|
@@ -18336,9 +18744,9 @@ class BaseGeminiNextGenAPIClient {
|
|
|
18336
18744
|
timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
|
|
18337
18745
|
}
|
|
18338
18746
|
}
|
|
18339
|
-
// If the API asks us to wait a certain amount of time
|
|
18340
|
-
//
|
|
18341
|
-
if (
|
|
18747
|
+
// If the API asks us to wait a certain amount of time, just do what it
|
|
18748
|
+
// says, but otherwise calculate a default
|
|
18749
|
+
if (timeoutMillis === undefined) {
|
|
18342
18750
|
const maxRetries = (_b = options.maxRetries) !== null && _b !== void 0 ? _b : this.maxRetries;
|
|
18343
18751
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
18344
18752
|
}
|
|
@@ -19715,18 +20123,18 @@ const MAX_RETRY_COUNT = 3;
|
|
|
19715
20123
|
const INITIAL_RETRY_DELAY_MS = 1000;
|
|
19716
20124
|
const DELAY_MULTIPLIER = 2;
|
|
19717
20125
|
const X_GOOG_UPLOAD_STATUS_HEADER_FIELD = 'x-goog-upload-status';
|
|
19718
|
-
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
20126
|
+
async function uploadBlob(file, uploadUrl, apiClient, httpOptions) {
|
|
19719
20127
|
var _a;
|
|
19720
|
-
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
20128
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
|
|
19721
20129
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
19722
20130
|
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') {
|
|
19723
20131
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
19724
20132
|
}
|
|
19725
20133
|
return responseJson['file'];
|
|
19726
20134
|
}
|
|
19727
|
-
async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
|
|
20135
|
+
async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
|
|
19728
20136
|
var _a;
|
|
19729
|
-
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
20137
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
|
|
19730
20138
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
19731
20139
|
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') {
|
|
19732
20140
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
@@ -19736,8 +20144,18 @@ async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
|
|
|
19736
20144
|
Object.assign(typedResp, resp);
|
|
19737
20145
|
return typedResp;
|
|
19738
20146
|
}
|
|
19739
|
-
async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
19740
|
-
var _a, _b;
|
|
20147
|
+
async function uploadBlobInternal(file, uploadUrl, apiClient, httpOptions) {
|
|
20148
|
+
var _a, _b, _c;
|
|
20149
|
+
let finalUrl = uploadUrl;
|
|
20150
|
+
const effectiveBaseUrl = (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl) || ((_a = apiClient.clientOptions.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl);
|
|
20151
|
+
if (effectiveBaseUrl) {
|
|
20152
|
+
const baseUri = new URL(effectiveBaseUrl);
|
|
20153
|
+
const uploadUri = new URL(uploadUrl);
|
|
20154
|
+
uploadUri.protocol = baseUri.protocol;
|
|
20155
|
+
uploadUri.host = baseUri.host;
|
|
20156
|
+
uploadUri.port = baseUri.port;
|
|
20157
|
+
finalUrl = uploadUri.toString();
|
|
20158
|
+
}
|
|
19741
20159
|
let fileSize = 0;
|
|
19742
20160
|
let offset = 0;
|
|
19743
20161
|
let response = new HttpResponse(new Response());
|
|
@@ -19752,21 +20170,14 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
|
19752
20170
|
let retryCount = 0;
|
|
19753
20171
|
let currentDelayMs = INITIAL_RETRY_DELAY_MS;
|
|
19754
20172
|
while (retryCount < MAX_RETRY_COUNT) {
|
|
20173
|
+
const mergedHeaders = Object.assign(Object.assign({}, ((httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.headers) || {})), { 'X-Goog-Upload-Command': uploadCommand, 'X-Goog-Upload-Offset': String(offset), 'Content-Length': String(chunkSize) });
|
|
19755
20174
|
response = await apiClient.request({
|
|
19756
20175
|
path: '',
|
|
19757
20176
|
body: chunk,
|
|
19758
20177
|
httpMethod: 'POST',
|
|
19759
|
-
httpOptions: {
|
|
19760
|
-
apiVersion: '',
|
|
19761
|
-
baseUrl: uploadUrl,
|
|
19762
|
-
headers: {
|
|
19763
|
-
'X-Goog-Upload-Command': uploadCommand,
|
|
19764
|
-
'X-Goog-Upload-Offset': String(offset),
|
|
19765
|
-
'Content-Length': String(chunkSize),
|
|
19766
|
-
},
|
|
19767
|
-
},
|
|
20178
|
+
httpOptions: Object.assign(Object.assign({}, httpOptions), { apiVersion: '', baseUrl: finalUrl, headers: mergedHeaders }),
|
|
19768
20179
|
});
|
|
19769
|
-
if ((
|
|
20180
|
+
if ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
|
|
19770
20181
|
break;
|
|
19771
20182
|
}
|
|
19772
20183
|
retryCount++;
|
|
@@ -19776,7 +20187,7 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
|
19776
20187
|
offset += chunkSize;
|
|
19777
20188
|
// The `x-goog-upload-status` header field can be `active`, `final` and
|
|
19778
20189
|
//`cancelled` in resposne.
|
|
19779
|
-
if (((
|
|
20190
|
+
if (((_c = response === null || response === void 0 ? void 0 : response.headers) === null || _c === void 0 ? void 0 : _c[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'active') {
|
|
19780
20191
|
break;
|
|
19781
20192
|
}
|
|
19782
20193
|
// TODO(b/401391430) Investigate why the upload status is not finalized
|
|
@@ -19796,17 +20207,17 @@ function sleep(ms) {
|
|
|
19796
20207
|
}
|
|
19797
20208
|
|
|
19798
20209
|
class BrowserUploader {
|
|
19799
|
-
async upload(file, uploadUrl, apiClient) {
|
|
20210
|
+
async upload(file, uploadUrl, apiClient, httpOptions) {
|
|
19800
20211
|
if (typeof file === 'string') {
|
|
19801
20212
|
throw new Error('File path is not supported in browser uploader.');
|
|
19802
20213
|
}
|
|
19803
|
-
return await uploadBlob(file, uploadUrl, apiClient);
|
|
20214
|
+
return await uploadBlob(file, uploadUrl, apiClient, httpOptions);
|
|
19804
20215
|
}
|
|
19805
|
-
async uploadToFileSearchStore(file, uploadUrl, apiClient) {
|
|
20216
|
+
async uploadToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
|
|
19806
20217
|
if (typeof file === 'string') {
|
|
19807
20218
|
throw new Error('File path is not supported in browser uploader.');
|
|
19808
20219
|
}
|
|
19809
|
-
return await uploadBlobToFileSearchStore(file, uploadUrl, apiClient);
|
|
20220
|
+
return await uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions);
|
|
19810
20221
|
}
|
|
19811
20222
|
async stat(file) {
|
|
19812
20223
|
if (typeof file === 'string') {
|
|
@@ -19996,5 +20407,5 @@ class GoogleGenAI {
|
|
|
19996
20407
|
}
|
|
19997
20408
|
}
|
|
19998
20409
|
|
|
19999
|
-
export { ActivityHandling, AdapterSize, AggregationMetric, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EmbeddingApiType, EndSensitivity, Environment, EvaluateDatasetResponse, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PairwiseChoice, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, ProminentPeople, RawReferenceImage, RecontextImageResponse, RegisterFilesResponse, ReplayResponse, ResourceScope, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, TrafficType, TuningJobState, TuningMethod, TuningMode, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VadSignalType, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, VoiceActivityType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
20410
|
+
export { ActivityHandling, AdapterSize, AggregationMetric, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EmbeddingApiType, EndSensitivity, Environment, EvaluateDatasetResponse, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PairwiseChoice, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, ProminentPeople, RawReferenceImage, RecontextImageResponse, RegisterFilesResponse, ReplayResponse, ResourceScope, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, ToolResponse, ToolType, TrafficType, TuningJobState, TuningMethod, TuningMode, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VadSignalType, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, VoiceActivityType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
20000
20411
|
//# sourceMappingURL=index.mjs.map
|