@google/genai 1.15.0 → 1.17.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.mjs CHANGED
@@ -769,6 +769,10 @@ var FunctionCallingConfigMode;
769
769
  * Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
770
770
  */
771
771
  FunctionCallingConfigMode["NONE"] = "NONE";
772
+ /**
773
+ * 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".
774
+ */
775
+ FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
772
776
  })(FunctionCallingConfigMode || (FunctionCallingConfigMode = {}));
773
777
  /** Enum that controls the safety filter level for objectionable content. */
774
778
  var SafetyFilterLevel;
@@ -855,7 +859,7 @@ var SubjectReferenceType;
855
859
  SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
856
860
  SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
857
861
  })(SubjectReferenceType || (SubjectReferenceType = {}));
858
- /** Enum representing the Imagen 3 Edit mode. */
862
+ /** Enum representing the editing mode. */
859
863
  var EditMode;
860
864
  (function (EditMode) {
861
865
  EditMode["EDIT_MODE_DEFAULT"] = "EDIT_MODE_DEFAULT";
@@ -876,6 +880,21 @@ var SegmentMode;
876
880
  SegmentMode["SEMANTIC"] = "SEMANTIC";
877
881
  SegmentMode["INTERACTIVE"] = "INTERACTIVE";
878
882
  })(SegmentMode || (SegmentMode = {}));
883
+ /** Enum for the reference type of a video generation reference image. */
884
+ var VideoGenerationReferenceType;
885
+ (function (VideoGenerationReferenceType) {
886
+ /**
887
+ * A reference image that provides assets to the generated video,
888
+ such as the scene, an object, a character, etc.
889
+ */
890
+ VideoGenerationReferenceType["ASSET"] = "ASSET";
891
+ /**
892
+ * A reference image that provides aesthetics including colors,
893
+ lighting, texture, etc., to be used as the style of the generated video,
894
+ such as 'anime', 'photography', 'origami', etc.
895
+ */
896
+ VideoGenerationReferenceType["STYLE"] = "STYLE";
897
+ })(VideoGenerationReferenceType || (VideoGenerationReferenceType = {}));
879
898
  /** Enum that controls the compression quality of the generated videos. */
880
899
  var VideoCompressionQuality;
881
900
  (function (VideoCompressionQuality) {
@@ -1538,6 +1557,65 @@ class ComputeTokensResponse {
1538
1557
  /** Response with generated videos. */
1539
1558
  class GenerateVideosResponse {
1540
1559
  }
1560
+ /** A video generation operation. */
1561
+ class GenerateVideosOperation {
1562
+ /**
1563
+ * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
1564
+ * @internal
1565
+ */
1566
+ _fromAPIResponse({ apiResponse, isVertexAI, }) {
1567
+ const operation = new GenerateVideosOperation();
1568
+ operation.name = apiResponse['name'];
1569
+ operation.metadata = apiResponse['metadata'];
1570
+ operation.done = apiResponse['done'];
1571
+ operation.error = apiResponse['error'];
1572
+ if (isVertexAI) {
1573
+ const response = apiResponse['response'];
1574
+ if (response) {
1575
+ const operationResponse = new GenerateVideosResponse();
1576
+ const responseVideos = response['videos'];
1577
+ operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1578
+ return {
1579
+ video: {
1580
+ uri: generatedVideo['gcsUri'],
1581
+ videoBytes: generatedVideo['bytesBase64Encoded']
1582
+ ? tBytes$1(generatedVideo['bytesBase64Encoded'])
1583
+ : undefined,
1584
+ mimeType: generatedVideo['mimeType'],
1585
+ },
1586
+ };
1587
+ });
1588
+ operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1589
+ operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1590
+ operation.response = operationResponse;
1591
+ }
1592
+ }
1593
+ else {
1594
+ const response = apiResponse['response'];
1595
+ if (response) {
1596
+ const operationResponse = new GenerateVideosResponse();
1597
+ const generatedVideoResponse = response['generateVideoResponse'];
1598
+ const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
1599
+ operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1600
+ const video = generatedVideo['video'];
1601
+ return {
1602
+ video: {
1603
+ uri: video === null || video === void 0 ? void 0 : video['uri'],
1604
+ videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
1605
+ ? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
1606
+ : undefined,
1607
+ mimeType: generatedVideo['encoding'],
1608
+ },
1609
+ };
1610
+ });
1611
+ operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1612
+ operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1613
+ operation.response = operationResponse;
1614
+ }
1615
+ }
1616
+ return operation;
1617
+ }
1618
+ }
1541
1619
  /** Response for the list tuning jobs method. */
1542
1620
  class ListTuningJobsResponse {
1543
1621
  }
@@ -1729,65 +1807,6 @@ class LiveServerMessage {
1729
1807
  return data.length > 0 ? btoa(data) : undefined;
1730
1808
  }
1731
1809
  }
1732
- /** A video generation long-running operation. */
1733
- class GenerateVideosOperation {
1734
- /**
1735
- * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
1736
- * @internal
1737
- */
1738
- _fromAPIResponse({ apiResponse, isVertexAI, }) {
1739
- const operation = new GenerateVideosOperation();
1740
- operation.name = apiResponse['name'];
1741
- operation.metadata = apiResponse['metadata'];
1742
- operation.done = apiResponse['done'];
1743
- operation.error = apiResponse['error'];
1744
- if (isVertexAI) {
1745
- const response = apiResponse['response'];
1746
- if (response) {
1747
- const operationResponse = new GenerateVideosResponse();
1748
- const responseVideos = response['videos'];
1749
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1750
- return {
1751
- video: {
1752
- uri: generatedVideo['gcsUri'],
1753
- videoBytes: generatedVideo['bytesBase64Encoded']
1754
- ? tBytes$1(generatedVideo['bytesBase64Encoded'])
1755
- : undefined,
1756
- mimeType: generatedVideo['mimeType'],
1757
- },
1758
- };
1759
- });
1760
- operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1761
- operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1762
- operation.response = operationResponse;
1763
- }
1764
- }
1765
- else {
1766
- const response = apiResponse['response'];
1767
- if (response) {
1768
- const operationResponse = new GenerateVideosResponse();
1769
- const generatedVideoResponse = response['generateVideoResponse'];
1770
- const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
1771
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1772
- const video = generatedVideo['video'];
1773
- return {
1774
- video: {
1775
- uri: video === null || video === void 0 ? void 0 : video['uri'],
1776
- videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
1777
- ? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
1778
- : undefined,
1779
- mimeType: generatedVideo['encoding'],
1780
- },
1781
- };
1782
- });
1783
- operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1784
- operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1785
- operation.response = operationResponse;
1786
- }
1787
- }
1788
- return operation;
1789
- }
1790
- }
1791
1810
  /** Client generated response to a `ToolCall` received from the server.
1792
1811
 
1793
1812
  Individual `FunctionResponse` objects are matched to the respective
@@ -2434,6 +2453,9 @@ function mcpToGeminiTool(mcpTool, config = {}) {
2434
2453
  description: mcpToolSchema['description'],
2435
2454
  parametersJsonSchema: mcpToolSchema['inputSchema'],
2436
2455
  };
2456
+ if (mcpToolSchema['outputSchema']) {
2457
+ functionDeclaration['responseJsonSchema'] = mcpToolSchema['outputSchema'];
2458
+ }
2437
2459
  if (config.behavior) {
2438
2460
  functionDeclaration['behavior'] = config.behavior;
2439
2461
  }
@@ -5681,8 +5703,14 @@ function cachedContentFromMldev(fromObject) {
5681
5703
  }
5682
5704
  return toObject;
5683
5705
  }
5684
- function deleteCachedContentResponseFromMldev() {
5706
+ function deleteCachedContentResponseFromMldev(fromObject) {
5685
5707
  const toObject = {};
5708
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
5709
+ 'sdkHttpResponse',
5710
+ ]);
5711
+ if (fromSdkHttpResponse != null) {
5712
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
5713
+ }
5686
5714
  return toObject;
5687
5715
  }
5688
5716
  function listCachedContentsResponseFromMldev(fromObject) {
@@ -5747,8 +5775,14 @@ function cachedContentFromVertex(fromObject) {
5747
5775
  }
5748
5776
  return toObject;
5749
5777
  }
5750
- function deleteCachedContentResponseFromVertex() {
5778
+ function deleteCachedContentResponseFromVertex(fromObject) {
5751
5779
  const toObject = {};
5780
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
5781
+ 'sdkHttpResponse',
5782
+ ]);
5783
+ if (fromSdkHttpResponse != null) {
5784
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
5785
+ }
5752
5786
  return toObject;
5753
5787
  }
5754
5788
  function listCachedContentsResponseFromVertex(fromObject) {
@@ -5985,10 +6019,16 @@ class Caches extends BaseModule {
5985
6019
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
5986
6020
  })
5987
6021
  .then((httpResponse) => {
5988
- return httpResponse.json();
6022
+ return httpResponse.json().then((jsonResponse) => {
6023
+ const response = jsonResponse;
6024
+ response.sdkHttpResponse = {
6025
+ headers: httpResponse.headers,
6026
+ };
6027
+ return response;
6028
+ });
5989
6029
  });
5990
- return response.then(() => {
5991
- const resp = deleteCachedContentResponseFromVertex();
6030
+ return response.then((apiResponse) => {
6031
+ const resp = deleteCachedContentResponseFromVertex(apiResponse);
5992
6032
  const typedResp = new DeleteCachedContentResponse();
5993
6033
  Object.assign(typedResp, resp);
5994
6034
  return typedResp;
@@ -6011,10 +6051,16 @@ class Caches extends BaseModule {
6011
6051
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
6012
6052
  })
6013
6053
  .then((httpResponse) => {
6014
- return httpResponse.json();
6054
+ return httpResponse.json().then((jsonResponse) => {
6055
+ const response = jsonResponse;
6056
+ response.sdkHttpResponse = {
6057
+ headers: httpResponse.headers,
6058
+ };
6059
+ return response;
6060
+ });
6015
6061
  });
6016
- return response.then(() => {
6017
- const resp = deleteCachedContentResponseFromMldev();
6062
+ return response.then((apiResponse) => {
6063
+ const resp = deleteCachedContentResponseFromMldev(apiResponse);
6018
6064
  const typedResp = new DeleteCachedContentResponse();
6019
6065
  Object.assign(typedResp, resp);
6020
6066
  return typedResp;
@@ -6569,7 +6615,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
6569
6615
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
6570
6616
  const USER_AGENT_HEADER = 'User-Agent';
6571
6617
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
6572
- const SDK_VERSION = '1.15.0'; // x-release-please-version
6618
+ const SDK_VERSION = '1.17.0'; // x-release-please-version
6573
6619
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
6574
6620
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
6575
6621
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -7515,8 +7561,14 @@ function createFileResponseFromMldev(fromObject) {
7515
7561
  }
7516
7562
  return toObject;
7517
7563
  }
7518
- function deleteFileResponseFromMldev() {
7564
+ function deleteFileResponseFromMldev(fromObject) {
7519
7565
  const toObject = {};
7566
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
7567
+ 'sdkHttpResponse',
7568
+ ]);
7569
+ if (fromSdkHttpResponse != null) {
7570
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
7571
+ }
7520
7572
  return toObject;
7521
7573
  }
7522
7574
 
@@ -7785,10 +7837,16 @@ class Files extends BaseModule {
7785
7837
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
7786
7838
  })
7787
7839
  .then((httpResponse) => {
7788
- return httpResponse.json();
7840
+ return httpResponse.json().then((jsonResponse) => {
7841
+ const response = jsonResponse;
7842
+ response.sdkHttpResponse = {
7843
+ headers: httpResponse.headers,
7844
+ };
7845
+ return response;
7846
+ });
7789
7847
  });
7790
- return response.then(() => {
7791
- const resp = deleteFileResponseFromMldev();
7848
+ return response.then((apiResponse) => {
7849
+ const resp = deleteFileResponseFromMldev(apiResponse);
7792
7850
  const typedResp = new DeleteFileResponse();
7793
7851
  Object.assign(typedResp, resp);
7794
7852
  return typedResp;
@@ -11091,6 +11149,21 @@ function imageToMldev(fromObject) {
11091
11149
  }
11092
11150
  return toObject;
11093
11151
  }
11152
+ function generateVideosSourceToMldev(fromObject, parentObject) {
11153
+ const toObject = {};
11154
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
11155
+ if (parentObject !== undefined && fromPrompt != null) {
11156
+ setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
11157
+ }
11158
+ const fromImage = getValueByPath(fromObject, ['image']);
11159
+ if (parentObject !== undefined && fromImage != null) {
11160
+ setValueByPath(parentObject, ['instances[0]', 'image'], imageToMldev(fromImage));
11161
+ }
11162
+ if (getValueByPath(fromObject, ['video']) !== undefined) {
11163
+ throw new Error('video parameter is not supported in Gemini API.');
11164
+ }
11165
+ return toObject;
11166
+ }
11094
11167
  function generateVideosConfigToMldev(fromObject, parentObject) {
11095
11168
  const toObject = {};
11096
11169
  const fromNumberOfVideos = getValueByPath(fromObject, [
@@ -11118,8 +11191,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
11118
11191
  if (parentObject !== undefined && fromAspectRatio != null) {
11119
11192
  setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
11120
11193
  }
11121
- if (getValueByPath(fromObject, ['resolution']) !== undefined) {
11122
- throw new Error('resolution parameter is not supported in Gemini API.');
11194
+ const fromResolution = getValueByPath(fromObject, ['resolution']);
11195
+ if (parentObject !== undefined && fromResolution != null) {
11196
+ setValueByPath(parentObject, ['parameters', 'resolution'], fromResolution);
11123
11197
  }
11124
11198
  const fromPersonGeneration = getValueByPath(fromObject, [
11125
11199
  'personGeneration',
@@ -11173,6 +11247,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
11173
11247
  if (getValueByPath(fromObject, ['video']) !== undefined) {
11174
11248
  throw new Error('video parameter is not supported in Gemini API.');
11175
11249
  }
11250
+ const fromSource = getValueByPath(fromObject, ['source']);
11251
+ if (fromSource != null) {
11252
+ setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
11253
+ }
11176
11254
  const fromConfig = getValueByPath(fromObject, ['config']);
11177
11255
  if (fromConfig != null) {
11178
11256
  setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
@@ -12297,6 +12375,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
12297
12375
  }
12298
12376
  function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
12299
12377
  const toObject = {};
12378
+ const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
12379
+ if (parentObject !== undefined && fromOutputGcsUri != null) {
12380
+ setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
12381
+ }
12300
12382
  const fromIncludeRaiReason = getValueByPath(fromObject, [
12301
12383
  'includeRaiReason',
12302
12384
  ]);
@@ -12425,6 +12507,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
12425
12507
  if (parentObject !== undefined && fromPersonGeneration != null) {
12426
12508
  setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
12427
12509
  }
12510
+ const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
12511
+ if (parentObject !== undefined && fromAddWatermark != null) {
12512
+ setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
12513
+ }
12428
12514
  const fromOutputMimeType = getValueByPath(fromObject, [
12429
12515
  'outputMimeType',
12430
12516
  ]);
@@ -12701,6 +12787,22 @@ function videoToVertex(fromObject) {
12701
12787
  }
12702
12788
  return toObject;
12703
12789
  }
12790
+ function generateVideosSourceToVertex(fromObject, parentObject) {
12791
+ const toObject = {};
12792
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
12793
+ if (parentObject !== undefined && fromPrompt != null) {
12794
+ setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
12795
+ }
12796
+ const fromImage = getValueByPath(fromObject, ['image']);
12797
+ if (parentObject !== undefined && fromImage != null) {
12798
+ setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
12799
+ }
12800
+ const fromVideo = getValueByPath(fromObject, ['video']);
12801
+ if (parentObject !== undefined && fromVideo != null) {
12802
+ setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
12803
+ }
12804
+ return toObject;
12805
+ }
12704
12806
  function videoGenerationReferenceImageToVertex(fromObject) {
12705
12807
  const toObject = {};
12706
12808
  const fromImage = getValueByPath(fromObject, ['image']);
@@ -12819,6 +12921,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
12819
12921
  if (fromVideo != null) {
12820
12922
  setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
12821
12923
  }
12924
+ const fromSource = getValueByPath(fromObject, ['source']);
12925
+ if (fromSource != null) {
12926
+ setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
12927
+ }
12822
12928
  const fromConfig = getValueByPath(fromObject, ['config']);
12823
12929
  if (fromConfig != null) {
12824
12930
  setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
@@ -13269,8 +13375,14 @@ function listModelsResponseFromMldev(fromObject) {
13269
13375
  }
13270
13376
  return toObject;
13271
13377
  }
13272
- function deleteModelResponseFromMldev() {
13378
+ function deleteModelResponseFromMldev(fromObject) {
13273
13379
  const toObject = {};
13380
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13381
+ 'sdkHttpResponse',
13382
+ ]);
13383
+ if (fromSdkHttpResponse != null) {
13384
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13385
+ }
13274
13386
  return toObject;
13275
13387
  }
13276
13388
  function countTokensResponseFromMldev(fromObject) {
@@ -14015,8 +14127,14 @@ function listModelsResponseFromVertex(fromObject) {
14015
14127
  }
14016
14128
  return toObject;
14017
14129
  }
14018
- function deleteModelResponseFromVertex() {
14130
+ function deleteModelResponseFromVertex(fromObject) {
14019
14131
  const toObject = {};
14132
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
14133
+ 'sdkHttpResponse',
14134
+ ]);
14135
+ if (fromSdkHttpResponse != null) {
14136
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
14137
+ }
14020
14138
  return toObject;
14021
14139
  }
14022
14140
  function countTokensResponseFromVertex(fromObject) {
@@ -15331,7 +15449,9 @@ class Models extends BaseModule {
15331
15449
  * ```ts
15332
15450
  * const operation = await ai.models.generateVideos({
15333
15451
  * model: 'veo-2.0-generate-001',
15334
- * prompt: 'A neon hologram of a cat driving at top speed',
15452
+ * source: {
15453
+ * prompt: 'A neon hologram of a cat driving at top speed',
15454
+ * },
15335
15455
  * config: {
15336
15456
  * numberOfVideos: 1
15337
15457
  * });
@@ -15345,6 +15465,9 @@ class Models extends BaseModule {
15345
15465
  * ```
15346
15466
  */
15347
15467
  this.generateVideos = async (params) => {
15468
+ if ((params.prompt || params.image || params.video) && params.source) {
15469
+ throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
15470
+ }
15348
15471
  return await this.generateVideosInternal(params);
15349
15472
  };
15350
15473
  }
@@ -15759,23 +15882,7 @@ class Models extends BaseModule {
15759
15882
  }
15760
15883
  }
15761
15884
  /**
15762
- * Generates an image based on a text description and configuration.
15763
- *
15764
- * @param params - The parameters for generating images.
15765
- * @return The response from the API.
15766
- *
15767
- * @example
15768
- * ```ts
15769
- * const response = await ai.models.generateImages({
15770
- * model: 'imagen-3.0-generate-002',
15771
- * prompt: 'Robot holding a red skateboard',
15772
- * config: {
15773
- * numberOfImages: 1,
15774
- * includeRaiReason: true,
15775
- * },
15776
- * });
15777
- * console.log(response?.generatedImages?.[0]?.image?.imageBytes);
15778
- * ```
15885
+ * Private method for generating images.
15779
15886
  */
15780
15887
  async generateImagesInternal(params) {
15781
15888
  var _a, _b, _c, _d;
@@ -15847,6 +15954,9 @@ class Models extends BaseModule {
15847
15954
  });
15848
15955
  }
15849
15956
  }
15957
+ /**
15958
+ * Private method for editing an image.
15959
+ */
15850
15960
  async editImageInternal(params) {
15851
15961
  var _a, _b;
15852
15962
  let response;
@@ -15888,6 +15998,9 @@ class Models extends BaseModule {
15888
15998
  throw new Error('This method is only supported by the Vertex AI.');
15889
15999
  }
15890
16000
  }
16001
+ /**
16002
+ * Private method for upscaling an image.
16003
+ */
15891
16004
  async upscaleImageInternal(params) {
15892
16005
  var _a, _b;
15893
16006
  let response;
@@ -16293,10 +16406,16 @@ class Models extends BaseModule {
16293
16406
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
16294
16407
  })
16295
16408
  .then((httpResponse) => {
16296
- return httpResponse.json();
16409
+ return httpResponse.json().then((jsonResponse) => {
16410
+ const response = jsonResponse;
16411
+ response.sdkHttpResponse = {
16412
+ headers: httpResponse.headers,
16413
+ };
16414
+ return response;
16415
+ });
16297
16416
  });
16298
- return response.then(() => {
16299
- const resp = deleteModelResponseFromVertex();
16417
+ return response.then((apiResponse) => {
16418
+ const resp = deleteModelResponseFromVertex(apiResponse);
16300
16419
  const typedResp = new DeleteModelResponse();
16301
16420
  Object.assign(typedResp, resp);
16302
16421
  return typedResp;
@@ -16319,10 +16438,16 @@ class Models extends BaseModule {
16319
16438
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
16320
16439
  })
16321
16440
  .then((httpResponse) => {
16322
- return httpResponse.json();
16441
+ return httpResponse.json().then((jsonResponse) => {
16442
+ const response = jsonResponse;
16443
+ response.sdkHttpResponse = {
16444
+ headers: httpResponse.headers,
16445
+ };
16446
+ return response;
16447
+ });
16323
16448
  });
16324
- return response.then(() => {
16325
- const resp = deleteModelResponseFromMldev();
16449
+ return response.then((apiResponse) => {
16450
+ const resp = deleteModelResponseFromMldev(apiResponse);
16326
16451
  const typedResp = new DeleteModelResponse();
16327
16452
  Object.assign(typedResp, resp);
16328
16453
  return typedResp;
@@ -16475,27 +16600,7 @@ class Models extends BaseModule {
16475
16600
  }
16476
16601
  }
16477
16602
  /**
16478
- * Generates videos based on a text description and configuration.
16479
- *
16480
- * @param params - The parameters for generating videos.
16481
- * @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
16482
- *
16483
- * @example
16484
- * ```ts
16485
- * const operation = await ai.models.generateVideos({
16486
- * model: 'veo-2.0-generate-001',
16487
- * prompt: 'A neon hologram of a cat driving at top speed',
16488
- * config: {
16489
- * numberOfVideos: 1
16490
- * });
16491
- *
16492
- * while (!operation.done) {
16493
- * await new Promise(resolve => setTimeout(resolve, 10000));
16494
- * operation = await ai.operations.getVideosOperation({operation: operation});
16495
- * }
16496
- *
16497
- * console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
16498
- * ```
16603
+ * Private method for generating videos.
16499
16604
  */
16500
16605
  async generateVideosInternal(params) {
16501
16606
  var _a, _b, _c, _d;
@@ -16577,13 +16682,17 @@ function getOperationParametersToMldev(fromObject) {
16577
16682
  }
16578
16683
  return toObject;
16579
16684
  }
16580
- function getOperationParametersToVertex(fromObject) {
16685
+ function fetchPredictOperationParametersToVertex(fromObject) {
16581
16686
  const toObject = {};
16582
16687
  const fromOperationName = getValueByPath(fromObject, [
16583
16688
  'operationName',
16584
16689
  ]);
16585
16690
  if (fromOperationName != null) {
16586
- setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
16691
+ setValueByPath(toObject, ['operationName'], fromOperationName);
16692
+ }
16693
+ const fromResourceName = getValueByPath(fromObject, ['resourceName']);
16694
+ if (fromResourceName != null) {
16695
+ setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
16587
16696
  }
16588
16697
  const fromConfig = getValueByPath(fromObject, ['config']);
16589
16698
  if (fromConfig != null) {
@@ -16591,17 +16700,13 @@ function getOperationParametersToVertex(fromObject) {
16591
16700
  }
16592
16701
  return toObject;
16593
16702
  }
16594
- function fetchPredictOperationParametersToVertex(fromObject) {
16703
+ function getOperationParametersToVertex(fromObject) {
16595
16704
  const toObject = {};
16596
16705
  const fromOperationName = getValueByPath(fromObject, [
16597
16706
  'operationName',
16598
16707
  ]);
16599
16708
  if (fromOperationName != null) {
16600
- setValueByPath(toObject, ['operationName'], fromOperationName);
16601
- }
16602
- const fromResourceName = getValueByPath(fromObject, ['resourceName']);
16603
- if (fromResourceName != null) {
16604
- setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
16709
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
16605
16710
  }
16606
16711
  const fromConfig = getValueByPath(fromObject, ['config']);
16607
16712
  if (fromConfig != null) {
@@ -17688,6 +17793,18 @@ function listTuningJobsParametersToMldev(fromObject) {
17688
17793
  }
17689
17794
  return toObject;
17690
17795
  }
17796
+ function cancelTuningJobParametersToMldev(fromObject) {
17797
+ const toObject = {};
17798
+ const fromName = getValueByPath(fromObject, ['name']);
17799
+ if (fromName != null) {
17800
+ setValueByPath(toObject, ['_url', 'name'], fromName);
17801
+ }
17802
+ const fromConfig = getValueByPath(fromObject, ['config']);
17803
+ if (fromConfig != null) {
17804
+ setValueByPath(toObject, ['config'], fromConfig);
17805
+ }
17806
+ return toObject;
17807
+ }
17691
17808
  function tuningExampleToMldev(fromObject) {
17692
17809
  const toObject = {};
17693
17810
  const fromTextInput = getValueByPath(fromObject, ['textInput']);
@@ -17825,6 +17942,18 @@ function listTuningJobsParametersToVertex(fromObject) {
17825
17942
  }
17826
17943
  return toObject;
17827
17944
  }
17945
+ function cancelTuningJobParametersToVertex(fromObject) {
17946
+ const toObject = {};
17947
+ const fromName = getValueByPath(fromObject, ['name']);
17948
+ if (fromName != null) {
17949
+ setValueByPath(toObject, ['_url', 'name'], fromName);
17950
+ }
17951
+ const fromConfig = getValueByPath(fromObject, ['config']);
17952
+ if (fromConfig != null) {
17953
+ setValueByPath(toObject, ['config'], fromConfig);
17954
+ }
17955
+ return toObject;
17956
+ }
17828
17957
  function tuningDatasetToVertex(fromObject, parentObject) {
17829
17958
  const toObject = {};
17830
17959
  const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
@@ -18478,6 +18607,54 @@ class Tunings extends BaseModule {
18478
18607
  });
18479
18608
  }
18480
18609
  }
18610
+ /**
18611
+ * Cancels a tuning job.
18612
+ *
18613
+ * @param params - The parameters for the cancel request.
18614
+ * @return The empty response returned by the API.
18615
+ *
18616
+ * @example
18617
+ * ```ts
18618
+ * await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
18619
+ * ```
18620
+ */
18621
+ async cancel(params) {
18622
+ var _a, _b, _c, _d;
18623
+ let path = '';
18624
+ let queryParams = {};
18625
+ if (this.apiClient.isVertexAI()) {
18626
+ const body = cancelTuningJobParametersToVertex(params);
18627
+ path = formatMap('{name}:cancel', body['_url']);
18628
+ queryParams = body['_query'];
18629
+ delete body['config'];
18630
+ delete body['_url'];
18631
+ delete body['_query'];
18632
+ await this.apiClient.request({
18633
+ path: path,
18634
+ queryParams: queryParams,
18635
+ body: JSON.stringify(body),
18636
+ httpMethod: 'POST',
18637
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
18638
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
18639
+ });
18640
+ }
18641
+ else {
18642
+ const body = cancelTuningJobParametersToMldev(params);
18643
+ path = formatMap('{name}:cancel', body['_url']);
18644
+ queryParams = body['_query'];
18645
+ delete body['config'];
18646
+ delete body['_url'];
18647
+ delete body['_query'];
18648
+ await this.apiClient.request({
18649
+ path: path,
18650
+ queryParams: queryParams,
18651
+ body: JSON.stringify(body),
18652
+ httpMethod: 'POST',
18653
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
18654
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
18655
+ });
18656
+ }
18657
+ }
18481
18658
  async tuneInternal(params) {
18482
18659
  var _a, _b;
18483
18660
  let response;
@@ -18653,5 +18830,5 @@ class GoogleGenAI {
18653
18830
  }
18654
18831
  }
18655
18832
 
18656
- 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 };
18833
+ 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 };
18657
18834
  //# sourceMappingURL=index.mjs.map