@google/genai 1.45.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 +437 -111
- package/dist/index.cjs +431 -47
- package/dist/index.mjs +431 -48
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +453 -67
- package/dist/node/index.mjs +453 -68
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +437 -111
- 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 +87 -54
- package/dist/vertex_internal/index.cjs.map +1 -1
- package/dist/vertex_internal/index.d.ts +87 -9
- package/dist/vertex_internal/index.js +87 -54
- package/dist/vertex_internal/index.js.map +1 -1
- package/dist/web/index.mjs +431 -48
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +437 -111
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -594,6 +594,18 @@ function videoFromVertex$1(fromObject) {
|
|
|
594
594
|
* Copyright 2025 Google LLC
|
|
595
595
|
* SPDX-License-Identifier: Apache-2.0
|
|
596
596
|
*/
|
|
597
|
+
/** Programming language of the `code`. */
|
|
598
|
+
var Language;
|
|
599
|
+
(function (Language) {
|
|
600
|
+
/**
|
|
601
|
+
* Unspecified language. This value should not be used.
|
|
602
|
+
*/
|
|
603
|
+
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
604
|
+
/**
|
|
605
|
+
* Python >= 3.10, with numpy and simpy available.
|
|
606
|
+
*/
|
|
607
|
+
Language["PYTHON"] = "PYTHON";
|
|
608
|
+
})(Language || (Language = {}));
|
|
597
609
|
/** Outcome of the code execution. */
|
|
598
610
|
var Outcome;
|
|
599
611
|
(function (Outcome) {
|
|
@@ -614,18 +626,6 @@ var Outcome;
|
|
|
614
626
|
*/
|
|
615
627
|
Outcome["OUTCOME_DEADLINE_EXCEEDED"] = "OUTCOME_DEADLINE_EXCEEDED";
|
|
616
628
|
})(Outcome || (Outcome = {}));
|
|
617
|
-
/** Programming language of the `code`. */
|
|
618
|
-
var Language;
|
|
619
|
-
(function (Language) {
|
|
620
|
-
/**
|
|
621
|
-
* Unspecified language. This value should not be used.
|
|
622
|
-
*/
|
|
623
|
-
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
624
|
-
/**
|
|
625
|
-
* Python >= 3.10, with numpy and simpy available.
|
|
626
|
-
*/
|
|
627
|
-
Language["PYTHON"] = "PYTHON";
|
|
628
|
-
})(Language || (Language = {}));
|
|
629
629
|
/** Specifies how the response should be scheduled in the conversation. */
|
|
630
630
|
var FunctionResponseScheduling;
|
|
631
631
|
(function (FunctionResponseScheduling) {
|
|
@@ -1454,6 +1454,34 @@ var PartMediaResolutionLevel;
|
|
|
1454
1454
|
*/
|
|
1455
1455
|
PartMediaResolutionLevel["MEDIA_RESOLUTION_ULTRA_HIGH"] = "MEDIA_RESOLUTION_ULTRA_HIGH";
|
|
1456
1456
|
})(PartMediaResolutionLevel || (PartMediaResolutionLevel = {}));
|
|
1457
|
+
/** The type of tool in the function call. */
|
|
1458
|
+
var ToolType;
|
|
1459
|
+
(function (ToolType) {
|
|
1460
|
+
/**
|
|
1461
|
+
* Unspecified tool type.
|
|
1462
|
+
*/
|
|
1463
|
+
ToolType["TOOL_TYPE_UNSPECIFIED"] = "TOOL_TYPE_UNSPECIFIED";
|
|
1464
|
+
/**
|
|
1465
|
+
* Google search tool, maps to Tool.google_search.search_types.web_search.
|
|
1466
|
+
*/
|
|
1467
|
+
ToolType["GOOGLE_SEARCH_WEB"] = "GOOGLE_SEARCH_WEB";
|
|
1468
|
+
/**
|
|
1469
|
+
* Image search tool, maps to Tool.google_search.search_types.image_search.
|
|
1470
|
+
*/
|
|
1471
|
+
ToolType["GOOGLE_SEARCH_IMAGE"] = "GOOGLE_SEARCH_IMAGE";
|
|
1472
|
+
/**
|
|
1473
|
+
* URL context tool, maps to Tool.url_context.
|
|
1474
|
+
*/
|
|
1475
|
+
ToolType["URL_CONTEXT"] = "URL_CONTEXT";
|
|
1476
|
+
/**
|
|
1477
|
+
* Google maps tool, maps to Tool.google_maps.
|
|
1478
|
+
*/
|
|
1479
|
+
ToolType["GOOGLE_MAPS"] = "GOOGLE_MAPS";
|
|
1480
|
+
/**
|
|
1481
|
+
* File search tool, maps to Tool.file_search.
|
|
1482
|
+
*/
|
|
1483
|
+
ToolType["FILE_SEARCH"] = "FILE_SEARCH";
|
|
1484
|
+
})(ToolType || (ToolType = {}));
|
|
1457
1485
|
/** Resource scope. */
|
|
1458
1486
|
var ResourceScope;
|
|
1459
1487
|
(function (ResourceScope) {
|
|
@@ -1949,6 +1977,14 @@ var LiveMusicPlaybackControl;
|
|
|
1949
1977
|
*/
|
|
1950
1978
|
LiveMusicPlaybackControl["RESET_CONTEXT"] = "RESET_CONTEXT";
|
|
1951
1979
|
})(LiveMusicPlaybackControl || (LiveMusicPlaybackControl = {}));
|
|
1980
|
+
/** The output from a server-side `ToolCall` execution.
|
|
1981
|
+
|
|
1982
|
+
This message contains the results of a tool invocation that was initiated by a
|
|
1983
|
+
`ToolCall` from the model. The client should pass this `ToolResponse` back to
|
|
1984
|
+
the API in a subsequent turn within a `Content` message, along with the
|
|
1985
|
+
corresponding `ToolCall`. */
|
|
1986
|
+
class ToolResponse {
|
|
1987
|
+
}
|
|
1952
1988
|
/** Raw media bytes for function response.
|
|
1953
1989
|
|
|
1954
1990
|
Text should not be sent as raw bytes, use the FunctionResponse.response
|
|
@@ -4677,6 +4713,14 @@ function partToMldev$4(fromObject) {
|
|
|
4677
4713
|
if (fromVideoMetadata != null) {
|
|
4678
4714
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
4679
4715
|
}
|
|
4716
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
4717
|
+
if (fromToolCall != null) {
|
|
4718
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
4719
|
+
}
|
|
4720
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
4721
|
+
if (fromToolResponse != null) {
|
|
4722
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
4723
|
+
}
|
|
4680
4724
|
return toObject;
|
|
4681
4725
|
}
|
|
4682
4726
|
function safetySettingToMldev$1(fromObject) {
|
|
@@ -4708,6 +4752,10 @@ function toolConfigToMldev$2(fromObject) {
|
|
|
4708
4752
|
if (fromFunctionCallingConfig != null) {
|
|
4709
4753
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$2(fromFunctionCallingConfig));
|
|
4710
4754
|
}
|
|
4755
|
+
const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
|
|
4756
|
+
if (fromIncludeServerSideToolInvocations != null) {
|
|
4757
|
+
setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
|
|
4758
|
+
}
|
|
4711
4759
|
return toObject;
|
|
4712
4760
|
}
|
|
4713
4761
|
function toolToMldev$4(fromObject) {
|
|
@@ -5530,6 +5578,24 @@ function contentToMldev$3(fromObject) {
|
|
|
5530
5578
|
}
|
|
5531
5579
|
return toObject;
|
|
5532
5580
|
}
|
|
5581
|
+
function contentToVertex$2(fromObject) {
|
|
5582
|
+
const toObject = {};
|
|
5583
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5584
|
+
if (fromParts != null) {
|
|
5585
|
+
let transformedList = fromParts;
|
|
5586
|
+
if (Array.isArray(transformedList)) {
|
|
5587
|
+
transformedList = transformedList.map((item) => {
|
|
5588
|
+
return partToVertex$2(item);
|
|
5589
|
+
});
|
|
5590
|
+
}
|
|
5591
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5592
|
+
}
|
|
5593
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5594
|
+
if (fromRole != null) {
|
|
5595
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
5596
|
+
}
|
|
5597
|
+
return toObject;
|
|
5598
|
+
}
|
|
5533
5599
|
function createCachedContentConfigToMldev(fromObject, parentObject) {
|
|
5534
5600
|
const toObject = {};
|
|
5535
5601
|
const fromTtl = getValueByPath(fromObject, ['ttl']);
|
|
@@ -5598,7 +5664,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
|
|
|
5598
5664
|
let transformedList = tContents(fromContents);
|
|
5599
5665
|
if (Array.isArray(transformedList)) {
|
|
5600
5666
|
transformedList = transformedList.map((item) => {
|
|
5601
|
-
return item;
|
|
5667
|
+
return contentToVertex$2(item);
|
|
5602
5668
|
});
|
|
5603
5669
|
}
|
|
5604
5670
|
setValueByPath(parentObject, ['contents'], transformedList);
|
|
@@ -5607,7 +5673,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
|
|
|
5607
5673
|
'systemInstruction',
|
|
5608
5674
|
]);
|
|
5609
5675
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
5610
|
-
setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
|
|
5676
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex$2(tContent(fromSystemInstruction)));
|
|
5611
5677
|
}
|
|
5612
5678
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
5613
5679
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -5621,7 +5687,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
|
|
|
5621
5687
|
}
|
|
5622
5688
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
5623
5689
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
5624
|
-
setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
|
|
5690
|
+
setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex$1(fromToolConfig));
|
|
5625
5691
|
}
|
|
5626
5692
|
const fromKmsKeyName = getValueByPath(fromObject, ['kmsKeyName']);
|
|
5627
5693
|
if (parentObject !== undefined && fromKmsKeyName != null) {
|
|
@@ -5981,6 +6047,80 @@ function partToMldev$3(fromObject) {
|
|
|
5981
6047
|
if (fromVideoMetadata != null) {
|
|
5982
6048
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
5983
6049
|
}
|
|
6050
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
6051
|
+
if (fromToolCall != null) {
|
|
6052
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
6053
|
+
}
|
|
6054
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
6055
|
+
if (fromToolResponse != null) {
|
|
6056
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
6057
|
+
}
|
|
6058
|
+
return toObject;
|
|
6059
|
+
}
|
|
6060
|
+
function partToVertex$2(fromObject) {
|
|
6061
|
+
const toObject = {};
|
|
6062
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
6063
|
+
'mediaResolution',
|
|
6064
|
+
]);
|
|
6065
|
+
if (fromMediaResolution != null) {
|
|
6066
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
6067
|
+
}
|
|
6068
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
6069
|
+
'codeExecutionResult',
|
|
6070
|
+
]);
|
|
6071
|
+
if (fromCodeExecutionResult != null) {
|
|
6072
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
6073
|
+
}
|
|
6074
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
6075
|
+
'executableCode',
|
|
6076
|
+
]);
|
|
6077
|
+
if (fromExecutableCode != null) {
|
|
6078
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
6079
|
+
}
|
|
6080
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
6081
|
+
if (fromFileData != null) {
|
|
6082
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
6083
|
+
}
|
|
6084
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
6085
|
+
if (fromFunctionCall != null) {
|
|
6086
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
6087
|
+
}
|
|
6088
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
6089
|
+
'functionResponse',
|
|
6090
|
+
]);
|
|
6091
|
+
if (fromFunctionResponse != null) {
|
|
6092
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
6093
|
+
}
|
|
6094
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
6095
|
+
if (fromInlineData != null) {
|
|
6096
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
6097
|
+
}
|
|
6098
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
6099
|
+
if (fromText != null) {
|
|
6100
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
6101
|
+
}
|
|
6102
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
6103
|
+
if (fromThought != null) {
|
|
6104
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
6105
|
+
}
|
|
6106
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
6107
|
+
'thoughtSignature',
|
|
6108
|
+
]);
|
|
6109
|
+
if (fromThoughtSignature != null) {
|
|
6110
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
6111
|
+
}
|
|
6112
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
6113
|
+
'videoMetadata',
|
|
6114
|
+
]);
|
|
6115
|
+
if (fromVideoMetadata != null) {
|
|
6116
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
6117
|
+
}
|
|
6118
|
+
if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
|
|
6119
|
+
throw new Error('toolCall parameter is not supported in Vertex AI.');
|
|
6120
|
+
}
|
|
6121
|
+
if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
|
|
6122
|
+
throw new Error('toolResponse parameter is not supported in Vertex AI.');
|
|
6123
|
+
}
|
|
5984
6124
|
return toObject;
|
|
5985
6125
|
}
|
|
5986
6126
|
function toolConfigToMldev$1(fromObject) {
|
|
@@ -5997,6 +6137,30 @@ function toolConfigToMldev$1(fromObject) {
|
|
|
5997
6137
|
if (fromFunctionCallingConfig != null) {
|
|
5998
6138
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(fromFunctionCallingConfig));
|
|
5999
6139
|
}
|
|
6140
|
+
const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
|
|
6141
|
+
if (fromIncludeServerSideToolInvocations != null) {
|
|
6142
|
+
setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
|
|
6143
|
+
}
|
|
6144
|
+
return toObject;
|
|
6145
|
+
}
|
|
6146
|
+
function toolConfigToVertex$1(fromObject) {
|
|
6147
|
+
const toObject = {};
|
|
6148
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
6149
|
+
'retrievalConfig',
|
|
6150
|
+
]);
|
|
6151
|
+
if (fromRetrievalConfig != null) {
|
|
6152
|
+
setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
|
|
6153
|
+
}
|
|
6154
|
+
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
6155
|
+
'functionCallingConfig',
|
|
6156
|
+
]);
|
|
6157
|
+
if (fromFunctionCallingConfig != null) {
|
|
6158
|
+
setValueByPath(toObject, ['functionCallingConfig'], fromFunctionCallingConfig);
|
|
6159
|
+
}
|
|
6160
|
+
if (getValueByPath(fromObject, ['includeServerSideToolInvocations']) !==
|
|
6161
|
+
undefined) {
|
|
6162
|
+
throw new Error('includeServerSideToolInvocations parameter is not supported in Vertex AI.');
|
|
6163
|
+
}
|
|
6000
6164
|
return toObject;
|
|
6001
6165
|
}
|
|
6002
6166
|
function toolToMldev$3(fromObject) {
|
|
@@ -7484,6 +7648,24 @@ function contentToMldev$2(fromObject) {
|
|
|
7484
7648
|
}
|
|
7485
7649
|
return toObject;
|
|
7486
7650
|
}
|
|
7651
|
+
function contentToVertex$1(fromObject) {
|
|
7652
|
+
const toObject = {};
|
|
7653
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
7654
|
+
if (fromParts != null) {
|
|
7655
|
+
let transformedList = fromParts;
|
|
7656
|
+
if (Array.isArray(transformedList)) {
|
|
7657
|
+
transformedList = transformedList.map((item) => {
|
|
7658
|
+
return partToVertex$1(item);
|
|
7659
|
+
});
|
|
7660
|
+
}
|
|
7661
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
7662
|
+
}
|
|
7663
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
7664
|
+
if (fromRole != null) {
|
|
7665
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
7666
|
+
}
|
|
7667
|
+
return toObject;
|
|
7668
|
+
}
|
|
7487
7669
|
function fileDataToMldev$2(fromObject) {
|
|
7488
7670
|
const toObject = {};
|
|
7489
7671
|
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
@@ -7891,7 +8073,7 @@ function liveConnectConfigToVertex(fromObject, parentObject) {
|
|
|
7891
8073
|
'systemInstruction',
|
|
7892
8074
|
]);
|
|
7893
8075
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
7894
|
-
setValueByPath(parentObject, ['setup', 'systemInstruction'], tContent(fromSystemInstruction));
|
|
8076
|
+
setValueByPath(parentObject, ['setup', 'systemInstruction'], contentToVertex$1(tContent(fromSystemInstruction)));
|
|
7895
8077
|
}
|
|
7896
8078
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
7897
8079
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -8191,6 +8373,80 @@ function partToMldev$2(fromObject) {
|
|
|
8191
8373
|
if (fromVideoMetadata != null) {
|
|
8192
8374
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
8193
8375
|
}
|
|
8376
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
8377
|
+
if (fromToolCall != null) {
|
|
8378
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
8379
|
+
}
|
|
8380
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
8381
|
+
if (fromToolResponse != null) {
|
|
8382
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
8383
|
+
}
|
|
8384
|
+
return toObject;
|
|
8385
|
+
}
|
|
8386
|
+
function partToVertex$1(fromObject) {
|
|
8387
|
+
const toObject = {};
|
|
8388
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
8389
|
+
'mediaResolution',
|
|
8390
|
+
]);
|
|
8391
|
+
if (fromMediaResolution != null) {
|
|
8392
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
8393
|
+
}
|
|
8394
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
8395
|
+
'codeExecutionResult',
|
|
8396
|
+
]);
|
|
8397
|
+
if (fromCodeExecutionResult != null) {
|
|
8398
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
8399
|
+
}
|
|
8400
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
8401
|
+
'executableCode',
|
|
8402
|
+
]);
|
|
8403
|
+
if (fromExecutableCode != null) {
|
|
8404
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
8405
|
+
}
|
|
8406
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
8407
|
+
if (fromFileData != null) {
|
|
8408
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
8409
|
+
}
|
|
8410
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
8411
|
+
if (fromFunctionCall != null) {
|
|
8412
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
8413
|
+
}
|
|
8414
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
8415
|
+
'functionResponse',
|
|
8416
|
+
]);
|
|
8417
|
+
if (fromFunctionResponse != null) {
|
|
8418
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
8419
|
+
}
|
|
8420
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
8421
|
+
if (fromInlineData != null) {
|
|
8422
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
8423
|
+
}
|
|
8424
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
8425
|
+
if (fromText != null) {
|
|
8426
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
8427
|
+
}
|
|
8428
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
8429
|
+
if (fromThought != null) {
|
|
8430
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
8431
|
+
}
|
|
8432
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
8433
|
+
'thoughtSignature',
|
|
8434
|
+
]);
|
|
8435
|
+
if (fromThoughtSignature != null) {
|
|
8436
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
8437
|
+
}
|
|
8438
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
8439
|
+
'videoMetadata',
|
|
8440
|
+
]);
|
|
8441
|
+
if (fromVideoMetadata != null) {
|
|
8442
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
8443
|
+
}
|
|
8444
|
+
if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
|
|
8445
|
+
throw new Error('toolCall parameter is not supported in Vertex AI.');
|
|
8446
|
+
}
|
|
8447
|
+
if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
|
|
8448
|
+
throw new Error('toolResponse parameter is not supported in Vertex AI.');
|
|
8449
|
+
}
|
|
8194
8450
|
return toObject;
|
|
8195
8451
|
}
|
|
8196
8452
|
function sessionResumptionConfigToMldev$1(fromObject) {
|
|
@@ -8559,7 +8815,7 @@ function citationMetadataFromMldev(fromObject, _rootObject) {
|
|
|
8559
8815
|
}
|
|
8560
8816
|
return toObject;
|
|
8561
8817
|
}
|
|
8562
|
-
function computeTokensParametersToVertex(apiClient, fromObject,
|
|
8818
|
+
function computeTokensParametersToVertex(apiClient, fromObject, rootObject) {
|
|
8563
8819
|
const toObject = {};
|
|
8564
8820
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
8565
8821
|
if (fromModel != null) {
|
|
@@ -8570,7 +8826,7 @@ function computeTokensParametersToVertex(apiClient, fromObject, _rootObject) {
|
|
|
8570
8826
|
let transformedList = tContents(fromContents);
|
|
8571
8827
|
if (Array.isArray(transformedList)) {
|
|
8572
8828
|
transformedList = transformedList.map((item) => {
|
|
8573
|
-
return item;
|
|
8829
|
+
return contentToVertex(item);
|
|
8574
8830
|
});
|
|
8575
8831
|
}
|
|
8576
8832
|
setValueByPath(toObject, ['contents'], transformedList);
|
|
@@ -8639,6 +8895,24 @@ function contentToMldev$1(fromObject, rootObject) {
|
|
|
8639
8895
|
}
|
|
8640
8896
|
return toObject;
|
|
8641
8897
|
}
|
|
8898
|
+
function contentToVertex(fromObject, rootObject) {
|
|
8899
|
+
const toObject = {};
|
|
8900
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
8901
|
+
if (fromParts != null) {
|
|
8902
|
+
let transformedList = fromParts;
|
|
8903
|
+
if (Array.isArray(transformedList)) {
|
|
8904
|
+
transformedList = transformedList.map((item) => {
|
|
8905
|
+
return partToVertex(item);
|
|
8906
|
+
});
|
|
8907
|
+
}
|
|
8908
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
8909
|
+
}
|
|
8910
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
8911
|
+
if (fromRole != null) {
|
|
8912
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
8913
|
+
}
|
|
8914
|
+
return toObject;
|
|
8915
|
+
}
|
|
8642
8916
|
function controlReferenceConfigToVertex(fromObject, _rootObject) {
|
|
8643
8917
|
const toObject = {};
|
|
8644
8918
|
const fromControlType = getValueByPath(fromObject, ['controlType']);
|
|
@@ -8672,7 +8946,7 @@ function countTokensConfigToVertex(fromObject, parentObject, rootObject) {
|
|
|
8672
8946
|
'systemInstruction',
|
|
8673
8947
|
]);
|
|
8674
8948
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
8675
|
-
setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
|
|
8949
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
|
|
8676
8950
|
}
|
|
8677
8951
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
8678
8952
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -8725,7 +8999,7 @@ function countTokensParametersToVertex(apiClient, fromObject, rootObject) {
|
|
|
8725
8999
|
let transformedList = tContents(fromContents);
|
|
8726
9000
|
if (Array.isArray(transformedList)) {
|
|
8727
9001
|
transformedList = transformedList.map((item) => {
|
|
8728
|
-
return item;
|
|
9002
|
+
return contentToVertex(item);
|
|
8729
9003
|
});
|
|
8730
9004
|
}
|
|
8731
9005
|
setValueByPath(toObject, ['contents'], transformedList);
|
|
@@ -9129,7 +9403,7 @@ function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject
|
|
|
9129
9403
|
if (discriminatorContent === 'EMBED_CONTENT') {
|
|
9130
9404
|
const fromContent = getValueByPath(fromObject, ['content']);
|
|
9131
9405
|
if (fromContent != null) {
|
|
9132
|
-
setValueByPath(toObject, ['content'], tContent(fromContent));
|
|
9406
|
+
setValueByPath(toObject, ['content'], contentToVertex(tContent(fromContent)));
|
|
9133
9407
|
}
|
|
9134
9408
|
}
|
|
9135
9409
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
@@ -9480,7 +9754,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
|
|
|
9480
9754
|
'systemInstruction',
|
|
9481
9755
|
]);
|
|
9482
9756
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
9483
|
-
setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
|
|
9757
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
|
|
9484
9758
|
}
|
|
9485
9759
|
const fromTemperature = getValueByPath(fromObject, ['temperature']);
|
|
9486
9760
|
if (fromTemperature != null) {
|
|
@@ -9592,7 +9866,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
|
|
|
9592
9866
|
}
|
|
9593
9867
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
9594
9868
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
9595
|
-
setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
|
|
9869
|
+
setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex(fromToolConfig));
|
|
9596
9870
|
}
|
|
9597
9871
|
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9598
9872
|
if (parentObject !== undefined && fromLabels != null) {
|
|
@@ -9681,7 +9955,7 @@ function generateContentParametersToVertex(apiClient, fromObject, rootObject) {
|
|
|
9681
9955
|
let transformedList = tContents(fromContents);
|
|
9682
9956
|
if (Array.isArray(transformedList)) {
|
|
9683
9957
|
transformedList = transformedList.map((item) => {
|
|
9684
|
-
return item;
|
|
9958
|
+
return contentToVertex(item);
|
|
9685
9959
|
});
|
|
9686
9960
|
}
|
|
9687
9961
|
setValueByPath(toObject, ['contents'], transformedList);
|
|
@@ -11085,6 +11359,80 @@ function partToMldev$1(fromObject, rootObject) {
|
|
|
11085
11359
|
if (fromVideoMetadata != null) {
|
|
11086
11360
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
11087
11361
|
}
|
|
11362
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
11363
|
+
if (fromToolCall != null) {
|
|
11364
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
11365
|
+
}
|
|
11366
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
11367
|
+
if (fromToolResponse != null) {
|
|
11368
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
11369
|
+
}
|
|
11370
|
+
return toObject;
|
|
11371
|
+
}
|
|
11372
|
+
function partToVertex(fromObject, _rootObject) {
|
|
11373
|
+
const toObject = {};
|
|
11374
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
11375
|
+
'mediaResolution',
|
|
11376
|
+
]);
|
|
11377
|
+
if (fromMediaResolution != null) {
|
|
11378
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
11379
|
+
}
|
|
11380
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
11381
|
+
'codeExecutionResult',
|
|
11382
|
+
]);
|
|
11383
|
+
if (fromCodeExecutionResult != null) {
|
|
11384
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
11385
|
+
}
|
|
11386
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
11387
|
+
'executableCode',
|
|
11388
|
+
]);
|
|
11389
|
+
if (fromExecutableCode != null) {
|
|
11390
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
11391
|
+
}
|
|
11392
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
11393
|
+
if (fromFileData != null) {
|
|
11394
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
11395
|
+
}
|
|
11396
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
11397
|
+
if (fromFunctionCall != null) {
|
|
11398
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
11399
|
+
}
|
|
11400
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
11401
|
+
'functionResponse',
|
|
11402
|
+
]);
|
|
11403
|
+
if (fromFunctionResponse != null) {
|
|
11404
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
11405
|
+
}
|
|
11406
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
11407
|
+
if (fromInlineData != null) {
|
|
11408
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
11409
|
+
}
|
|
11410
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
11411
|
+
if (fromText != null) {
|
|
11412
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
11413
|
+
}
|
|
11414
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
11415
|
+
if (fromThought != null) {
|
|
11416
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
11417
|
+
}
|
|
11418
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
11419
|
+
'thoughtSignature',
|
|
11420
|
+
]);
|
|
11421
|
+
if (fromThoughtSignature != null) {
|
|
11422
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
11423
|
+
}
|
|
11424
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
11425
|
+
'videoMetadata',
|
|
11426
|
+
]);
|
|
11427
|
+
if (fromVideoMetadata != null) {
|
|
11428
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
11429
|
+
}
|
|
11430
|
+
if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
|
|
11431
|
+
throw new Error('toolCall parameter is not supported in Vertex AI.');
|
|
11432
|
+
}
|
|
11433
|
+
if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
|
|
11434
|
+
throw new Error('toolResponse parameter is not supported in Vertex AI.');
|
|
11435
|
+
}
|
|
11088
11436
|
return toObject;
|
|
11089
11437
|
}
|
|
11090
11438
|
function productImageToVertex(fromObject, rootObject) {
|
|
@@ -11418,6 +11766,30 @@ function toolConfigToMldev(fromObject, rootObject) {
|
|
|
11418
11766
|
if (fromFunctionCallingConfig != null) {
|
|
11419
11767
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(fromFunctionCallingConfig));
|
|
11420
11768
|
}
|
|
11769
|
+
const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
|
|
11770
|
+
if (fromIncludeServerSideToolInvocations != null) {
|
|
11771
|
+
setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
|
|
11772
|
+
}
|
|
11773
|
+
return toObject;
|
|
11774
|
+
}
|
|
11775
|
+
function toolConfigToVertex(fromObject, _rootObject) {
|
|
11776
|
+
const toObject = {};
|
|
11777
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
11778
|
+
'retrievalConfig',
|
|
11779
|
+
]);
|
|
11780
|
+
if (fromRetrievalConfig != null) {
|
|
11781
|
+
setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
|
|
11782
|
+
}
|
|
11783
|
+
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
11784
|
+
'functionCallingConfig',
|
|
11785
|
+
]);
|
|
11786
|
+
if (fromFunctionCallingConfig != null) {
|
|
11787
|
+
setValueByPath(toObject, ['functionCallingConfig'], fromFunctionCallingConfig);
|
|
11788
|
+
}
|
|
11789
|
+
if (getValueByPath(fromObject, ['includeServerSideToolInvocations']) !==
|
|
11790
|
+
undefined) {
|
|
11791
|
+
throw new Error('includeServerSideToolInvocations parameter is not supported in Vertex AI.');
|
|
11792
|
+
}
|
|
11421
11793
|
return toObject;
|
|
11422
11794
|
}
|
|
11423
11795
|
function toolToMldev$1(fromObject, rootObject) {
|
|
@@ -12107,7 +12479,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12107
12479
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12108
12480
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12109
12481
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12110
|
-
const SDK_VERSION = '1.
|
|
12482
|
+
const SDK_VERSION = '1.46.0'; // x-release-please-version
|
|
12111
12483
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12112
12484
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12113
12485
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13466,7 +13838,7 @@ class Session {
|
|
|
13466
13838
|
}
|
|
13467
13839
|
}
|
|
13468
13840
|
const clientMessage = {
|
|
13469
|
-
toolResponse: { functionResponses: functionResponses },
|
|
13841
|
+
toolResponse: { 'functionResponses': functionResponses },
|
|
13470
13842
|
};
|
|
13471
13843
|
return clientMessage;
|
|
13472
13844
|
}
|
|
@@ -15796,6 +16168,14 @@ function partToMldev(fromObject) {
|
|
|
15796
16168
|
if (fromVideoMetadata != null) {
|
|
15797
16169
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
15798
16170
|
}
|
|
16171
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
16172
|
+
if (fromToolCall != null) {
|
|
16173
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
16174
|
+
}
|
|
16175
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
16176
|
+
if (fromToolResponse != null) {
|
|
16177
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
16178
|
+
}
|
|
15799
16179
|
return toObject;
|
|
15800
16180
|
}
|
|
15801
16181
|
function sessionResumptionConfigToMldev(fromObject) {
|
|
@@ -19919,18 +20299,18 @@ const MAX_RETRY_COUNT = 3;
|
|
|
19919
20299
|
const INITIAL_RETRY_DELAY_MS = 1000;
|
|
19920
20300
|
const DELAY_MULTIPLIER = 2;
|
|
19921
20301
|
const X_GOOG_UPLOAD_STATUS_HEADER_FIELD = 'x-goog-upload-status';
|
|
19922
|
-
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
20302
|
+
async function uploadBlob(file, uploadUrl, apiClient, httpOptions) {
|
|
19923
20303
|
var _a;
|
|
19924
|
-
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
20304
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
|
|
19925
20305
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
19926
20306
|
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') {
|
|
19927
20307
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
19928
20308
|
}
|
|
19929
20309
|
return responseJson['file'];
|
|
19930
20310
|
}
|
|
19931
|
-
async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
|
|
20311
|
+
async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
|
|
19932
20312
|
var _a;
|
|
19933
|
-
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
20313
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
|
|
19934
20314
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
19935
20315
|
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') {
|
|
19936
20316
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
@@ -19940,8 +20320,18 @@ async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
|
|
|
19940
20320
|
Object.assign(typedResp, resp);
|
|
19941
20321
|
return typedResp;
|
|
19942
20322
|
}
|
|
19943
|
-
async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
19944
|
-
var _a, _b;
|
|
20323
|
+
async function uploadBlobInternal(file, uploadUrl, apiClient, httpOptions) {
|
|
20324
|
+
var _a, _b, _c;
|
|
20325
|
+
let finalUrl = uploadUrl;
|
|
20326
|
+
const effectiveBaseUrl = (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl) || ((_a = apiClient.clientOptions.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl);
|
|
20327
|
+
if (effectiveBaseUrl) {
|
|
20328
|
+
const baseUri = new URL(effectiveBaseUrl);
|
|
20329
|
+
const uploadUri = new URL(uploadUrl);
|
|
20330
|
+
uploadUri.protocol = baseUri.protocol;
|
|
20331
|
+
uploadUri.host = baseUri.host;
|
|
20332
|
+
uploadUri.port = baseUri.port;
|
|
20333
|
+
finalUrl = uploadUri.toString();
|
|
20334
|
+
}
|
|
19945
20335
|
let fileSize = 0;
|
|
19946
20336
|
let offset = 0;
|
|
19947
20337
|
let response = new HttpResponse(new Response());
|
|
@@ -19956,21 +20346,14 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
|
19956
20346
|
let retryCount = 0;
|
|
19957
20347
|
let currentDelayMs = INITIAL_RETRY_DELAY_MS;
|
|
19958
20348
|
while (retryCount < MAX_RETRY_COUNT) {
|
|
20349
|
+
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) });
|
|
19959
20350
|
response = await apiClient.request({
|
|
19960
20351
|
path: '',
|
|
19961
20352
|
body: chunk,
|
|
19962
20353
|
httpMethod: 'POST',
|
|
19963
|
-
httpOptions: {
|
|
19964
|
-
apiVersion: '',
|
|
19965
|
-
baseUrl: uploadUrl,
|
|
19966
|
-
headers: {
|
|
19967
|
-
'X-Goog-Upload-Command': uploadCommand,
|
|
19968
|
-
'X-Goog-Upload-Offset': String(offset),
|
|
19969
|
-
'Content-Length': String(chunkSize),
|
|
19970
|
-
},
|
|
19971
|
-
},
|
|
20354
|
+
httpOptions: Object.assign(Object.assign({}, httpOptions), { apiVersion: '', baseUrl: finalUrl, headers: mergedHeaders }),
|
|
19972
20355
|
});
|
|
19973
|
-
if ((
|
|
20356
|
+
if ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
|
|
19974
20357
|
break;
|
|
19975
20358
|
}
|
|
19976
20359
|
retryCount++;
|
|
@@ -19980,7 +20363,7 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
|
19980
20363
|
offset += chunkSize;
|
|
19981
20364
|
// The `x-goog-upload-status` header field can be `active`, `final` and
|
|
19982
20365
|
//`cancelled` in resposne.
|
|
19983
|
-
if (((
|
|
20366
|
+
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') {
|
|
19984
20367
|
break;
|
|
19985
20368
|
}
|
|
19986
20369
|
// TODO(b/401391430) Investigate why the upload status is not finalized
|
|
@@ -20017,20 +20400,20 @@ class NodeUploader {
|
|
|
20017
20400
|
return await getBlobStat(file);
|
|
20018
20401
|
}
|
|
20019
20402
|
}
|
|
20020
|
-
async upload(file, uploadUrl, apiClient) {
|
|
20403
|
+
async upload(file, uploadUrl, apiClient, httpOptions) {
|
|
20021
20404
|
if (typeof file === 'string') {
|
|
20022
|
-
return await this.uploadFileFromPath(file, uploadUrl, apiClient);
|
|
20405
|
+
return await this.uploadFileFromPath(file, uploadUrl, apiClient, httpOptions);
|
|
20023
20406
|
}
|
|
20024
20407
|
else {
|
|
20025
|
-
return uploadBlob(file, uploadUrl, apiClient);
|
|
20408
|
+
return uploadBlob(file, uploadUrl, apiClient, httpOptions);
|
|
20026
20409
|
}
|
|
20027
20410
|
}
|
|
20028
|
-
async uploadToFileSearchStore(file, uploadUrl, apiClient) {
|
|
20411
|
+
async uploadToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
|
|
20029
20412
|
if (typeof file === 'string') {
|
|
20030
|
-
return await this.uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient);
|
|
20413
|
+
return await this.uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient, httpOptions);
|
|
20031
20414
|
}
|
|
20032
20415
|
else {
|
|
20033
|
-
return uploadBlobToFileSearchStore(file, uploadUrl, apiClient);
|
|
20416
|
+
return uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions);
|
|
20034
20417
|
}
|
|
20035
20418
|
}
|
|
20036
20419
|
/**
|
|
@@ -20123,18 +20506,18 @@ class NodeUploader {
|
|
|
20123
20506
|
// Return the MIME type.
|
|
20124
20507
|
return mimeType;
|
|
20125
20508
|
}
|
|
20126
|
-
async uploadFileFromPath(file, uploadUrl, apiClient) {
|
|
20509
|
+
async uploadFileFromPath(file, uploadUrl, apiClient, httpOptions) {
|
|
20127
20510
|
var _a;
|
|
20128
|
-
const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
|
|
20511
|
+
const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions);
|
|
20129
20512
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
20130
20513
|
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') {
|
|
20131
20514
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
20132
20515
|
}
|
|
20133
20516
|
return responseJson['file'];
|
|
20134
20517
|
}
|
|
20135
|
-
async uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient) {
|
|
20518
|
+
async uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient, httpOptions) {
|
|
20136
20519
|
var _a;
|
|
20137
|
-
const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
|
|
20520
|
+
const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions);
|
|
20138
20521
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
20139
20522
|
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') {
|
|
20140
20523
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
@@ -20144,8 +20527,18 @@ class NodeUploader {
|
|
|
20144
20527
|
Object.assign(typedResp, resp);
|
|
20145
20528
|
return typedResp;
|
|
20146
20529
|
}
|
|
20147
|
-
async uploadFileFromPathInternal(file, uploadUrl, apiClient) {
|
|
20148
|
-
var _a, _b;
|
|
20530
|
+
async uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions) {
|
|
20531
|
+
var _a, _b, _c;
|
|
20532
|
+
let finalUrl = uploadUrl;
|
|
20533
|
+
const effectiveBaseUrl = (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl) || ((_a = apiClient.clientOptions.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl);
|
|
20534
|
+
if (effectiveBaseUrl) {
|
|
20535
|
+
const baseUri = new URL(effectiveBaseUrl);
|
|
20536
|
+
const uploadUri = new URL(uploadUrl);
|
|
20537
|
+
uploadUri.protocol = baseUri.protocol;
|
|
20538
|
+
uploadUri.host = baseUri.host;
|
|
20539
|
+
uploadUri.port = baseUri.port;
|
|
20540
|
+
finalUrl = uploadUri.toString();
|
|
20541
|
+
}
|
|
20149
20542
|
let fileSize = 0;
|
|
20150
20543
|
let offset = 0;
|
|
20151
20544
|
let response = new HttpResponse(new Response());
|
|
@@ -20172,22 +20565,14 @@ class NodeUploader {
|
|
|
20172
20565
|
let retryCount = 0;
|
|
20173
20566
|
let currentDelayMs = INITIAL_RETRY_DELAY_MS;
|
|
20174
20567
|
while (retryCount < MAX_RETRY_COUNT) {
|
|
20568
|
+
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(bytesRead), 'X-Goog-Upload-File-Name': fileName });
|
|
20175
20569
|
response = await apiClient.request({
|
|
20176
20570
|
path: '',
|
|
20177
20571
|
body: chunk,
|
|
20178
20572
|
httpMethod: 'POST',
|
|
20179
|
-
httpOptions: {
|
|
20180
|
-
apiVersion: '',
|
|
20181
|
-
baseUrl: uploadUrl,
|
|
20182
|
-
headers: {
|
|
20183
|
-
'X-Goog-Upload-Command': uploadCommand,
|
|
20184
|
-
'X-Goog-Upload-Offset': String(offset),
|
|
20185
|
-
'Content-Length': String(bytesRead),
|
|
20186
|
-
'X-Goog-Upload-File-Name': fileName,
|
|
20187
|
-
},
|
|
20188
|
-
},
|
|
20573
|
+
httpOptions: Object.assign(Object.assign({}, httpOptions), { apiVersion: '', baseUrl: finalUrl, headers: mergedHeaders }),
|
|
20189
20574
|
});
|
|
20190
|
-
if ((
|
|
20575
|
+
if ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
|
|
20191
20576
|
break;
|
|
20192
20577
|
}
|
|
20193
20578
|
retryCount++;
|
|
@@ -20197,7 +20582,7 @@ class NodeUploader {
|
|
|
20197
20582
|
offset += bytesRead;
|
|
20198
20583
|
// The `x-goog-upload-status` header field can be `active`, `final` and
|
|
20199
20584
|
//`cancelled` in resposne.
|
|
20200
|
-
if (((
|
|
20585
|
+
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') {
|
|
20201
20586
|
break;
|
|
20202
20587
|
}
|
|
20203
20588
|
if (fileSize <= offset) {
|
|
@@ -20437,5 +20822,5 @@ function getApiKeyFromEnv() {
|
|
|
20437
20822
|
return envGoogleApiKey || envGeminiApiKey || undefined;
|
|
20438
20823
|
}
|
|
20439
20824
|
|
|
20440
|
-
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 };
|
|
20825
|
+
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 };
|
|
20441
20826
|
//# sourceMappingURL=index.mjs.map
|