@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/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.45.0'; // x-release-please-version
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 ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
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 (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'active') {
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
@@ -10856,6 +11023,24 @@ function contentToMldev$2(fromObject) {
10856
11023
  }
10857
11024
  return toObject;
10858
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
+ }
10859
11044
  function fileDataToMldev$2(fromObject) {
10860
11045
  const toObject = {};
10861
11046
  if (getValueByPath(fromObject, ['displayName']) !== undefined) {
@@ -11263,7 +11448,7 @@ function liveConnectConfigToVertex(fromObject, parentObject) {
11263
11448
  'systemInstruction',
11264
11449
  ]);
11265
11450
  if (parentObject !== undefined && fromSystemInstruction != null) {
11266
- setValueByPath(parentObject, ['setup', 'systemInstruction'], tContent(fromSystemInstruction));
11451
+ setValueByPath(parentObject, ['setup', 'systemInstruction'], contentToVertex$1(tContent(fromSystemInstruction)));
11267
11452
  }
11268
11453
  const fromTools = getValueByPath(fromObject, ['tools']);
11269
11454
  if (parentObject !== undefined && fromTools != null) {
@@ -11563,6 +11748,80 @@ function partToMldev$2(fromObject) {
11563
11748
  if (fromVideoMetadata != null) {
11564
11749
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
11565
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
+ }
11566
11825
  return toObject;
11567
11826
  }
11568
11827
  function sessionResumptionConfigToMldev$1(fromObject) {
@@ -11931,7 +12190,7 @@ function citationMetadataFromMldev(fromObject, _rootObject) {
11931
12190
  }
11932
12191
  return toObject;
11933
12192
  }
11934
- function computeTokensParametersToVertex(apiClient, fromObject, _rootObject) {
12193
+ function computeTokensParametersToVertex(apiClient, fromObject, rootObject) {
11935
12194
  const toObject = {};
11936
12195
  const fromModel = getValueByPath(fromObject, ['model']);
11937
12196
  if (fromModel != null) {
@@ -11942,7 +12201,7 @@ function computeTokensParametersToVertex(apiClient, fromObject, _rootObject) {
11942
12201
  let transformedList = tContents(fromContents);
11943
12202
  if (Array.isArray(transformedList)) {
11944
12203
  transformedList = transformedList.map((item) => {
11945
- return item;
12204
+ return contentToVertex(item);
11946
12205
  });
11947
12206
  }
11948
12207
  setValueByPath(toObject, ['contents'], transformedList);
@@ -12011,6 +12270,24 @@ function contentToMldev$1(fromObject, rootObject) {
12011
12270
  }
12012
12271
  return toObject;
12013
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
+ }
12014
12291
  function controlReferenceConfigToVertex(fromObject, _rootObject) {
12015
12292
  const toObject = {};
12016
12293
  const fromControlType = getValueByPath(fromObject, ['controlType']);
@@ -12044,7 +12321,7 @@ function countTokensConfigToVertex(fromObject, parentObject, rootObject) {
12044
12321
  'systemInstruction',
12045
12322
  ]);
12046
12323
  if (parentObject !== undefined && fromSystemInstruction != null) {
12047
- setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
12324
+ setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
12048
12325
  }
12049
12326
  const fromTools = getValueByPath(fromObject, ['tools']);
12050
12327
  if (parentObject !== undefined && fromTools != null) {
@@ -12097,7 +12374,7 @@ function countTokensParametersToVertex(apiClient, fromObject, rootObject) {
12097
12374
  let transformedList = tContents(fromContents);
12098
12375
  if (Array.isArray(transformedList)) {
12099
12376
  transformedList = transformedList.map((item) => {
12100
- return item;
12377
+ return contentToVertex(item);
12101
12378
  });
12102
12379
  }
12103
12380
  setValueByPath(toObject, ['contents'], transformedList);
@@ -12501,7 +12778,7 @@ function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject
12501
12778
  if (discriminatorContent === 'EMBED_CONTENT') {
12502
12779
  const fromContent = getValueByPath(fromObject, ['content']);
12503
12780
  if (fromContent != null) {
12504
- setValueByPath(toObject, ['content'], tContent(fromContent));
12781
+ setValueByPath(toObject, ['content'], contentToVertex(tContent(fromContent)));
12505
12782
  }
12506
12783
  }
12507
12784
  const fromConfig = getValueByPath(fromObject, ['config']);
@@ -12852,7 +13129,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
12852
13129
  'systemInstruction',
12853
13130
  ]);
12854
13131
  if (parentObject !== undefined && fromSystemInstruction != null) {
12855
- setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
13132
+ setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
12856
13133
  }
12857
13134
  const fromTemperature = getValueByPath(fromObject, ['temperature']);
12858
13135
  if (fromTemperature != null) {
@@ -12964,7 +13241,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
12964
13241
  }
12965
13242
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
12966
13243
  if (parentObject !== undefined && fromToolConfig != null) {
12967
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
13244
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex(fromToolConfig));
12968
13245
  }
12969
13246
  const fromLabels = getValueByPath(fromObject, ['labels']);
12970
13247
  if (parentObject !== undefined && fromLabels != null) {
@@ -13053,7 +13330,7 @@ function generateContentParametersToVertex(apiClient, fromObject, rootObject) {
13053
13330
  let transformedList = tContents(fromContents);
13054
13331
  if (Array.isArray(transformedList)) {
13055
13332
  transformedList = transformedList.map((item) => {
13056
- return item;
13333
+ return contentToVertex(item);
13057
13334
  });
13058
13335
  }
13059
13336
  setValueByPath(toObject, ['contents'], transformedList);
@@ -14457,6 +14734,80 @@ function partToMldev$1(fromObject, rootObject) {
14457
14734
  if (fromVideoMetadata != null) {
14458
14735
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
14459
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
+ }
14460
14811
  return toObject;
14461
14812
  }
14462
14813
  function productImageToVertex(fromObject, rootObject) {
@@ -14790,6 +15141,30 @@ function toolConfigToMldev(fromObject, rootObject) {
14790
15141
  if (fromFunctionCallingConfig != null) {
14791
15142
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(fromFunctionCallingConfig));
14792
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
+ }
14793
15168
  return toObject;
14794
15169
  }
14795
15170
  function toolToMldev$1(fromObject, rootObject) {
@@ -15928,7 +16303,7 @@ class Session {
15928
16303
  }
15929
16304
  }
15930
16305
  const clientMessage = {
15931
- toolResponse: { functionResponses: functionResponses },
16306
+ toolResponse: { 'functionResponses': functionResponses },
15932
16307
  };
15933
16308
  return clientMessage;
15934
16309
  }
@@ -18258,6 +18633,14 @@ function partToMldev(fromObject) {
18258
18633
  if (fromVideoMetadata != null) {
18259
18634
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
18260
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
+ }
18261
18644
  return toObject;
18262
18645
  }
18263
18646
  function sessionResumptionConfigToMldev(fromObject) {
@@ -20031,6 +20414,7 @@ exports.SingleEmbedContentResponse = SingleEmbedContentResponse;
20031
20414
  exports.StyleReferenceImage = StyleReferenceImage;
20032
20415
  exports.SubjectReferenceImage = SubjectReferenceImage;
20033
20416
  exports.Tokens = Tokens;
20417
+ exports.ToolResponse = ToolResponse;
20034
20418
  exports.UploadToFileSearchStoreOperation = UploadToFileSearchStoreOperation;
20035
20419
  exports.UploadToFileSearchStoreResponse = UploadToFileSearchStoreResponse;
20036
20420
  exports.UploadToFileSearchStoreResumableResponse = UploadToFileSearchStoreResumableResponse;