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