@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.
@@ -644,23 +644,23 @@ exports.HarmCategory = void 0;
644
644
  */
645
645
  HarmCategory["HARM_CATEGORY_CIVIC_INTEGRITY"] = "HARM_CATEGORY_CIVIC_INTEGRITY";
646
646
  /**
647
- * The harm category is image hate.
647
+ * The harm category is image hate. This enum value is not supported in Gemini API.
648
648
  */
649
649
  HarmCategory["HARM_CATEGORY_IMAGE_HATE"] = "HARM_CATEGORY_IMAGE_HATE";
650
650
  /**
651
- * The harm category is image dangerous content.
651
+ * The harm category is image dangerous content. This enum value is not supported in Gemini API.
652
652
  */
653
653
  HarmCategory["HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT"] = "HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT";
654
654
  /**
655
- * The harm category is image harassment.
655
+ * The harm category is image harassment. This enum value is not supported in Gemini API.
656
656
  */
657
657
  HarmCategory["HARM_CATEGORY_IMAGE_HARASSMENT"] = "HARM_CATEGORY_IMAGE_HARASSMENT";
658
658
  /**
659
- * The harm category is image sexually explicit content.
659
+ * The harm category is image sexually explicit content. This enum value is not supported in Gemini API.
660
660
  */
661
661
  HarmCategory["HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT";
662
662
  /**
663
- * The harm category is for jailbreak prompts.
663
+ * The harm category is for jailbreak prompts. This enum value is not supported in Gemini API.
664
664
  */
665
665
  HarmCategory["HARM_CATEGORY_JAILBREAK"] = "HARM_CATEGORY_JAILBREAK";
666
666
  })(exports.HarmCategory || (exports.HarmCategory = {}));
@@ -931,11 +931,11 @@ exports.BlockedReason = void 0;
931
931
  */
932
932
  BlockedReason["IMAGE_SAFETY"] = "IMAGE_SAFETY";
933
933
  /**
934
- * The prompt was blocked by Model Armor.
934
+ * The prompt was blocked by Model Armor. This enum value is not supported in Gemini API.
935
935
  */
936
936
  BlockedReason["MODEL_ARMOR"] = "MODEL_ARMOR";
937
937
  /**
938
- * The prompt was blocked as a jailbreak attempt.
938
+ * The prompt was blocked as a jailbreak attempt. This enum value is not supported in Gemini API.
939
939
  */
940
940
  BlockedReason["JAILBREAK"] = "JAILBREAK";
941
941
  })(exports.BlockedReason || (exports.BlockedReason = {}));
@@ -1772,7 +1772,7 @@ class HttpResponse {
1772
1772
  /** 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. */
1773
1773
  class GenerateContentResponsePromptFeedback {
1774
1774
  }
1775
- /** Usage metadata about response(s). */
1775
+ /** Usage metadata about response(s). This data type is not supported in Gemini API. */
1776
1776
  class GenerateContentResponseUsageMetadata {
1777
1777
  }
1778
1778
  /** Response message for PredictionService.GenerateContent. */
@@ -10615,7 +10615,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
10615
10615
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
10616
10616
  const USER_AGENT_HEADER = 'User-Agent';
10617
10617
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
10618
- const SDK_VERSION = '1.26.0'; // x-release-please-version
10618
+ const SDK_VERSION = '1.27.0'; // x-release-please-version
10619
10619
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
10620
10620
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
10621
10621
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -10804,7 +10804,7 @@ class ApiClient {
10804
10804
  else {
10805
10805
  requestInit.body = request.body;
10806
10806
  }
10807
- requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, request.abortSignal);
10807
+ requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, url.toString(), request.abortSignal);
10808
10808
  return this.unaryApiCall(url, requestInit, request.httpMethod);
10809
10809
  }
10810
10810
  patchHttpOptions(baseHttpOptions, requestHttpOptions) {
@@ -10838,10 +10838,10 @@ class ApiClient {
10838
10838
  }
10839
10839
  let requestInit = {};
10840
10840
  requestInit.body = request.body;
10841
- requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, request.abortSignal);
10841
+ requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, url.toString(), request.abortSignal);
10842
10842
  return this.streamApiCall(url, requestInit, request.httpMethod);
10843
10843
  }
10844
- async includeExtraHttpOptionsToRequestInit(requestInit, httpOptions, abortSignal) {
10844
+ async includeExtraHttpOptionsToRequestInit(requestInit, httpOptions, url, abortSignal) {
10845
10845
  if ((httpOptions && httpOptions.timeout) || abortSignal) {
10846
10846
  const abortController = new AbortController();
10847
10847
  const signal = abortController.signal;
@@ -10865,7 +10865,7 @@ class ApiClient {
10865
10865
  if (httpOptions && httpOptions.extraBody !== null) {
10866
10866
  includeExtraBodyToRequestInit(requestInit, httpOptions.extraBody);
10867
10867
  }
10868
- requestInit.headers = await this.getHeadersInternal(httpOptions);
10868
+ requestInit.headers = await this.getHeadersInternal(httpOptions, url);
10869
10869
  return requestInit;
10870
10870
  }
10871
10871
  async unaryApiCall(url, requestInit, httpMethod) {
@@ -10978,7 +10978,7 @@ class ApiClient {
10978
10978
  headers[CONTENT_TYPE_HEADER] = 'application/json';
10979
10979
  return headers;
10980
10980
  }
10981
- async getHeadersInternal(httpOptions) {
10981
+ async getHeadersInternal(httpOptions, url) {
10982
10982
  const headers = new Headers();
10983
10983
  if (httpOptions && httpOptions.headers) {
10984
10984
  for (const [key, value] of Object.entries(httpOptions.headers)) {
@@ -10990,7 +10990,7 @@ class ApiClient {
10990
10990
  headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
10991
10991
  }
10992
10992
  }
10993
- await this.clientOptions.auth.addAuthHeaders(headers);
10993
+ await this.clientOptions.auth.addAuthHeaders(headers, url);
10994
10994
  return headers;
10995
10995
  }
10996
10996
  /**
@@ -11703,7 +11703,7 @@ class Live {
11703
11703
  const headers = mapToHeaders(clientHeaders);
11704
11704
  if (this.apiClient.isVertexAI()) {
11705
11705
  url = `${websocketBaseUrl}/ws/google.cloud.aiplatform.${apiVersion}.LlmBidiService/BidiGenerateContent`;
11706
- await this.auth.addAuthHeaders(headers);
11706
+ await this.auth.addAuthHeaders(headers, url);
11707
11707
  }
11708
11708
  else {
11709
11709
  const apiKey = this.apiClient.getApiKey();
@@ -14386,7 +14386,7 @@ class NodeAuth {
14386
14386
  const vertexAuthOptions = buildGoogleAuthOptions(opts.googleAuthOptions);
14387
14387
  this.googleAuth = new googleAuthLibrary.GoogleAuth(vertexAuthOptions);
14388
14388
  }
14389
- async addAuthHeaders(headers) {
14389
+ async addAuthHeaders(headers, url) {
14390
14390
  if (this.apiKey !== undefined) {
14391
14391
  if (this.apiKey.startsWith('auth_tokens/')) {
14392
14392
  throw new Error('Ephemeral tokens are only supported by the live API.');
@@ -14394,7 +14394,7 @@ class NodeAuth {
14394
14394
  this.addKeyHeader(headers);
14395
14395
  return;
14396
14396
  }
14397
- return this.addGoogleAuthHeaders(headers);
14397
+ return this.addGoogleAuthHeaders(headers, url);
14398
14398
  }
14399
14399
  addKeyHeader(headers) {
14400
14400
  if (headers.get(GOOGLE_API_KEY_HEADER) !== null) {
@@ -14407,15 +14407,15 @@ class NodeAuth {
14407
14407
  }
14408
14408
  headers.append(GOOGLE_API_KEY_HEADER, this.apiKey);
14409
14409
  }
14410
- async addGoogleAuthHeaders(headers) {
14410
+ async addGoogleAuthHeaders(headers, url) {
14411
14411
  if (this.googleAuth === undefined) {
14412
14412
  // This should never happen, addGoogleAuthHeaders should only be
14413
14413
  // called when there is no apiKey set and in these cases googleAuth
14414
14414
  // is set.
14415
14415
  throw new Error('Trying to set google-auth headers but googleAuth is unset');
14416
14416
  }
14417
- const authHeaders = await this.googleAuth.getRequestHeaders();
14418
- for (const [key, value] of Object.entries(authHeaders)) {
14417
+ const authHeaders = await this.googleAuth.getRequestHeaders(url);
14418
+ for (const [key, value] of authHeaders) {
14419
14419
  if (headers.get(key) !== null) {
14420
14420
  continue;
14421
14421
  }
@@ -14550,7 +14550,7 @@ class NodeWebSocket {
14550
14550
  * SPDX-License-Identifier: Apache-2.0
14551
14551
  */
14552
14552
  // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
14553
- function cancelTuningJobParametersToMldev(fromObject) {
14553
+ function cancelTuningJobParametersToMldev(fromObject, _rootObject) {
14554
14554
  const toObject = {};
14555
14555
  const fromName = getValueByPath(fromObject, ['name']);
14556
14556
  if (fromName != null) {
@@ -14558,7 +14558,7 @@ function cancelTuningJobParametersToMldev(fromObject) {
14558
14558
  }
14559
14559
  return toObject;
14560
14560
  }
14561
- function cancelTuningJobParametersToVertex(fromObject) {
14561
+ function cancelTuningJobParametersToVertex(fromObject, _rootObject) {
14562
14562
  const toObject = {};
14563
14563
  const fromName = getValueByPath(fromObject, ['name']);
14564
14564
  if (fromName != null) {
@@ -14566,7 +14566,7 @@ function cancelTuningJobParametersToVertex(fromObject) {
14566
14566
  }
14567
14567
  return toObject;
14568
14568
  }
14569
- function createTuningJobConfigToMldev(fromObject, parentObject) {
14569
+ function createTuningJobConfigToMldev(fromObject, parentObject, _rootObject) {
14570
14570
  const toObject = {};
14571
14571
  if (getValueByPath(fromObject, ['validationDataset']) !== undefined) {
14572
14572
  throw new Error('validationDataset parameter is not supported in Gemini API.');
@@ -14614,13 +14614,13 @@ function createTuningJobConfigToMldev(fromObject, parentObject) {
14614
14614
  }
14615
14615
  return toObject;
14616
14616
  }
14617
- function createTuningJobConfigToVertex(fromObject, parentObject) {
14617
+ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
14618
14618
  const toObject = {};
14619
14619
  const fromValidationDataset = getValueByPath(fromObject, [
14620
14620
  'validationDataset',
14621
14621
  ]);
14622
14622
  if (parentObject !== undefined && fromValidationDataset != null) {
14623
- setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(fromValidationDataset, toObject));
14623
+ setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(fromValidationDataset));
14624
14624
  }
14625
14625
  const fromTunedModelDisplayName = getValueByPath(fromObject, [
14626
14626
  'tunedModelDisplayName',
@@ -14664,7 +14664,7 @@ function createTuningJobConfigToVertex(fromObject, parentObject) {
14664
14664
  }
14665
14665
  return toObject;
14666
14666
  }
14667
- function createTuningJobParametersPrivateToMldev(fromObject) {
14667
+ function createTuningJobParametersPrivateToMldev(fromObject, rootObject) {
14668
14668
  const toObject = {};
14669
14669
  const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
14670
14670
  if (fromBaseModel != null) {
@@ -14688,7 +14688,7 @@ function createTuningJobParametersPrivateToMldev(fromObject) {
14688
14688
  }
14689
14689
  return toObject;
14690
14690
  }
14691
- function createTuningJobParametersPrivateToVertex(fromObject) {
14691
+ function createTuningJobParametersPrivateToVertex(fromObject, rootObject) {
14692
14692
  const toObject = {};
14693
14693
  const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
14694
14694
  if (fromBaseModel != null) {
@@ -14704,7 +14704,7 @@ function createTuningJobParametersPrivateToVertex(fromObject) {
14704
14704
  'trainingDataset',
14705
14705
  ]);
14706
14706
  if (fromTrainingDataset != null) {
14707
- setValueByPath(toObject, ['supervisedTuningSpec', 'trainingDatasetUri'], tuningDatasetToVertex(fromTrainingDataset, toObject));
14707
+ tuningDatasetToVertex(fromTrainingDataset, toObject);
14708
14708
  }
14709
14709
  const fromConfig = getValueByPath(fromObject, ['config']);
14710
14710
  if (fromConfig != null) {
@@ -14712,7 +14712,7 @@ function createTuningJobParametersPrivateToVertex(fromObject) {
14712
14712
  }
14713
14713
  return toObject;
14714
14714
  }
14715
- function getTuningJobParametersToMldev(fromObject) {
14715
+ function getTuningJobParametersToMldev(fromObject, _rootObject) {
14716
14716
  const toObject = {};
14717
14717
  const fromName = getValueByPath(fromObject, ['name']);
14718
14718
  if (fromName != null) {
@@ -14720,7 +14720,7 @@ function getTuningJobParametersToMldev(fromObject) {
14720
14720
  }
14721
14721
  return toObject;
14722
14722
  }
14723
- function getTuningJobParametersToVertex(fromObject) {
14723
+ function getTuningJobParametersToVertex(fromObject, _rootObject) {
14724
14724
  const toObject = {};
14725
14725
  const fromName = getValueByPath(fromObject, ['name']);
14726
14726
  if (fromName != null) {
@@ -14728,7 +14728,7 @@ function getTuningJobParametersToVertex(fromObject) {
14728
14728
  }
14729
14729
  return toObject;
14730
14730
  }
14731
- function listTuningJobsConfigToMldev(fromObject, parentObject) {
14731
+ function listTuningJobsConfigToMldev(fromObject, parentObject, _rootObject) {
14732
14732
  const toObject = {};
14733
14733
  const fromPageSize = getValueByPath(fromObject, ['pageSize']);
14734
14734
  if (parentObject !== undefined && fromPageSize != null) {
@@ -14744,7 +14744,7 @@ function listTuningJobsConfigToMldev(fromObject, parentObject) {
14744
14744
  }
14745
14745
  return toObject;
14746
14746
  }
14747
- function listTuningJobsConfigToVertex(fromObject, parentObject) {
14747
+ function listTuningJobsConfigToVertex(fromObject, parentObject, _rootObject) {
14748
14748
  const toObject = {};
14749
14749
  const fromPageSize = getValueByPath(fromObject, ['pageSize']);
14750
14750
  if (parentObject !== undefined && fromPageSize != null) {
@@ -14760,7 +14760,7 @@ function listTuningJobsConfigToVertex(fromObject, parentObject) {
14760
14760
  }
14761
14761
  return toObject;
14762
14762
  }
14763
- function listTuningJobsParametersToMldev(fromObject) {
14763
+ function listTuningJobsParametersToMldev(fromObject, rootObject) {
14764
14764
  const toObject = {};
14765
14765
  const fromConfig = getValueByPath(fromObject, ['config']);
14766
14766
  if (fromConfig != null) {
@@ -14768,7 +14768,7 @@ function listTuningJobsParametersToMldev(fromObject) {
14768
14768
  }
14769
14769
  return toObject;
14770
14770
  }
14771
- function listTuningJobsParametersToVertex(fromObject) {
14771
+ function listTuningJobsParametersToVertex(fromObject, rootObject) {
14772
14772
  const toObject = {};
14773
14773
  const fromConfig = getValueByPath(fromObject, ['config']);
14774
14774
  if (fromConfig != null) {
@@ -14776,7 +14776,7 @@ function listTuningJobsParametersToVertex(fromObject) {
14776
14776
  }
14777
14777
  return toObject;
14778
14778
  }
14779
- function listTuningJobsResponseFromMldev(fromObject) {
14779
+ function listTuningJobsResponseFromMldev(fromObject, rootObject) {
14780
14780
  const toObject = {};
14781
14781
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14782
14782
  'sdkHttpResponse',
@@ -14802,7 +14802,7 @@ function listTuningJobsResponseFromMldev(fromObject) {
14802
14802
  }
14803
14803
  return toObject;
14804
14804
  }
14805
- function listTuningJobsResponseFromVertex(fromObject) {
14805
+ function listTuningJobsResponseFromVertex(fromObject, rootObject) {
14806
14806
  const toObject = {};
14807
14807
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14808
14808
  'sdkHttpResponse',
@@ -14828,7 +14828,7 @@ function listTuningJobsResponseFromVertex(fromObject) {
14828
14828
  }
14829
14829
  return toObject;
14830
14830
  }
14831
- function tunedModelFromMldev(fromObject) {
14831
+ function tunedModelFromMldev(fromObject, _rootObject) {
14832
14832
  const toObject = {};
14833
14833
  const fromModel = getValueByPath(fromObject, ['name']);
14834
14834
  if (fromModel != null) {
@@ -14840,7 +14840,7 @@ function tunedModelFromMldev(fromObject) {
14840
14840
  }
14841
14841
  return toObject;
14842
14842
  }
14843
- function tuningDatasetToMldev(fromObject) {
14843
+ function tuningDatasetToMldev(fromObject, _rootObject) {
14844
14844
  const toObject = {};
14845
14845
  if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
14846
14846
  throw new Error('gcsUri parameter is not supported in Gemini API.');
@@ -14860,7 +14860,7 @@ function tuningDatasetToMldev(fromObject) {
14860
14860
  }
14861
14861
  return toObject;
14862
14862
  }
14863
- function tuningDatasetToVertex(fromObject, parentObject) {
14863
+ function tuningDatasetToVertex(fromObject, parentObject, _rootObject) {
14864
14864
  const toObject = {};
14865
14865
  const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
14866
14866
  if (parentObject !== undefined && fromGcsUri != null) {
@@ -14877,7 +14877,7 @@ function tuningDatasetToVertex(fromObject, parentObject) {
14877
14877
  }
14878
14878
  return toObject;
14879
14879
  }
14880
- function tuningJobFromMldev(fromObject) {
14880
+ function tuningJobFromMldev(fromObject, rootObject) {
14881
14881
  const toObject = {};
14882
14882
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14883
14883
  'sdkHttpResponse',
@@ -14929,7 +14929,7 @@ function tuningJobFromMldev(fromObject) {
14929
14929
  }
14930
14930
  return toObject;
14931
14931
  }
14932
- function tuningJobFromVertex(fromObject) {
14932
+ function tuningJobFromVertex(fromObject, _rootObject) {
14933
14933
  const toObject = {};
14934
14934
  const fromSdkHttpResponse = getValueByPath(fromObject, [
14935
14935
  'sdkHttpResponse',
@@ -15049,7 +15049,7 @@ function tuningJobFromVertex(fromObject) {
15049
15049
  }
15050
15050
  return toObject;
15051
15051
  }
15052
- function tuningOperationFromMldev(fromObject) {
15052
+ function tuningOperationFromMldev(fromObject, _rootObject) {
15053
15053
  const toObject = {};
15054
15054
  const fromSdkHttpResponse = getValueByPath(fromObject, [
15055
15055
  'sdkHttpResponse',
@@ -15075,7 +15075,7 @@ function tuningOperationFromMldev(fromObject) {
15075
15075
  }
15076
15076
  return toObject;
15077
15077
  }
15078
- function tuningValidationDatasetToVertex(fromObject, parentObject) {
15078
+ function tuningValidationDatasetToVertex(fromObject, _rootObject) {
15079
15079
  const toObject = {};
15080
15080
  const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
15081
15081
  if (fromGcsUri != null) {
@@ -15084,8 +15084,8 @@ function tuningValidationDatasetToVertex(fromObject, parentObject) {
15084
15084
  const fromVertexDatasetResource = getValueByPath(fromObject, [
15085
15085
  'vertexDatasetResource',
15086
15086
  ]);
15087
- if (parentObject !== undefined && fromVertexDatasetResource != null) {
15088
- setValueByPath(parentObject, ['supervisedTuningSpec', 'trainingDatasetUri'], fromVertexDatasetResource);
15087
+ if (fromVertexDatasetResource != null) {
15088
+ setValueByPath(toObject, ['validationDatasetUri'], fromVertexDatasetResource);
15089
15089
  }
15090
15090
  return toObject;
15091
15091
  }