@google/genai 1.15.0 → 1.16.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.
@@ -805,6 +805,10 @@ var FunctionCallingConfigMode;
805
805
  * Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
806
806
  */
807
807
  FunctionCallingConfigMode["NONE"] = "NONE";
808
+ /**
809
+ * Model decides to predict either a function call or a natural language response, but will validate function calls with constrained decoding. If "allowed_function_names" are set, the predicted function call will be limited to any one of "allowed_function_names", else the predicted function call will be any one of the provided "function_declarations".
810
+ */
811
+ FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
808
812
  })(FunctionCallingConfigMode || (FunctionCallingConfigMode = {}));
809
813
  /** Enum that controls the safety filter level for objectionable content. */
810
814
  var SafetyFilterLevel;
@@ -912,6 +916,21 @@ var SegmentMode;
912
916
  SegmentMode["SEMANTIC"] = "SEMANTIC";
913
917
  SegmentMode["INTERACTIVE"] = "INTERACTIVE";
914
918
  })(SegmentMode || (SegmentMode = {}));
919
+ /** Enum for the reference type of a video generation reference image. */
920
+ var VideoGenerationReferenceType;
921
+ (function (VideoGenerationReferenceType) {
922
+ /**
923
+ * A reference image that provides assets to the generated video,
924
+ such as the scene, an object, a character, etc.
925
+ */
926
+ VideoGenerationReferenceType["ASSET"] = "ASSET";
927
+ /**
928
+ * A reference image that provides aesthetics including colors,
929
+ lighting, texture, etc., to be used as the style of the generated video,
930
+ such as 'anime', 'photography', 'origami', etc.
931
+ */
932
+ VideoGenerationReferenceType["STYLE"] = "STYLE";
933
+ })(VideoGenerationReferenceType || (VideoGenerationReferenceType = {}));
915
934
  /** Enum that controls the compression quality of the generated videos. */
916
935
  var VideoCompressionQuality;
917
936
  (function (VideoCompressionQuality) {
@@ -1574,6 +1593,65 @@ class ComputeTokensResponse {
1574
1593
  /** Response with generated videos. */
1575
1594
  class GenerateVideosResponse {
1576
1595
  }
1596
+ /** A video generation operation. */
1597
+ class GenerateVideosOperation {
1598
+ /**
1599
+ * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
1600
+ * @internal
1601
+ */
1602
+ _fromAPIResponse({ apiResponse, isVertexAI, }) {
1603
+ const operation = new GenerateVideosOperation();
1604
+ operation.name = apiResponse['name'];
1605
+ operation.metadata = apiResponse['metadata'];
1606
+ operation.done = apiResponse['done'];
1607
+ operation.error = apiResponse['error'];
1608
+ if (isVertexAI) {
1609
+ const response = apiResponse['response'];
1610
+ if (response) {
1611
+ const operationResponse = new GenerateVideosResponse();
1612
+ const responseVideos = response['videos'];
1613
+ operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1614
+ return {
1615
+ video: {
1616
+ uri: generatedVideo['gcsUri'],
1617
+ videoBytes: generatedVideo['bytesBase64Encoded']
1618
+ ? tBytes$1(generatedVideo['bytesBase64Encoded'])
1619
+ : undefined,
1620
+ mimeType: generatedVideo['mimeType'],
1621
+ },
1622
+ };
1623
+ });
1624
+ operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1625
+ operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1626
+ operation.response = operationResponse;
1627
+ }
1628
+ }
1629
+ else {
1630
+ const response = apiResponse['response'];
1631
+ if (response) {
1632
+ const operationResponse = new GenerateVideosResponse();
1633
+ const generatedVideoResponse = response['generateVideoResponse'];
1634
+ const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
1635
+ operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1636
+ const video = generatedVideo['video'];
1637
+ return {
1638
+ video: {
1639
+ uri: video === null || video === void 0 ? void 0 : video['uri'],
1640
+ videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
1641
+ ? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
1642
+ : undefined,
1643
+ mimeType: generatedVideo['encoding'],
1644
+ },
1645
+ };
1646
+ });
1647
+ operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1648
+ operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1649
+ operation.response = operationResponse;
1650
+ }
1651
+ }
1652
+ return operation;
1653
+ }
1654
+ }
1577
1655
  /** Response for the list tuning jobs method. */
1578
1656
  class ListTuningJobsResponse {
1579
1657
  }
@@ -1765,65 +1843,6 @@ class LiveServerMessage {
1765
1843
  return data.length > 0 ? btoa(data) : undefined;
1766
1844
  }
1767
1845
  }
1768
- /** A video generation long-running operation. */
1769
- class GenerateVideosOperation {
1770
- /**
1771
- * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
1772
- * @internal
1773
- */
1774
- _fromAPIResponse({ apiResponse, isVertexAI, }) {
1775
- const operation = new GenerateVideosOperation();
1776
- operation.name = apiResponse['name'];
1777
- operation.metadata = apiResponse['metadata'];
1778
- operation.done = apiResponse['done'];
1779
- operation.error = apiResponse['error'];
1780
- if (isVertexAI) {
1781
- const response = apiResponse['response'];
1782
- if (response) {
1783
- const operationResponse = new GenerateVideosResponse();
1784
- const responseVideos = response['videos'];
1785
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1786
- return {
1787
- video: {
1788
- uri: generatedVideo['gcsUri'],
1789
- videoBytes: generatedVideo['bytesBase64Encoded']
1790
- ? tBytes$1(generatedVideo['bytesBase64Encoded'])
1791
- : undefined,
1792
- mimeType: generatedVideo['mimeType'],
1793
- },
1794
- };
1795
- });
1796
- operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1797
- operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1798
- operation.response = operationResponse;
1799
- }
1800
- }
1801
- else {
1802
- const response = apiResponse['response'];
1803
- if (response) {
1804
- const operationResponse = new GenerateVideosResponse();
1805
- const generatedVideoResponse = response['generateVideoResponse'];
1806
- const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
1807
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1808
- const video = generatedVideo['video'];
1809
- return {
1810
- video: {
1811
- uri: video === null || video === void 0 ? void 0 : video['uri'],
1812
- videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
1813
- ? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
1814
- : undefined,
1815
- mimeType: generatedVideo['encoding'],
1816
- },
1817
- };
1818
- });
1819
- operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1820
- operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1821
- operation.response = operationResponse;
1822
- }
1823
- }
1824
- return operation;
1825
- }
1826
- }
1827
1846
  /** Client generated response to a `ToolCall` received from the server.
1828
1847
 
1829
1848
  Individual `FunctionResponse` objects are matched to the respective
@@ -2470,6 +2489,9 @@ function mcpToGeminiTool(mcpTool, config = {}) {
2470
2489
  description: mcpToolSchema['description'],
2471
2490
  parametersJsonSchema: mcpToolSchema['inputSchema'],
2472
2491
  };
2492
+ if (mcpToolSchema['outputSchema']) {
2493
+ functionDeclaration['responseJsonSchema'] = mcpToolSchema['outputSchema'];
2494
+ }
2473
2495
  if (config.behavior) {
2474
2496
  functionDeclaration['behavior'] = config.behavior;
2475
2497
  }
@@ -5717,8 +5739,14 @@ function cachedContentFromMldev(fromObject) {
5717
5739
  }
5718
5740
  return toObject;
5719
5741
  }
5720
- function deleteCachedContentResponseFromMldev() {
5742
+ function deleteCachedContentResponseFromMldev(fromObject) {
5721
5743
  const toObject = {};
5744
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
5745
+ 'sdkHttpResponse',
5746
+ ]);
5747
+ if (fromSdkHttpResponse != null) {
5748
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
5749
+ }
5722
5750
  return toObject;
5723
5751
  }
5724
5752
  function listCachedContentsResponseFromMldev(fromObject) {
@@ -5783,8 +5811,14 @@ function cachedContentFromVertex(fromObject) {
5783
5811
  }
5784
5812
  return toObject;
5785
5813
  }
5786
- function deleteCachedContentResponseFromVertex() {
5814
+ function deleteCachedContentResponseFromVertex(fromObject) {
5787
5815
  const toObject = {};
5816
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
5817
+ 'sdkHttpResponse',
5818
+ ]);
5819
+ if (fromSdkHttpResponse != null) {
5820
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
5821
+ }
5788
5822
  return toObject;
5789
5823
  }
5790
5824
  function listCachedContentsResponseFromVertex(fromObject) {
@@ -6021,10 +6055,16 @@ class Caches extends BaseModule {
6021
6055
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
6022
6056
  })
6023
6057
  .then((httpResponse) => {
6024
- return httpResponse.json();
6058
+ return httpResponse.json().then((jsonResponse) => {
6059
+ const response = jsonResponse;
6060
+ response.sdkHttpResponse = {
6061
+ headers: httpResponse.headers,
6062
+ };
6063
+ return response;
6064
+ });
6025
6065
  });
6026
- return response.then(() => {
6027
- const resp = deleteCachedContentResponseFromVertex();
6066
+ return response.then((apiResponse) => {
6067
+ const resp = deleteCachedContentResponseFromVertex(apiResponse);
6028
6068
  const typedResp = new DeleteCachedContentResponse();
6029
6069
  Object.assign(typedResp, resp);
6030
6070
  return typedResp;
@@ -6047,10 +6087,16 @@ class Caches extends BaseModule {
6047
6087
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
6048
6088
  })
6049
6089
  .then((httpResponse) => {
6050
- return httpResponse.json();
6090
+ return httpResponse.json().then((jsonResponse) => {
6091
+ const response = jsonResponse;
6092
+ response.sdkHttpResponse = {
6093
+ headers: httpResponse.headers,
6094
+ };
6095
+ return response;
6096
+ });
6051
6097
  });
6052
- return response.then(() => {
6053
- const resp = deleteCachedContentResponseFromMldev();
6098
+ return response.then((apiResponse) => {
6099
+ const resp = deleteCachedContentResponseFromMldev(apiResponse);
6054
6100
  const typedResp = new DeleteCachedContentResponse();
6055
6101
  Object.assign(typedResp, resp);
6056
6102
  return typedResp;
@@ -6854,8 +6900,14 @@ function createFileResponseFromMldev(fromObject) {
6854
6900
  }
6855
6901
  return toObject;
6856
6902
  }
6857
- function deleteFileResponseFromMldev() {
6903
+ function deleteFileResponseFromMldev(fromObject) {
6858
6904
  const toObject = {};
6905
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
6906
+ 'sdkHttpResponse',
6907
+ ]);
6908
+ if (fromSdkHttpResponse != null) {
6909
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
6910
+ }
6859
6911
  return toObject;
6860
6912
  }
6861
6913
 
@@ -7124,10 +7176,16 @@ class Files extends BaseModule {
7124
7176
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
7125
7177
  })
7126
7178
  .then((httpResponse) => {
7127
- return httpResponse.json();
7179
+ return httpResponse.json().then((jsonResponse) => {
7180
+ const response = jsonResponse;
7181
+ response.sdkHttpResponse = {
7182
+ headers: httpResponse.headers,
7183
+ };
7184
+ return response;
7185
+ });
7128
7186
  });
7129
- return response.then(() => {
7130
- const resp = deleteFileResponseFromMldev();
7187
+ return response.then((apiResponse) => {
7188
+ const resp = deleteFileResponseFromMldev(apiResponse);
7131
7189
  const typedResp = new DeleteFileResponse();
7132
7190
  Object.assign(typedResp, resp);
7133
7191
  return typedResp;
@@ -10430,6 +10488,21 @@ function imageToMldev(fromObject) {
10430
10488
  }
10431
10489
  return toObject;
10432
10490
  }
10491
+ function generateVideosSourceToMldev(fromObject, parentObject) {
10492
+ const toObject = {};
10493
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
10494
+ if (parentObject !== undefined && fromPrompt != null) {
10495
+ setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
10496
+ }
10497
+ const fromImage = getValueByPath(fromObject, ['image']);
10498
+ if (parentObject !== undefined && fromImage != null) {
10499
+ setValueByPath(parentObject, ['instances[0]', 'image'], imageToMldev(fromImage));
10500
+ }
10501
+ if (getValueByPath(fromObject, ['video']) !== undefined) {
10502
+ throw new Error('video parameter is not supported in Gemini API.');
10503
+ }
10504
+ return toObject;
10505
+ }
10433
10506
  function generateVideosConfigToMldev(fromObject, parentObject) {
10434
10507
  const toObject = {};
10435
10508
  const fromNumberOfVideos = getValueByPath(fromObject, [
@@ -10512,6 +10585,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
10512
10585
  if (getValueByPath(fromObject, ['video']) !== undefined) {
10513
10586
  throw new Error('video parameter is not supported in Gemini API.');
10514
10587
  }
10588
+ const fromSource = getValueByPath(fromObject, ['source']);
10589
+ if (fromSource != null) {
10590
+ setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
10591
+ }
10515
10592
  const fromConfig = getValueByPath(fromObject, ['config']);
10516
10593
  if (fromConfig != null) {
10517
10594
  setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
@@ -11636,6 +11713,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
11636
11713
  }
11637
11714
  function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
11638
11715
  const toObject = {};
11716
+ const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
11717
+ if (parentObject !== undefined && fromOutputGcsUri != null) {
11718
+ setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
11719
+ }
11639
11720
  const fromIncludeRaiReason = getValueByPath(fromObject, [
11640
11721
  'includeRaiReason',
11641
11722
  ]);
@@ -11764,6 +11845,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
11764
11845
  if (parentObject !== undefined && fromPersonGeneration != null) {
11765
11846
  setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
11766
11847
  }
11848
+ const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
11849
+ if (parentObject !== undefined && fromAddWatermark != null) {
11850
+ setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
11851
+ }
11767
11852
  const fromOutputMimeType = getValueByPath(fromObject, [
11768
11853
  'outputMimeType',
11769
11854
  ]);
@@ -12040,6 +12125,22 @@ function videoToVertex(fromObject) {
12040
12125
  }
12041
12126
  return toObject;
12042
12127
  }
12128
+ function generateVideosSourceToVertex(fromObject, parentObject) {
12129
+ const toObject = {};
12130
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
12131
+ if (parentObject !== undefined && fromPrompt != null) {
12132
+ setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
12133
+ }
12134
+ const fromImage = getValueByPath(fromObject, ['image']);
12135
+ if (parentObject !== undefined && fromImage != null) {
12136
+ setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
12137
+ }
12138
+ const fromVideo = getValueByPath(fromObject, ['video']);
12139
+ if (parentObject !== undefined && fromVideo != null) {
12140
+ setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
12141
+ }
12142
+ return toObject;
12143
+ }
12043
12144
  function videoGenerationReferenceImageToVertex(fromObject) {
12044
12145
  const toObject = {};
12045
12146
  const fromImage = getValueByPath(fromObject, ['image']);
@@ -12158,6 +12259,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
12158
12259
  if (fromVideo != null) {
12159
12260
  setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
12160
12261
  }
12262
+ const fromSource = getValueByPath(fromObject, ['source']);
12263
+ if (fromSource != null) {
12264
+ setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
12265
+ }
12161
12266
  const fromConfig = getValueByPath(fromObject, ['config']);
12162
12267
  if (fromConfig != null) {
12163
12268
  setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
@@ -12608,8 +12713,14 @@ function listModelsResponseFromMldev(fromObject) {
12608
12713
  }
12609
12714
  return toObject;
12610
12715
  }
12611
- function deleteModelResponseFromMldev() {
12716
+ function deleteModelResponseFromMldev(fromObject) {
12612
12717
  const toObject = {};
12718
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12719
+ 'sdkHttpResponse',
12720
+ ]);
12721
+ if (fromSdkHttpResponse != null) {
12722
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12723
+ }
12613
12724
  return toObject;
12614
12725
  }
12615
12726
  function countTokensResponseFromMldev(fromObject) {
@@ -13354,8 +13465,14 @@ function listModelsResponseFromVertex(fromObject) {
13354
13465
  }
13355
13466
  return toObject;
13356
13467
  }
13357
- function deleteModelResponseFromVertex() {
13468
+ function deleteModelResponseFromVertex(fromObject) {
13358
13469
  const toObject = {};
13470
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13471
+ 'sdkHttpResponse',
13472
+ ]);
13473
+ if (fromSdkHttpResponse != null) {
13474
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13475
+ }
13359
13476
  return toObject;
13360
13477
  }
13361
13478
  function countTokensResponseFromVertex(fromObject) {
@@ -13472,7 +13589,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
13472
13589
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
13473
13590
  const USER_AGENT_HEADER = 'User-Agent';
13474
13591
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
13475
- const SDK_VERSION = '1.15.0'; // x-release-please-version
13592
+ const SDK_VERSION = '1.16.0'; // x-release-please-version
13476
13593
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
13477
13594
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
13478
13595
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -15244,7 +15361,9 @@ class Models extends BaseModule {
15244
15361
  * ```ts
15245
15362
  * const operation = await ai.models.generateVideos({
15246
15363
  * model: 'veo-2.0-generate-001',
15247
- * prompt: 'A neon hologram of a cat driving at top speed',
15364
+ * source: {
15365
+ * prompt: 'A neon hologram of a cat driving at top speed',
15366
+ * },
15248
15367
  * config: {
15249
15368
  * numberOfVideos: 1
15250
15369
  * });
@@ -15258,6 +15377,9 @@ class Models extends BaseModule {
15258
15377
  * ```
15259
15378
  */
15260
15379
  this.generateVideos = async (params) => {
15380
+ if ((params.prompt || params.image || params.video) && params.source) {
15381
+ throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
15382
+ }
15261
15383
  return await this.generateVideosInternal(params);
15262
15384
  };
15263
15385
  }
@@ -16206,10 +16328,16 @@ class Models extends BaseModule {
16206
16328
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
16207
16329
  })
16208
16330
  .then((httpResponse) => {
16209
- return httpResponse.json();
16331
+ return httpResponse.json().then((jsonResponse) => {
16332
+ const response = jsonResponse;
16333
+ response.sdkHttpResponse = {
16334
+ headers: httpResponse.headers,
16335
+ };
16336
+ return response;
16337
+ });
16210
16338
  });
16211
- return response.then(() => {
16212
- const resp = deleteModelResponseFromVertex();
16339
+ return response.then((apiResponse) => {
16340
+ const resp = deleteModelResponseFromVertex(apiResponse);
16213
16341
  const typedResp = new DeleteModelResponse();
16214
16342
  Object.assign(typedResp, resp);
16215
16343
  return typedResp;
@@ -16232,10 +16360,16 @@ class Models extends BaseModule {
16232
16360
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
16233
16361
  })
16234
16362
  .then((httpResponse) => {
16235
- return httpResponse.json();
16363
+ return httpResponse.json().then((jsonResponse) => {
16364
+ const response = jsonResponse;
16365
+ response.sdkHttpResponse = {
16366
+ headers: httpResponse.headers,
16367
+ };
16368
+ return response;
16369
+ });
16236
16370
  });
16237
- return response.then(() => {
16238
- const resp = deleteModelResponseFromMldev();
16371
+ return response.then((apiResponse) => {
16372
+ const resp = deleteModelResponseFromMldev(apiResponse);
16239
16373
  const typedResp = new DeleteModelResponse();
16240
16374
  Object.assign(typedResp, resp);
16241
16375
  return typedResp;
@@ -16490,13 +16624,17 @@ function getOperationParametersToMldev(fromObject) {
16490
16624
  }
16491
16625
  return toObject;
16492
16626
  }
16493
- function getOperationParametersToVertex(fromObject) {
16627
+ function fetchPredictOperationParametersToVertex(fromObject) {
16494
16628
  const toObject = {};
16495
16629
  const fromOperationName = getValueByPath(fromObject, [
16496
16630
  'operationName',
16497
16631
  ]);
16498
16632
  if (fromOperationName != null) {
16499
- setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
16633
+ setValueByPath(toObject, ['operationName'], fromOperationName);
16634
+ }
16635
+ const fromResourceName = getValueByPath(fromObject, ['resourceName']);
16636
+ if (fromResourceName != null) {
16637
+ setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
16500
16638
  }
16501
16639
  const fromConfig = getValueByPath(fromObject, ['config']);
16502
16640
  if (fromConfig != null) {
@@ -16504,17 +16642,13 @@ function getOperationParametersToVertex(fromObject) {
16504
16642
  }
16505
16643
  return toObject;
16506
16644
  }
16507
- function fetchPredictOperationParametersToVertex(fromObject) {
16645
+ function getOperationParametersToVertex(fromObject) {
16508
16646
  const toObject = {};
16509
16647
  const fromOperationName = getValueByPath(fromObject, [
16510
16648
  'operationName',
16511
16649
  ]);
16512
16650
  if (fromOperationName != null) {
16513
- setValueByPath(toObject, ['operationName'], fromOperationName);
16514
- }
16515
- const fromResourceName = getValueByPath(fromObject, ['resourceName']);
16516
- if (fromResourceName != null) {
16517
- setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
16651
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
16518
16652
  }
16519
16653
  const fromConfig = getValueByPath(fromObject, ['config']);
16520
16654
  if (fromConfig != null) {
@@ -17775,6 +17909,18 @@ function listTuningJobsParametersToMldev(fromObject) {
17775
17909
  }
17776
17910
  return toObject;
17777
17911
  }
17912
+ function cancelTuningJobParametersToMldev(fromObject) {
17913
+ const toObject = {};
17914
+ const fromName = getValueByPath(fromObject, ['name']);
17915
+ if (fromName != null) {
17916
+ setValueByPath(toObject, ['_url', 'name'], fromName);
17917
+ }
17918
+ const fromConfig = getValueByPath(fromObject, ['config']);
17919
+ if (fromConfig != null) {
17920
+ setValueByPath(toObject, ['config'], fromConfig);
17921
+ }
17922
+ return toObject;
17923
+ }
17778
17924
  function tuningExampleToMldev(fromObject) {
17779
17925
  const toObject = {};
17780
17926
  const fromTextInput = getValueByPath(fromObject, ['textInput']);
@@ -17912,6 +18058,18 @@ function listTuningJobsParametersToVertex(fromObject) {
17912
18058
  }
17913
18059
  return toObject;
17914
18060
  }
18061
+ function cancelTuningJobParametersToVertex(fromObject) {
18062
+ const toObject = {};
18063
+ const fromName = getValueByPath(fromObject, ['name']);
18064
+ if (fromName != null) {
18065
+ setValueByPath(toObject, ['_url', 'name'], fromName);
18066
+ }
18067
+ const fromConfig = getValueByPath(fromObject, ['config']);
18068
+ if (fromConfig != null) {
18069
+ setValueByPath(toObject, ['config'], fromConfig);
18070
+ }
18071
+ return toObject;
18072
+ }
17915
18073
  function tuningDatasetToVertex(fromObject, parentObject) {
17916
18074
  const toObject = {};
17917
18075
  const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
@@ -18565,6 +18723,54 @@ class Tunings extends BaseModule {
18565
18723
  });
18566
18724
  }
18567
18725
  }
18726
+ /**
18727
+ * Cancels a tuning job.
18728
+ *
18729
+ * @param params - The parameters for the cancel request.
18730
+ * @return The empty response returned by the API.
18731
+ *
18732
+ * @example
18733
+ * ```ts
18734
+ * await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
18735
+ * ```
18736
+ */
18737
+ async cancel(params) {
18738
+ var _a, _b, _c, _d;
18739
+ let path = '';
18740
+ let queryParams = {};
18741
+ if (this.apiClient.isVertexAI()) {
18742
+ const body = cancelTuningJobParametersToVertex(params);
18743
+ path = formatMap('{name}:cancel', body['_url']);
18744
+ queryParams = body['_query'];
18745
+ delete body['config'];
18746
+ delete body['_url'];
18747
+ delete body['_query'];
18748
+ await this.apiClient.request({
18749
+ path: path,
18750
+ queryParams: queryParams,
18751
+ body: JSON.stringify(body),
18752
+ httpMethod: 'POST',
18753
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
18754
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
18755
+ });
18756
+ }
18757
+ else {
18758
+ const body = cancelTuningJobParametersToMldev(params);
18759
+ path = formatMap('{name}:cancel', body['_url']);
18760
+ queryParams = body['_query'];
18761
+ delete body['config'];
18762
+ delete body['_url'];
18763
+ delete body['_query'];
18764
+ await this.apiClient.request({
18765
+ path: path,
18766
+ queryParams: queryParams,
18767
+ body: JSON.stringify(body),
18768
+ httpMethod: 'POST',
18769
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
18770
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
18771
+ });
18772
+ }
18773
+ }
18568
18774
  async tuneInternal(params) {
18569
18775
  var _a, _b;
18570
18776
  let response;
@@ -19048,8 +19254,8 @@ function getApiKeyFromEnv() {
19048
19254
  if (envGoogleApiKey && envGeminiApiKey) {
19049
19255
  console.warn('Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.');
19050
19256
  }
19051
- return envGoogleApiKey || envGeminiApiKey;
19257
+ return envGoogleApiKey || envGeminiApiKey || undefined;
19052
19258
  }
19053
19259
 
19054
- export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TuningMode, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
19260
+ export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TuningMode, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, VideoGenerationReferenceType, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
19055
19261
  //# sourceMappingURL=index.mjs.map