@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.
@@ -622,23 +622,23 @@ var HarmCategory;
622
622
  */
623
623
  HarmCategory["HARM_CATEGORY_CIVIC_INTEGRITY"] = "HARM_CATEGORY_CIVIC_INTEGRITY";
624
624
  /**
625
- * The harm category is image hate.
625
+ * The harm category is image hate. This enum value is not supported in Gemini API.
626
626
  */
627
627
  HarmCategory["HARM_CATEGORY_IMAGE_HATE"] = "HARM_CATEGORY_IMAGE_HATE";
628
628
  /**
629
- * The harm category is image dangerous content.
629
+ * The harm category is image dangerous content. This enum value is not supported in Gemini API.
630
630
  */
631
631
  HarmCategory["HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT"] = "HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT";
632
632
  /**
633
- * The harm category is image harassment.
633
+ * The harm category is image harassment. This enum value is not supported in Gemini API.
634
634
  */
635
635
  HarmCategory["HARM_CATEGORY_IMAGE_HARASSMENT"] = "HARM_CATEGORY_IMAGE_HARASSMENT";
636
636
  /**
637
- * The harm category is image sexually explicit content.
637
+ * The harm category is image sexually explicit content. This enum value is not supported in Gemini API.
638
638
  */
639
639
  HarmCategory["HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT";
640
640
  /**
641
- * The harm category is for jailbreak prompts.
641
+ * The harm category is for jailbreak prompts. This enum value is not supported in Gemini API.
642
642
  */
643
643
  HarmCategory["HARM_CATEGORY_JAILBREAK"] = "HARM_CATEGORY_JAILBREAK";
644
644
  })(HarmCategory || (HarmCategory = {}));
@@ -909,11 +909,11 @@ var BlockedReason;
909
909
  */
910
910
  BlockedReason["IMAGE_SAFETY"] = "IMAGE_SAFETY";
911
911
  /**
912
- * The prompt was blocked by Model Armor.
912
+ * The prompt was blocked by Model Armor. This enum value is not supported in Gemini API.
913
913
  */
914
914
  BlockedReason["MODEL_ARMOR"] = "MODEL_ARMOR";
915
915
  /**
916
- * The prompt was blocked as a jailbreak attempt.
916
+ * The prompt was blocked as a jailbreak attempt. This enum value is not supported in Gemini API.
917
917
  */
918
918
  BlockedReason["JAILBREAK"] = "JAILBREAK";
919
919
  })(BlockedReason || (BlockedReason = {}));
@@ -1750,7 +1750,7 @@ class HttpResponse {
1750
1750
  /** 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. */
1751
1751
  class GenerateContentResponsePromptFeedback {
1752
1752
  }
1753
- /** Usage metadata about response(s). */
1753
+ /** Usage metadata about response(s). This data type is not supported in Gemini API. */
1754
1754
  class GenerateContentResponseUsageMetadata {
1755
1755
  }
1756
1756
  /** Response message for PredictionService.GenerateContent. */
@@ -10593,7 +10593,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
10593
10593
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
10594
10594
  const USER_AGENT_HEADER = 'User-Agent';
10595
10595
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
10596
- const SDK_VERSION = '1.26.0'; // x-release-please-version
10596
+ const SDK_VERSION = '1.27.0'; // x-release-please-version
10597
10597
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
10598
10598
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
10599
10599
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -10782,7 +10782,7 @@ class ApiClient {
10782
10782
  else {
10783
10783
  requestInit.body = request.body;
10784
10784
  }
10785
- requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, request.abortSignal);
10785
+ requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, url.toString(), request.abortSignal);
10786
10786
  return this.unaryApiCall(url, requestInit, request.httpMethod);
10787
10787
  }
10788
10788
  patchHttpOptions(baseHttpOptions, requestHttpOptions) {
@@ -10816,10 +10816,10 @@ class ApiClient {
10816
10816
  }
10817
10817
  let requestInit = {};
10818
10818
  requestInit.body = request.body;
10819
- requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, request.abortSignal);
10819
+ requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, url.toString(), request.abortSignal);
10820
10820
  return this.streamApiCall(url, requestInit, request.httpMethod);
10821
10821
  }
10822
- async includeExtraHttpOptionsToRequestInit(requestInit, httpOptions, abortSignal) {
10822
+ async includeExtraHttpOptionsToRequestInit(requestInit, httpOptions, url, abortSignal) {
10823
10823
  if ((httpOptions && httpOptions.timeout) || abortSignal) {
10824
10824
  const abortController = new AbortController();
10825
10825
  const signal = abortController.signal;
@@ -10843,7 +10843,7 @@ class ApiClient {
10843
10843
  if (httpOptions && httpOptions.extraBody !== null) {
10844
10844
  includeExtraBodyToRequestInit(requestInit, httpOptions.extraBody);
10845
10845
  }
10846
- requestInit.headers = await this.getHeadersInternal(httpOptions);
10846
+ requestInit.headers = await this.getHeadersInternal(httpOptions, url);
10847
10847
  return requestInit;
10848
10848
  }
10849
10849
  async unaryApiCall(url, requestInit, httpMethod) {
@@ -10956,7 +10956,7 @@ class ApiClient {
10956
10956
  headers[CONTENT_TYPE_HEADER] = 'application/json';
10957
10957
  return headers;
10958
10958
  }
10959
- async getHeadersInternal(httpOptions) {
10959
+ async getHeadersInternal(httpOptions, url) {
10960
10960
  const headers = new Headers();
10961
10961
  if (httpOptions && httpOptions.headers) {
10962
10962
  for (const [key, value] of Object.entries(httpOptions.headers)) {
@@ -10968,7 +10968,7 @@ class ApiClient {
10968
10968
  headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
10969
10969
  }
10970
10970
  }
10971
- await this.clientOptions.auth.addAuthHeaders(headers);
10971
+ await this.clientOptions.auth.addAuthHeaders(headers, url);
10972
10972
  return headers;
10973
10973
  }
10974
10974
  /**
@@ -11681,7 +11681,7 @@ class Live {
11681
11681
  const headers = mapToHeaders(clientHeaders);
11682
11682
  if (this.apiClient.isVertexAI()) {
11683
11683
  url = `${websocketBaseUrl}/ws/google.cloud.aiplatform.${apiVersion}.LlmBidiService/BidiGenerateContent`;
11684
- await this.auth.addAuthHeaders(headers);
11684
+ await this.auth.addAuthHeaders(headers, url);
11685
11685
  }
11686
11686
  else {
11687
11687
  const apiKey = this.apiClient.getApiKey();
@@ -14364,7 +14364,7 @@ class NodeAuth {
14364
14364
  const vertexAuthOptions = buildGoogleAuthOptions(opts.googleAuthOptions);
14365
14365
  this.googleAuth = new GoogleAuth(vertexAuthOptions);
14366
14366
  }
14367
- async addAuthHeaders(headers) {
14367
+ async addAuthHeaders(headers, url) {
14368
14368
  if (this.apiKey !== undefined) {
14369
14369
  if (this.apiKey.startsWith('auth_tokens/')) {
14370
14370
  throw new Error('Ephemeral tokens are only supported by the live API.');
@@ -14372,7 +14372,7 @@ class NodeAuth {
14372
14372
  this.addKeyHeader(headers);
14373
14373
  return;
14374
14374
  }
14375
- return this.addGoogleAuthHeaders(headers);
14375
+ return this.addGoogleAuthHeaders(headers, url);
14376
14376
  }
14377
14377
  addKeyHeader(headers) {
14378
14378
  if (headers.get(GOOGLE_API_KEY_HEADER) !== null) {
@@ -14385,15 +14385,15 @@ class NodeAuth {
14385
14385
  }
14386
14386
  headers.append(GOOGLE_API_KEY_HEADER, this.apiKey);
14387
14387
  }
14388
- async addGoogleAuthHeaders(headers) {
14388
+ async addGoogleAuthHeaders(headers, url) {
14389
14389
  if (this.googleAuth === undefined) {
14390
14390
  // This should never happen, addGoogleAuthHeaders should only be
14391
14391
  // called when there is no apiKey set and in these cases googleAuth
14392
14392
  // is set.
14393
14393
  throw new Error('Trying to set google-auth headers but googleAuth is unset');
14394
14394
  }
14395
- const authHeaders = await this.googleAuth.getRequestHeaders();
14396
- for (const [key, value] of Object.entries(authHeaders)) {
14395
+ const authHeaders = await this.googleAuth.getRequestHeaders(url);
14396
+ for (const [key, value] of authHeaders) {
14397
14397
  if (headers.get(key) !== null) {
14398
14398
  continue;
14399
14399
  }
@@ -14528,7 +14528,7 @@ class NodeWebSocket {
14528
14528
  * SPDX-License-Identifier: Apache-2.0
14529
14529
  */
14530
14530
  // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
14531
- function cancelTuningJobParametersToMldev(fromObject) {
14531
+ function cancelTuningJobParametersToMldev(fromObject, _rootObject) {
14532
14532
  const toObject = {};
14533
14533
  const fromName = getValueByPath(fromObject, ['name']);
14534
14534
  if (fromName != null) {
@@ -14536,7 +14536,7 @@ function cancelTuningJobParametersToMldev(fromObject) {
14536
14536
  }
14537
14537
  return toObject;
14538
14538
  }
14539
- function cancelTuningJobParametersToVertex(fromObject) {
14539
+ function cancelTuningJobParametersToVertex(fromObject, _rootObject) {
14540
14540
  const toObject = {};
14541
14541
  const fromName = getValueByPath(fromObject, ['name']);
14542
14542
  if (fromName != null) {
@@ -14544,7 +14544,7 @@ function cancelTuningJobParametersToVertex(fromObject) {
14544
14544
  }
14545
14545
  return toObject;
14546
14546
  }
14547
- function createTuningJobConfigToMldev(fromObject, parentObject) {
14547
+ function createTuningJobConfigToMldev(fromObject, parentObject, _rootObject) {
14548
14548
  const toObject = {};
14549
14549
  if (getValueByPath(fromObject, ['validationDataset']) !== undefined) {
14550
14550
  throw new Error('validationDataset parameter is not supported in Gemini API.');
@@ -14592,13 +14592,13 @@ function createTuningJobConfigToMldev(fromObject, parentObject) {
14592
14592
  }
14593
14593
  return toObject;
14594
14594
  }
14595
- function createTuningJobConfigToVertex(fromObject, parentObject) {
14595
+ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
14596
14596
  const toObject = {};
14597
14597
  const fromValidationDataset = getValueByPath(fromObject, [
14598
14598
  'validationDataset',
14599
14599
  ]);
14600
14600
  if (parentObject !== undefined && fromValidationDataset != null) {
14601
- setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(fromValidationDataset, toObject));
14601
+ setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(fromValidationDataset));
14602
14602
  }
14603
14603
  const fromTunedModelDisplayName = getValueByPath(fromObject, [
14604
14604
  'tunedModelDisplayName',
@@ -14642,7 +14642,7 @@ function createTuningJobConfigToVertex(fromObject, parentObject) {
14642
14642
  }
14643
14643
  return toObject;
14644
14644
  }
14645
- function createTuningJobParametersPrivateToMldev(fromObject) {
14645
+ function createTuningJobParametersPrivateToMldev(fromObject, rootObject) {
14646
14646
  const toObject = {};
14647
14647
  const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
14648
14648
  if (fromBaseModel != null) {
@@ -14666,7 +14666,7 @@ function createTuningJobParametersPrivateToMldev(fromObject) {
14666
14666
  }
14667
14667
  return toObject;
14668
14668
  }
14669
- function createTuningJobParametersPrivateToVertex(fromObject) {
14669
+ function createTuningJobParametersPrivateToVertex(fromObject, rootObject) {
14670
14670
  const toObject = {};
14671
14671
  const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
14672
14672
  if (fromBaseModel != null) {
@@ -14682,7 +14682,7 @@ function createTuningJobParametersPrivateToVertex(fromObject) {
14682
14682
  'trainingDataset',
14683
14683
  ]);
14684
14684
  if (fromTrainingDataset != null) {
14685
- setValueByPath(toObject, ['supervisedTuningSpec', 'trainingDatasetUri'], tuningDatasetToVertex(fromTrainingDataset, toObject));
14685
+ tuningDatasetToVertex(fromTrainingDataset, toObject);
14686
14686
  }
14687
14687
  const fromConfig = getValueByPath(fromObject, ['config']);
14688
14688
  if (fromConfig != null) {
@@ -14690,7 +14690,7 @@ function createTuningJobParametersPrivateToVertex(fromObject) {
14690
14690
  }
14691
14691
  return toObject;
14692
14692
  }
14693
- function getTuningJobParametersToMldev(fromObject) {
14693
+ function getTuningJobParametersToMldev(fromObject, _rootObject) {
14694
14694
  const toObject = {};
14695
14695
  const fromName = getValueByPath(fromObject, ['name']);
14696
14696
  if (fromName != null) {
@@ -14698,7 +14698,7 @@ function getTuningJobParametersToMldev(fromObject) {
14698
14698
  }
14699
14699
  return toObject;
14700
14700
  }
14701
- function getTuningJobParametersToVertex(fromObject) {
14701
+ function getTuningJobParametersToVertex(fromObject, _rootObject) {
14702
14702
  const toObject = {};
14703
14703
  const fromName = getValueByPath(fromObject, ['name']);
14704
14704
  if (fromName != null) {
@@ -14706,7 +14706,7 @@ function getTuningJobParametersToVertex(fromObject) {
14706
14706
  }
14707
14707
  return toObject;
14708
14708
  }
14709
- function listTuningJobsConfigToMldev(fromObject, parentObject) {
14709
+ function listTuningJobsConfigToMldev(fromObject, parentObject, _rootObject) {
14710
14710
  const toObject = {};
14711
14711
  const fromPageSize = getValueByPath(fromObject, ['pageSize']);
14712
14712
  if (parentObject !== undefined && fromPageSize != null) {
@@ -14722,7 +14722,7 @@ function listTuningJobsConfigToMldev(fromObject, parentObject) {
14722
14722
  }
14723
14723
  return toObject;
14724
14724
  }
14725
- function listTuningJobsConfigToVertex(fromObject, parentObject) {
14725
+ function listTuningJobsConfigToVertex(fromObject, parentObject, _rootObject) {
14726
14726
  const toObject = {};
14727
14727
  const fromPageSize = getValueByPath(fromObject, ['pageSize']);
14728
14728
  if (parentObject !== undefined && fromPageSize != null) {
@@ -14738,7 +14738,7 @@ function listTuningJobsConfigToVertex(fromObject, parentObject) {
14738
14738
  }
14739
14739
  return toObject;
14740
14740
  }
14741
- function listTuningJobsParametersToMldev(fromObject) {
14741
+ function listTuningJobsParametersToMldev(fromObject, rootObject) {
14742
14742
  const toObject = {};
14743
14743
  const fromConfig = getValueByPath(fromObject, ['config']);
14744
14744
  if (fromConfig != null) {
@@ -14746,7 +14746,7 @@ function listTuningJobsParametersToMldev(fromObject) {
14746
14746
  }
14747
14747
  return toObject;
14748
14748
  }
14749
- function listTuningJobsParametersToVertex(fromObject) {
14749
+ function listTuningJobsParametersToVertex(fromObject, rootObject) {
14750
14750
  const toObject = {};
14751
14751
  const fromConfig = getValueByPath(fromObject, ['config']);
14752
14752
  if (fromConfig != null) {
@@ -14754,7 +14754,7 @@ function listTuningJobsParametersToVertex(fromObject) {
14754
14754
  }
14755
14755
  return toObject;
14756
14756
  }
14757
- function listTuningJobsResponseFromMldev(fromObject) {
14757
+ function listTuningJobsResponseFromMldev(fromObject, rootObject) {
14758
14758
  const toObject = {};
14759
14759
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14760
14760
  'sdkHttpResponse',
@@ -14780,7 +14780,7 @@ function listTuningJobsResponseFromMldev(fromObject) {
14780
14780
  }
14781
14781
  return toObject;
14782
14782
  }
14783
- function listTuningJobsResponseFromVertex(fromObject) {
14783
+ function listTuningJobsResponseFromVertex(fromObject, rootObject) {
14784
14784
  const toObject = {};
14785
14785
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14786
14786
  'sdkHttpResponse',
@@ -14806,7 +14806,7 @@ function listTuningJobsResponseFromVertex(fromObject) {
14806
14806
  }
14807
14807
  return toObject;
14808
14808
  }
14809
- function tunedModelFromMldev(fromObject) {
14809
+ function tunedModelFromMldev(fromObject, _rootObject) {
14810
14810
  const toObject = {};
14811
14811
  const fromModel = getValueByPath(fromObject, ['name']);
14812
14812
  if (fromModel != null) {
@@ -14818,7 +14818,7 @@ function tunedModelFromMldev(fromObject) {
14818
14818
  }
14819
14819
  return toObject;
14820
14820
  }
14821
- function tuningDatasetToMldev(fromObject) {
14821
+ function tuningDatasetToMldev(fromObject, _rootObject) {
14822
14822
  const toObject = {};
14823
14823
  if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
14824
14824
  throw new Error('gcsUri parameter is not supported in Gemini API.');
@@ -14838,7 +14838,7 @@ function tuningDatasetToMldev(fromObject) {
14838
14838
  }
14839
14839
  return toObject;
14840
14840
  }
14841
- function tuningDatasetToVertex(fromObject, parentObject) {
14841
+ function tuningDatasetToVertex(fromObject, parentObject, _rootObject) {
14842
14842
  const toObject = {};
14843
14843
  const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
14844
14844
  if (parentObject !== undefined && fromGcsUri != null) {
@@ -14855,7 +14855,7 @@ function tuningDatasetToVertex(fromObject, parentObject) {
14855
14855
  }
14856
14856
  return toObject;
14857
14857
  }
14858
- function tuningJobFromMldev(fromObject) {
14858
+ function tuningJobFromMldev(fromObject, rootObject) {
14859
14859
  const toObject = {};
14860
14860
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14861
14861
  'sdkHttpResponse',
@@ -14907,7 +14907,7 @@ function tuningJobFromMldev(fromObject) {
14907
14907
  }
14908
14908
  return toObject;
14909
14909
  }
14910
- function tuningJobFromVertex(fromObject) {
14910
+ function tuningJobFromVertex(fromObject, _rootObject) {
14911
14911
  const toObject = {};
14912
14912
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14913
14913
  'sdkHttpResponse',
@@ -15027,7 +15027,7 @@ function tuningJobFromVertex(fromObject) {
15027
15027
  }
15028
15028
  return toObject;
15029
15029
  }
15030
- function tuningOperationFromMldev(fromObject) {
15030
+ function tuningOperationFromMldev(fromObject, _rootObject) {
15031
15031
  const toObject = {};
15032
15032
  const fromSdkHttpResponse = getValueByPath(fromObject, [
15033
15033
  'sdkHttpResponse',
@@ -15053,7 +15053,7 @@ function tuningOperationFromMldev(fromObject) {
15053
15053
  }
15054
15054
  return toObject;
15055
15055
  }
15056
- function tuningValidationDatasetToVertex(fromObject, parentObject) {
15056
+ function tuningValidationDatasetToVertex(fromObject, _rootObject) {
15057
15057
  const toObject = {};
15058
15058
  const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
15059
15059
  if (fromGcsUri != null) {
@@ -15062,8 +15062,8 @@ function tuningValidationDatasetToVertex(fromObject, parentObject) {
15062
15062
  const fromVertexDatasetResource = getValueByPath(fromObject, [
15063
15063
  'vertexDatasetResource',
15064
15064
  ]);
15065
- if (parentObject !== undefined && fromVertexDatasetResource != null) {
15066
- setValueByPath(parentObject, ['supervisedTuningSpec', 'trainingDatasetUri'], fromVertexDatasetResource);
15065
+ if (fromVertexDatasetResource != null) {
15066
+ setValueByPath(toObject, ['validationDatasetUri'], fromVertexDatasetResource);
15067
15067
  }
15068
15068
  return toObject;
15069
15069
  }