@google/genai 1.26.0 → 1.27.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.
@@ -616,23 +616,23 @@ var HarmCategory;
616
616
  */
617
617
  HarmCategory["HARM_CATEGORY_CIVIC_INTEGRITY"] = "HARM_CATEGORY_CIVIC_INTEGRITY";
618
618
  /**
619
- * The harm category is image hate.
619
+ * The harm category is image hate. This enum value is not supported in Gemini API.
620
620
  */
621
621
  HarmCategory["HARM_CATEGORY_IMAGE_HATE"] = "HARM_CATEGORY_IMAGE_HATE";
622
622
  /**
623
- * The harm category is image dangerous content.
623
+ * The harm category is image dangerous content. This enum value is not supported in Gemini API.
624
624
  */
625
625
  HarmCategory["HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT"] = "HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT";
626
626
  /**
627
- * The harm category is image harassment.
627
+ * The harm category is image harassment. This enum value is not supported in Gemini API.
628
628
  */
629
629
  HarmCategory["HARM_CATEGORY_IMAGE_HARASSMENT"] = "HARM_CATEGORY_IMAGE_HARASSMENT";
630
630
  /**
631
- * The harm category is image sexually explicit content.
631
+ * The harm category is image sexually explicit content. This enum value is not supported in Gemini API.
632
632
  */
633
633
  HarmCategory["HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT";
634
634
  /**
635
- * The harm category is for jailbreak prompts.
635
+ * The harm category is for jailbreak prompts. This enum value is not supported in Gemini API.
636
636
  */
637
637
  HarmCategory["HARM_CATEGORY_JAILBREAK"] = "HARM_CATEGORY_JAILBREAK";
638
638
  })(HarmCategory || (HarmCategory = {}));
@@ -903,11 +903,11 @@ var BlockedReason;
903
903
  */
904
904
  BlockedReason["IMAGE_SAFETY"] = "IMAGE_SAFETY";
905
905
  /**
906
- * The prompt was blocked by Model Armor.
906
+ * The prompt was blocked by Model Armor. This enum value is not supported in Gemini API.
907
907
  */
908
908
  BlockedReason["MODEL_ARMOR"] = "MODEL_ARMOR";
909
909
  /**
910
- * The prompt was blocked as a jailbreak attempt.
910
+ * The prompt was blocked as a jailbreak attempt. This enum value is not supported in Gemini API.
911
911
  */
912
912
  BlockedReason["JAILBREAK"] = "JAILBREAK";
913
913
  })(BlockedReason || (BlockedReason = {}));
@@ -1744,7 +1744,7 @@ class HttpResponse {
1744
1744
  /** Content filter results for a prompt sent in the request. Note: This is sent only in the first stream chunk and only if no candidates were generated due to content violations. */
1745
1745
  class GenerateContentResponsePromptFeedback {
1746
1746
  }
1747
- /** Usage metadata about response(s). */
1747
+ /** Usage metadata about response(s). This data type is not supported in Gemini API. */
1748
1748
  class GenerateContentResponseUsageMetadata {
1749
1749
  }
1750
1750
  /** Response message for PredictionService.GenerateContent. */
@@ -10587,7 +10587,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
10587
10587
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
10588
10588
  const USER_AGENT_HEADER = 'User-Agent';
10589
10589
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
10590
- const SDK_VERSION = '1.26.0'; // x-release-please-version
10590
+ const SDK_VERSION = '1.27.0'; // x-release-please-version
10591
10591
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
10592
10592
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
10593
10593
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -10776,7 +10776,7 @@ class ApiClient {
10776
10776
  else {
10777
10777
  requestInit.body = request.body;
10778
10778
  }
10779
- requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, request.abortSignal);
10779
+ requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, url.toString(), request.abortSignal);
10780
10780
  return this.unaryApiCall(url, requestInit, request.httpMethod);
10781
10781
  }
10782
10782
  patchHttpOptions(baseHttpOptions, requestHttpOptions) {
@@ -10810,10 +10810,10 @@ class ApiClient {
10810
10810
  }
10811
10811
  let requestInit = {};
10812
10812
  requestInit.body = request.body;
10813
- requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, request.abortSignal);
10813
+ requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, url.toString(), request.abortSignal);
10814
10814
  return this.streamApiCall(url, requestInit, request.httpMethod);
10815
10815
  }
10816
- async includeExtraHttpOptionsToRequestInit(requestInit, httpOptions, abortSignal) {
10816
+ async includeExtraHttpOptionsToRequestInit(requestInit, httpOptions, url, abortSignal) {
10817
10817
  if ((httpOptions && httpOptions.timeout) || abortSignal) {
10818
10818
  const abortController = new AbortController();
10819
10819
  const signal = abortController.signal;
@@ -10837,7 +10837,7 @@ class ApiClient {
10837
10837
  if (httpOptions && httpOptions.extraBody !== null) {
10838
10838
  includeExtraBodyToRequestInit(requestInit, httpOptions.extraBody);
10839
10839
  }
10840
- requestInit.headers = await this.getHeadersInternal(httpOptions);
10840
+ requestInit.headers = await this.getHeadersInternal(httpOptions, url);
10841
10841
  return requestInit;
10842
10842
  }
10843
10843
  async unaryApiCall(url, requestInit, httpMethod) {
@@ -10950,7 +10950,7 @@ class ApiClient {
10950
10950
  headers[CONTENT_TYPE_HEADER] = 'application/json';
10951
10951
  return headers;
10952
10952
  }
10953
- async getHeadersInternal(httpOptions) {
10953
+ async getHeadersInternal(httpOptions, url) {
10954
10954
  const headers = new Headers();
10955
10955
  if (httpOptions && httpOptions.headers) {
10956
10956
  for (const [key, value] of Object.entries(httpOptions.headers)) {
@@ -10962,7 +10962,7 @@ class ApiClient {
10962
10962
  headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
10963
10963
  }
10964
10964
  }
10965
- await this.clientOptions.auth.addAuthHeaders(headers);
10965
+ await this.clientOptions.auth.addAuthHeaders(headers, url);
10966
10966
  return headers;
10967
10967
  }
10968
10968
  /**
@@ -11675,7 +11675,7 @@ class Live {
11675
11675
  const headers = mapToHeaders(clientHeaders);
11676
11676
  if (this.apiClient.isVertexAI()) {
11677
11677
  url = `${websocketBaseUrl}/ws/google.cloud.aiplatform.${apiVersion}.LlmBidiService/BidiGenerateContent`;
11678
- await this.auth.addAuthHeaders(headers);
11678
+ await this.auth.addAuthHeaders(headers, url);
11679
11679
  }
11680
11680
  else {
11681
11681
  const apiKey = this.apiClient.getApiKey();
@@ -14348,7 +14348,7 @@ class Tokens extends BaseModule {
14348
14348
  * SPDX-License-Identifier: Apache-2.0
14349
14349
  */
14350
14350
  // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
14351
- function cancelTuningJobParametersToMldev(fromObject) {
14351
+ function cancelTuningJobParametersToMldev(fromObject, _rootObject) {
14352
14352
  const toObject = {};
14353
14353
  const fromName = getValueByPath(fromObject, ['name']);
14354
14354
  if (fromName != null) {
@@ -14356,7 +14356,7 @@ function cancelTuningJobParametersToMldev(fromObject) {
14356
14356
  }
14357
14357
  return toObject;
14358
14358
  }
14359
- function cancelTuningJobParametersToVertex(fromObject) {
14359
+ function cancelTuningJobParametersToVertex(fromObject, _rootObject) {
14360
14360
  const toObject = {};
14361
14361
  const fromName = getValueByPath(fromObject, ['name']);
14362
14362
  if (fromName != null) {
@@ -14364,7 +14364,7 @@ function cancelTuningJobParametersToVertex(fromObject) {
14364
14364
  }
14365
14365
  return toObject;
14366
14366
  }
14367
- function createTuningJobConfigToMldev(fromObject, parentObject) {
14367
+ function createTuningJobConfigToMldev(fromObject, parentObject, _rootObject) {
14368
14368
  const toObject = {};
14369
14369
  if (getValueByPath(fromObject, ['validationDataset']) !== undefined) {
14370
14370
  throw new Error('validationDataset parameter is not supported in Gemini API.');
@@ -14412,13 +14412,13 @@ function createTuningJobConfigToMldev(fromObject, parentObject) {
14412
14412
  }
14413
14413
  return toObject;
14414
14414
  }
14415
- function createTuningJobConfigToVertex(fromObject, parentObject) {
14415
+ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
14416
14416
  const toObject = {};
14417
14417
  const fromValidationDataset = getValueByPath(fromObject, [
14418
14418
  'validationDataset',
14419
14419
  ]);
14420
14420
  if (parentObject !== undefined && fromValidationDataset != null) {
14421
- setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(fromValidationDataset, toObject));
14421
+ setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(fromValidationDataset));
14422
14422
  }
14423
14423
  const fromTunedModelDisplayName = getValueByPath(fromObject, [
14424
14424
  'tunedModelDisplayName',
@@ -14462,7 +14462,7 @@ function createTuningJobConfigToVertex(fromObject, parentObject) {
14462
14462
  }
14463
14463
  return toObject;
14464
14464
  }
14465
- function createTuningJobParametersPrivateToMldev(fromObject) {
14465
+ function createTuningJobParametersPrivateToMldev(fromObject, rootObject) {
14466
14466
  const toObject = {};
14467
14467
  const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
14468
14468
  if (fromBaseModel != null) {
@@ -14486,7 +14486,7 @@ function createTuningJobParametersPrivateToMldev(fromObject) {
14486
14486
  }
14487
14487
  return toObject;
14488
14488
  }
14489
- function createTuningJobParametersPrivateToVertex(fromObject) {
14489
+ function createTuningJobParametersPrivateToVertex(fromObject, rootObject) {
14490
14490
  const toObject = {};
14491
14491
  const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
14492
14492
  if (fromBaseModel != null) {
@@ -14502,7 +14502,7 @@ function createTuningJobParametersPrivateToVertex(fromObject) {
14502
14502
  'trainingDataset',
14503
14503
  ]);
14504
14504
  if (fromTrainingDataset != null) {
14505
- setValueByPath(toObject, ['supervisedTuningSpec', 'trainingDatasetUri'], tuningDatasetToVertex(fromTrainingDataset, toObject));
14505
+ tuningDatasetToVertex(fromTrainingDataset, toObject);
14506
14506
  }
14507
14507
  const fromConfig = getValueByPath(fromObject, ['config']);
14508
14508
  if (fromConfig != null) {
@@ -14510,7 +14510,7 @@ function createTuningJobParametersPrivateToVertex(fromObject) {
14510
14510
  }
14511
14511
  return toObject;
14512
14512
  }
14513
- function getTuningJobParametersToMldev(fromObject) {
14513
+ function getTuningJobParametersToMldev(fromObject, _rootObject) {
14514
14514
  const toObject = {};
14515
14515
  const fromName = getValueByPath(fromObject, ['name']);
14516
14516
  if (fromName != null) {
@@ -14518,7 +14518,7 @@ function getTuningJobParametersToMldev(fromObject) {
14518
14518
  }
14519
14519
  return toObject;
14520
14520
  }
14521
- function getTuningJobParametersToVertex(fromObject) {
14521
+ function getTuningJobParametersToVertex(fromObject, _rootObject) {
14522
14522
  const toObject = {};
14523
14523
  const fromName = getValueByPath(fromObject, ['name']);
14524
14524
  if (fromName != null) {
@@ -14526,7 +14526,7 @@ function getTuningJobParametersToVertex(fromObject) {
14526
14526
  }
14527
14527
  return toObject;
14528
14528
  }
14529
- function listTuningJobsConfigToMldev(fromObject, parentObject) {
14529
+ function listTuningJobsConfigToMldev(fromObject, parentObject, _rootObject) {
14530
14530
  const toObject = {};
14531
14531
  const fromPageSize = getValueByPath(fromObject, ['pageSize']);
14532
14532
  if (parentObject !== undefined && fromPageSize != null) {
@@ -14542,7 +14542,7 @@ function listTuningJobsConfigToMldev(fromObject, parentObject) {
14542
14542
  }
14543
14543
  return toObject;
14544
14544
  }
14545
- function listTuningJobsConfigToVertex(fromObject, parentObject) {
14545
+ function listTuningJobsConfigToVertex(fromObject, parentObject, _rootObject) {
14546
14546
  const toObject = {};
14547
14547
  const fromPageSize = getValueByPath(fromObject, ['pageSize']);
14548
14548
  if (parentObject !== undefined && fromPageSize != null) {
@@ -14558,7 +14558,7 @@ function listTuningJobsConfigToVertex(fromObject, parentObject) {
14558
14558
  }
14559
14559
  return toObject;
14560
14560
  }
14561
- function listTuningJobsParametersToMldev(fromObject) {
14561
+ function listTuningJobsParametersToMldev(fromObject, rootObject) {
14562
14562
  const toObject = {};
14563
14563
  const fromConfig = getValueByPath(fromObject, ['config']);
14564
14564
  if (fromConfig != null) {
@@ -14566,7 +14566,7 @@ function listTuningJobsParametersToMldev(fromObject) {
14566
14566
  }
14567
14567
  return toObject;
14568
14568
  }
14569
- function listTuningJobsParametersToVertex(fromObject) {
14569
+ function listTuningJobsParametersToVertex(fromObject, rootObject) {
14570
14570
  const toObject = {};
14571
14571
  const fromConfig = getValueByPath(fromObject, ['config']);
14572
14572
  if (fromConfig != null) {
@@ -14574,7 +14574,7 @@ function listTuningJobsParametersToVertex(fromObject) {
14574
14574
  }
14575
14575
  return toObject;
14576
14576
  }
14577
- function listTuningJobsResponseFromMldev(fromObject) {
14577
+ function listTuningJobsResponseFromMldev(fromObject, rootObject) {
14578
14578
  const toObject = {};
14579
14579
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14580
14580
  'sdkHttpResponse',
@@ -14600,7 +14600,7 @@ function listTuningJobsResponseFromMldev(fromObject) {
14600
14600
  }
14601
14601
  return toObject;
14602
14602
  }
14603
- function listTuningJobsResponseFromVertex(fromObject) {
14603
+ function listTuningJobsResponseFromVertex(fromObject, rootObject) {
14604
14604
  const toObject = {};
14605
14605
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14606
14606
  'sdkHttpResponse',
@@ -14626,7 +14626,7 @@ function listTuningJobsResponseFromVertex(fromObject) {
14626
14626
  }
14627
14627
  return toObject;
14628
14628
  }
14629
- function tunedModelFromMldev(fromObject) {
14629
+ function tunedModelFromMldev(fromObject, _rootObject) {
14630
14630
  const toObject = {};
14631
14631
  const fromModel = getValueByPath(fromObject, ['name']);
14632
14632
  if (fromModel != null) {
@@ -14638,7 +14638,7 @@ function tunedModelFromMldev(fromObject) {
14638
14638
  }
14639
14639
  return toObject;
14640
14640
  }
14641
- function tuningDatasetToMldev(fromObject) {
14641
+ function tuningDatasetToMldev(fromObject, _rootObject) {
14642
14642
  const toObject = {};
14643
14643
  if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
14644
14644
  throw new Error('gcsUri parameter is not supported in Gemini API.');
@@ -14658,7 +14658,7 @@ function tuningDatasetToMldev(fromObject) {
14658
14658
  }
14659
14659
  return toObject;
14660
14660
  }
14661
- function tuningDatasetToVertex(fromObject, parentObject) {
14661
+ function tuningDatasetToVertex(fromObject, parentObject, _rootObject) {
14662
14662
  const toObject = {};
14663
14663
  const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
14664
14664
  if (parentObject !== undefined && fromGcsUri != null) {
@@ -14675,7 +14675,7 @@ function tuningDatasetToVertex(fromObject, parentObject) {
14675
14675
  }
14676
14676
  return toObject;
14677
14677
  }
14678
- function tuningJobFromMldev(fromObject) {
14678
+ function tuningJobFromMldev(fromObject, rootObject) {
14679
14679
  const toObject = {};
14680
14680
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14681
14681
  'sdkHttpResponse',
@@ -14727,7 +14727,7 @@ function tuningJobFromMldev(fromObject) {
14727
14727
  }
14728
14728
  return toObject;
14729
14729
  }
14730
- function tuningJobFromVertex(fromObject) {
14730
+ function tuningJobFromVertex(fromObject, _rootObject) {
14731
14731
  const toObject = {};
14732
14732
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14733
14733
  'sdkHttpResponse',
@@ -14847,7 +14847,7 @@ function tuningJobFromVertex(fromObject) {
14847
14847
  }
14848
14848
  return toObject;
14849
14849
  }
14850
- function tuningOperationFromMldev(fromObject) {
14850
+ function tuningOperationFromMldev(fromObject, _rootObject) {
14851
14851
  const toObject = {};
14852
14852
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14853
14853
  'sdkHttpResponse',
@@ -14873,7 +14873,7 @@ function tuningOperationFromMldev(fromObject) {
14873
14873
  }
14874
14874
  return toObject;
14875
14875
  }
14876
- function tuningValidationDatasetToVertex(fromObject, parentObject) {
14876
+ function tuningValidationDatasetToVertex(fromObject, _rootObject) {
14877
14877
  const toObject = {};
14878
14878
  const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
14879
14879
  if (fromGcsUri != null) {
@@ -14882,8 +14882,8 @@ function tuningValidationDatasetToVertex(fromObject, parentObject) {
14882
14882
  const fromVertexDatasetResource = getValueByPath(fromObject, [
14883
14883
  'vertexDatasetResource',
14884
14884
  ]);
14885
- if (parentObject !== undefined && fromVertexDatasetResource != null) {
14886
- setValueByPath(parentObject, ['supervisedTuningSpec', 'trainingDatasetUri'], fromVertexDatasetResource);
14885
+ if (fromVertexDatasetResource != null) {
14886
+ setValueByPath(toObject, ['validationDatasetUri'], fromVertexDatasetResource);
14887
14887
  }
14888
14888
  return toObject;
14889
14889
  }
@@ -15369,7 +15369,8 @@ class WebAuth {
15369
15369
  constructor(apiKey) {
15370
15370
  this.apiKey = apiKey;
15371
15371
  }
15372
- async addAuthHeaders(headers) {
15372
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
15373
+ async addAuthHeaders(headers, url) {
15373
15374
  if (headers.get(GOOGLE_API_KEY_HEADER) !== null) {
15374
15375
  return;
15375
15376
  }