@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.cjs
CHANGED
|
@@ -616,6 +616,18 @@ function videoFromVertex$1(fromObject) {
|
|
|
616
616
|
* Copyright 2025 Google LLC
|
|
617
617
|
* SPDX-License-Identifier: Apache-2.0
|
|
618
618
|
*/
|
|
619
|
+
/** Programming language of the `code`. */
|
|
620
|
+
exports.Language = void 0;
|
|
621
|
+
(function (Language) {
|
|
622
|
+
/**
|
|
623
|
+
* Unspecified language. This value should not be used.
|
|
624
|
+
*/
|
|
625
|
+
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
626
|
+
/**
|
|
627
|
+
* Python >= 3.10, with numpy and simpy available.
|
|
628
|
+
*/
|
|
629
|
+
Language["PYTHON"] = "PYTHON";
|
|
630
|
+
})(exports.Language || (exports.Language = {}));
|
|
619
631
|
/** Outcome of the code execution. */
|
|
620
632
|
exports.Outcome = void 0;
|
|
621
633
|
(function (Outcome) {
|
|
@@ -636,18 +648,6 @@ exports.Outcome = void 0;
|
|
|
636
648
|
*/
|
|
637
649
|
Outcome["OUTCOME_DEADLINE_EXCEEDED"] = "OUTCOME_DEADLINE_EXCEEDED";
|
|
638
650
|
})(exports.Outcome || (exports.Outcome = {}));
|
|
639
|
-
/** Programming language of the `code`. */
|
|
640
|
-
exports.Language = void 0;
|
|
641
|
-
(function (Language) {
|
|
642
|
-
/**
|
|
643
|
-
* Unspecified language. This value should not be used.
|
|
644
|
-
*/
|
|
645
|
-
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
646
|
-
/**
|
|
647
|
-
* Python >= 3.10, with numpy and simpy available.
|
|
648
|
-
*/
|
|
649
|
-
Language["PYTHON"] = "PYTHON";
|
|
650
|
-
})(exports.Language || (exports.Language = {}));
|
|
651
651
|
/** Specifies how the response should be scheduled in the conversation. */
|
|
652
652
|
exports.FunctionResponseScheduling = void 0;
|
|
653
653
|
(function (FunctionResponseScheduling) {
|
|
@@ -1476,6 +1476,34 @@ exports.PartMediaResolutionLevel = void 0;
|
|
|
1476
1476
|
*/
|
|
1477
1477
|
PartMediaResolutionLevel["MEDIA_RESOLUTION_ULTRA_HIGH"] = "MEDIA_RESOLUTION_ULTRA_HIGH";
|
|
1478
1478
|
})(exports.PartMediaResolutionLevel || (exports.PartMediaResolutionLevel = {}));
|
|
1479
|
+
/** The type of tool in the function call. */
|
|
1480
|
+
exports.ToolType = void 0;
|
|
1481
|
+
(function (ToolType) {
|
|
1482
|
+
/**
|
|
1483
|
+
* Unspecified tool type.
|
|
1484
|
+
*/
|
|
1485
|
+
ToolType["TOOL_TYPE_UNSPECIFIED"] = "TOOL_TYPE_UNSPECIFIED";
|
|
1486
|
+
/**
|
|
1487
|
+
* Google search tool, maps to Tool.google_search.search_types.web_search.
|
|
1488
|
+
*/
|
|
1489
|
+
ToolType["GOOGLE_SEARCH_WEB"] = "GOOGLE_SEARCH_WEB";
|
|
1490
|
+
/**
|
|
1491
|
+
* Image search tool, maps to Tool.google_search.search_types.image_search.
|
|
1492
|
+
*/
|
|
1493
|
+
ToolType["GOOGLE_SEARCH_IMAGE"] = "GOOGLE_SEARCH_IMAGE";
|
|
1494
|
+
/**
|
|
1495
|
+
* URL context tool, maps to Tool.url_context.
|
|
1496
|
+
*/
|
|
1497
|
+
ToolType["URL_CONTEXT"] = "URL_CONTEXT";
|
|
1498
|
+
/**
|
|
1499
|
+
* Google maps tool, maps to Tool.google_maps.
|
|
1500
|
+
*/
|
|
1501
|
+
ToolType["GOOGLE_MAPS"] = "GOOGLE_MAPS";
|
|
1502
|
+
/**
|
|
1503
|
+
* File search tool, maps to Tool.file_search.
|
|
1504
|
+
*/
|
|
1505
|
+
ToolType["FILE_SEARCH"] = "FILE_SEARCH";
|
|
1506
|
+
})(exports.ToolType || (exports.ToolType = {}));
|
|
1479
1507
|
/** Resource scope. */
|
|
1480
1508
|
exports.ResourceScope = void 0;
|
|
1481
1509
|
(function (ResourceScope) {
|
|
@@ -1971,6 +1999,14 @@ exports.LiveMusicPlaybackControl = void 0;
|
|
|
1971
1999
|
*/
|
|
1972
2000
|
LiveMusicPlaybackControl["RESET_CONTEXT"] = "RESET_CONTEXT";
|
|
1973
2001
|
})(exports.LiveMusicPlaybackControl || (exports.LiveMusicPlaybackControl = {}));
|
|
2002
|
+
/** The output from a server-side `ToolCall` execution.
|
|
2003
|
+
|
|
2004
|
+
This message contains the results of a tool invocation that was initiated by a
|
|
2005
|
+
`ToolCall` from the model. The client should pass this `ToolResponse` back to
|
|
2006
|
+
the API in a subsequent turn within a `Content` message, along with the
|
|
2007
|
+
corresponding `ToolCall`. */
|
|
2008
|
+
class ToolResponse {
|
|
2009
|
+
}
|
|
1974
2010
|
/** Raw media bytes for function response.
|
|
1975
2011
|
|
|
1976
2012
|
Text should not be sent as raw bytes, use the FunctionResponse.response
|
|
@@ -4699,6 +4735,14 @@ function partToMldev$4(fromObject) {
|
|
|
4699
4735
|
if (fromVideoMetadata != null) {
|
|
4700
4736
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
4701
4737
|
}
|
|
4738
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
4739
|
+
if (fromToolCall != null) {
|
|
4740
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
4741
|
+
}
|
|
4742
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
4743
|
+
if (fromToolResponse != null) {
|
|
4744
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
4745
|
+
}
|
|
4702
4746
|
return toObject;
|
|
4703
4747
|
}
|
|
4704
4748
|
function safetySettingToMldev$1(fromObject) {
|
|
@@ -4730,6 +4774,10 @@ function toolConfigToMldev$2(fromObject) {
|
|
|
4730
4774
|
if (fromFunctionCallingConfig != null) {
|
|
4731
4775
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$2(fromFunctionCallingConfig));
|
|
4732
4776
|
}
|
|
4777
|
+
const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
|
|
4778
|
+
if (fromIncludeServerSideToolInvocations != null) {
|
|
4779
|
+
setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
|
|
4780
|
+
}
|
|
4733
4781
|
return toObject;
|
|
4734
4782
|
}
|
|
4735
4783
|
function toolToMldev$4(fromObject) {
|
|
@@ -5552,6 +5600,24 @@ function contentToMldev$3(fromObject) {
|
|
|
5552
5600
|
}
|
|
5553
5601
|
return toObject;
|
|
5554
5602
|
}
|
|
5603
|
+
function contentToVertex$2(fromObject) {
|
|
5604
|
+
const toObject = {};
|
|
5605
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5606
|
+
if (fromParts != null) {
|
|
5607
|
+
let transformedList = fromParts;
|
|
5608
|
+
if (Array.isArray(transformedList)) {
|
|
5609
|
+
transformedList = transformedList.map((item) => {
|
|
5610
|
+
return partToVertex$2(item);
|
|
5611
|
+
});
|
|
5612
|
+
}
|
|
5613
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5614
|
+
}
|
|
5615
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5616
|
+
if (fromRole != null) {
|
|
5617
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
5618
|
+
}
|
|
5619
|
+
return toObject;
|
|
5620
|
+
}
|
|
5555
5621
|
function createCachedContentConfigToMldev(fromObject, parentObject) {
|
|
5556
5622
|
const toObject = {};
|
|
5557
5623
|
const fromTtl = getValueByPath(fromObject, ['ttl']);
|
|
@@ -5620,7 +5686,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
|
|
|
5620
5686
|
let transformedList = tContents(fromContents);
|
|
5621
5687
|
if (Array.isArray(transformedList)) {
|
|
5622
5688
|
transformedList = transformedList.map((item) => {
|
|
5623
|
-
return item;
|
|
5689
|
+
return contentToVertex$2(item);
|
|
5624
5690
|
});
|
|
5625
5691
|
}
|
|
5626
5692
|
setValueByPath(parentObject, ['contents'], transformedList);
|
|
@@ -5629,7 +5695,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
|
|
|
5629
5695
|
'systemInstruction',
|
|
5630
5696
|
]);
|
|
5631
5697
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
5632
|
-
setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
|
|
5698
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex$2(tContent(fromSystemInstruction)));
|
|
5633
5699
|
}
|
|
5634
5700
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
5635
5701
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -5643,7 +5709,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
|
|
|
5643
5709
|
}
|
|
5644
5710
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
5645
5711
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
5646
|
-
setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
|
|
5712
|
+
setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex$1(fromToolConfig));
|
|
5647
5713
|
}
|
|
5648
5714
|
const fromKmsKeyName = getValueByPath(fromObject, ['kmsKeyName']);
|
|
5649
5715
|
if (parentObject !== undefined && fromKmsKeyName != null) {
|
|
@@ -6003,6 +6069,80 @@ function partToMldev$3(fromObject) {
|
|
|
6003
6069
|
if (fromVideoMetadata != null) {
|
|
6004
6070
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
6005
6071
|
}
|
|
6072
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
6073
|
+
if (fromToolCall != null) {
|
|
6074
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
6075
|
+
}
|
|
6076
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
6077
|
+
if (fromToolResponse != null) {
|
|
6078
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
6079
|
+
}
|
|
6080
|
+
return toObject;
|
|
6081
|
+
}
|
|
6082
|
+
function partToVertex$2(fromObject) {
|
|
6083
|
+
const toObject = {};
|
|
6084
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
6085
|
+
'mediaResolution',
|
|
6086
|
+
]);
|
|
6087
|
+
if (fromMediaResolution != null) {
|
|
6088
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
6089
|
+
}
|
|
6090
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
6091
|
+
'codeExecutionResult',
|
|
6092
|
+
]);
|
|
6093
|
+
if (fromCodeExecutionResult != null) {
|
|
6094
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
6095
|
+
}
|
|
6096
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
6097
|
+
'executableCode',
|
|
6098
|
+
]);
|
|
6099
|
+
if (fromExecutableCode != null) {
|
|
6100
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
6101
|
+
}
|
|
6102
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
6103
|
+
if (fromFileData != null) {
|
|
6104
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
6105
|
+
}
|
|
6106
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
6107
|
+
if (fromFunctionCall != null) {
|
|
6108
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
6109
|
+
}
|
|
6110
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
6111
|
+
'functionResponse',
|
|
6112
|
+
]);
|
|
6113
|
+
if (fromFunctionResponse != null) {
|
|
6114
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
6115
|
+
}
|
|
6116
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
6117
|
+
if (fromInlineData != null) {
|
|
6118
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
6119
|
+
}
|
|
6120
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
6121
|
+
if (fromText != null) {
|
|
6122
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
6123
|
+
}
|
|
6124
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
6125
|
+
if (fromThought != null) {
|
|
6126
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
6127
|
+
}
|
|
6128
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
6129
|
+
'thoughtSignature',
|
|
6130
|
+
]);
|
|
6131
|
+
if (fromThoughtSignature != null) {
|
|
6132
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
6133
|
+
}
|
|
6134
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
6135
|
+
'videoMetadata',
|
|
6136
|
+
]);
|
|
6137
|
+
if (fromVideoMetadata != null) {
|
|
6138
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
6139
|
+
}
|
|
6140
|
+
if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
|
|
6141
|
+
throw new Error('toolCall parameter is not supported in Vertex AI.');
|
|
6142
|
+
}
|
|
6143
|
+
if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
|
|
6144
|
+
throw new Error('toolResponse parameter is not supported in Vertex AI.');
|
|
6145
|
+
}
|
|
6006
6146
|
return toObject;
|
|
6007
6147
|
}
|
|
6008
6148
|
function toolConfigToMldev$1(fromObject) {
|
|
@@ -6019,6 +6159,30 @@ function toolConfigToMldev$1(fromObject) {
|
|
|
6019
6159
|
if (fromFunctionCallingConfig != null) {
|
|
6020
6160
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(fromFunctionCallingConfig));
|
|
6021
6161
|
}
|
|
6162
|
+
const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
|
|
6163
|
+
if (fromIncludeServerSideToolInvocations != null) {
|
|
6164
|
+
setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
|
|
6165
|
+
}
|
|
6166
|
+
return toObject;
|
|
6167
|
+
}
|
|
6168
|
+
function toolConfigToVertex$1(fromObject) {
|
|
6169
|
+
const toObject = {};
|
|
6170
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
6171
|
+
'retrievalConfig',
|
|
6172
|
+
]);
|
|
6173
|
+
if (fromRetrievalConfig != null) {
|
|
6174
|
+
setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
|
|
6175
|
+
}
|
|
6176
|
+
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
6177
|
+
'functionCallingConfig',
|
|
6178
|
+
]);
|
|
6179
|
+
if (fromFunctionCallingConfig != null) {
|
|
6180
|
+
setValueByPath(toObject, ['functionCallingConfig'], fromFunctionCallingConfig);
|
|
6181
|
+
}
|
|
6182
|
+
if (getValueByPath(fromObject, ['includeServerSideToolInvocations']) !==
|
|
6183
|
+
undefined) {
|
|
6184
|
+
throw new Error('includeServerSideToolInvocations parameter is not supported in Vertex AI.');
|
|
6185
|
+
}
|
|
6022
6186
|
return toObject;
|
|
6023
6187
|
}
|
|
6024
6188
|
function toolToMldev$3(fromObject) {
|
|
@@ -7506,6 +7670,24 @@ function contentToMldev$2(fromObject) {
|
|
|
7506
7670
|
}
|
|
7507
7671
|
return toObject;
|
|
7508
7672
|
}
|
|
7673
|
+
function contentToVertex$1(fromObject) {
|
|
7674
|
+
const toObject = {};
|
|
7675
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
7676
|
+
if (fromParts != null) {
|
|
7677
|
+
let transformedList = fromParts;
|
|
7678
|
+
if (Array.isArray(transformedList)) {
|
|
7679
|
+
transformedList = transformedList.map((item) => {
|
|
7680
|
+
return partToVertex$1(item);
|
|
7681
|
+
});
|
|
7682
|
+
}
|
|
7683
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
7684
|
+
}
|
|
7685
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
7686
|
+
if (fromRole != null) {
|
|
7687
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
7688
|
+
}
|
|
7689
|
+
return toObject;
|
|
7690
|
+
}
|
|
7509
7691
|
function fileDataToMldev$2(fromObject) {
|
|
7510
7692
|
const toObject = {};
|
|
7511
7693
|
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
@@ -7913,7 +8095,7 @@ function liveConnectConfigToVertex(fromObject, parentObject) {
|
|
|
7913
8095
|
'systemInstruction',
|
|
7914
8096
|
]);
|
|
7915
8097
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
7916
|
-
setValueByPath(parentObject, ['setup', 'systemInstruction'], tContent(fromSystemInstruction));
|
|
8098
|
+
setValueByPath(parentObject, ['setup', 'systemInstruction'], contentToVertex$1(tContent(fromSystemInstruction)));
|
|
7917
8099
|
}
|
|
7918
8100
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
7919
8101
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -8213,6 +8395,80 @@ function partToMldev$2(fromObject) {
|
|
|
8213
8395
|
if (fromVideoMetadata != null) {
|
|
8214
8396
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
8215
8397
|
}
|
|
8398
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
8399
|
+
if (fromToolCall != null) {
|
|
8400
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
8401
|
+
}
|
|
8402
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
8403
|
+
if (fromToolResponse != null) {
|
|
8404
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
8405
|
+
}
|
|
8406
|
+
return toObject;
|
|
8407
|
+
}
|
|
8408
|
+
function partToVertex$1(fromObject) {
|
|
8409
|
+
const toObject = {};
|
|
8410
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
8411
|
+
'mediaResolution',
|
|
8412
|
+
]);
|
|
8413
|
+
if (fromMediaResolution != null) {
|
|
8414
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
8415
|
+
}
|
|
8416
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
8417
|
+
'codeExecutionResult',
|
|
8418
|
+
]);
|
|
8419
|
+
if (fromCodeExecutionResult != null) {
|
|
8420
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
8421
|
+
}
|
|
8422
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
8423
|
+
'executableCode',
|
|
8424
|
+
]);
|
|
8425
|
+
if (fromExecutableCode != null) {
|
|
8426
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
8427
|
+
}
|
|
8428
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
8429
|
+
if (fromFileData != null) {
|
|
8430
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
8431
|
+
}
|
|
8432
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
8433
|
+
if (fromFunctionCall != null) {
|
|
8434
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
8435
|
+
}
|
|
8436
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
8437
|
+
'functionResponse',
|
|
8438
|
+
]);
|
|
8439
|
+
if (fromFunctionResponse != null) {
|
|
8440
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
8441
|
+
}
|
|
8442
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
8443
|
+
if (fromInlineData != null) {
|
|
8444
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
8445
|
+
}
|
|
8446
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
8447
|
+
if (fromText != null) {
|
|
8448
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
8449
|
+
}
|
|
8450
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
8451
|
+
if (fromThought != null) {
|
|
8452
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
8453
|
+
}
|
|
8454
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
8455
|
+
'thoughtSignature',
|
|
8456
|
+
]);
|
|
8457
|
+
if (fromThoughtSignature != null) {
|
|
8458
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
8459
|
+
}
|
|
8460
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
8461
|
+
'videoMetadata',
|
|
8462
|
+
]);
|
|
8463
|
+
if (fromVideoMetadata != null) {
|
|
8464
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
8465
|
+
}
|
|
8466
|
+
if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
|
|
8467
|
+
throw new Error('toolCall parameter is not supported in Vertex AI.');
|
|
8468
|
+
}
|
|
8469
|
+
if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
|
|
8470
|
+
throw new Error('toolResponse parameter is not supported in Vertex AI.');
|
|
8471
|
+
}
|
|
8216
8472
|
return toObject;
|
|
8217
8473
|
}
|
|
8218
8474
|
function sessionResumptionConfigToMldev$1(fromObject) {
|
|
@@ -8581,7 +8837,7 @@ function citationMetadataFromMldev(fromObject, _rootObject) {
|
|
|
8581
8837
|
}
|
|
8582
8838
|
return toObject;
|
|
8583
8839
|
}
|
|
8584
|
-
function computeTokensParametersToVertex(apiClient, fromObject,
|
|
8840
|
+
function computeTokensParametersToVertex(apiClient, fromObject, rootObject) {
|
|
8585
8841
|
const toObject = {};
|
|
8586
8842
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
8587
8843
|
if (fromModel != null) {
|
|
@@ -8592,7 +8848,7 @@ function computeTokensParametersToVertex(apiClient, fromObject, _rootObject) {
|
|
|
8592
8848
|
let transformedList = tContents(fromContents);
|
|
8593
8849
|
if (Array.isArray(transformedList)) {
|
|
8594
8850
|
transformedList = transformedList.map((item) => {
|
|
8595
|
-
return item;
|
|
8851
|
+
return contentToVertex(item);
|
|
8596
8852
|
});
|
|
8597
8853
|
}
|
|
8598
8854
|
setValueByPath(toObject, ['contents'], transformedList);
|
|
@@ -8661,6 +8917,24 @@ function contentToMldev$1(fromObject, rootObject) {
|
|
|
8661
8917
|
}
|
|
8662
8918
|
return toObject;
|
|
8663
8919
|
}
|
|
8920
|
+
function contentToVertex(fromObject, rootObject) {
|
|
8921
|
+
const toObject = {};
|
|
8922
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
8923
|
+
if (fromParts != null) {
|
|
8924
|
+
let transformedList = fromParts;
|
|
8925
|
+
if (Array.isArray(transformedList)) {
|
|
8926
|
+
transformedList = transformedList.map((item) => {
|
|
8927
|
+
return partToVertex(item);
|
|
8928
|
+
});
|
|
8929
|
+
}
|
|
8930
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
8931
|
+
}
|
|
8932
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
8933
|
+
if (fromRole != null) {
|
|
8934
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
8935
|
+
}
|
|
8936
|
+
return toObject;
|
|
8937
|
+
}
|
|
8664
8938
|
function controlReferenceConfigToVertex(fromObject, _rootObject) {
|
|
8665
8939
|
const toObject = {};
|
|
8666
8940
|
const fromControlType = getValueByPath(fromObject, ['controlType']);
|
|
@@ -8694,7 +8968,7 @@ function countTokensConfigToVertex(fromObject, parentObject, rootObject) {
|
|
|
8694
8968
|
'systemInstruction',
|
|
8695
8969
|
]);
|
|
8696
8970
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
8697
|
-
setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
|
|
8971
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
|
|
8698
8972
|
}
|
|
8699
8973
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
8700
8974
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -8747,7 +9021,7 @@ function countTokensParametersToVertex(apiClient, fromObject, rootObject) {
|
|
|
8747
9021
|
let transformedList = tContents(fromContents);
|
|
8748
9022
|
if (Array.isArray(transformedList)) {
|
|
8749
9023
|
transformedList = transformedList.map((item) => {
|
|
8750
|
-
return item;
|
|
9024
|
+
return contentToVertex(item);
|
|
8751
9025
|
});
|
|
8752
9026
|
}
|
|
8753
9027
|
setValueByPath(toObject, ['contents'], transformedList);
|
|
@@ -9151,7 +9425,7 @@ function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject
|
|
|
9151
9425
|
if (discriminatorContent === 'EMBED_CONTENT') {
|
|
9152
9426
|
const fromContent = getValueByPath(fromObject, ['content']);
|
|
9153
9427
|
if (fromContent != null) {
|
|
9154
|
-
setValueByPath(toObject, ['content'], tContent(fromContent));
|
|
9428
|
+
setValueByPath(toObject, ['content'], contentToVertex(tContent(fromContent)));
|
|
9155
9429
|
}
|
|
9156
9430
|
}
|
|
9157
9431
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
@@ -9502,7 +9776,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
|
|
|
9502
9776
|
'systemInstruction',
|
|
9503
9777
|
]);
|
|
9504
9778
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
9505
|
-
setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
|
|
9779
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
|
|
9506
9780
|
}
|
|
9507
9781
|
const fromTemperature = getValueByPath(fromObject, ['temperature']);
|
|
9508
9782
|
if (fromTemperature != null) {
|
|
@@ -9614,7 +9888,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
|
|
|
9614
9888
|
}
|
|
9615
9889
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
9616
9890
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
9617
|
-
setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
|
|
9891
|
+
setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex(fromToolConfig));
|
|
9618
9892
|
}
|
|
9619
9893
|
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9620
9894
|
if (parentObject !== undefined && fromLabels != null) {
|
|
@@ -9703,7 +9977,7 @@ function generateContentParametersToVertex(apiClient, fromObject, rootObject) {
|
|
|
9703
9977
|
let transformedList = tContents(fromContents);
|
|
9704
9978
|
if (Array.isArray(transformedList)) {
|
|
9705
9979
|
transformedList = transformedList.map((item) => {
|
|
9706
|
-
return item;
|
|
9980
|
+
return contentToVertex(item);
|
|
9707
9981
|
});
|
|
9708
9982
|
}
|
|
9709
9983
|
setValueByPath(toObject, ['contents'], transformedList);
|
|
@@ -11107,6 +11381,80 @@ function partToMldev$1(fromObject, rootObject) {
|
|
|
11107
11381
|
if (fromVideoMetadata != null) {
|
|
11108
11382
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
11109
11383
|
}
|
|
11384
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
11385
|
+
if (fromToolCall != null) {
|
|
11386
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
11387
|
+
}
|
|
11388
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
11389
|
+
if (fromToolResponse != null) {
|
|
11390
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
11391
|
+
}
|
|
11392
|
+
return toObject;
|
|
11393
|
+
}
|
|
11394
|
+
function partToVertex(fromObject, _rootObject) {
|
|
11395
|
+
const toObject = {};
|
|
11396
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
11397
|
+
'mediaResolution',
|
|
11398
|
+
]);
|
|
11399
|
+
if (fromMediaResolution != null) {
|
|
11400
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
11401
|
+
}
|
|
11402
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
11403
|
+
'codeExecutionResult',
|
|
11404
|
+
]);
|
|
11405
|
+
if (fromCodeExecutionResult != null) {
|
|
11406
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
11407
|
+
}
|
|
11408
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
11409
|
+
'executableCode',
|
|
11410
|
+
]);
|
|
11411
|
+
if (fromExecutableCode != null) {
|
|
11412
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
11413
|
+
}
|
|
11414
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
11415
|
+
if (fromFileData != null) {
|
|
11416
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
11417
|
+
}
|
|
11418
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
11419
|
+
if (fromFunctionCall != null) {
|
|
11420
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
11421
|
+
}
|
|
11422
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
11423
|
+
'functionResponse',
|
|
11424
|
+
]);
|
|
11425
|
+
if (fromFunctionResponse != null) {
|
|
11426
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
11427
|
+
}
|
|
11428
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
11429
|
+
if (fromInlineData != null) {
|
|
11430
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
11431
|
+
}
|
|
11432
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
11433
|
+
if (fromText != null) {
|
|
11434
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
11435
|
+
}
|
|
11436
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
11437
|
+
if (fromThought != null) {
|
|
11438
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
11439
|
+
}
|
|
11440
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
11441
|
+
'thoughtSignature',
|
|
11442
|
+
]);
|
|
11443
|
+
if (fromThoughtSignature != null) {
|
|
11444
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
11445
|
+
}
|
|
11446
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
11447
|
+
'videoMetadata',
|
|
11448
|
+
]);
|
|
11449
|
+
if (fromVideoMetadata != null) {
|
|
11450
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
11451
|
+
}
|
|
11452
|
+
if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
|
|
11453
|
+
throw new Error('toolCall parameter is not supported in Vertex AI.');
|
|
11454
|
+
}
|
|
11455
|
+
if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
|
|
11456
|
+
throw new Error('toolResponse parameter is not supported in Vertex AI.');
|
|
11457
|
+
}
|
|
11110
11458
|
return toObject;
|
|
11111
11459
|
}
|
|
11112
11460
|
function productImageToVertex(fromObject, rootObject) {
|
|
@@ -11440,6 +11788,30 @@ function toolConfigToMldev(fromObject, rootObject) {
|
|
|
11440
11788
|
if (fromFunctionCallingConfig != null) {
|
|
11441
11789
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(fromFunctionCallingConfig));
|
|
11442
11790
|
}
|
|
11791
|
+
const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
|
|
11792
|
+
if (fromIncludeServerSideToolInvocations != null) {
|
|
11793
|
+
setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
|
|
11794
|
+
}
|
|
11795
|
+
return toObject;
|
|
11796
|
+
}
|
|
11797
|
+
function toolConfigToVertex(fromObject, _rootObject) {
|
|
11798
|
+
const toObject = {};
|
|
11799
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
11800
|
+
'retrievalConfig',
|
|
11801
|
+
]);
|
|
11802
|
+
if (fromRetrievalConfig != null) {
|
|
11803
|
+
setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
|
|
11804
|
+
}
|
|
11805
|
+
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
11806
|
+
'functionCallingConfig',
|
|
11807
|
+
]);
|
|
11808
|
+
if (fromFunctionCallingConfig != null) {
|
|
11809
|
+
setValueByPath(toObject, ['functionCallingConfig'], fromFunctionCallingConfig);
|
|
11810
|
+
}
|
|
11811
|
+
if (getValueByPath(fromObject, ['includeServerSideToolInvocations']) !==
|
|
11812
|
+
undefined) {
|
|
11813
|
+
throw new Error('includeServerSideToolInvocations parameter is not supported in Vertex AI.');
|
|
11814
|
+
}
|
|
11443
11815
|
return toObject;
|
|
11444
11816
|
}
|
|
11445
11817
|
function toolToMldev$1(fromObject, rootObject) {
|
|
@@ -12129,7 +12501,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12129
12501
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12130
12502
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12131
12503
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12132
|
-
const SDK_VERSION = '1.
|
|
12504
|
+
const SDK_VERSION = '1.46.0'; // x-release-please-version
|
|
12133
12505
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12134
12506
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12135
12507
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13488,7 +13860,7 @@ class Session {
|
|
|
13488
13860
|
}
|
|
13489
13861
|
}
|
|
13490
13862
|
const clientMessage = {
|
|
13491
|
-
toolResponse: { functionResponses: functionResponses },
|
|
13863
|
+
toolResponse: { 'functionResponses': functionResponses },
|
|
13492
13864
|
};
|
|
13493
13865
|
return clientMessage;
|
|
13494
13866
|
}
|
|
@@ -15818,6 +16190,14 @@ function partToMldev(fromObject) {
|
|
|
15818
16190
|
if (fromVideoMetadata != null) {
|
|
15819
16191
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
15820
16192
|
}
|
|
16193
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
16194
|
+
if (fromToolCall != null) {
|
|
16195
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
16196
|
+
}
|
|
16197
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
16198
|
+
if (fromToolResponse != null) {
|
|
16199
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
16200
|
+
}
|
|
15821
16201
|
return toObject;
|
|
15822
16202
|
}
|
|
15823
16203
|
function sessionResumptionConfigToMldev(fromObject) {
|
|
@@ -19941,18 +20321,18 @@ const MAX_RETRY_COUNT = 3;
|
|
|
19941
20321
|
const INITIAL_RETRY_DELAY_MS = 1000;
|
|
19942
20322
|
const DELAY_MULTIPLIER = 2;
|
|
19943
20323
|
const X_GOOG_UPLOAD_STATUS_HEADER_FIELD = 'x-goog-upload-status';
|
|
19944
|
-
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
20324
|
+
async function uploadBlob(file, uploadUrl, apiClient, httpOptions) {
|
|
19945
20325
|
var _a;
|
|
19946
|
-
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
20326
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
|
|
19947
20327
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
19948
20328
|
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') {
|
|
19949
20329
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
19950
20330
|
}
|
|
19951
20331
|
return responseJson['file'];
|
|
19952
20332
|
}
|
|
19953
|
-
async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
|
|
20333
|
+
async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
|
|
19954
20334
|
var _a;
|
|
19955
|
-
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
20335
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
|
|
19956
20336
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
19957
20337
|
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') {
|
|
19958
20338
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
@@ -19962,8 +20342,18 @@ async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
|
|
|
19962
20342
|
Object.assign(typedResp, resp);
|
|
19963
20343
|
return typedResp;
|
|
19964
20344
|
}
|
|
19965
|
-
async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
19966
|
-
var _a, _b;
|
|
20345
|
+
async function uploadBlobInternal(file, uploadUrl, apiClient, httpOptions) {
|
|
20346
|
+
var _a, _b, _c;
|
|
20347
|
+
let finalUrl = uploadUrl;
|
|
20348
|
+
const effectiveBaseUrl = (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl) || ((_a = apiClient.clientOptions.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl);
|
|
20349
|
+
if (effectiveBaseUrl) {
|
|
20350
|
+
const baseUri = new URL(effectiveBaseUrl);
|
|
20351
|
+
const uploadUri = new URL(uploadUrl);
|
|
20352
|
+
uploadUri.protocol = baseUri.protocol;
|
|
20353
|
+
uploadUri.host = baseUri.host;
|
|
20354
|
+
uploadUri.port = baseUri.port;
|
|
20355
|
+
finalUrl = uploadUri.toString();
|
|
20356
|
+
}
|
|
19967
20357
|
let fileSize = 0;
|
|
19968
20358
|
let offset = 0;
|
|
19969
20359
|
let response = new HttpResponse(new Response());
|
|
@@ -19978,21 +20368,14 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
|
19978
20368
|
let retryCount = 0;
|
|
19979
20369
|
let currentDelayMs = INITIAL_RETRY_DELAY_MS;
|
|
19980
20370
|
while (retryCount < MAX_RETRY_COUNT) {
|
|
20371
|
+
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) });
|
|
19981
20372
|
response = await apiClient.request({
|
|
19982
20373
|
path: '',
|
|
19983
20374
|
body: chunk,
|
|
19984
20375
|
httpMethod: 'POST',
|
|
19985
|
-
httpOptions: {
|
|
19986
|
-
apiVersion: '',
|
|
19987
|
-
baseUrl: uploadUrl,
|
|
19988
|
-
headers: {
|
|
19989
|
-
'X-Goog-Upload-Command': uploadCommand,
|
|
19990
|
-
'X-Goog-Upload-Offset': String(offset),
|
|
19991
|
-
'Content-Length': String(chunkSize),
|
|
19992
|
-
},
|
|
19993
|
-
},
|
|
20376
|
+
httpOptions: Object.assign(Object.assign({}, httpOptions), { apiVersion: '', baseUrl: finalUrl, headers: mergedHeaders }),
|
|
19994
20377
|
});
|
|
19995
|
-
if ((
|
|
20378
|
+
if ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
|
|
19996
20379
|
break;
|
|
19997
20380
|
}
|
|
19998
20381
|
retryCount++;
|
|
@@ -20002,7 +20385,7 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
|
20002
20385
|
offset += chunkSize;
|
|
20003
20386
|
// The `x-goog-upload-status` header field can be `active`, `final` and
|
|
20004
20387
|
//`cancelled` in resposne.
|
|
20005
|
-
if (((
|
|
20388
|
+
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') {
|
|
20006
20389
|
break;
|
|
20007
20390
|
}
|
|
20008
20391
|
// TODO(b/401391430) Investigate why the upload status is not finalized
|
|
@@ -20039,20 +20422,20 @@ class NodeUploader {
|
|
|
20039
20422
|
return await getBlobStat(file);
|
|
20040
20423
|
}
|
|
20041
20424
|
}
|
|
20042
|
-
async upload(file, uploadUrl, apiClient) {
|
|
20425
|
+
async upload(file, uploadUrl, apiClient, httpOptions) {
|
|
20043
20426
|
if (typeof file === 'string') {
|
|
20044
|
-
return await this.uploadFileFromPath(file, uploadUrl, apiClient);
|
|
20427
|
+
return await this.uploadFileFromPath(file, uploadUrl, apiClient, httpOptions);
|
|
20045
20428
|
}
|
|
20046
20429
|
else {
|
|
20047
|
-
return uploadBlob(file, uploadUrl, apiClient);
|
|
20430
|
+
return uploadBlob(file, uploadUrl, apiClient, httpOptions);
|
|
20048
20431
|
}
|
|
20049
20432
|
}
|
|
20050
|
-
async uploadToFileSearchStore(file, uploadUrl, apiClient) {
|
|
20433
|
+
async uploadToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
|
|
20051
20434
|
if (typeof file === 'string') {
|
|
20052
|
-
return await this.uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient);
|
|
20435
|
+
return await this.uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient, httpOptions);
|
|
20053
20436
|
}
|
|
20054
20437
|
else {
|
|
20055
|
-
return uploadBlobToFileSearchStore(file, uploadUrl, apiClient);
|
|
20438
|
+
return uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions);
|
|
20056
20439
|
}
|
|
20057
20440
|
}
|
|
20058
20441
|
/**
|
|
@@ -20145,18 +20528,18 @@ class NodeUploader {
|
|
|
20145
20528
|
// Return the MIME type.
|
|
20146
20529
|
return mimeType;
|
|
20147
20530
|
}
|
|
20148
|
-
async uploadFileFromPath(file, uploadUrl, apiClient) {
|
|
20531
|
+
async uploadFileFromPath(file, uploadUrl, apiClient, httpOptions) {
|
|
20149
20532
|
var _a;
|
|
20150
|
-
const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
|
|
20533
|
+
const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions);
|
|
20151
20534
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
20152
20535
|
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') {
|
|
20153
20536
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
20154
20537
|
}
|
|
20155
20538
|
return responseJson['file'];
|
|
20156
20539
|
}
|
|
20157
|
-
async uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient) {
|
|
20540
|
+
async uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient, httpOptions) {
|
|
20158
20541
|
var _a;
|
|
20159
|
-
const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
|
|
20542
|
+
const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions);
|
|
20160
20543
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
20161
20544
|
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') {
|
|
20162
20545
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
@@ -20166,8 +20549,18 @@ class NodeUploader {
|
|
|
20166
20549
|
Object.assign(typedResp, resp);
|
|
20167
20550
|
return typedResp;
|
|
20168
20551
|
}
|
|
20169
|
-
async uploadFileFromPathInternal(file, uploadUrl, apiClient) {
|
|
20170
|
-
var _a, _b;
|
|
20552
|
+
async uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions) {
|
|
20553
|
+
var _a, _b, _c;
|
|
20554
|
+
let finalUrl = uploadUrl;
|
|
20555
|
+
const effectiveBaseUrl = (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl) || ((_a = apiClient.clientOptions.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl);
|
|
20556
|
+
if (effectiveBaseUrl) {
|
|
20557
|
+
const baseUri = new URL(effectiveBaseUrl);
|
|
20558
|
+
const uploadUri = new URL(uploadUrl);
|
|
20559
|
+
uploadUri.protocol = baseUri.protocol;
|
|
20560
|
+
uploadUri.host = baseUri.host;
|
|
20561
|
+
uploadUri.port = baseUri.port;
|
|
20562
|
+
finalUrl = uploadUri.toString();
|
|
20563
|
+
}
|
|
20171
20564
|
let fileSize = 0;
|
|
20172
20565
|
let offset = 0;
|
|
20173
20566
|
let response = new HttpResponse(new Response());
|
|
@@ -20194,22 +20587,14 @@ class NodeUploader {
|
|
|
20194
20587
|
let retryCount = 0;
|
|
20195
20588
|
let currentDelayMs = INITIAL_RETRY_DELAY_MS;
|
|
20196
20589
|
while (retryCount < MAX_RETRY_COUNT) {
|
|
20590
|
+
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 });
|
|
20197
20591
|
response = await apiClient.request({
|
|
20198
20592
|
path: '',
|
|
20199
20593
|
body: chunk,
|
|
20200
20594
|
httpMethod: 'POST',
|
|
20201
|
-
httpOptions: {
|
|
20202
|
-
apiVersion: '',
|
|
20203
|
-
baseUrl: uploadUrl,
|
|
20204
|
-
headers: {
|
|
20205
|
-
'X-Goog-Upload-Command': uploadCommand,
|
|
20206
|
-
'X-Goog-Upload-Offset': String(offset),
|
|
20207
|
-
'Content-Length': String(bytesRead),
|
|
20208
|
-
'X-Goog-Upload-File-Name': fileName,
|
|
20209
|
-
},
|
|
20210
|
-
},
|
|
20595
|
+
httpOptions: Object.assign(Object.assign({}, httpOptions), { apiVersion: '', baseUrl: finalUrl, headers: mergedHeaders }),
|
|
20211
20596
|
});
|
|
20212
|
-
if ((
|
|
20597
|
+
if ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
|
|
20213
20598
|
break;
|
|
20214
20599
|
}
|
|
20215
20600
|
retryCount++;
|
|
@@ -20219,7 +20604,7 @@ class NodeUploader {
|
|
|
20219
20604
|
offset += bytesRead;
|
|
20220
20605
|
// The `x-goog-upload-status` header field can be `active`, `final` and
|
|
20221
20606
|
//`cancelled` in resposne.
|
|
20222
|
-
if (((
|
|
20607
|
+
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') {
|
|
20223
20608
|
break;
|
|
20224
20609
|
}
|
|
20225
20610
|
if (fileSize <= offset) {
|
|
@@ -20519,6 +20904,7 @@ exports.SingleEmbedContentResponse = SingleEmbedContentResponse;
|
|
|
20519
20904
|
exports.StyleReferenceImage = StyleReferenceImage;
|
|
20520
20905
|
exports.SubjectReferenceImage = SubjectReferenceImage;
|
|
20521
20906
|
exports.Tokens = Tokens;
|
|
20907
|
+
exports.ToolResponse = ToolResponse;
|
|
20522
20908
|
exports.UploadToFileSearchStoreOperation = UploadToFileSearchStoreOperation;
|
|
20523
20909
|
exports.UploadToFileSearchStoreResponse = UploadToFileSearchStoreResponse;
|
|
20524
20910
|
exports.UploadToFileSearchStoreResumableResponse = UploadToFileSearchStoreResumableResponse;
|