@google/genai 1.29.1 → 1.31.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
@@ -756,6 +756,22 @@ var PhishBlockThreshold;
756
756
  */
757
757
  PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
758
758
  })(PhishBlockThreshold || (PhishBlockThreshold = {}));
759
+ /** The level of thoughts tokens that the model should generate. */
760
+ var ThinkingLevel;
761
+ (function (ThinkingLevel) {
762
+ /**
763
+ * Default value.
764
+ */
765
+ ThinkingLevel["THINKING_LEVEL_UNSPECIFIED"] = "THINKING_LEVEL_UNSPECIFIED";
766
+ /**
767
+ * Low thinking level.
768
+ */
769
+ ThinkingLevel["LOW"] = "LOW";
770
+ /**
771
+ * High thinking level.
772
+ */
773
+ ThinkingLevel["HIGH"] = "HIGH";
774
+ })(ThinkingLevel || (ThinkingLevel = {}));
759
775
  /** Harm category. */
760
776
  var HarmCategory;
761
777
  (function (HarmCategory) {
@@ -1198,6 +1214,26 @@ var TuningTask;
1198
1214
  */
1199
1215
  TuningTask["TUNING_TASK_R2V"] = "TUNING_TASK_R2V";
1200
1216
  })(TuningTask || (TuningTask = {}));
1217
+ /** The tokenization quality used for given media. */
1218
+ var PartMediaResolutionLevel;
1219
+ (function (PartMediaResolutionLevel) {
1220
+ /**
1221
+ * Media resolution has not been set.
1222
+ */
1223
+ PartMediaResolutionLevel["MEDIA_RESOLUTION_UNSPECIFIED"] = "MEDIA_RESOLUTION_UNSPECIFIED";
1224
+ /**
1225
+ * Media resolution set to low.
1226
+ */
1227
+ PartMediaResolutionLevel["MEDIA_RESOLUTION_LOW"] = "MEDIA_RESOLUTION_LOW";
1228
+ /**
1229
+ * Media resolution set to medium.
1230
+ */
1231
+ PartMediaResolutionLevel["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
1232
+ /**
1233
+ * Media resolution set to high.
1234
+ */
1235
+ PartMediaResolutionLevel["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
1236
+ })(PartMediaResolutionLevel || (PartMediaResolutionLevel = {}));
1201
1237
  /** Options for feature selection preference. */
1202
1238
  var FeatureSelectionPreference;
1203
1239
  (function (FeatureSelectionPreference) {
@@ -1732,13 +1768,11 @@ class FunctionResponse {
1732
1768
  /**
1733
1769
  * Creates a `Part` object from a `URI` string.
1734
1770
  */
1735
- function createPartFromUri(uri, mimeType) {
1736
- return {
1737
- fileData: {
1771
+ function createPartFromUri(uri, mimeType, mediaResolution) {
1772
+ return Object.assign({ fileData: {
1738
1773
  fileUri: uri,
1739
1774
  mimeType: mimeType,
1740
- },
1741
- };
1775
+ } }, (mediaResolution && { mediaResolution: { level: mediaResolution } }));
1742
1776
  }
1743
1777
  /**
1744
1778
  * Creates a `Part` object from a `text` string.
@@ -1770,13 +1804,11 @@ function createPartFromFunctionResponse(id, name, response, parts = []) {
1770
1804
  /**
1771
1805
  * Creates a `Part` object from a `base64` encoded `string`.
1772
1806
  */
1773
- function createPartFromBase64(data, mimeType) {
1774
- return {
1775
- inlineData: {
1807
+ function createPartFromBase64(data, mimeType, mediaResolution) {
1808
+ return Object.assign({ inlineData: {
1776
1809
  data: data,
1777
1810
  mimeType: mimeType,
1778
- },
1779
- };
1811
+ } }, (mediaResolution && { mediaResolution: { level: mediaResolution } }));
1780
1812
  }
1781
1813
  /**
1782
1814
  * Creates a `Part` object from the `outcome` and `output` of a `CodeExecutionResult` object.
@@ -2162,6 +2194,9 @@ class GenerateVideosOperation {
2162
2194
  /** Response for the list tuning jobs method. */
2163
2195
  class ListTuningJobsResponse {
2164
2196
  }
2197
+ /** Empty response for tunings.cancel method. */
2198
+ class CancelTuningJobResponse {
2199
+ }
2165
2200
  /** Empty response for caches.delete method. */
2166
2201
  class DeleteCachedContentResponse {
2167
2202
  }
@@ -3856,6 +3891,46 @@ function fileDataToMldev$4(fromObject) {
3856
3891
  }
3857
3892
  return toObject;
3858
3893
  }
3894
+ function functionCallToMldev$4(fromObject) {
3895
+ const toObject = {};
3896
+ const fromId = getValueByPath(fromObject, ['id']);
3897
+ if (fromId != null) {
3898
+ setValueByPath(toObject, ['id'], fromId);
3899
+ }
3900
+ const fromArgs = getValueByPath(fromObject, ['args']);
3901
+ if (fromArgs != null) {
3902
+ setValueByPath(toObject, ['args'], fromArgs);
3903
+ }
3904
+ const fromName = getValueByPath(fromObject, ['name']);
3905
+ if (fromName != null) {
3906
+ setValueByPath(toObject, ['name'], fromName);
3907
+ }
3908
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
3909
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
3910
+ }
3911
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
3912
+ throw new Error('willContinue parameter is not supported in Gemini API.');
3913
+ }
3914
+ return toObject;
3915
+ }
3916
+ function functionCallingConfigToMldev$2(fromObject) {
3917
+ const toObject = {};
3918
+ const fromMode = getValueByPath(fromObject, ['mode']);
3919
+ if (fromMode != null) {
3920
+ setValueByPath(toObject, ['mode'], fromMode);
3921
+ }
3922
+ const fromAllowedFunctionNames = getValueByPath(fromObject, [
3923
+ 'allowedFunctionNames',
3924
+ ]);
3925
+ if (fromAllowedFunctionNames != null) {
3926
+ setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
3927
+ }
3928
+ if (getValueByPath(fromObject, ['streamFunctionCallArguments']) !==
3929
+ undefined) {
3930
+ throw new Error('streamFunctionCallArguments parameter is not supported in Gemini API.');
3931
+ }
3932
+ return toObject;
3933
+ }
3859
3934
  function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
3860
3935
  const toObject = {};
3861
3936
  const fromSystemInstruction = getValueByPath(fromObject, [
@@ -3968,7 +4043,7 @@ function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
3968
4043
  }
3969
4044
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
3970
4045
  if (parentObject !== undefined && fromToolConfig != null) {
3971
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
4046
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev$2(fromToolConfig));
3972
4047
  }
3973
4048
  if (getValueByPath(fromObject, ['labels']) !== undefined) {
3974
4049
  throw new Error('labels parameter is not supported in Gemini API.');
@@ -4006,7 +4081,7 @@ function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
4006
4081
  }
4007
4082
  const fromImageConfig = getValueByPath(fromObject, ['imageConfig']);
4008
4083
  if (fromImageConfig != null) {
4009
- setValueByPath(toObject, ['imageConfig'], fromImageConfig);
4084
+ setValueByPath(toObject, ['imageConfig'], imageConfigToMldev$1(fromImageConfig));
4010
4085
  }
4011
4086
  return toObject;
4012
4087
  }
@@ -4093,6 +4168,25 @@ function googleSearchToMldev$4(fromObject) {
4093
4168
  }
4094
4169
  return toObject;
4095
4170
  }
4171
+ function imageConfigToMldev$1(fromObject) {
4172
+ const toObject = {};
4173
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
4174
+ if (fromAspectRatio != null) {
4175
+ setValueByPath(toObject, ['aspectRatio'], fromAspectRatio);
4176
+ }
4177
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
4178
+ if (fromImageSize != null) {
4179
+ setValueByPath(toObject, ['imageSize'], fromImageSize);
4180
+ }
4181
+ if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
4182
+ throw new Error('outputMimeType parameter is not supported in Gemini API.');
4183
+ }
4184
+ if (getValueByPath(fromObject, ['outputCompressionQuality']) !==
4185
+ undefined) {
4186
+ throw new Error('outputCompressionQuality parameter is not supported in Gemini API.');
4187
+ }
4188
+ return toObject;
4189
+ }
4096
4190
  function inlinedRequestToMldev(apiClient, fromObject) {
4097
4191
  const toObject = {};
4098
4192
  const fromModel = getValueByPath(fromObject, ['model']);
@@ -4234,9 +4328,11 @@ function listBatchJobsResponseFromVertex(fromObject) {
4234
4328
  }
4235
4329
  function partToMldev$4(fromObject) {
4236
4330
  const toObject = {};
4237
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
4238
- if (fromFunctionCall != null) {
4239
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
4331
+ const fromMediaResolution = getValueByPath(fromObject, [
4332
+ 'mediaResolution',
4333
+ ]);
4334
+ if (fromMediaResolution != null) {
4335
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
4240
4336
  }
4241
4337
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4242
4338
  'codeExecutionResult',
@@ -4254,6 +4350,10 @@ function partToMldev$4(fromObject) {
4254
4350
  if (fromFileData != null) {
4255
4351
  setValueByPath(toObject, ['fileData'], fileDataToMldev$4(fromFileData));
4256
4352
  }
4353
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
4354
+ if (fromFunctionCall != null) {
4355
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$4(fromFunctionCall));
4356
+ }
4257
4357
  const fromFunctionResponse = getValueByPath(fromObject, [
4258
4358
  'functionResponse',
4259
4359
  ]);
@@ -4301,6 +4401,22 @@ function safetySettingToMldev$1(fromObject) {
4301
4401
  }
4302
4402
  return toObject;
4303
4403
  }
4404
+ function toolConfigToMldev$2(fromObject) {
4405
+ const toObject = {};
4406
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
4407
+ 'functionCallingConfig',
4408
+ ]);
4409
+ if (fromFunctionCallingConfig != null) {
4410
+ setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$2(fromFunctionCallingConfig));
4411
+ }
4412
+ const fromRetrievalConfig = getValueByPath(fromObject, [
4413
+ 'retrievalConfig',
4414
+ ]);
4415
+ if (fromRetrievalConfig != null) {
4416
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
4417
+ }
4418
+ return toObject;
4419
+ }
4304
4420
  function toolToMldev$4(fromObject) {
4305
4421
  const toObject = {};
4306
4422
  const fromFunctionDeclarations = getValueByPath(fromObject, [
@@ -4548,6 +4664,23 @@ class Batches extends BaseModule {
4548
4664
  constructor(apiClient) {
4549
4665
  super();
4550
4666
  this.apiClient = apiClient;
4667
+ /**
4668
+ * Lists batch jobs.
4669
+ *
4670
+ * @param params - The parameters for the list request.
4671
+ * @return - A pager of batch jobs.
4672
+ *
4673
+ * @example
4674
+ * ```ts
4675
+ * const batchJobs = await ai.batches.list({config: {'pageSize': 2}});
4676
+ * for await (const batchJob of batchJobs) {
4677
+ * console.log(batchJob);
4678
+ * }
4679
+ * ```
4680
+ */
4681
+ this.list = async (params = {}) => {
4682
+ return new Pager(PagedItem.PAGED_ITEM_BATCH_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
4683
+ };
4551
4684
  /**
4552
4685
  * Create batch job.
4553
4686
  *
@@ -4596,23 +4729,6 @@ class Batches extends BaseModule {
4596
4729
  }
4597
4730
  return this.createEmbeddingsInternal(params);
4598
4731
  };
4599
- /**
4600
- * Lists batch job configurations.
4601
- *
4602
- * @param params - The parameters for the list request.
4603
- * @return The paginated results of the list of batch jobs.
4604
- *
4605
- * @example
4606
- * ```ts
4607
- * const batchJobs = await ai.batches.list({config: {'pageSize': 2}});
4608
- * for await (const batchJob of batchJobs) {
4609
- * console.log(batchJob);
4610
- * }
4611
- * ```
4612
- */
4613
- this.list = async (params = {}) => {
4614
- return new Pager(PagedItem.PAGED_ITEM_BATCH_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
4615
- };
4616
4732
  }
4617
4733
  // Helper function to handle inlined generate content requests
4618
4734
  createInlinedGenerateContentRequest(params) {
@@ -5123,7 +5239,7 @@ function createCachedContentConfigToMldev(fromObject, parentObject) {
5123
5239
  }
5124
5240
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
5125
5241
  if (parentObject !== undefined && fromToolConfig != null) {
5126
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
5242
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev$1(fromToolConfig));
5127
5243
  }
5128
5244
  if (getValueByPath(fromObject, ['kmsKeyName']) !== undefined) {
5129
5245
  throw new Error('kmsKeyName parameter is not supported in Gemini API.');
@@ -5255,6 +5371,46 @@ function fileDataToMldev$3(fromObject) {
5255
5371
  }
5256
5372
  return toObject;
5257
5373
  }
5374
+ function functionCallToMldev$3(fromObject) {
5375
+ const toObject = {};
5376
+ const fromId = getValueByPath(fromObject, ['id']);
5377
+ if (fromId != null) {
5378
+ setValueByPath(toObject, ['id'], fromId);
5379
+ }
5380
+ const fromArgs = getValueByPath(fromObject, ['args']);
5381
+ if (fromArgs != null) {
5382
+ setValueByPath(toObject, ['args'], fromArgs);
5383
+ }
5384
+ const fromName = getValueByPath(fromObject, ['name']);
5385
+ if (fromName != null) {
5386
+ setValueByPath(toObject, ['name'], fromName);
5387
+ }
5388
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
5389
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
5390
+ }
5391
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
5392
+ throw new Error('willContinue parameter is not supported in Gemini API.');
5393
+ }
5394
+ return toObject;
5395
+ }
5396
+ function functionCallingConfigToMldev$1(fromObject) {
5397
+ const toObject = {};
5398
+ const fromMode = getValueByPath(fromObject, ['mode']);
5399
+ if (fromMode != null) {
5400
+ setValueByPath(toObject, ['mode'], fromMode);
5401
+ }
5402
+ const fromAllowedFunctionNames = getValueByPath(fromObject, [
5403
+ 'allowedFunctionNames',
5404
+ ]);
5405
+ if (fromAllowedFunctionNames != null) {
5406
+ setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
5407
+ }
5408
+ if (getValueByPath(fromObject, ['streamFunctionCallArguments']) !==
5409
+ undefined) {
5410
+ throw new Error('streamFunctionCallArguments parameter is not supported in Gemini API.');
5411
+ }
5412
+ return toObject;
5413
+ }
5258
5414
  function functionDeclarationToVertex$2(fromObject) {
5259
5415
  const toObject = {};
5260
5416
  if (getValueByPath(fromObject, ['behavior']) !== undefined) {
@@ -5431,9 +5587,11 @@ function listCachedContentsResponseFromVertex(fromObject) {
5431
5587
  }
5432
5588
  function partToMldev$3(fromObject) {
5433
5589
  const toObject = {};
5434
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5435
- if (fromFunctionCall != null) {
5436
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
5590
+ const fromMediaResolution = getValueByPath(fromObject, [
5591
+ 'mediaResolution',
5592
+ ]);
5593
+ if (fromMediaResolution != null) {
5594
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
5437
5595
  }
5438
5596
  const fromCodeExecutionResult = getValueByPath(fromObject, [
5439
5597
  'codeExecutionResult',
@@ -5451,6 +5609,10 @@ function partToMldev$3(fromObject) {
5451
5609
  if (fromFileData != null) {
5452
5610
  setValueByPath(toObject, ['fileData'], fileDataToMldev$3(fromFileData));
5453
5611
  }
5612
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5613
+ if (fromFunctionCall != null) {
5614
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$3(fromFunctionCall));
5615
+ }
5454
5616
  const fromFunctionResponse = getValueByPath(fromObject, [
5455
5617
  'functionResponse',
5456
5618
  ]);
@@ -5483,6 +5645,22 @@ function partToMldev$3(fromObject) {
5483
5645
  }
5484
5646
  return toObject;
5485
5647
  }
5648
+ function toolConfigToMldev$1(fromObject) {
5649
+ const toObject = {};
5650
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
5651
+ 'functionCallingConfig',
5652
+ ]);
5653
+ if (fromFunctionCallingConfig != null) {
5654
+ setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(fromFunctionCallingConfig));
5655
+ }
5656
+ const fromRetrievalConfig = getValueByPath(fromObject, [
5657
+ 'retrievalConfig',
5658
+ ]);
5659
+ if (fromRetrievalConfig != null) {
5660
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
5661
+ }
5662
+ return toObject;
5663
+ }
5486
5664
  function toolToMldev$3(fromObject) {
5487
5665
  const toObject = {};
5488
5666
  const fromFunctionDeclarations = getValueByPath(fromObject, [
@@ -5653,10 +5831,10 @@ class Caches extends BaseModule {
5653
5831
  super();
5654
5832
  this.apiClient = apiClient;
5655
5833
  /**
5656
- * Lists cached content configurations.
5834
+ * Lists cached contents.
5657
5835
  *
5658
5836
  * @param params - The parameters for the list request.
5659
- * @return The paginated results of the list of cached contents.
5837
+ * @return - A pager of cached contents.
5660
5838
  *
5661
5839
  * @example
5662
5840
  * ```ts
@@ -6407,101 +6585,336 @@ class Chat {
6407
6585
  * Copyright 2025 Google LLC
6408
6586
  * SPDX-License-Identifier: Apache-2.0
6409
6587
  */
6410
- /**
6411
- * API errors raised by the GenAI API.
6412
- */
6413
- class ApiError extends Error {
6414
- constructor(options) {
6415
- super(options.message);
6416
- this.name = 'ApiError';
6417
- this.status = options.status;
6418
- Object.setPrototypeOf(this, ApiError.prototype);
6588
+ // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
6589
+ function createFileSearchStoreConfigToMldev(fromObject, parentObject) {
6590
+ const toObject = {};
6591
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
6592
+ if (parentObject !== undefined && fromDisplayName != null) {
6593
+ setValueByPath(parentObject, ['displayName'], fromDisplayName);
6419
6594
  }
6595
+ return toObject;
6420
6596
  }
6421
-
6422
- /**
6423
- * @license
6424
- * Copyright 2025 Google LLC
6425
- * SPDX-License-Identifier: Apache-2.0
6426
- */
6427
- const CONTENT_TYPE_HEADER = 'Content-Type';
6428
- const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
6429
- const USER_AGENT_HEADER = 'User-Agent';
6430
- const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
6431
- const SDK_VERSION = '1.29.1'; // x-release-please-version
6432
- const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
6433
- const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
6434
- const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
6435
- const responseLineRE = /^\s*data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;
6436
- /**
6437
- * The ApiClient class is used to send requests to the Gemini API or Vertex AI
6438
- * endpoints.
6439
- */
6440
- class ApiClient {
6441
- constructor(opts) {
6442
- var _a, _b;
6443
- this.clientOptions = Object.assign(Object.assign({}, opts), { project: opts.project, location: opts.location, apiKey: opts.apiKey, vertexai: opts.vertexai });
6444
- const initHttpOptions = {};
6445
- if (this.clientOptions.vertexai) {
6446
- initHttpOptions.apiVersion =
6447
- (_a = this.clientOptions.apiVersion) !== null && _a !== void 0 ? _a : VERTEX_AI_API_DEFAULT_VERSION;
6448
- initHttpOptions.baseUrl = this.baseUrlFromProjectLocation();
6449
- this.normalizeAuthParameters();
6450
- }
6451
- else {
6452
- // Gemini API
6453
- initHttpOptions.apiVersion =
6454
- (_b = this.clientOptions.apiVersion) !== null && _b !== void 0 ? _b : GOOGLE_AI_API_DEFAULT_VERSION;
6455
- initHttpOptions.baseUrl = `https://generativelanguage.googleapis.com/`;
6456
- }
6457
- initHttpOptions.headers = this.getDefaultHeaders();
6458
- this.clientOptions.httpOptions = initHttpOptions;
6459
- if (opts.httpOptions) {
6460
- this.clientOptions.httpOptions = this.patchHttpOptions(initHttpOptions, opts.httpOptions);
6461
- }
6462
- }
6463
- /**
6464
- * Determines the base URL for Vertex AI based on project and location.
6465
- * Uses the global endpoint if location is 'global' or if project/location
6466
- * are not specified (implying API key usage).
6467
- * @private
6468
- */
6469
- baseUrlFromProjectLocation() {
6470
- if (this.clientOptions.project &&
6471
- this.clientOptions.location &&
6472
- this.clientOptions.location !== 'global') {
6473
- // Regional endpoint
6474
- return `https://${this.clientOptions.location}-aiplatform.googleapis.com/`;
6475
- }
6476
- // Global endpoint (covers 'global' location and API key usage)
6477
- return `https://aiplatform.googleapis.com/`;
6597
+ function createFileSearchStoreParametersToMldev(fromObject) {
6598
+ const toObject = {};
6599
+ const fromConfig = getValueByPath(fromObject, ['config']);
6600
+ if (fromConfig != null) {
6601
+ createFileSearchStoreConfigToMldev(fromConfig, toObject);
6478
6602
  }
6479
- /**
6480
- * Normalizes authentication parameters for Vertex AI.
6481
- * If project and location are provided, API key is cleared.
6482
- * If project and location are not provided (implying API key usage),
6483
- * project and location are cleared.
6484
- * @private
6485
- */
6486
- normalizeAuthParameters() {
6487
- if (this.clientOptions.project && this.clientOptions.location) {
6488
- // Using project/location for auth, clear potential API key
6489
- this.clientOptions.apiKey = undefined;
6490
- return;
6491
- }
6492
- // Using API key for auth (or no auth provided yet), clear project/location
6493
- this.clientOptions.project = undefined;
6494
- this.clientOptions.location = undefined;
6603
+ return toObject;
6604
+ }
6605
+ function deleteFileSearchStoreConfigToMldev(fromObject, parentObject) {
6606
+ const toObject = {};
6607
+ const fromForce = getValueByPath(fromObject, ['force']);
6608
+ if (parentObject !== undefined && fromForce != null) {
6609
+ setValueByPath(parentObject, ['_query', 'force'], fromForce);
6495
6610
  }
6496
- isVertexAI() {
6497
- var _a;
6498
- return (_a = this.clientOptions.vertexai) !== null && _a !== void 0 ? _a : false;
6611
+ return toObject;
6612
+ }
6613
+ function deleteFileSearchStoreParametersToMldev(fromObject) {
6614
+ const toObject = {};
6615
+ const fromName = getValueByPath(fromObject, ['name']);
6616
+ if (fromName != null) {
6617
+ setValueByPath(toObject, ['_url', 'name'], fromName);
6499
6618
  }
6500
- getProject() {
6501
- return this.clientOptions.project;
6619
+ const fromConfig = getValueByPath(fromObject, ['config']);
6620
+ if (fromConfig != null) {
6621
+ deleteFileSearchStoreConfigToMldev(fromConfig, toObject);
6502
6622
  }
6503
- getLocation() {
6504
- return this.clientOptions.location;
6623
+ return toObject;
6624
+ }
6625
+ function getFileSearchStoreParametersToMldev(fromObject) {
6626
+ const toObject = {};
6627
+ const fromName = getValueByPath(fromObject, ['name']);
6628
+ if (fromName != null) {
6629
+ setValueByPath(toObject, ['_url', 'name'], fromName);
6630
+ }
6631
+ return toObject;
6632
+ }
6633
+ function importFileConfigToMldev(fromObject, parentObject) {
6634
+ const toObject = {};
6635
+ const fromCustomMetadata = getValueByPath(fromObject, [
6636
+ 'customMetadata',
6637
+ ]);
6638
+ if (parentObject !== undefined && fromCustomMetadata != null) {
6639
+ let transformedList = fromCustomMetadata;
6640
+ if (Array.isArray(transformedList)) {
6641
+ transformedList = transformedList.map((item) => {
6642
+ return item;
6643
+ });
6644
+ }
6645
+ setValueByPath(parentObject, ['customMetadata'], transformedList);
6646
+ }
6647
+ const fromChunkingConfig = getValueByPath(fromObject, [
6648
+ 'chunkingConfig',
6649
+ ]);
6650
+ if (parentObject !== undefined && fromChunkingConfig != null) {
6651
+ setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
6652
+ }
6653
+ return toObject;
6654
+ }
6655
+ function importFileOperationFromMldev(fromObject) {
6656
+ const toObject = {};
6657
+ const fromName = getValueByPath(fromObject, ['name']);
6658
+ if (fromName != null) {
6659
+ setValueByPath(toObject, ['name'], fromName);
6660
+ }
6661
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
6662
+ if (fromMetadata != null) {
6663
+ setValueByPath(toObject, ['metadata'], fromMetadata);
6664
+ }
6665
+ const fromDone = getValueByPath(fromObject, ['done']);
6666
+ if (fromDone != null) {
6667
+ setValueByPath(toObject, ['done'], fromDone);
6668
+ }
6669
+ const fromError = getValueByPath(fromObject, ['error']);
6670
+ if (fromError != null) {
6671
+ setValueByPath(toObject, ['error'], fromError);
6672
+ }
6673
+ const fromResponse = getValueByPath(fromObject, ['response']);
6674
+ if (fromResponse != null) {
6675
+ setValueByPath(toObject, ['response'], importFileResponseFromMldev(fromResponse));
6676
+ }
6677
+ return toObject;
6678
+ }
6679
+ function importFileParametersToMldev(fromObject) {
6680
+ const toObject = {};
6681
+ const fromFileSearchStoreName = getValueByPath(fromObject, [
6682
+ 'fileSearchStoreName',
6683
+ ]);
6684
+ if (fromFileSearchStoreName != null) {
6685
+ setValueByPath(toObject, ['_url', 'file_search_store_name'], fromFileSearchStoreName);
6686
+ }
6687
+ const fromFileName = getValueByPath(fromObject, ['fileName']);
6688
+ if (fromFileName != null) {
6689
+ setValueByPath(toObject, ['fileName'], fromFileName);
6690
+ }
6691
+ const fromConfig = getValueByPath(fromObject, ['config']);
6692
+ if (fromConfig != null) {
6693
+ importFileConfigToMldev(fromConfig, toObject);
6694
+ }
6695
+ return toObject;
6696
+ }
6697
+ function importFileResponseFromMldev(fromObject) {
6698
+ const toObject = {};
6699
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
6700
+ 'sdkHttpResponse',
6701
+ ]);
6702
+ if (fromSdkHttpResponse != null) {
6703
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
6704
+ }
6705
+ const fromParent = getValueByPath(fromObject, ['parent']);
6706
+ if (fromParent != null) {
6707
+ setValueByPath(toObject, ['parent'], fromParent);
6708
+ }
6709
+ const fromDocumentName = getValueByPath(fromObject, ['documentName']);
6710
+ if (fromDocumentName != null) {
6711
+ setValueByPath(toObject, ['documentName'], fromDocumentName);
6712
+ }
6713
+ return toObject;
6714
+ }
6715
+ function listFileSearchStoresConfigToMldev(fromObject, parentObject) {
6716
+ const toObject = {};
6717
+ const fromPageSize = getValueByPath(fromObject, ['pageSize']);
6718
+ if (parentObject !== undefined && fromPageSize != null) {
6719
+ setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
6720
+ }
6721
+ const fromPageToken = getValueByPath(fromObject, ['pageToken']);
6722
+ if (parentObject !== undefined && fromPageToken != null) {
6723
+ setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
6724
+ }
6725
+ return toObject;
6726
+ }
6727
+ function listFileSearchStoresParametersToMldev(fromObject) {
6728
+ const toObject = {};
6729
+ const fromConfig = getValueByPath(fromObject, ['config']);
6730
+ if (fromConfig != null) {
6731
+ listFileSearchStoresConfigToMldev(fromConfig, toObject);
6732
+ }
6733
+ return toObject;
6734
+ }
6735
+ function listFileSearchStoresResponseFromMldev(fromObject) {
6736
+ const toObject = {};
6737
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
6738
+ 'sdkHttpResponse',
6739
+ ]);
6740
+ if (fromSdkHttpResponse != null) {
6741
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
6742
+ }
6743
+ const fromNextPageToken = getValueByPath(fromObject, [
6744
+ 'nextPageToken',
6745
+ ]);
6746
+ if (fromNextPageToken != null) {
6747
+ setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
6748
+ }
6749
+ const fromFileSearchStores = getValueByPath(fromObject, [
6750
+ 'fileSearchStores',
6751
+ ]);
6752
+ if (fromFileSearchStores != null) {
6753
+ let transformedList = fromFileSearchStores;
6754
+ if (Array.isArray(transformedList)) {
6755
+ transformedList = transformedList.map((item) => {
6756
+ return item;
6757
+ });
6758
+ }
6759
+ setValueByPath(toObject, ['fileSearchStores'], transformedList);
6760
+ }
6761
+ return toObject;
6762
+ }
6763
+ function uploadToFileSearchStoreConfigToMldev(fromObject, parentObject) {
6764
+ const toObject = {};
6765
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
6766
+ if (parentObject !== undefined && fromMimeType != null) {
6767
+ setValueByPath(parentObject, ['mimeType'], fromMimeType);
6768
+ }
6769
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
6770
+ if (parentObject !== undefined && fromDisplayName != null) {
6771
+ setValueByPath(parentObject, ['displayName'], fromDisplayName);
6772
+ }
6773
+ const fromCustomMetadata = getValueByPath(fromObject, [
6774
+ 'customMetadata',
6775
+ ]);
6776
+ if (parentObject !== undefined && fromCustomMetadata != null) {
6777
+ let transformedList = fromCustomMetadata;
6778
+ if (Array.isArray(transformedList)) {
6779
+ transformedList = transformedList.map((item) => {
6780
+ return item;
6781
+ });
6782
+ }
6783
+ setValueByPath(parentObject, ['customMetadata'], transformedList);
6784
+ }
6785
+ const fromChunkingConfig = getValueByPath(fromObject, [
6786
+ 'chunkingConfig',
6787
+ ]);
6788
+ if (parentObject !== undefined && fromChunkingConfig != null) {
6789
+ setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
6790
+ }
6791
+ return toObject;
6792
+ }
6793
+ function uploadToFileSearchStoreParametersToMldev(fromObject) {
6794
+ const toObject = {};
6795
+ const fromFileSearchStoreName = getValueByPath(fromObject, [
6796
+ 'fileSearchStoreName',
6797
+ ]);
6798
+ if (fromFileSearchStoreName != null) {
6799
+ setValueByPath(toObject, ['_url', 'file_search_store_name'], fromFileSearchStoreName);
6800
+ }
6801
+ const fromConfig = getValueByPath(fromObject, ['config']);
6802
+ if (fromConfig != null) {
6803
+ uploadToFileSearchStoreConfigToMldev(fromConfig, toObject);
6804
+ }
6805
+ return toObject;
6806
+ }
6807
+ function uploadToFileSearchStoreResumableResponseFromMldev(fromObject) {
6808
+ const toObject = {};
6809
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
6810
+ 'sdkHttpResponse',
6811
+ ]);
6812
+ if (fromSdkHttpResponse != null) {
6813
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
6814
+ }
6815
+ return toObject;
6816
+ }
6817
+
6818
+ /**
6819
+ * @license
6820
+ * Copyright 2025 Google LLC
6821
+ * SPDX-License-Identifier: Apache-2.0
6822
+ */
6823
+ /**
6824
+ * API errors raised by the GenAI API.
6825
+ */
6826
+ class ApiError extends Error {
6827
+ constructor(options) {
6828
+ super(options.message);
6829
+ this.name = 'ApiError';
6830
+ this.status = options.status;
6831
+ Object.setPrototypeOf(this, ApiError.prototype);
6832
+ }
6833
+ }
6834
+
6835
+ /**
6836
+ * @license
6837
+ * Copyright 2025 Google LLC
6838
+ * SPDX-License-Identifier: Apache-2.0
6839
+ */
6840
+ const CONTENT_TYPE_HEADER = 'Content-Type';
6841
+ const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
6842
+ const USER_AGENT_HEADER = 'User-Agent';
6843
+ const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
6844
+ const SDK_VERSION = '1.31.0'; // x-release-please-version
6845
+ const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
6846
+ const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
6847
+ const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
6848
+ const responseLineRE = /^\s*data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;
6849
+ /**
6850
+ * The ApiClient class is used to send requests to the Gemini API or Vertex AI
6851
+ * endpoints.
6852
+ */
6853
+ class ApiClient {
6854
+ constructor(opts) {
6855
+ var _a, _b;
6856
+ this.clientOptions = Object.assign(Object.assign({}, opts), { project: opts.project, location: opts.location, apiKey: opts.apiKey, vertexai: opts.vertexai });
6857
+ const initHttpOptions = {};
6858
+ if (this.clientOptions.vertexai) {
6859
+ initHttpOptions.apiVersion =
6860
+ (_a = this.clientOptions.apiVersion) !== null && _a !== void 0 ? _a : VERTEX_AI_API_DEFAULT_VERSION;
6861
+ initHttpOptions.baseUrl = this.baseUrlFromProjectLocation();
6862
+ this.normalizeAuthParameters();
6863
+ }
6864
+ else {
6865
+ // Gemini API
6866
+ initHttpOptions.apiVersion =
6867
+ (_b = this.clientOptions.apiVersion) !== null && _b !== void 0 ? _b : GOOGLE_AI_API_DEFAULT_VERSION;
6868
+ initHttpOptions.baseUrl = `https://generativelanguage.googleapis.com/`;
6869
+ }
6870
+ initHttpOptions.headers = this.getDefaultHeaders();
6871
+ this.clientOptions.httpOptions = initHttpOptions;
6872
+ if (opts.httpOptions) {
6873
+ this.clientOptions.httpOptions = this.patchHttpOptions(initHttpOptions, opts.httpOptions);
6874
+ }
6875
+ }
6876
+ /**
6877
+ * Determines the base URL for Vertex AI based on project and location.
6878
+ * Uses the global endpoint if location is 'global' or if project/location
6879
+ * are not specified (implying API key usage).
6880
+ * @private
6881
+ */
6882
+ baseUrlFromProjectLocation() {
6883
+ if (this.clientOptions.project &&
6884
+ this.clientOptions.location &&
6885
+ this.clientOptions.location !== 'global') {
6886
+ // Regional endpoint
6887
+ return `https://${this.clientOptions.location}-aiplatform.googleapis.com/`;
6888
+ }
6889
+ // Global endpoint (covers 'global' location and API key usage)
6890
+ return `https://aiplatform.googleapis.com/`;
6891
+ }
6892
+ /**
6893
+ * Normalizes authentication parameters for Vertex AI.
6894
+ * If project and location are provided, API key is cleared.
6895
+ * If project and location are not provided (implying API key usage),
6896
+ * project and location are cleared.
6897
+ * @private
6898
+ */
6899
+ normalizeAuthParameters() {
6900
+ if (this.clientOptions.project && this.clientOptions.location) {
6901
+ // Using project/location for auth, clear potential API key
6902
+ this.clientOptions.apiKey = undefined;
6903
+ return;
6904
+ }
6905
+ // Using API key for auth (or no auth provided yet), clear project/location
6906
+ this.clientOptions.project = undefined;
6907
+ this.clientOptions.location = undefined;
6908
+ }
6909
+ isVertexAI() {
6910
+ var _a;
6911
+ return (_a = this.clientOptions.vertexai) !== null && _a !== void 0 ? _a : false;
6912
+ }
6913
+ getProject() {
6914
+ return this.clientOptions.project;
6915
+ }
6916
+ getLocation() {
6917
+ return this.clientOptions.location;
6505
6918
  }
6506
6919
  getApiVersion() {
6507
6920
  if (this.clientOptions.httpOptions &&
@@ -6877,11 +7290,8 @@ class ApiClient {
6877
7290
  const path = `upload/v1beta/${fileSearchStoreName}:uploadToFileSearchStore`;
6878
7291
  const fileName = this.getFileName(file);
6879
7292
  const body = {};
6880
- if (config === null || config === void 0 ? void 0 : config.customMetadata) {
6881
- body['customMetadata'] = config.customMetadata;
6882
- }
6883
- if (config === null || config === void 0 ? void 0 : config.chunkingConfig) {
6884
- body['chunkingConfig'] = config.chunkingConfig;
7293
+ if (config != null) {
7294
+ uploadToFileSearchStoreConfigToMldev(config, body);
6885
7295
  }
6886
7296
  const uploadUrl = await this.fetchUploadUrl(path, sizeBytes, mimeType, fileName, body, config === null || config === void 0 ? void 0 : config.httpOptions);
6887
7297
  return uploader.uploadToFileSearchStore(file, uploadUrl, this);
@@ -7286,19 +7696,16 @@ class Files extends BaseModule {
7286
7696
  super();
7287
7697
  this.apiClient = apiClient;
7288
7698
  /**
7289
- * Lists all current project files from the service.
7699
+ * Lists files.
7290
7700
  *
7291
- * @param params - The parameters for the list request
7292
- * @return The paginated results of the list of files
7701
+ * @param params - The parameters for the list request.
7702
+ * @return - A pager of files.
7293
7703
  *
7294
7704
  * @example
7295
- * The following code prints the names of all files from the service, the
7296
- * size of each page is 10.
7297
- *
7298
7705
  * ```ts
7299
- * const listResponse = await ai.files.list({config: {'pageSize': 10}});
7300
- * for await (const file of listResponse) {
7301
- * console.log(file.name);
7706
+ * const files = await ai.files.list({config: {'pageSize': 2}});
7707
+ * for await (const file of files) {
7708
+ * console.log(file);
7302
7709
  * }
7303
7710
  * ```
7304
7711
  */
@@ -7533,259 +7940,24 @@ class Files extends BaseModule {
7533
7940
  httpMethod: 'DELETE',
7534
7941
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
7535
7942
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
7536
- })
7537
- .then((httpResponse) => {
7538
- return httpResponse.json().then((jsonResponse) => {
7539
- const response = jsonResponse;
7540
- response.sdkHttpResponse = {
7541
- headers: httpResponse.headers,
7542
- };
7543
- return response;
7544
- });
7545
- });
7546
- return response.then((apiResponse) => {
7547
- const resp = deleteFileResponseFromMldev(apiResponse);
7548
- const typedResp = new DeleteFileResponse();
7549
- Object.assign(typedResp, resp);
7550
- return typedResp;
7551
- });
7552
- }
7553
- }
7554
- }
7555
-
7556
- /**
7557
- * @license
7558
- * Copyright 2025 Google LLC
7559
- * SPDX-License-Identifier: Apache-2.0
7560
- */
7561
- // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
7562
- function createFileSearchStoreConfigToMldev(fromObject, parentObject) {
7563
- const toObject = {};
7564
- const fromDisplayName = getValueByPath(fromObject, ['displayName']);
7565
- if (parentObject !== undefined && fromDisplayName != null) {
7566
- setValueByPath(parentObject, ['displayName'], fromDisplayName);
7567
- }
7568
- return toObject;
7569
- }
7570
- function createFileSearchStoreParametersToMldev(fromObject) {
7571
- const toObject = {};
7572
- const fromConfig = getValueByPath(fromObject, ['config']);
7573
- if (fromConfig != null) {
7574
- createFileSearchStoreConfigToMldev(fromConfig, toObject);
7575
- }
7576
- return toObject;
7577
- }
7578
- function deleteFileSearchStoreConfigToMldev(fromObject, parentObject) {
7579
- const toObject = {};
7580
- const fromForce = getValueByPath(fromObject, ['force']);
7581
- if (parentObject !== undefined && fromForce != null) {
7582
- setValueByPath(parentObject, ['_query', 'force'], fromForce);
7583
- }
7584
- return toObject;
7585
- }
7586
- function deleteFileSearchStoreParametersToMldev(fromObject) {
7587
- const toObject = {};
7588
- const fromName = getValueByPath(fromObject, ['name']);
7589
- if (fromName != null) {
7590
- setValueByPath(toObject, ['_url', 'name'], fromName);
7591
- }
7592
- const fromConfig = getValueByPath(fromObject, ['config']);
7593
- if (fromConfig != null) {
7594
- deleteFileSearchStoreConfigToMldev(fromConfig, toObject);
7595
- }
7596
- return toObject;
7597
- }
7598
- function getFileSearchStoreParametersToMldev(fromObject) {
7599
- const toObject = {};
7600
- const fromName = getValueByPath(fromObject, ['name']);
7601
- if (fromName != null) {
7602
- setValueByPath(toObject, ['_url', 'name'], fromName);
7603
- }
7604
- return toObject;
7605
- }
7606
- function importFileConfigToMldev(fromObject, parentObject) {
7607
- const toObject = {};
7608
- const fromCustomMetadata = getValueByPath(fromObject, [
7609
- 'customMetadata',
7610
- ]);
7611
- if (parentObject !== undefined && fromCustomMetadata != null) {
7612
- let transformedList = fromCustomMetadata;
7613
- if (Array.isArray(transformedList)) {
7614
- transformedList = transformedList.map((item) => {
7615
- return item;
7616
- });
7617
- }
7618
- setValueByPath(parentObject, ['customMetadata'], transformedList);
7619
- }
7620
- const fromChunkingConfig = getValueByPath(fromObject, [
7621
- 'chunkingConfig',
7622
- ]);
7623
- if (parentObject !== undefined && fromChunkingConfig != null) {
7624
- setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
7625
- }
7626
- return toObject;
7627
- }
7628
- function importFileOperationFromMldev(fromObject) {
7629
- const toObject = {};
7630
- const fromName = getValueByPath(fromObject, ['name']);
7631
- if (fromName != null) {
7632
- setValueByPath(toObject, ['name'], fromName);
7633
- }
7634
- const fromMetadata = getValueByPath(fromObject, ['metadata']);
7635
- if (fromMetadata != null) {
7636
- setValueByPath(toObject, ['metadata'], fromMetadata);
7637
- }
7638
- const fromDone = getValueByPath(fromObject, ['done']);
7639
- if (fromDone != null) {
7640
- setValueByPath(toObject, ['done'], fromDone);
7641
- }
7642
- const fromError = getValueByPath(fromObject, ['error']);
7643
- if (fromError != null) {
7644
- setValueByPath(toObject, ['error'], fromError);
7645
- }
7646
- const fromResponse = getValueByPath(fromObject, ['response']);
7647
- if (fromResponse != null) {
7648
- setValueByPath(toObject, ['response'], importFileResponseFromMldev(fromResponse));
7649
- }
7650
- return toObject;
7651
- }
7652
- function importFileParametersToMldev(fromObject) {
7653
- const toObject = {};
7654
- const fromFileSearchStoreName = getValueByPath(fromObject, [
7655
- 'fileSearchStoreName',
7656
- ]);
7657
- if (fromFileSearchStoreName != null) {
7658
- setValueByPath(toObject, ['_url', 'file_search_store_name'], fromFileSearchStoreName);
7659
- }
7660
- const fromFileName = getValueByPath(fromObject, ['fileName']);
7661
- if (fromFileName != null) {
7662
- setValueByPath(toObject, ['fileName'], fromFileName);
7663
- }
7664
- const fromConfig = getValueByPath(fromObject, ['config']);
7665
- if (fromConfig != null) {
7666
- importFileConfigToMldev(fromConfig, toObject);
7667
- }
7668
- return toObject;
7669
- }
7670
- function importFileResponseFromMldev(fromObject) {
7671
- const toObject = {};
7672
- const fromSdkHttpResponse = getValueByPath(fromObject, [
7673
- 'sdkHttpResponse',
7674
- ]);
7675
- if (fromSdkHttpResponse != null) {
7676
- setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
7677
- }
7678
- const fromParent = getValueByPath(fromObject, ['parent']);
7679
- if (fromParent != null) {
7680
- setValueByPath(toObject, ['parent'], fromParent);
7681
- }
7682
- const fromDocumentName = getValueByPath(fromObject, ['documentName']);
7683
- if (fromDocumentName != null) {
7684
- setValueByPath(toObject, ['documentName'], fromDocumentName);
7685
- }
7686
- return toObject;
7687
- }
7688
- function listFileSearchStoresConfigToMldev(fromObject, parentObject) {
7689
- const toObject = {};
7690
- const fromPageSize = getValueByPath(fromObject, ['pageSize']);
7691
- if (parentObject !== undefined && fromPageSize != null) {
7692
- setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
7693
- }
7694
- const fromPageToken = getValueByPath(fromObject, ['pageToken']);
7695
- if (parentObject !== undefined && fromPageToken != null) {
7696
- setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
7697
- }
7698
- return toObject;
7699
- }
7700
- function listFileSearchStoresParametersToMldev(fromObject) {
7701
- const toObject = {};
7702
- const fromConfig = getValueByPath(fromObject, ['config']);
7703
- if (fromConfig != null) {
7704
- listFileSearchStoresConfigToMldev(fromConfig, toObject);
7705
- }
7706
- return toObject;
7707
- }
7708
- function listFileSearchStoresResponseFromMldev(fromObject) {
7709
- const toObject = {};
7710
- const fromSdkHttpResponse = getValueByPath(fromObject, [
7711
- 'sdkHttpResponse',
7712
- ]);
7713
- if (fromSdkHttpResponse != null) {
7714
- setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
7715
- }
7716
- const fromNextPageToken = getValueByPath(fromObject, [
7717
- 'nextPageToken',
7718
- ]);
7719
- if (fromNextPageToken != null) {
7720
- setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
7721
- }
7722
- const fromFileSearchStores = getValueByPath(fromObject, [
7723
- 'fileSearchStores',
7724
- ]);
7725
- if (fromFileSearchStores != null) {
7726
- let transformedList = fromFileSearchStores;
7727
- if (Array.isArray(transformedList)) {
7728
- transformedList = transformedList.map((item) => {
7729
- return item;
7943
+ })
7944
+ .then((httpResponse) => {
7945
+ return httpResponse.json().then((jsonResponse) => {
7946
+ const response = jsonResponse;
7947
+ response.sdkHttpResponse = {
7948
+ headers: httpResponse.headers,
7949
+ };
7950
+ return response;
7951
+ });
7730
7952
  });
7731
- }
7732
- setValueByPath(toObject, ['fileSearchStores'], transformedList);
7733
- }
7734
- return toObject;
7735
- }
7736
- function uploadToFileSearchStoreConfigToMldev(fromObject, parentObject) {
7737
- const toObject = {};
7738
- const fromMimeType = getValueByPath(fromObject, ['mimeType']);
7739
- if (parentObject !== undefined && fromMimeType != null) {
7740
- setValueByPath(parentObject, ['mimeType'], fromMimeType);
7741
- }
7742
- const fromDisplayName = getValueByPath(fromObject, ['displayName']);
7743
- if (parentObject !== undefined && fromDisplayName != null) {
7744
- setValueByPath(parentObject, ['displayName'], fromDisplayName);
7745
- }
7746
- const fromCustomMetadata = getValueByPath(fromObject, [
7747
- 'customMetadata',
7748
- ]);
7749
- if (parentObject !== undefined && fromCustomMetadata != null) {
7750
- let transformedList = fromCustomMetadata;
7751
- if (Array.isArray(transformedList)) {
7752
- transformedList = transformedList.map((item) => {
7753
- return item;
7953
+ return response.then((apiResponse) => {
7954
+ const resp = deleteFileResponseFromMldev(apiResponse);
7955
+ const typedResp = new DeleteFileResponse();
7956
+ Object.assign(typedResp, resp);
7957
+ return typedResp;
7754
7958
  });
7755
7959
  }
7756
- setValueByPath(parentObject, ['customMetadata'], transformedList);
7757
- }
7758
- const fromChunkingConfig = getValueByPath(fromObject, [
7759
- 'chunkingConfig',
7760
- ]);
7761
- if (parentObject !== undefined && fromChunkingConfig != null) {
7762
- setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
7763
- }
7764
- return toObject;
7765
- }
7766
- function uploadToFileSearchStoreParametersToMldev(fromObject) {
7767
- const toObject = {};
7768
- const fromFileSearchStoreName = getValueByPath(fromObject, [
7769
- 'fileSearchStoreName',
7770
- ]);
7771
- if (fromFileSearchStoreName != null) {
7772
- setValueByPath(toObject, ['_url', 'file_search_store_name'], fromFileSearchStoreName);
7773
- }
7774
- const fromConfig = getValueByPath(fromObject, ['config']);
7775
- if (fromConfig != null) {
7776
- uploadToFileSearchStoreConfigToMldev(fromConfig, toObject);
7777
- }
7778
- return toObject;
7779
- }
7780
- function uploadToFileSearchStoreResumableResponseFromMldev(fromObject) {
7781
- const toObject = {};
7782
- const fromSdkHttpResponse = getValueByPath(fromObject, [
7783
- 'sdkHttpResponse',
7784
- ]);
7785
- if (fromSdkHttpResponse != null) {
7786
- setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
7787
7960
  }
7788
- return toObject;
7789
7961
  }
7790
7962
 
7791
7963
  /**
@@ -7890,17 +8062,14 @@ class Documents extends BaseModule {
7890
8062
  *
7891
8063
  * @example
7892
8064
  * ```ts
7893
- * const documents = await ai.documents.list({config: {'pageSize': 2}});
8065
+ * const documents = await ai.documents.list({parent:'rag_store_name', config: {'pageSize': 2}});
7894
8066
  * for await (const document of documents) {
7895
8067
  * console.log(document);
7896
8068
  * }
7897
8069
  * ```
7898
8070
  */
7899
8071
  this.list = async (params) => {
7900
- return new Pager(PagedItem.PAGED_ITEM_DOCUMENTS, (x) => this.listInternal({
7901
- parent: params.parent,
7902
- config: x.config,
7903
- }), await this.listInternal(params), params);
8072
+ return new Pager(PagedItem.PAGED_ITEM_DOCUMENTS, (x) => this.listInternal({ parent: params.parent, config: x.config }), await this.listInternal(params), params);
7904
8073
  };
7905
8074
  }
7906
8075
  /**
@@ -7968,12 +8137,6 @@ class Documents extends BaseModule {
7968
8137
  });
7969
8138
  }
7970
8139
  }
7971
- /**
7972
- * Lists all Documents in a FileSearchStore.
7973
- *
7974
- * @param params - The parameters for listing documents.
7975
- * @return ListDocumentsResponse.
7976
- */
7977
8140
  async listInternal(params) {
7978
8141
  var _a, _b;
7979
8142
  let response;
@@ -8182,12 +8345,6 @@ class FileSearchStores extends BaseModule {
8182
8345
  });
8183
8346
  }
8184
8347
  }
8185
- /**
8186
- * Lists all FileSearchStore owned by the user.
8187
- *
8188
- * @param params - The parameters for listing file search stores.
8189
- * @return ListFileSearchStoresResponse.
8190
- */
8191
8348
  async listInternal(params) {
8192
8349
  var _a, _b;
8193
8350
  let response;
@@ -8353,6 +8510,28 @@ function fileDataToMldev$2(fromObject) {
8353
8510
  }
8354
8511
  return toObject;
8355
8512
  }
8513
+ function functionCallToMldev$2(fromObject) {
8514
+ const toObject = {};
8515
+ const fromId = getValueByPath(fromObject, ['id']);
8516
+ if (fromId != null) {
8517
+ setValueByPath(toObject, ['id'], fromId);
8518
+ }
8519
+ const fromArgs = getValueByPath(fromObject, ['args']);
8520
+ if (fromArgs != null) {
8521
+ setValueByPath(toObject, ['args'], fromArgs);
8522
+ }
8523
+ const fromName = getValueByPath(fromObject, ['name']);
8524
+ if (fromName != null) {
8525
+ setValueByPath(toObject, ['name'], fromName);
8526
+ }
8527
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
8528
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
8529
+ }
8530
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
8531
+ throw new Error('willContinue parameter is not supported in Gemini API.');
8532
+ }
8533
+ return toObject;
8534
+ }
8356
8535
  function functionDeclarationToVertex$1(fromObject) {
8357
8536
  const toObject = {};
8358
8537
  if (getValueByPath(fromObject, ['behavior']) !== undefined) {
@@ -8941,9 +9120,11 @@ function liveServerMessageFromVertex(fromObject) {
8941
9120
  }
8942
9121
  function partToMldev$2(fromObject) {
8943
9122
  const toObject = {};
8944
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8945
- if (fromFunctionCall != null) {
8946
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
9123
+ const fromMediaResolution = getValueByPath(fromObject, [
9124
+ 'mediaResolution',
9125
+ ]);
9126
+ if (fromMediaResolution != null) {
9127
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
8947
9128
  }
8948
9129
  const fromCodeExecutionResult = getValueByPath(fromObject, [
8949
9130
  'codeExecutionResult',
@@ -8961,6 +9142,10 @@ function partToMldev$2(fromObject) {
8961
9142
  if (fromFileData != null) {
8962
9143
  setValueByPath(toObject, ['fileData'], fileDataToMldev$2(fromFileData));
8963
9144
  }
9145
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9146
+ if (fromFunctionCall != null) {
9147
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$2(fromFunctionCall));
9148
+ }
8964
9149
  const fromFunctionResponse = getValueByPath(fromObject, [
8965
9150
  'functionResponse',
8966
9151
  ]);
@@ -9882,6 +10067,46 @@ function fileDataToMldev$1(fromObject) {
9882
10067
  }
9883
10068
  return toObject;
9884
10069
  }
10070
+ function functionCallToMldev$1(fromObject) {
10071
+ const toObject = {};
10072
+ const fromId = getValueByPath(fromObject, ['id']);
10073
+ if (fromId != null) {
10074
+ setValueByPath(toObject, ['id'], fromId);
10075
+ }
10076
+ const fromArgs = getValueByPath(fromObject, ['args']);
10077
+ if (fromArgs != null) {
10078
+ setValueByPath(toObject, ['args'], fromArgs);
10079
+ }
10080
+ const fromName = getValueByPath(fromObject, ['name']);
10081
+ if (fromName != null) {
10082
+ setValueByPath(toObject, ['name'], fromName);
10083
+ }
10084
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
10085
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
10086
+ }
10087
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
10088
+ throw new Error('willContinue parameter is not supported in Gemini API.');
10089
+ }
10090
+ return toObject;
10091
+ }
10092
+ function functionCallingConfigToMldev(fromObject) {
10093
+ const toObject = {};
10094
+ const fromMode = getValueByPath(fromObject, ['mode']);
10095
+ if (fromMode != null) {
10096
+ setValueByPath(toObject, ['mode'], fromMode);
10097
+ }
10098
+ const fromAllowedFunctionNames = getValueByPath(fromObject, [
10099
+ 'allowedFunctionNames',
10100
+ ]);
10101
+ if (fromAllowedFunctionNames != null) {
10102
+ setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
10103
+ }
10104
+ if (getValueByPath(fromObject, ['streamFunctionCallArguments']) !==
10105
+ undefined) {
10106
+ throw new Error('streamFunctionCallArguments parameter is not supported in Gemini API.');
10107
+ }
10108
+ return toObject;
10109
+ }
9885
10110
  function functionDeclarationToVertex(fromObject) {
9886
10111
  const toObject = {};
9887
10112
  if (getValueByPath(fromObject, ['behavior']) !== undefined) {
@@ -10029,7 +10254,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
10029
10254
  }
10030
10255
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
10031
10256
  if (parentObject !== undefined && fromToolConfig != null) {
10032
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
10257
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev(fromToolConfig));
10033
10258
  }
10034
10259
  if (getValueByPath(fromObject, ['labels']) !== undefined) {
10035
10260
  throw new Error('labels parameter is not supported in Gemini API.');
@@ -10067,7 +10292,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
10067
10292
  }
10068
10293
  const fromImageConfig = getValueByPath(fromObject, ['imageConfig']);
10069
10294
  if (fromImageConfig != null) {
10070
- setValueByPath(toObject, ['imageConfig'], fromImageConfig);
10295
+ setValueByPath(toObject, ['imageConfig'], imageConfigToMldev(fromImageConfig));
10071
10296
  }
10072
10297
  return toObject;
10073
10298
  }
@@ -10231,7 +10456,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
10231
10456
  }
10232
10457
  const fromImageConfig = getValueByPath(fromObject, ['imageConfig']);
10233
10458
  if (fromImageConfig != null) {
10234
- setValueByPath(toObject, ['imageConfig'], fromImageConfig);
10459
+ setValueByPath(toObject, ['imageConfig'], imageConfigToVertex(fromImageConfig));
10235
10460
  }
10236
10461
  return toObject;
10237
10462
  }
@@ -11232,6 +11457,49 @@ function googleSearchToMldev$1(fromObject) {
11232
11457
  }
11233
11458
  return toObject;
11234
11459
  }
11460
+ function imageConfigToMldev(fromObject) {
11461
+ const toObject = {};
11462
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
11463
+ if (fromAspectRatio != null) {
11464
+ setValueByPath(toObject, ['aspectRatio'], fromAspectRatio);
11465
+ }
11466
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
11467
+ if (fromImageSize != null) {
11468
+ setValueByPath(toObject, ['imageSize'], fromImageSize);
11469
+ }
11470
+ if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
11471
+ throw new Error('outputMimeType parameter is not supported in Gemini API.');
11472
+ }
11473
+ if (getValueByPath(fromObject, ['outputCompressionQuality']) !==
11474
+ undefined) {
11475
+ throw new Error('outputCompressionQuality parameter is not supported in Gemini API.');
11476
+ }
11477
+ return toObject;
11478
+ }
11479
+ function imageConfigToVertex(fromObject) {
11480
+ const toObject = {};
11481
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
11482
+ if (fromAspectRatio != null) {
11483
+ setValueByPath(toObject, ['aspectRatio'], fromAspectRatio);
11484
+ }
11485
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
11486
+ if (fromImageSize != null) {
11487
+ setValueByPath(toObject, ['imageSize'], fromImageSize);
11488
+ }
11489
+ const fromOutputMimeType = getValueByPath(fromObject, [
11490
+ 'outputMimeType',
11491
+ ]);
11492
+ if (fromOutputMimeType != null) {
11493
+ setValueByPath(toObject, ['imageOutputOptions', 'mimeType'], fromOutputMimeType);
11494
+ }
11495
+ const fromOutputCompressionQuality = getValueByPath(fromObject, [
11496
+ 'outputCompressionQuality',
11497
+ ]);
11498
+ if (fromOutputCompressionQuality != null) {
11499
+ setValueByPath(toObject, ['imageOutputOptions', 'compressionQuality'], fromOutputCompressionQuality);
11500
+ }
11501
+ return toObject;
11502
+ }
11235
11503
  function imageFromMldev(fromObject) {
11236
11504
  const toObject = {};
11237
11505
  const fromImageBytes = getValueByPath(fromObject, [
@@ -11541,9 +11809,11 @@ function modelFromVertex(fromObject) {
11541
11809
  }
11542
11810
  function partToMldev$1(fromObject) {
11543
11811
  const toObject = {};
11544
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
11545
- if (fromFunctionCall != null) {
11546
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
11812
+ const fromMediaResolution = getValueByPath(fromObject, [
11813
+ 'mediaResolution',
11814
+ ]);
11815
+ if (fromMediaResolution != null) {
11816
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
11547
11817
  }
11548
11818
  const fromCodeExecutionResult = getValueByPath(fromObject, [
11549
11819
  'codeExecutionResult',
@@ -11561,6 +11831,10 @@ function partToMldev$1(fromObject) {
11561
11831
  if (fromFileData != null) {
11562
11832
  setValueByPath(toObject, ['fileData'], fileDataToMldev$1(fromFileData));
11563
11833
  }
11834
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
11835
+ if (fromFunctionCall != null) {
11836
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$1(fromFunctionCall));
11837
+ }
11564
11838
  const fromFunctionResponse = getValueByPath(fromObject, [
11565
11839
  'functionResponse',
11566
11840
  ]);
@@ -11925,6 +12199,22 @@ function speechConfigToVertex(fromObject) {
11925
12199
  }
11926
12200
  return toObject;
11927
12201
  }
12202
+ function toolConfigToMldev(fromObject) {
12203
+ const toObject = {};
12204
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
12205
+ 'functionCallingConfig',
12206
+ ]);
12207
+ if (fromFunctionCallingConfig != null) {
12208
+ setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(fromFunctionCallingConfig));
12209
+ }
12210
+ const fromRetrievalConfig = getValueByPath(fromObject, [
12211
+ 'retrievalConfig',
12212
+ ]);
12213
+ if (fromRetrievalConfig != null) {
12214
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
12215
+ }
12216
+ return toObject;
12217
+ }
11928
12218
  function toolToMldev$1(fromObject) {
11929
12219
  const toObject = {};
11930
12220
  const fromFunctionDeclarations = getValueByPath(fromObject, [
@@ -13400,6 +13690,7 @@ class Models extends BaseModule {
13400
13690
  * ```
13401
13691
  */
13402
13692
  this.generateContentStream = async (params) => {
13693
+ var _a, _b, _c, _d, _e;
13403
13694
  this.maybeMoveToResponseJsonSchem(params);
13404
13695
  if (shouldDisableAfc(params.config)) {
13405
13696
  const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
@@ -13412,6 +13703,17 @@ class Models extends BaseModule {
13412
13703
  .join(', ');
13413
13704
  throw new Error(`Incompatible tools found at ${formattedIndexes}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`);
13414
13705
  }
13706
+ // With tool compatibility confirmed, validate that the configuration are
13707
+ // compatible with each other and raise an error if invalid.
13708
+ const streamFunctionCall = (_c = (_b = (_a = params === null || params === void 0 ? void 0 : params.config) === null || _a === void 0 ? void 0 : _a.toolConfig) === null || _b === void 0 ? void 0 : _b.functionCallingConfig) === null || _c === void 0 ? void 0 : _c.streamFunctionCallArguments;
13709
+ const disableAfc = (_e = (_d = params === null || params === void 0 ? void 0 : params.config) === null || _d === void 0 ? void 0 : _d.automaticFunctionCalling) === null || _e === void 0 ? void 0 : _e.disable;
13710
+ if (streamFunctionCall && !disableAfc) {
13711
+ throw new Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, " +
13712
+ 'this feature is not compatible with automatic function calling (AFC). ' +
13713
+ "Please set 'config.automaticFunctionCalling.disable' to true to disable AFC " +
13714
+ "or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' " +
13715
+ 'to be undefined or set to false to disable streaming function call arguments feature.');
13716
+ }
13415
13717
  return await this.processAfcStream(params);
13416
13718
  };
13417
13719
  /**
@@ -15029,6 +15331,28 @@ function fileDataToMldev(fromObject) {
15029
15331
  }
15030
15332
  return toObject;
15031
15333
  }
15334
+ function functionCallToMldev(fromObject) {
15335
+ const toObject = {};
15336
+ const fromId = getValueByPath(fromObject, ['id']);
15337
+ if (fromId != null) {
15338
+ setValueByPath(toObject, ['id'], fromId);
15339
+ }
15340
+ const fromArgs = getValueByPath(fromObject, ['args']);
15341
+ if (fromArgs != null) {
15342
+ setValueByPath(toObject, ['args'], fromArgs);
15343
+ }
15344
+ const fromName = getValueByPath(fromObject, ['name']);
15345
+ if (fromName != null) {
15346
+ setValueByPath(toObject, ['name'], fromName);
15347
+ }
15348
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
15349
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
15350
+ }
15351
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
15352
+ throw new Error('willContinue parameter is not supported in Gemini API.');
15353
+ }
15354
+ return toObject;
15355
+ }
15032
15356
  function googleMapsToMldev(fromObject) {
15033
15357
  const toObject = {};
15034
15358
  if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
@@ -15180,9 +15504,11 @@ function liveConnectConstraintsToMldev(apiClient, fromObject) {
15180
15504
  }
15181
15505
  function partToMldev(fromObject) {
15182
15506
  const toObject = {};
15183
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
15184
- if (fromFunctionCall != null) {
15185
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
15507
+ const fromMediaResolution = getValueByPath(fromObject, [
15508
+ 'mediaResolution',
15509
+ ]);
15510
+ if (fromMediaResolution != null) {
15511
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
15186
15512
  }
15187
15513
  const fromCodeExecutionResult = getValueByPath(fromObject, [
15188
15514
  'codeExecutionResult',
@@ -15200,6 +15526,10 @@ function partToMldev(fromObject) {
15200
15526
  if (fromFileData != null) {
15201
15527
  setValueByPath(toObject, ['fileData'], fileDataToMldev(fromFileData));
15202
15528
  }
15529
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
15530
+ if (fromFunctionCall != null) {
15531
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev(fromFunctionCall));
15532
+ }
15203
15533
  const fromFunctionResponse = getValueByPath(fromObject, [
15204
15534
  'functionResponse',
15205
15535
  ]);
@@ -15590,6 +15920,26 @@ function cancelTuningJobParametersToVertex(fromObject, _rootObject) {
15590
15920
  }
15591
15921
  return toObject;
15592
15922
  }
15923
+ function cancelTuningJobResponseFromMldev(fromObject, _rootObject) {
15924
+ const toObject = {};
15925
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
15926
+ 'sdkHttpResponse',
15927
+ ]);
15928
+ if (fromSdkHttpResponse != null) {
15929
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
15930
+ }
15931
+ return toObject;
15932
+ }
15933
+ function cancelTuningJobResponseFromVertex(fromObject, _rootObject) {
15934
+ const toObject = {};
15935
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
15936
+ 'sdkHttpResponse',
15937
+ ]);
15938
+ if (fromSdkHttpResponse != null) {
15939
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
15940
+ }
15941
+ return toObject;
15942
+ }
15593
15943
  function createTuningJobConfigToMldev(fromObject, parentObject, _rootObject) {
15594
15944
  const toObject = {};
15595
15945
  if (getValueByPath(fromObject, ['validationDataset']) !== undefined) {
@@ -16251,28 +16601,33 @@ class Tunings extends BaseModule {
16251
16601
  super();
16252
16602
  this.apiClient = apiClient;
16253
16603
  /**
16254
- * Gets a TuningJob.
16604
+ * Lists tuning jobs.
16255
16605
  *
16256
- * @param name - The resource name of the tuning job.
16257
- * @return - A TuningJob object.
16606
+ * @param params - The parameters for the list request.
16607
+ * @return - A pager of tuning jobs.
16258
16608
  *
16259
- * @experimental - The SDK's tuning implementation is experimental, and may
16260
- * change in future versions.
16609
+ * @example
16610
+ * ```ts
16611
+ * const tuningJobs = await ai.tunings.list({config: {'pageSize': 2}});
16612
+ * for await (const tuningJob of tuningJobs) {
16613
+ * console.log(tuningJob);
16614
+ * }
16615
+ * ```
16261
16616
  */
16262
- this.get = async (params) => {
16263
- return await this.getInternal(params);
16617
+ this.list = async (params = {}) => {
16618
+ return new Pager(PagedItem.PAGED_ITEM_TUNING_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
16264
16619
  };
16265
16620
  /**
16266
- * Lists tuning jobs.
16621
+ * Gets a TuningJob.
16267
16622
  *
16268
- * @param config - The configuration for the list request.
16269
- * @return - A list of tuning jobs.
16623
+ * @param name - The resource name of the tuning job.
16624
+ * @return - A TuningJob object.
16270
16625
  *
16271
16626
  * @experimental - The SDK's tuning implementation is experimental, and may
16272
16627
  * change in future versions.
16273
16628
  */
16274
- this.list = async (params = {}) => {
16275
- return new Pager(PagedItem.PAGED_ITEM_TUNING_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
16629
+ this.get = async (params) => {
16630
+ return await this.getInternal(params);
16276
16631
  };
16277
16632
  /**
16278
16633
  * Creates a supervised fine-tuning job.
@@ -16467,6 +16822,7 @@ class Tunings extends BaseModule {
16467
16822
  */
16468
16823
  async cancel(params) {
16469
16824
  var _a, _b, _c, _d;
16825
+ let response;
16470
16826
  let path = '';
16471
16827
  let queryParams = {};
16472
16828
  if (this.apiClient.isVertexAI()) {
@@ -16475,13 +16831,29 @@ class Tunings extends BaseModule {
16475
16831
  queryParams = body['_query'];
16476
16832
  delete body['_url'];
16477
16833
  delete body['_query'];
16478
- await this.apiClient.request({
16834
+ response = this.apiClient
16835
+ .request({
16479
16836
  path: path,
16480
16837
  queryParams: queryParams,
16481
16838
  body: JSON.stringify(body),
16482
16839
  httpMethod: 'POST',
16483
16840
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
16484
16841
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
16842
+ })
16843
+ .then((httpResponse) => {
16844
+ return httpResponse.json().then((jsonResponse) => {
16845
+ const response = jsonResponse;
16846
+ response.sdkHttpResponse = {
16847
+ headers: httpResponse.headers,
16848
+ };
16849
+ return response;
16850
+ });
16851
+ });
16852
+ return response.then((apiResponse) => {
16853
+ const resp = cancelTuningJobResponseFromVertex(apiResponse);
16854
+ const typedResp = new CancelTuningJobResponse();
16855
+ Object.assign(typedResp, resp);
16856
+ return typedResp;
16485
16857
  });
16486
16858
  }
16487
16859
  else {
@@ -16490,13 +16862,29 @@ class Tunings extends BaseModule {
16490
16862
  queryParams = body['_query'];
16491
16863
  delete body['_url'];
16492
16864
  delete body['_query'];
16493
- await this.apiClient.request({
16865
+ response = this.apiClient
16866
+ .request({
16494
16867
  path: path,
16495
16868
  queryParams: queryParams,
16496
16869
  body: JSON.stringify(body),
16497
16870
  httpMethod: 'POST',
16498
16871
  httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
16499
16872
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
16873
+ })
16874
+ .then((httpResponse) => {
16875
+ return httpResponse.json().then((jsonResponse) => {
16876
+ const response = jsonResponse;
16877
+ response.sdkHttpResponse = {
16878
+ headers: httpResponse.headers,
16879
+ };
16880
+ return response;
16881
+ });
16882
+ });
16883
+ return response.then((apiResponse) => {
16884
+ const resp = cancelTuningJobResponseFromMldev(apiResponse);
16885
+ const typedResp = new CancelTuningJobResponse();
16886
+ Object.assign(typedResp, resp);
16887
+ return typedResp;
16500
16888
  });
16501
16889
  }
16502
16890
  }
@@ -16651,13 +17039,14 @@ class GoogleGenAI {
16651
17039
  this.vertexai = (_a = options.vertexai) !== null && _a !== void 0 ? _a : false;
16652
17040
  this.apiKey = options.apiKey;
16653
17041
  this.apiVersion = options.apiVersion;
17042
+ this.httpOptions = options.httpOptions;
16654
17043
  const auth = new WebAuth(this.apiKey);
16655
17044
  this.apiClient = new ApiClient({
16656
17045
  auth: auth,
16657
17046
  apiVersion: this.apiVersion,
16658
17047
  apiKey: this.apiKey,
16659
17048
  vertexai: this.vertexai,
16660
- httpOptions: options.httpOptions,
17049
+ httpOptions: this.httpOptions,
16661
17050
  userAgentExtra: LANGUAGE_LABEL_PREFIX + 'cross',
16662
17051
  uploader: new CrossUploader(),
16663
17052
  downloader: new CrossDownloader(),
@@ -16675,5 +17064,5 @@ class GoogleGenAI {
16675
17064
  }
16676
17065
  }
16677
17066
 
16678
- export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PersonGeneration, PhishBlockThreshold, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TuningMethod, TuningMode, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
17067
+ export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, TrafficType, TuningMethod, TuningMode, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
16679
17068
  //# sourceMappingURL=index.mjs.map