@google/genai 1.44.0 → 1.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/genai.d.ts +401 -125
- package/dist/index.cjs +480 -68
- package/dist/index.mjs +480 -69
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +502 -88
- package/dist/node/index.mjs +502 -89
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +401 -125
- package/dist/tokenizer/node.cjs +40 -12
- package/dist/tokenizer/node.d.ts +74 -2
- package/dist/tokenizer/node.mjs +40 -12
- package/dist/tokenizer/node.mjs.map +1 -1
- package/dist/vertex_internal/index.cjs +3013 -0
- package/dist/vertex_internal/index.cjs.map +1 -0
- package/dist/vertex_internal/index.d.ts +8038 -0
- package/dist/vertex_internal/index.js +2984 -0
- package/dist/vertex_internal/index.js.map +1 -0
- package/dist/web/index.mjs +480 -69
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +401 -125
- package/package.json +10 -2
package/dist/index.cjs
CHANGED
|
@@ -558,6 +558,18 @@ function videoFromVertex$1(fromObject) {
|
|
|
558
558
|
* Copyright 2025 Google LLC
|
|
559
559
|
* SPDX-License-Identifier: Apache-2.0
|
|
560
560
|
*/
|
|
561
|
+
/** Programming language of the `code`. */
|
|
562
|
+
exports.Language = void 0;
|
|
563
|
+
(function (Language) {
|
|
564
|
+
/**
|
|
565
|
+
* Unspecified language. This value should not be used.
|
|
566
|
+
*/
|
|
567
|
+
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
568
|
+
/**
|
|
569
|
+
* Python >= 3.10, with numpy and simpy available.
|
|
570
|
+
*/
|
|
571
|
+
Language["PYTHON"] = "PYTHON";
|
|
572
|
+
})(exports.Language || (exports.Language = {}));
|
|
561
573
|
/** Outcome of the code execution. */
|
|
562
574
|
exports.Outcome = void 0;
|
|
563
575
|
(function (Outcome) {
|
|
@@ -578,18 +590,6 @@ exports.Outcome = void 0;
|
|
|
578
590
|
*/
|
|
579
591
|
Outcome["OUTCOME_DEADLINE_EXCEEDED"] = "OUTCOME_DEADLINE_EXCEEDED";
|
|
580
592
|
})(exports.Outcome || (exports.Outcome = {}));
|
|
581
|
-
/** Programming language of the `code`. */
|
|
582
|
-
exports.Language = void 0;
|
|
583
|
-
(function (Language) {
|
|
584
|
-
/**
|
|
585
|
-
* Unspecified language. This value should not be used.
|
|
586
|
-
*/
|
|
587
|
-
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
588
|
-
/**
|
|
589
|
-
* Python >= 3.10, with numpy and simpy available.
|
|
590
|
-
*/
|
|
591
|
-
Language["PYTHON"] = "PYTHON";
|
|
592
|
-
})(exports.Language || (exports.Language = {}));
|
|
593
593
|
/** Specifies how the response should be scheduled in the conversation. */
|
|
594
594
|
exports.FunctionResponseScheduling = void 0;
|
|
595
595
|
(function (FunctionResponseScheduling) {
|
|
@@ -1418,6 +1418,34 @@ exports.PartMediaResolutionLevel = void 0;
|
|
|
1418
1418
|
*/
|
|
1419
1419
|
PartMediaResolutionLevel["MEDIA_RESOLUTION_ULTRA_HIGH"] = "MEDIA_RESOLUTION_ULTRA_HIGH";
|
|
1420
1420
|
})(exports.PartMediaResolutionLevel || (exports.PartMediaResolutionLevel = {}));
|
|
1421
|
+
/** The type of tool in the function call. */
|
|
1422
|
+
exports.ToolType = void 0;
|
|
1423
|
+
(function (ToolType) {
|
|
1424
|
+
/**
|
|
1425
|
+
* Unspecified tool type.
|
|
1426
|
+
*/
|
|
1427
|
+
ToolType["TOOL_TYPE_UNSPECIFIED"] = "TOOL_TYPE_UNSPECIFIED";
|
|
1428
|
+
/**
|
|
1429
|
+
* Google search tool, maps to Tool.google_search.search_types.web_search.
|
|
1430
|
+
*/
|
|
1431
|
+
ToolType["GOOGLE_SEARCH_WEB"] = "GOOGLE_SEARCH_WEB";
|
|
1432
|
+
/**
|
|
1433
|
+
* Image search tool, maps to Tool.google_search.search_types.image_search.
|
|
1434
|
+
*/
|
|
1435
|
+
ToolType["GOOGLE_SEARCH_IMAGE"] = "GOOGLE_SEARCH_IMAGE";
|
|
1436
|
+
/**
|
|
1437
|
+
* URL context tool, maps to Tool.url_context.
|
|
1438
|
+
*/
|
|
1439
|
+
ToolType["URL_CONTEXT"] = "URL_CONTEXT";
|
|
1440
|
+
/**
|
|
1441
|
+
* Google maps tool, maps to Tool.google_maps.
|
|
1442
|
+
*/
|
|
1443
|
+
ToolType["GOOGLE_MAPS"] = "GOOGLE_MAPS";
|
|
1444
|
+
/**
|
|
1445
|
+
* File search tool, maps to Tool.file_search.
|
|
1446
|
+
*/
|
|
1447
|
+
ToolType["FILE_SEARCH"] = "FILE_SEARCH";
|
|
1448
|
+
})(exports.ToolType || (exports.ToolType = {}));
|
|
1421
1449
|
/** Resource scope. */
|
|
1422
1450
|
exports.ResourceScope = void 0;
|
|
1423
1451
|
(function (ResourceScope) {
|
|
@@ -1913,6 +1941,14 @@ exports.LiveMusicPlaybackControl = void 0;
|
|
|
1913
1941
|
*/
|
|
1914
1942
|
LiveMusicPlaybackControl["RESET_CONTEXT"] = "RESET_CONTEXT";
|
|
1915
1943
|
})(exports.LiveMusicPlaybackControl || (exports.LiveMusicPlaybackControl = {}));
|
|
1944
|
+
/** The output from a server-side `ToolCall` execution.
|
|
1945
|
+
|
|
1946
|
+
This message contains the results of a tool invocation that was initiated by a
|
|
1947
|
+
`ToolCall` from the model. The client should pass this `ToolResponse` back to
|
|
1948
|
+
the API in a subsequent turn within a `Content` message, along with the
|
|
1949
|
+
corresponding `ToolCall`. */
|
|
1950
|
+
class ToolResponse {
|
|
1951
|
+
}
|
|
1916
1952
|
/** Raw media bytes for function response.
|
|
1917
1953
|
|
|
1918
1954
|
Text should not be sent as raw bytes, use the FunctionResponse.response
|
|
@@ -4641,6 +4677,14 @@ function partToMldev$4(fromObject) {
|
|
|
4641
4677
|
if (fromVideoMetadata != null) {
|
|
4642
4678
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
4643
4679
|
}
|
|
4680
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
4681
|
+
if (fromToolCall != null) {
|
|
4682
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
4683
|
+
}
|
|
4684
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
4685
|
+
if (fromToolResponse != null) {
|
|
4686
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
4687
|
+
}
|
|
4644
4688
|
return toObject;
|
|
4645
4689
|
}
|
|
4646
4690
|
function safetySettingToMldev$1(fromObject) {
|
|
@@ -4672,6 +4716,10 @@ function toolConfigToMldev$2(fromObject) {
|
|
|
4672
4716
|
if (fromFunctionCallingConfig != null) {
|
|
4673
4717
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$2(fromFunctionCallingConfig));
|
|
4674
4718
|
}
|
|
4719
|
+
const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
|
|
4720
|
+
if (fromIncludeServerSideToolInvocations != null) {
|
|
4721
|
+
setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
|
|
4722
|
+
}
|
|
4675
4723
|
return toObject;
|
|
4676
4724
|
}
|
|
4677
4725
|
function toolToMldev$4(fromObject) {
|
|
@@ -5494,6 +5542,24 @@ function contentToMldev$3(fromObject) {
|
|
|
5494
5542
|
}
|
|
5495
5543
|
return toObject;
|
|
5496
5544
|
}
|
|
5545
|
+
function contentToVertex$2(fromObject) {
|
|
5546
|
+
const toObject = {};
|
|
5547
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5548
|
+
if (fromParts != null) {
|
|
5549
|
+
let transformedList = fromParts;
|
|
5550
|
+
if (Array.isArray(transformedList)) {
|
|
5551
|
+
transformedList = transformedList.map((item) => {
|
|
5552
|
+
return partToVertex$2(item);
|
|
5553
|
+
});
|
|
5554
|
+
}
|
|
5555
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5556
|
+
}
|
|
5557
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5558
|
+
if (fromRole != null) {
|
|
5559
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
5560
|
+
}
|
|
5561
|
+
return toObject;
|
|
5562
|
+
}
|
|
5497
5563
|
function createCachedContentConfigToMldev(fromObject, parentObject) {
|
|
5498
5564
|
const toObject = {};
|
|
5499
5565
|
const fromTtl = getValueByPath(fromObject, ['ttl']);
|
|
@@ -5562,7 +5628,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
|
|
|
5562
5628
|
let transformedList = tContents(fromContents);
|
|
5563
5629
|
if (Array.isArray(transformedList)) {
|
|
5564
5630
|
transformedList = transformedList.map((item) => {
|
|
5565
|
-
return item;
|
|
5631
|
+
return contentToVertex$2(item);
|
|
5566
5632
|
});
|
|
5567
5633
|
}
|
|
5568
5634
|
setValueByPath(parentObject, ['contents'], transformedList);
|
|
@@ -5571,7 +5637,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
|
|
|
5571
5637
|
'systemInstruction',
|
|
5572
5638
|
]);
|
|
5573
5639
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
5574
|
-
setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
|
|
5640
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex$2(tContent(fromSystemInstruction)));
|
|
5575
5641
|
}
|
|
5576
5642
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
5577
5643
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -5585,7 +5651,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
|
|
|
5585
5651
|
}
|
|
5586
5652
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
5587
5653
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
5588
|
-
setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
|
|
5654
|
+
setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex$1(fromToolConfig));
|
|
5589
5655
|
}
|
|
5590
5656
|
const fromKmsKeyName = getValueByPath(fromObject, ['kmsKeyName']);
|
|
5591
5657
|
if (parentObject !== undefined && fromKmsKeyName != null) {
|
|
@@ -5945,6 +6011,80 @@ function partToMldev$3(fromObject) {
|
|
|
5945
6011
|
if (fromVideoMetadata != null) {
|
|
5946
6012
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
5947
6013
|
}
|
|
6014
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
6015
|
+
if (fromToolCall != null) {
|
|
6016
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
6017
|
+
}
|
|
6018
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
6019
|
+
if (fromToolResponse != null) {
|
|
6020
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
6021
|
+
}
|
|
6022
|
+
return toObject;
|
|
6023
|
+
}
|
|
6024
|
+
function partToVertex$2(fromObject) {
|
|
6025
|
+
const toObject = {};
|
|
6026
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
6027
|
+
'mediaResolution',
|
|
6028
|
+
]);
|
|
6029
|
+
if (fromMediaResolution != null) {
|
|
6030
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
6031
|
+
}
|
|
6032
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
6033
|
+
'codeExecutionResult',
|
|
6034
|
+
]);
|
|
6035
|
+
if (fromCodeExecutionResult != null) {
|
|
6036
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
6037
|
+
}
|
|
6038
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
6039
|
+
'executableCode',
|
|
6040
|
+
]);
|
|
6041
|
+
if (fromExecutableCode != null) {
|
|
6042
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
6043
|
+
}
|
|
6044
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
6045
|
+
if (fromFileData != null) {
|
|
6046
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
6047
|
+
}
|
|
6048
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
6049
|
+
if (fromFunctionCall != null) {
|
|
6050
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
6051
|
+
}
|
|
6052
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
6053
|
+
'functionResponse',
|
|
6054
|
+
]);
|
|
6055
|
+
if (fromFunctionResponse != null) {
|
|
6056
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
6057
|
+
}
|
|
6058
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
6059
|
+
if (fromInlineData != null) {
|
|
6060
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
6061
|
+
}
|
|
6062
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
6063
|
+
if (fromText != null) {
|
|
6064
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
6065
|
+
}
|
|
6066
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
6067
|
+
if (fromThought != null) {
|
|
6068
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
6069
|
+
}
|
|
6070
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
6071
|
+
'thoughtSignature',
|
|
6072
|
+
]);
|
|
6073
|
+
if (fromThoughtSignature != null) {
|
|
6074
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
6075
|
+
}
|
|
6076
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
6077
|
+
'videoMetadata',
|
|
6078
|
+
]);
|
|
6079
|
+
if (fromVideoMetadata != null) {
|
|
6080
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
6081
|
+
}
|
|
6082
|
+
if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
|
|
6083
|
+
throw new Error('toolCall parameter is not supported in Vertex AI.');
|
|
6084
|
+
}
|
|
6085
|
+
if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
|
|
6086
|
+
throw new Error('toolResponse parameter is not supported in Vertex AI.');
|
|
6087
|
+
}
|
|
5948
6088
|
return toObject;
|
|
5949
6089
|
}
|
|
5950
6090
|
function toolConfigToMldev$1(fromObject) {
|
|
@@ -5961,6 +6101,30 @@ function toolConfigToMldev$1(fromObject) {
|
|
|
5961
6101
|
if (fromFunctionCallingConfig != null) {
|
|
5962
6102
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(fromFunctionCallingConfig));
|
|
5963
6103
|
}
|
|
6104
|
+
const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
|
|
6105
|
+
if (fromIncludeServerSideToolInvocations != null) {
|
|
6106
|
+
setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
|
|
6107
|
+
}
|
|
6108
|
+
return toObject;
|
|
6109
|
+
}
|
|
6110
|
+
function toolConfigToVertex$1(fromObject) {
|
|
6111
|
+
const toObject = {};
|
|
6112
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
6113
|
+
'retrievalConfig',
|
|
6114
|
+
]);
|
|
6115
|
+
if (fromRetrievalConfig != null) {
|
|
6116
|
+
setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
|
|
6117
|
+
}
|
|
6118
|
+
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
6119
|
+
'functionCallingConfig',
|
|
6120
|
+
]);
|
|
6121
|
+
if (fromFunctionCallingConfig != null) {
|
|
6122
|
+
setValueByPath(toObject, ['functionCallingConfig'], fromFunctionCallingConfig);
|
|
6123
|
+
}
|
|
6124
|
+
if (getValueByPath(fromObject, ['includeServerSideToolInvocations']) !==
|
|
6125
|
+
undefined) {
|
|
6126
|
+
throw new Error('includeServerSideToolInvocations parameter is not supported in Vertex AI.');
|
|
6127
|
+
}
|
|
5964
6128
|
return toObject;
|
|
5965
6129
|
}
|
|
5966
6130
|
function toolToMldev$3(fromObject) {
|
|
@@ -7177,7 +7341,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
7177
7341
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
7178
7342
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
7179
7343
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
7180
|
-
const SDK_VERSION = '1.
|
|
7344
|
+
const SDK_VERSION = '1.46.0'; // x-release-please-version
|
|
7181
7345
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
7182
7346
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
7183
7347
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -7875,20 +8039,20 @@ const INITIAL_RETRY_DELAY_MS = 1000;
|
|
|
7875
8039
|
const DELAY_MULTIPLIER = 2;
|
|
7876
8040
|
const X_GOOG_UPLOAD_STATUS_HEADER_FIELD = 'x-goog-upload-status';
|
|
7877
8041
|
class CrossUploader {
|
|
7878
|
-
async upload(file, uploadUrl, apiClient) {
|
|
8042
|
+
async upload(file, uploadUrl, apiClient, httpOptions) {
|
|
7879
8043
|
if (typeof file === 'string') {
|
|
7880
8044
|
throw crossError();
|
|
7881
8045
|
}
|
|
7882
8046
|
else {
|
|
7883
|
-
return uploadBlob(file, uploadUrl, apiClient);
|
|
8047
|
+
return uploadBlob(file, uploadUrl, apiClient, httpOptions);
|
|
7884
8048
|
}
|
|
7885
8049
|
}
|
|
7886
|
-
async uploadToFileSearchStore(file, uploadUrl, apiClient) {
|
|
8050
|
+
async uploadToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
|
|
7887
8051
|
if (typeof file === 'string') {
|
|
7888
8052
|
throw crossError();
|
|
7889
8053
|
}
|
|
7890
8054
|
else {
|
|
7891
|
-
return uploadBlobToFileSearchStore(file, uploadUrl, apiClient);
|
|
8055
|
+
return uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions);
|
|
7892
8056
|
}
|
|
7893
8057
|
}
|
|
7894
8058
|
async stat(file) {
|
|
@@ -7900,18 +8064,18 @@ class CrossUploader {
|
|
|
7900
8064
|
}
|
|
7901
8065
|
}
|
|
7902
8066
|
}
|
|
7903
|
-
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
8067
|
+
async function uploadBlob(file, uploadUrl, apiClient, httpOptions) {
|
|
7904
8068
|
var _a;
|
|
7905
|
-
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
8069
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
|
|
7906
8070
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
7907
8071
|
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') {
|
|
7908
8072
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
7909
8073
|
}
|
|
7910
8074
|
return responseJson['file'];
|
|
7911
8075
|
}
|
|
7912
|
-
async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
|
|
8076
|
+
async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
|
|
7913
8077
|
var _a;
|
|
7914
|
-
const response = await uploadBlobInternal(file, uploadUrl, apiClient);
|
|
8078
|
+
const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
|
|
7915
8079
|
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
7916
8080
|
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') {
|
|
7917
8081
|
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
@@ -7921,8 +8085,18 @@ async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
|
|
|
7921
8085
|
Object.assign(typedResp, resp);
|
|
7922
8086
|
return typedResp;
|
|
7923
8087
|
}
|
|
7924
|
-
async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
7925
|
-
var _a, _b;
|
|
8088
|
+
async function uploadBlobInternal(file, uploadUrl, apiClient, httpOptions) {
|
|
8089
|
+
var _a, _b, _c;
|
|
8090
|
+
let finalUrl = uploadUrl;
|
|
8091
|
+
const effectiveBaseUrl = (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl) || ((_a = apiClient.clientOptions.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl);
|
|
8092
|
+
if (effectiveBaseUrl) {
|
|
8093
|
+
const baseUri = new URL(effectiveBaseUrl);
|
|
8094
|
+
const uploadUri = new URL(uploadUrl);
|
|
8095
|
+
uploadUri.protocol = baseUri.protocol;
|
|
8096
|
+
uploadUri.host = baseUri.host;
|
|
8097
|
+
uploadUri.port = baseUri.port;
|
|
8098
|
+
finalUrl = uploadUri.toString();
|
|
8099
|
+
}
|
|
7926
8100
|
let fileSize = 0;
|
|
7927
8101
|
let offset = 0;
|
|
7928
8102
|
let response = new HttpResponse(new Response());
|
|
@@ -7937,21 +8111,14 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
|
7937
8111
|
let retryCount = 0;
|
|
7938
8112
|
let currentDelayMs = INITIAL_RETRY_DELAY_MS;
|
|
7939
8113
|
while (retryCount < MAX_RETRY_COUNT) {
|
|
8114
|
+
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) });
|
|
7940
8115
|
response = await apiClient.request({
|
|
7941
8116
|
path: '',
|
|
7942
8117
|
body: chunk,
|
|
7943
8118
|
httpMethod: 'POST',
|
|
7944
|
-
httpOptions: {
|
|
7945
|
-
apiVersion: '',
|
|
7946
|
-
baseUrl: uploadUrl,
|
|
7947
|
-
headers: {
|
|
7948
|
-
'X-Goog-Upload-Command': uploadCommand,
|
|
7949
|
-
'X-Goog-Upload-Offset': String(offset),
|
|
7950
|
-
'Content-Length': String(chunkSize),
|
|
7951
|
-
},
|
|
7952
|
-
},
|
|
8119
|
+
httpOptions: Object.assign(Object.assign({}, httpOptions), { apiVersion: '', baseUrl: finalUrl, headers: mergedHeaders }),
|
|
7953
8120
|
});
|
|
7954
|
-
if ((
|
|
8121
|
+
if ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
|
|
7955
8122
|
break;
|
|
7956
8123
|
}
|
|
7957
8124
|
retryCount++;
|
|
@@ -7961,7 +8128,7 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
|
|
|
7961
8128
|
offset += chunkSize;
|
|
7962
8129
|
// The `x-goog-upload-status` header field can be `active`, `final` and
|
|
7963
8130
|
//`cancelled` in resposne.
|
|
7964
|
-
if (((
|
|
8131
|
+
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') {
|
|
7965
8132
|
break;
|
|
7966
8133
|
}
|
|
7967
8134
|
// TODO(b/401391430) Investigate why the upload status is not finalized
|
|
@@ -9252,6 +9419,30 @@ const FallbackEncoder = ({ headers, body }) => {
|
|
|
9252
9419
|
};
|
|
9253
9420
|
};
|
|
9254
9421
|
|
|
9422
|
+
/**
|
|
9423
|
+
* @license
|
|
9424
|
+
* Copyright 2025 Google LLC
|
|
9425
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9426
|
+
*/
|
|
9427
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
9428
|
+
/**
|
|
9429
|
+
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
9430
|
+
*/
|
|
9431
|
+
function stringifyQuery(query) {
|
|
9432
|
+
return Object.entries(query)
|
|
9433
|
+
.filter(([_, value]) => typeof value !== 'undefined')
|
|
9434
|
+
.map(([key, value]) => {
|
|
9435
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
9436
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
9437
|
+
}
|
|
9438
|
+
if (value === null) {
|
|
9439
|
+
return `${encodeURIComponent(key)}=`;
|
|
9440
|
+
}
|
|
9441
|
+
throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
9442
|
+
})
|
|
9443
|
+
.join('&');
|
|
9444
|
+
}
|
|
9445
|
+
|
|
9255
9446
|
/**
|
|
9256
9447
|
* @license
|
|
9257
9448
|
* Copyright 2025 Google LLC
|
|
@@ -10395,18 +10586,7 @@ class BaseGeminiNextGenAPIClient {
|
|
|
10395
10586
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
10396
10587
|
*/
|
|
10397
10588
|
stringifyQuery(query) {
|
|
10398
|
-
return
|
|
10399
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
10400
|
-
.map(([key, value]) => {
|
|
10401
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
10402
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
10403
|
-
}
|
|
10404
|
-
if (value === null) {
|
|
10405
|
-
return `${encodeURIComponent(key)}=`;
|
|
10406
|
-
}
|
|
10407
|
-
throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
10408
|
-
})
|
|
10409
|
-
.join('&');
|
|
10589
|
+
return stringifyQuery(query);
|
|
10410
10590
|
}
|
|
10411
10591
|
getUserAgent() {
|
|
10412
10592
|
return `${this.constructor.name}/JS ${VERSION}`;
|
|
@@ -10423,8 +10603,9 @@ class BaseGeminiNextGenAPIClient {
|
|
|
10423
10603
|
new URL(path)
|
|
10424
10604
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
10425
10605
|
const defaultQuery = this.defaultQuery();
|
|
10426
|
-
|
|
10427
|
-
|
|
10606
|
+
const pathQuery = Object.fromEntries(url.searchParams);
|
|
10607
|
+
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
|
|
10608
|
+
query = Object.assign(Object.assign(Object.assign({}, pathQuery), defaultQuery), query);
|
|
10428
10609
|
}
|
|
10429
10610
|
if (typeof query === 'object' && query && !Array.isArray(query)) {
|
|
10430
10611
|
url.search = this.stringifyQuery(query);
|
|
@@ -10645,9 +10826,9 @@ class BaseGeminiNextGenAPIClient {
|
|
|
10645
10826
|
timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
|
|
10646
10827
|
}
|
|
10647
10828
|
}
|
|
10648
|
-
// If the API asks us to wait a certain amount of time
|
|
10649
|
-
//
|
|
10650
|
-
if (
|
|
10829
|
+
// If the API asks us to wait a certain amount of time, just do what it
|
|
10830
|
+
// says, but otherwise calculate a default
|
|
10831
|
+
if (timeoutMillis === undefined) {
|
|
10651
10832
|
const maxRetries = (_b = options.maxRetries) !== null && _b !== void 0 ? _b : this.maxRetries;
|
|
10652
10833
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
10653
10834
|
}
|
|
@@ -10775,6 +10956,13 @@ GeminiNextGenAPIClient.Interactions = Interactions;
|
|
|
10775
10956
|
* Copyright 2025 Google LLC
|
|
10776
10957
|
* SPDX-License-Identifier: Apache-2.0
|
|
10777
10958
|
*/
|
|
10959
|
+
function audioTranscriptionConfigToMldev$1(fromObject) {
|
|
10960
|
+
const toObject = {};
|
|
10961
|
+
if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
|
|
10962
|
+
throw new Error('languageCodes parameter is not supported in Gemini API.');
|
|
10963
|
+
}
|
|
10964
|
+
return toObject;
|
|
10965
|
+
}
|
|
10778
10966
|
function authConfigToMldev$2(fromObject) {
|
|
10779
10967
|
const toObject = {};
|
|
10780
10968
|
const fromApiKey = getValueByPath(fromObject, ['apiKey']);
|
|
@@ -10835,6 +11023,24 @@ function contentToMldev$2(fromObject) {
|
|
|
10835
11023
|
}
|
|
10836
11024
|
return toObject;
|
|
10837
11025
|
}
|
|
11026
|
+
function contentToVertex$1(fromObject) {
|
|
11027
|
+
const toObject = {};
|
|
11028
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
11029
|
+
if (fromParts != null) {
|
|
11030
|
+
let transformedList = fromParts;
|
|
11031
|
+
if (Array.isArray(transformedList)) {
|
|
11032
|
+
transformedList = transformedList.map((item) => {
|
|
11033
|
+
return partToVertex$1(item);
|
|
11034
|
+
});
|
|
11035
|
+
}
|
|
11036
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
11037
|
+
}
|
|
11038
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
11039
|
+
if (fromRole != null) {
|
|
11040
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
11041
|
+
}
|
|
11042
|
+
return toObject;
|
|
11043
|
+
}
|
|
10838
11044
|
function fileDataToMldev$2(fromObject) {
|
|
10839
11045
|
const toObject = {};
|
|
10840
11046
|
if (getValueByPath(fromObject, ['displayName']) !== undefined) {
|
|
@@ -11151,13 +11357,13 @@ function liveConnectConfigToMldev$1(fromObject, parentObject) {
|
|
|
11151
11357
|
'inputAudioTranscription',
|
|
11152
11358
|
]);
|
|
11153
11359
|
if (parentObject !== undefined && fromInputAudioTranscription != null) {
|
|
11154
|
-
setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
|
|
11360
|
+
setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromInputAudioTranscription));
|
|
11155
11361
|
}
|
|
11156
11362
|
const fromOutputAudioTranscription = getValueByPath(fromObject, [
|
|
11157
11363
|
'outputAudioTranscription',
|
|
11158
11364
|
]);
|
|
11159
11365
|
if (parentObject !== undefined && fromOutputAudioTranscription != null) {
|
|
11160
|
-
setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
|
|
11366
|
+
setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromOutputAudioTranscription));
|
|
11161
11367
|
}
|
|
11162
11368
|
const fromRealtimeInputConfig = getValueByPath(fromObject, [
|
|
11163
11369
|
'realtimeInputConfig',
|
|
@@ -11242,7 +11448,7 @@ function liveConnectConfigToVertex(fromObject, parentObject) {
|
|
|
11242
11448
|
'systemInstruction',
|
|
11243
11449
|
]);
|
|
11244
11450
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
11245
|
-
setValueByPath(parentObject, ['setup', 'systemInstruction'], tContent(fromSystemInstruction));
|
|
11451
|
+
setValueByPath(parentObject, ['setup', 'systemInstruction'], contentToVertex$1(tContent(fromSystemInstruction)));
|
|
11246
11452
|
}
|
|
11247
11453
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
11248
11454
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -11542,6 +11748,80 @@ function partToMldev$2(fromObject) {
|
|
|
11542
11748
|
if (fromVideoMetadata != null) {
|
|
11543
11749
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
11544
11750
|
}
|
|
11751
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
11752
|
+
if (fromToolCall != null) {
|
|
11753
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
11754
|
+
}
|
|
11755
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
11756
|
+
if (fromToolResponse != null) {
|
|
11757
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
11758
|
+
}
|
|
11759
|
+
return toObject;
|
|
11760
|
+
}
|
|
11761
|
+
function partToVertex$1(fromObject) {
|
|
11762
|
+
const toObject = {};
|
|
11763
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
11764
|
+
'mediaResolution',
|
|
11765
|
+
]);
|
|
11766
|
+
if (fromMediaResolution != null) {
|
|
11767
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
11768
|
+
}
|
|
11769
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
11770
|
+
'codeExecutionResult',
|
|
11771
|
+
]);
|
|
11772
|
+
if (fromCodeExecutionResult != null) {
|
|
11773
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
11774
|
+
}
|
|
11775
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
11776
|
+
'executableCode',
|
|
11777
|
+
]);
|
|
11778
|
+
if (fromExecutableCode != null) {
|
|
11779
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
11780
|
+
}
|
|
11781
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
11782
|
+
if (fromFileData != null) {
|
|
11783
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
11784
|
+
}
|
|
11785
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
11786
|
+
if (fromFunctionCall != null) {
|
|
11787
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
11788
|
+
}
|
|
11789
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
11790
|
+
'functionResponse',
|
|
11791
|
+
]);
|
|
11792
|
+
if (fromFunctionResponse != null) {
|
|
11793
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
11794
|
+
}
|
|
11795
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
11796
|
+
if (fromInlineData != null) {
|
|
11797
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
11798
|
+
}
|
|
11799
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
11800
|
+
if (fromText != null) {
|
|
11801
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
11802
|
+
}
|
|
11803
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
11804
|
+
if (fromThought != null) {
|
|
11805
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
11806
|
+
}
|
|
11807
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
11808
|
+
'thoughtSignature',
|
|
11809
|
+
]);
|
|
11810
|
+
if (fromThoughtSignature != null) {
|
|
11811
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
11812
|
+
}
|
|
11813
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
11814
|
+
'videoMetadata',
|
|
11815
|
+
]);
|
|
11816
|
+
if (fromVideoMetadata != null) {
|
|
11817
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
11818
|
+
}
|
|
11819
|
+
if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
|
|
11820
|
+
throw new Error('toolCall parameter is not supported in Vertex AI.');
|
|
11821
|
+
}
|
|
11822
|
+
if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
|
|
11823
|
+
throw new Error('toolResponse parameter is not supported in Vertex AI.');
|
|
11824
|
+
}
|
|
11545
11825
|
return toObject;
|
|
11546
11826
|
}
|
|
11547
11827
|
function sessionResumptionConfigToMldev$1(fromObject) {
|
|
@@ -11910,7 +12190,7 @@ function citationMetadataFromMldev(fromObject, _rootObject) {
|
|
|
11910
12190
|
}
|
|
11911
12191
|
return toObject;
|
|
11912
12192
|
}
|
|
11913
|
-
function computeTokensParametersToVertex(apiClient, fromObject,
|
|
12193
|
+
function computeTokensParametersToVertex(apiClient, fromObject, rootObject) {
|
|
11914
12194
|
const toObject = {};
|
|
11915
12195
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
11916
12196
|
if (fromModel != null) {
|
|
@@ -11921,7 +12201,7 @@ function computeTokensParametersToVertex(apiClient, fromObject, _rootObject) {
|
|
|
11921
12201
|
let transformedList = tContents(fromContents);
|
|
11922
12202
|
if (Array.isArray(transformedList)) {
|
|
11923
12203
|
transformedList = transformedList.map((item) => {
|
|
11924
|
-
return item;
|
|
12204
|
+
return contentToVertex(item);
|
|
11925
12205
|
});
|
|
11926
12206
|
}
|
|
11927
12207
|
setValueByPath(toObject, ['contents'], transformedList);
|
|
@@ -11990,6 +12270,24 @@ function contentToMldev$1(fromObject, rootObject) {
|
|
|
11990
12270
|
}
|
|
11991
12271
|
return toObject;
|
|
11992
12272
|
}
|
|
12273
|
+
function contentToVertex(fromObject, rootObject) {
|
|
12274
|
+
const toObject = {};
|
|
12275
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
12276
|
+
if (fromParts != null) {
|
|
12277
|
+
let transformedList = fromParts;
|
|
12278
|
+
if (Array.isArray(transformedList)) {
|
|
12279
|
+
transformedList = transformedList.map((item) => {
|
|
12280
|
+
return partToVertex(item);
|
|
12281
|
+
});
|
|
12282
|
+
}
|
|
12283
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
12284
|
+
}
|
|
12285
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
12286
|
+
if (fromRole != null) {
|
|
12287
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
12288
|
+
}
|
|
12289
|
+
return toObject;
|
|
12290
|
+
}
|
|
11993
12291
|
function controlReferenceConfigToVertex(fromObject, _rootObject) {
|
|
11994
12292
|
const toObject = {};
|
|
11995
12293
|
const fromControlType = getValueByPath(fromObject, ['controlType']);
|
|
@@ -12023,7 +12321,7 @@ function countTokensConfigToVertex(fromObject, parentObject, rootObject) {
|
|
|
12023
12321
|
'systemInstruction',
|
|
12024
12322
|
]);
|
|
12025
12323
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
12026
|
-
setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
|
|
12324
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
|
|
12027
12325
|
}
|
|
12028
12326
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
12029
12327
|
if (parentObject !== undefined && fromTools != null) {
|
|
@@ -12076,7 +12374,7 @@ function countTokensParametersToVertex(apiClient, fromObject, rootObject) {
|
|
|
12076
12374
|
let transformedList = tContents(fromContents);
|
|
12077
12375
|
if (Array.isArray(transformedList)) {
|
|
12078
12376
|
transformedList = transformedList.map((item) => {
|
|
12079
|
-
return item;
|
|
12377
|
+
return contentToVertex(item);
|
|
12080
12378
|
});
|
|
12081
12379
|
}
|
|
12082
12380
|
setValueByPath(toObject, ['contents'], transformedList);
|
|
@@ -12480,7 +12778,7 @@ function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject
|
|
|
12480
12778
|
if (discriminatorContent === 'EMBED_CONTENT') {
|
|
12481
12779
|
const fromContent = getValueByPath(fromObject, ['content']);
|
|
12482
12780
|
if (fromContent != null) {
|
|
12483
|
-
setValueByPath(toObject, ['content'], tContent(fromContent));
|
|
12781
|
+
setValueByPath(toObject, ['content'], contentToVertex(tContent(fromContent)));
|
|
12484
12782
|
}
|
|
12485
12783
|
}
|
|
12486
12784
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
@@ -12831,7 +13129,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
|
|
|
12831
13129
|
'systemInstruction',
|
|
12832
13130
|
]);
|
|
12833
13131
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
12834
|
-
setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
|
|
13132
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
|
|
12835
13133
|
}
|
|
12836
13134
|
const fromTemperature = getValueByPath(fromObject, ['temperature']);
|
|
12837
13135
|
if (fromTemperature != null) {
|
|
@@ -12943,7 +13241,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
|
|
|
12943
13241
|
}
|
|
12944
13242
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
12945
13243
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
12946
|
-
setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
|
|
13244
|
+
setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex(fromToolConfig));
|
|
12947
13245
|
}
|
|
12948
13246
|
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
12949
13247
|
if (parentObject !== undefined && fromLabels != null) {
|
|
@@ -13032,7 +13330,7 @@ function generateContentParametersToVertex(apiClient, fromObject, rootObject) {
|
|
|
13032
13330
|
let transformedList = tContents(fromContents);
|
|
13033
13331
|
if (Array.isArray(transformedList)) {
|
|
13034
13332
|
transformedList = transformedList.map((item) => {
|
|
13035
|
-
return item;
|
|
13333
|
+
return contentToVertex(item);
|
|
13036
13334
|
});
|
|
13037
13335
|
}
|
|
13038
13336
|
setValueByPath(toObject, ['contents'], transformedList);
|
|
@@ -14436,6 +14734,80 @@ function partToMldev$1(fromObject, rootObject) {
|
|
|
14436
14734
|
if (fromVideoMetadata != null) {
|
|
14437
14735
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
14438
14736
|
}
|
|
14737
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
14738
|
+
if (fromToolCall != null) {
|
|
14739
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
14740
|
+
}
|
|
14741
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
14742
|
+
if (fromToolResponse != null) {
|
|
14743
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
14744
|
+
}
|
|
14745
|
+
return toObject;
|
|
14746
|
+
}
|
|
14747
|
+
function partToVertex(fromObject, _rootObject) {
|
|
14748
|
+
const toObject = {};
|
|
14749
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
14750
|
+
'mediaResolution',
|
|
14751
|
+
]);
|
|
14752
|
+
if (fromMediaResolution != null) {
|
|
14753
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
14754
|
+
}
|
|
14755
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
14756
|
+
'codeExecutionResult',
|
|
14757
|
+
]);
|
|
14758
|
+
if (fromCodeExecutionResult != null) {
|
|
14759
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
14760
|
+
}
|
|
14761
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
14762
|
+
'executableCode',
|
|
14763
|
+
]);
|
|
14764
|
+
if (fromExecutableCode != null) {
|
|
14765
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
14766
|
+
}
|
|
14767
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
14768
|
+
if (fromFileData != null) {
|
|
14769
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
14770
|
+
}
|
|
14771
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
14772
|
+
if (fromFunctionCall != null) {
|
|
14773
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
14774
|
+
}
|
|
14775
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
14776
|
+
'functionResponse',
|
|
14777
|
+
]);
|
|
14778
|
+
if (fromFunctionResponse != null) {
|
|
14779
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
14780
|
+
}
|
|
14781
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
14782
|
+
if (fromInlineData != null) {
|
|
14783
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
14784
|
+
}
|
|
14785
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
14786
|
+
if (fromText != null) {
|
|
14787
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
14788
|
+
}
|
|
14789
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
14790
|
+
if (fromThought != null) {
|
|
14791
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
14792
|
+
}
|
|
14793
|
+
const fromThoughtSignature = getValueByPath(fromObject, [
|
|
14794
|
+
'thoughtSignature',
|
|
14795
|
+
]);
|
|
14796
|
+
if (fromThoughtSignature != null) {
|
|
14797
|
+
setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
|
|
14798
|
+
}
|
|
14799
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
14800
|
+
'videoMetadata',
|
|
14801
|
+
]);
|
|
14802
|
+
if (fromVideoMetadata != null) {
|
|
14803
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
14804
|
+
}
|
|
14805
|
+
if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
|
|
14806
|
+
throw new Error('toolCall parameter is not supported in Vertex AI.');
|
|
14807
|
+
}
|
|
14808
|
+
if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
|
|
14809
|
+
throw new Error('toolResponse parameter is not supported in Vertex AI.');
|
|
14810
|
+
}
|
|
14439
14811
|
return toObject;
|
|
14440
14812
|
}
|
|
14441
14813
|
function productImageToVertex(fromObject, rootObject) {
|
|
@@ -14769,6 +15141,30 @@ function toolConfigToMldev(fromObject, rootObject) {
|
|
|
14769
15141
|
if (fromFunctionCallingConfig != null) {
|
|
14770
15142
|
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(fromFunctionCallingConfig));
|
|
14771
15143
|
}
|
|
15144
|
+
const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
|
|
15145
|
+
if (fromIncludeServerSideToolInvocations != null) {
|
|
15146
|
+
setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
|
|
15147
|
+
}
|
|
15148
|
+
return toObject;
|
|
15149
|
+
}
|
|
15150
|
+
function toolConfigToVertex(fromObject, _rootObject) {
|
|
15151
|
+
const toObject = {};
|
|
15152
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
15153
|
+
'retrievalConfig',
|
|
15154
|
+
]);
|
|
15155
|
+
if (fromRetrievalConfig != null) {
|
|
15156
|
+
setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
|
|
15157
|
+
}
|
|
15158
|
+
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
15159
|
+
'functionCallingConfig',
|
|
15160
|
+
]);
|
|
15161
|
+
if (fromFunctionCallingConfig != null) {
|
|
15162
|
+
setValueByPath(toObject, ['functionCallingConfig'], fromFunctionCallingConfig);
|
|
15163
|
+
}
|
|
15164
|
+
if (getValueByPath(fromObject, ['includeServerSideToolInvocations']) !==
|
|
15165
|
+
undefined) {
|
|
15166
|
+
throw new Error('includeServerSideToolInvocations parameter is not supported in Vertex AI.');
|
|
15167
|
+
}
|
|
14772
15168
|
return toObject;
|
|
14773
15169
|
}
|
|
14774
15170
|
function toolToMldev$1(fromObject, rootObject) {
|
|
@@ -15907,7 +16303,7 @@ class Session {
|
|
|
15907
16303
|
}
|
|
15908
16304
|
}
|
|
15909
16305
|
const clientMessage = {
|
|
15910
|
-
toolResponse: { functionResponses: functionResponses },
|
|
16306
|
+
toolResponse: { 'functionResponses': functionResponses },
|
|
15911
16307
|
};
|
|
15912
16308
|
return clientMessage;
|
|
15913
16309
|
}
|
|
@@ -17880,6 +18276,13 @@ class Operations extends BaseModule {
|
|
|
17880
18276
|
* Copyright 2025 Google LLC
|
|
17881
18277
|
* SPDX-License-Identifier: Apache-2.0
|
|
17882
18278
|
*/
|
|
18279
|
+
function audioTranscriptionConfigToMldev(fromObject) {
|
|
18280
|
+
const toObject = {};
|
|
18281
|
+
if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
|
|
18282
|
+
throw new Error('languageCodes parameter is not supported in Gemini API.');
|
|
18283
|
+
}
|
|
18284
|
+
return toObject;
|
|
18285
|
+
}
|
|
17883
18286
|
function authConfigToMldev(fromObject) {
|
|
17884
18287
|
const toObject = {};
|
|
17885
18288
|
const fromApiKey = getValueByPath(fromObject, ['apiKey']);
|
|
@@ -18131,13 +18534,13 @@ function liveConnectConfigToMldev(fromObject, parentObject) {
|
|
|
18131
18534
|
'inputAudioTranscription',
|
|
18132
18535
|
]);
|
|
18133
18536
|
if (parentObject !== undefined && fromInputAudioTranscription != null) {
|
|
18134
|
-
setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
|
|
18537
|
+
setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev(fromInputAudioTranscription));
|
|
18135
18538
|
}
|
|
18136
18539
|
const fromOutputAudioTranscription = getValueByPath(fromObject, [
|
|
18137
18540
|
'outputAudioTranscription',
|
|
18138
18541
|
]);
|
|
18139
18542
|
if (parentObject !== undefined && fromOutputAudioTranscription != null) {
|
|
18140
|
-
setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
|
|
18543
|
+
setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev(fromOutputAudioTranscription));
|
|
18141
18544
|
}
|
|
18142
18545
|
const fromRealtimeInputConfig = getValueByPath(fromObject, [
|
|
18143
18546
|
'realtimeInputConfig',
|
|
@@ -18230,6 +18633,14 @@ function partToMldev(fromObject) {
|
|
|
18230
18633
|
if (fromVideoMetadata != null) {
|
|
18231
18634
|
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
18232
18635
|
}
|
|
18636
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
18637
|
+
if (fromToolCall != null) {
|
|
18638
|
+
setValueByPath(toObject, ['toolCall'], fromToolCall);
|
|
18639
|
+
}
|
|
18640
|
+
const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
|
|
18641
|
+
if (fromToolResponse != null) {
|
|
18642
|
+
setValueByPath(toObject, ['toolResponse'], fromToolResponse);
|
|
18643
|
+
}
|
|
18233
18644
|
return toObject;
|
|
18234
18645
|
}
|
|
18235
18646
|
function sessionResumptionConfigToMldev(fromObject) {
|
|
@@ -20003,6 +20414,7 @@ exports.SingleEmbedContentResponse = SingleEmbedContentResponse;
|
|
|
20003
20414
|
exports.StyleReferenceImage = StyleReferenceImage;
|
|
20004
20415
|
exports.SubjectReferenceImage = SubjectReferenceImage;
|
|
20005
20416
|
exports.Tokens = Tokens;
|
|
20417
|
+
exports.ToolResponse = ToolResponse;
|
|
20006
20418
|
exports.UploadToFileSearchStoreOperation = UploadToFileSearchStoreOperation;
|
|
20007
20419
|
exports.UploadToFileSearchStoreResponse = UploadToFileSearchStoreResponse;
|
|
20008
20420
|
exports.UploadToFileSearchStoreResumableResponse = UploadToFileSearchStoreResumableResponse;
|