@google/genai 2.6.0 → 2.7.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
@@ -794,30 +794,6 @@ var DynamicRetrievalConfigMode;
794
794
  */
795
795
  DynamicRetrievalConfigMode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
796
796
  })(DynamicRetrievalConfigMode || (DynamicRetrievalConfigMode = {}));
797
- /** Function calling mode. */
798
- var FunctionCallingConfigMode;
799
- (function (FunctionCallingConfigMode) {
800
- /**
801
- * Unspecified function calling mode. This value should not be used.
802
- */
803
- FunctionCallingConfigMode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
804
- /**
805
- * Default model behavior, model decides to predict either function calls or natural language response.
806
- */
807
- FunctionCallingConfigMode["AUTO"] = "AUTO";
808
- /**
809
- * Model is constrained to always predicting function calls only. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations".
810
- */
811
- FunctionCallingConfigMode["ANY"] = "ANY";
812
- /**
813
- * Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
814
- */
815
- FunctionCallingConfigMode["NONE"] = "NONE";
816
- /**
817
- * Model is constrained to predict either function calls or natural language response. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations".
818
- */
819
- FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
820
- })(FunctionCallingConfigMode || (FunctionCallingConfigMode = {}));
821
797
  /** The number of thoughts tokens that the model should generate. */
822
798
  var ThinkingLevel;
823
799
  (function (ThinkingLevel) {
@@ -966,6 +942,30 @@ var HarmBlockThreshold;
966
942
  */
967
943
  HarmBlockThreshold["OFF"] = "OFF";
968
944
  })(HarmBlockThreshold || (HarmBlockThreshold = {}));
945
+ /** Function calling mode. */
946
+ var FunctionCallingConfigMode;
947
+ (function (FunctionCallingConfigMode) {
948
+ /**
949
+ * Unspecified function calling mode. This value should not be used.
950
+ */
951
+ FunctionCallingConfigMode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
952
+ /**
953
+ * Default model behavior, model decides to predict either function calls or natural language response.
954
+ */
955
+ FunctionCallingConfigMode["AUTO"] = "AUTO";
956
+ /**
957
+ * Model is constrained to always predicting function calls only. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations".
958
+ */
959
+ FunctionCallingConfigMode["ANY"] = "ANY";
960
+ /**
961
+ * Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
962
+ */
963
+ FunctionCallingConfigMode["NONE"] = "NONE";
964
+ /**
965
+ * Model is constrained to predict either function calls or natural language response. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations".
966
+ */
967
+ FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
968
+ })(FunctionCallingConfigMode || (FunctionCallingConfigMode = {}));
969
969
  /** Output only. The reason why the model stopped generating tokens.
970
970
 
971
971
  If empty, the model has not stopped generating the tokens. */
@@ -1799,6 +1799,10 @@ var TuningMethod;
1799
1799
  * Distillation tuning.
1800
1800
  */
1801
1801
  TuningMethod["DISTILLATION"] = "DISTILLATION";
1802
+ /**
1803
+ * Reinforcement tuning.
1804
+ */
1805
+ TuningMethod["REINFORCEMENT_TUNING"] = "REINFORCEMENT_TUNING";
1802
1806
  })(TuningMethod || (TuningMethod = {}));
1803
1807
  /** State for the lifecycle of a File. */
1804
1808
  var FileState;
@@ -5120,6 +5124,7 @@ var PagedItem;
5120
5124
  PagedItem["PAGED_ITEM_CACHED_CONTENTS"] = "cachedContents";
5121
5125
  PagedItem["PAGED_ITEM_FILE_SEARCH_STORES"] = "fileSearchStores";
5122
5126
  PagedItem["PAGED_ITEM_DOCUMENTS"] = "documents";
5127
+ PagedItem["PAGED_ITEM_SKILLS"] = "skills";
5123
5128
  })(PagedItem || (PagedItem = {}));
5124
5129
  /**
5125
5130
  * Pager class for iterating through paginated results.
@@ -5855,24 +5860,6 @@ function codeExecutionResultToVertex$2(fromObject) {
5855
5860
  }
5856
5861
  return toObject;
5857
5862
  }
5858
- function computerUseToVertex$2(fromObject) {
5859
- const toObject = {};
5860
- const fromEnvironment = getValueByPath(fromObject, ['environment']);
5861
- if (fromEnvironment != null) {
5862
- setValueByPath(toObject, ['environment'], fromEnvironment);
5863
- }
5864
- const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
5865
- 'excludedPredefinedFunctions',
5866
- ]);
5867
- if (fromExcludedPredefinedFunctions != null) {
5868
- setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
5869
- }
5870
- if (getValueByPath(fromObject, ['enablePromptInjectionDetection']) !==
5871
- undefined) {
5872
- throw new Error('enablePromptInjectionDetection parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
5873
- }
5874
- return toObject;
5875
- }
5876
5863
  function contentToMldev$3(fromObject) {
5877
5864
  const toObject = {};
5878
5865
  const fromParts = getValueByPath(fromObject, ['parts']);
@@ -6538,7 +6525,7 @@ function toolToVertex$2(fromObject) {
6538
6525
  }
6539
6526
  const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
6540
6527
  if (fromComputerUse != null) {
6541
- setValueByPath(toObject, ['computerUse'], computerUseToVertex$2(fromComputerUse));
6528
+ setValueByPath(toObject, ['computerUse'], fromComputerUse);
6542
6529
  }
6543
6530
  if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
6544
6531
  throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
@@ -7682,7 +7669,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
7682
7669
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
7683
7670
  const USER_AGENT_HEADER = 'User-Agent';
7684
7671
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
7685
- const SDK_VERSION = '2.6.0'; // x-release-please-version
7672
+ const SDK_VERSION = '2.7.0'; // x-release-please-version
7686
7673
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
7687
7674
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
7688
7675
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -11734,24 +11721,6 @@ function codeExecutionResultToVertex$1(fromObject) {
11734
11721
  }
11735
11722
  return toObject;
11736
11723
  }
11737
- function computerUseToVertex$1(fromObject) {
11738
- const toObject = {};
11739
- const fromEnvironment = getValueByPath(fromObject, ['environment']);
11740
- if (fromEnvironment != null) {
11741
- setValueByPath(toObject, ['environment'], fromEnvironment);
11742
- }
11743
- const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
11744
- 'excludedPredefinedFunctions',
11745
- ]);
11746
- if (fromExcludedPredefinedFunctions != null) {
11747
- setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
11748
- }
11749
- if (getValueByPath(fromObject, ['enablePromptInjectionDetection']) !==
11750
- undefined) {
11751
- throw new Error('enablePromptInjectionDetection parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
11752
- }
11753
- return toObject;
11754
- }
11755
11724
  function contentToMldev$2(fromObject) {
11756
11725
  const toObject = {};
11757
11726
  const fromParts = getValueByPath(fromObject, ['parts']);
@@ -12700,7 +12669,7 @@ function toolToVertex$1(fromObject) {
12700
12669
  }
12701
12670
  const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
12702
12671
  if (fromComputerUse != null) {
12703
- setValueByPath(toObject, ['computerUse'], computerUseToVertex$1(fromComputerUse));
12672
+ setValueByPath(toObject, ['computerUse'], fromComputerUse);
12704
12673
  }
12705
12674
  if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
12706
12675
  throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
@@ -13033,24 +13002,6 @@ function computeTokensResponseFromVertex(fromObject, _rootObject) {
13033
13002
  }
13034
13003
  return toObject;
13035
13004
  }
13036
- function computerUseToVertex(fromObject, _rootObject) {
13037
- const toObject = {};
13038
- const fromEnvironment = getValueByPath(fromObject, ['environment']);
13039
- if (fromEnvironment != null) {
13040
- setValueByPath(toObject, ['environment'], fromEnvironment);
13041
- }
13042
- const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
13043
- 'excludedPredefinedFunctions',
13044
- ]);
13045
- if (fromExcludedPredefinedFunctions != null) {
13046
- setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
13047
- }
13048
- if (getValueByPath(fromObject, ['enablePromptInjectionDetection']) !==
13049
- undefined) {
13050
- throw new Error('enablePromptInjectionDetection parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
13051
- }
13052
- return toObject;
13053
- }
13054
13005
  function contentEmbeddingFromVertex(fromObject, rootObject) {
13055
13006
  const toObject = {};
13056
13007
  const fromValues = getValueByPath(fromObject, ['values']);
@@ -16111,7 +16062,7 @@ function toolToMldev$1(fromObject, rootObject) {
16111
16062
  }
16112
16063
  return toObject;
16113
16064
  }
16114
- function toolToVertex(fromObject, rootObject) {
16065
+ function toolToVertex(fromObject, _rootObject) {
16115
16066
  const toObject = {};
16116
16067
  const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
16117
16068
  if (fromRetrieval != null) {
@@ -16119,7 +16070,7 @@ function toolToVertex(fromObject, rootObject) {
16119
16070
  }
16120
16071
  const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
16121
16072
  if (fromComputerUse != null) {
16122
- setValueByPath(toObject, ['computerUse'], computerUseToVertex(fromComputerUse));
16073
+ setValueByPath(toObject, ['computerUse'], fromComputerUse);
16123
16074
  }
16124
16075
  if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
16125
16076
  throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
@@ -20012,6 +19963,24 @@ function createTuningJobConfigToMldev(fromObject, parentObject, _rootObject) {
20012
19963
  if (getValueByPath(fromObject, ['encryptionSpec']) !== undefined) {
20013
19964
  throw new Error('encryptionSpec parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
20014
19965
  }
19966
+ if (getValueByPath(fromObject, ['rewardConfig']) !== undefined) {
19967
+ throw new Error('rewardConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
19968
+ }
19969
+ if (getValueByPath(fromObject, ['compositeRewardConfig']) !== undefined) {
19970
+ throw new Error('compositeRewardConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
19971
+ }
19972
+ if (getValueByPath(fromObject, ['samplesPerPrompt']) !== undefined) {
19973
+ throw new Error('samplesPerPrompt parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
19974
+ }
19975
+ if (getValueByPath(fromObject, ['evaluateInterval']) !== undefined) {
19976
+ throw new Error('evaluateInterval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
19977
+ }
19978
+ if (getValueByPath(fromObject, ['checkpointInterval']) !== undefined) {
19979
+ throw new Error('checkpointInterval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
19980
+ }
19981
+ if (getValueByPath(fromObject, ['maxOutputTokens']) !== undefined) {
19982
+ throw new Error('maxOutputTokens parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
19983
+ }
20015
19984
  return toObject;
20016
19985
  }
20017
19986
  function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
@@ -20047,6 +20016,14 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
20047
20016
  setValueByPath(parentObject, ['distillationSpec'], tuningValidationDatasetToVertex(fromValidationDataset));
20048
20017
  }
20049
20018
  }
20019
+ else if (discriminatorValidationDataset === 'REINFORCEMENT_TUNING') {
20020
+ const fromValidationDataset = getValueByPath(fromObject, [
20021
+ 'validationDataset',
20022
+ ]);
20023
+ if (parentObject !== undefined && fromValidationDataset != null) {
20024
+ setValueByPath(parentObject, ['reinforcementTuningSpec'], tuningValidationDatasetToVertex(fromValidationDataset));
20025
+ }
20026
+ }
20050
20027
  const fromTunedModelDisplayName = getValueByPath(fromObject, [
20051
20028
  'tunedModelDisplayName',
20052
20029
  ]);
@@ -20082,6 +20059,12 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
20082
20059
  setValueByPath(parentObject, ['distillationSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
20083
20060
  }
20084
20061
  }
20062
+ else if (discriminatorEpochCount === 'REINFORCEMENT_TUNING') {
20063
+ const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
20064
+ if (parentObject !== undefined && fromEpochCount != null) {
20065
+ setValueByPath(parentObject, ['reinforcementTuningSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
20066
+ }
20067
+ }
20085
20068
  let discriminatorLearningRateMultiplier = getValueByPath(rootObject, [
20086
20069
  'config',
20087
20070
  'method',
@@ -20117,6 +20100,18 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
20117
20100
  setValueByPath(parentObject, ['distillationSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
20118
20101
  }
20119
20102
  }
20103
+ else if (discriminatorLearningRateMultiplier === 'REINFORCEMENT_TUNING') {
20104
+ const fromLearningRateMultiplier = getValueByPath(fromObject, [
20105
+ 'learningRateMultiplier',
20106
+ ]);
20107
+ if (parentObject !== undefined && fromLearningRateMultiplier != null) {
20108
+ setValueByPath(parentObject, [
20109
+ 'reinforcementTuningSpec',
20110
+ 'hyperParameters',
20111
+ 'learningRateMultiplier',
20112
+ ], fromLearningRateMultiplier);
20113
+ }
20114
+ }
20120
20115
  let discriminatorExportLastCheckpointOnly = getValueByPath(rootObject, ['config', 'method']);
20121
20116
  if (discriminatorExportLastCheckpointOnly === undefined) {
20122
20117
  discriminatorExportLastCheckpointOnly = 'SUPERVISED_FINE_TUNING';
@@ -20170,6 +20165,12 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
20170
20165
  setValueByPath(parentObject, ['distillationSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
20171
20166
  }
20172
20167
  }
20168
+ else if (discriminatorAdapterSize === 'REINFORCEMENT_TUNING') {
20169
+ const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
20170
+ if (parentObject !== undefined && fromAdapterSize != null) {
20171
+ setValueByPath(parentObject, ['reinforcementTuningSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
20172
+ }
20173
+ }
20173
20174
  let discriminatorTuningMode = getValueByPath(rootObject, [
20174
20175
  'config',
20175
20176
  'method',
@@ -20214,6 +20215,12 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
20214
20215
  setValueByPath(parentObject, ['distillationSpec', 'hyperParameters', 'batchSize'], fromBatchSize);
20215
20216
  }
20216
20217
  }
20218
+ else if (discriminatorBatchSize === 'REINFORCEMENT_TUNING') {
20219
+ const fromBatchSize = getValueByPath(fromObject, ['batchSize']);
20220
+ if (parentObject !== undefined && fromBatchSize != null) {
20221
+ setValueByPath(parentObject, ['reinforcementTuningSpec', 'hyperParameters', 'batchSize'], fromBatchSize);
20222
+ }
20223
+ }
20217
20224
  let discriminatorLearningRate = getValueByPath(rootObject, [
20218
20225
  'config',
20219
20226
  'method',
@@ -20273,6 +20280,40 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
20273
20280
  if (parentObject !== undefined && fromEncryptionSpec != null) {
20274
20281
  setValueByPath(parentObject, ['encryptionSpec'], fromEncryptionSpec);
20275
20282
  }
20283
+ const fromRewardConfig = getValueByPath(fromObject, ['rewardConfig']);
20284
+ if (parentObject !== undefined && fromRewardConfig != null) {
20285
+ setValueByPath(parentObject, ['reinforcementTuningSpec', 'singleRewardConfig'], fromRewardConfig);
20286
+ }
20287
+ const fromCompositeRewardConfig = getValueByPath(fromObject, [
20288
+ 'compositeRewardConfig',
20289
+ ]);
20290
+ if (parentObject !== undefined && fromCompositeRewardConfig != null) {
20291
+ setValueByPath(parentObject, ['reinforcementTuningSpec', 'compositeRewardConfig'], fromCompositeRewardConfig);
20292
+ }
20293
+ const fromSamplesPerPrompt = getValueByPath(fromObject, [
20294
+ 'samplesPerPrompt',
20295
+ ]);
20296
+ if (parentObject !== undefined && fromSamplesPerPrompt != null) {
20297
+ setValueByPath(parentObject, ['reinforcementTuningSpec', 'hyperParameters', 'samplesPerPrompt'], fromSamplesPerPrompt);
20298
+ }
20299
+ const fromEvaluateInterval = getValueByPath(fromObject, [
20300
+ 'evaluateInterval',
20301
+ ]);
20302
+ if (parentObject !== undefined && fromEvaluateInterval != null) {
20303
+ setValueByPath(parentObject, ['reinforcementTuningSpec', 'hyperParameters', 'evaluateInterval'], fromEvaluateInterval);
20304
+ }
20305
+ const fromCheckpointInterval = getValueByPath(fromObject, [
20306
+ 'checkpointInterval',
20307
+ ]);
20308
+ if (parentObject !== undefined && fromCheckpointInterval != null) {
20309
+ setValueByPath(parentObject, ['reinforcementTuningSpec', 'hyperParameters', 'checkpointInterval'], fromCheckpointInterval);
20310
+ }
20311
+ const fromMaxOutputTokens = getValueByPath(fromObject, [
20312
+ 'maxOutputTokens',
20313
+ ]);
20314
+ if (parentObject !== undefined && fromMaxOutputTokens != null) {
20315
+ setValueByPath(parentObject, ['reinforcementTuningSpec', 'hyperParameters', 'maxOutputTokens'], fromMaxOutputTokens);
20316
+ }
20276
20317
  return toObject;
20277
20318
  }
20278
20319
  function createTuningJobParametersPrivateToMldev(fromObject, rootObject) {
@@ -20692,6 +20733,12 @@ function tuningDatasetToVertex(fromObject, parentObject, rootObject) {
20692
20733
  setValueByPath(parentObject, ['distillationSpec', 'promptDatasetUri'], fromGcsUri);
20693
20734
  }
20694
20735
  }
20736
+ else if (discriminatorGcsUri === 'REINFORCEMENT_TUNING') {
20737
+ const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
20738
+ if (parentObject !== undefined && fromGcsUri != null) {
20739
+ setValueByPath(parentObject, ['reinforcementTuningSpec', 'trainingDatasetUri'], fromGcsUri);
20740
+ }
20741
+ }
20695
20742
  let discriminatorVertexDatasetResource = getValueByPath(rootObject, [
20696
20743
  'config',
20697
20744
  'method',
@@ -20723,6 +20770,14 @@ function tuningDatasetToVertex(fromObject, parentObject, rootObject) {
20723
20770
  setValueByPath(parentObject, ['distillationSpec', 'promptDatasetUri'], fromVertexDatasetResource);
20724
20771
  }
20725
20772
  }
20773
+ else if (discriminatorVertexDatasetResource === 'REINFORCEMENT_TUNING') {
20774
+ const fromVertexDatasetResource = getValueByPath(fromObject, [
20775
+ 'vertexDatasetResource',
20776
+ ]);
20777
+ if (parentObject !== undefined && fromVertexDatasetResource != null) {
20778
+ setValueByPath(parentObject, ['reinforcementTuningSpec', 'trainingDatasetUri'], fromVertexDatasetResource);
20779
+ }
20780
+ }
20726
20781
  if (getValueByPath(fromObject, ['examples']) !== undefined) {
20727
20782
  throw new Error('examples parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
20728
20783
  }