@google/genai 1.29.0 → 1.30.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.
@@ -795,6 +795,22 @@ var PhishBlockThreshold;
795
795
  */
796
796
  PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
797
797
  })(PhishBlockThreshold || (PhishBlockThreshold = {}));
798
+ /** The level of thoughts tokens that the model should generate. */
799
+ var ThinkingLevel;
800
+ (function (ThinkingLevel) {
801
+ /**
802
+ * Default value.
803
+ */
804
+ ThinkingLevel["THINKING_LEVEL_UNSPECIFIED"] = "THINKING_LEVEL_UNSPECIFIED";
805
+ /**
806
+ * Low thinking level.
807
+ */
808
+ ThinkingLevel["LOW"] = "LOW";
809
+ /**
810
+ * High thinking level.
811
+ */
812
+ ThinkingLevel["HIGH"] = "HIGH";
813
+ })(ThinkingLevel || (ThinkingLevel = {}));
798
814
  /** Harm category. */
799
815
  var HarmCategory;
800
816
  (function (HarmCategory) {
@@ -1237,6 +1253,26 @@ var TuningTask;
1237
1253
  */
1238
1254
  TuningTask["TUNING_TASK_R2V"] = "TUNING_TASK_R2V";
1239
1255
  })(TuningTask || (TuningTask = {}));
1256
+ /** The tokenization quality used for given media. */
1257
+ var PartMediaResolutionLevel;
1258
+ (function (PartMediaResolutionLevel) {
1259
+ /**
1260
+ * Media resolution has not been set.
1261
+ */
1262
+ PartMediaResolutionLevel["MEDIA_RESOLUTION_UNSPECIFIED"] = "MEDIA_RESOLUTION_UNSPECIFIED";
1263
+ /**
1264
+ * Media resolution set to low.
1265
+ */
1266
+ PartMediaResolutionLevel["MEDIA_RESOLUTION_LOW"] = "MEDIA_RESOLUTION_LOW";
1267
+ /**
1268
+ * Media resolution set to medium.
1269
+ */
1270
+ PartMediaResolutionLevel["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
1271
+ /**
1272
+ * Media resolution set to high.
1273
+ */
1274
+ PartMediaResolutionLevel["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
1275
+ })(PartMediaResolutionLevel || (PartMediaResolutionLevel = {}));
1240
1276
  /** Options for feature selection preference. */
1241
1277
  var FeatureSelectionPreference;
1242
1278
  (function (FeatureSelectionPreference) {
@@ -1771,13 +1807,11 @@ class FunctionResponse {
1771
1807
  /**
1772
1808
  * Creates a `Part` object from a `URI` string.
1773
1809
  */
1774
- function createPartFromUri(uri, mimeType) {
1775
- return {
1776
- fileData: {
1810
+ function createPartFromUri(uri, mimeType, mediaResolution) {
1811
+ return Object.assign({ fileData: {
1777
1812
  fileUri: uri,
1778
1813
  mimeType: mimeType,
1779
- },
1780
- };
1814
+ } }, (mediaResolution && { mediaResolution: { level: mediaResolution } }));
1781
1815
  }
1782
1816
  /**
1783
1817
  * Creates a `Part` object from a `text` string.
@@ -1809,13 +1843,11 @@ function createPartFromFunctionResponse(id, name, response, parts = []) {
1809
1843
  /**
1810
1844
  * Creates a `Part` object from a `base64` encoded `string`.
1811
1845
  */
1812
- function createPartFromBase64(data, mimeType) {
1813
- return {
1814
- inlineData: {
1846
+ function createPartFromBase64(data, mimeType, mediaResolution) {
1847
+ return Object.assign({ inlineData: {
1815
1848
  data: data,
1816
1849
  mimeType: mimeType,
1817
- },
1818
- };
1850
+ } }, (mediaResolution && { mediaResolution: { level: mediaResolution } }));
1819
1851
  }
1820
1852
  /**
1821
1853
  * Creates a `Part` object from the `outcome` and `output` of a `CodeExecutionResult` object.
@@ -1960,6 +1992,7 @@ class GenerateContentResponse {
1960
1992
  for (const [fieldName, fieldValue] of Object.entries(part)) {
1961
1993
  if (fieldName !== 'text' &&
1962
1994
  fieldName !== 'thought' &&
1995
+ fieldName !== 'thoughtSignature' &&
1963
1996
  (fieldValue !== null || fieldValue !== undefined)) {
1964
1997
  nonTextParts.push(fieldName);
1965
1998
  }
@@ -2493,6 +2526,9 @@ function tModel(apiClient, model) {
2493
2526
  if (!model || typeof model !== 'string') {
2494
2527
  throw new Error('model is required and must be a string');
2495
2528
  }
2529
+ if (model.includes('..') || model.includes('?') || model.includes('&')) {
2530
+ throw new Error('invalid model parameter');
2531
+ }
2496
2532
  if (apiClient.isVertexAI()) {
2497
2533
  if (model.startsWith('publishers/') ||
2498
2534
  model.startsWith('projects/') ||
@@ -3891,6 +3927,46 @@ function fileDataToMldev$4(fromObject) {
3891
3927
  }
3892
3928
  return toObject;
3893
3929
  }
3930
+ function functionCallToMldev$4(fromObject) {
3931
+ const toObject = {};
3932
+ const fromId = getValueByPath(fromObject, ['id']);
3933
+ if (fromId != null) {
3934
+ setValueByPath(toObject, ['id'], fromId);
3935
+ }
3936
+ const fromArgs = getValueByPath(fromObject, ['args']);
3937
+ if (fromArgs != null) {
3938
+ setValueByPath(toObject, ['args'], fromArgs);
3939
+ }
3940
+ const fromName = getValueByPath(fromObject, ['name']);
3941
+ if (fromName != null) {
3942
+ setValueByPath(toObject, ['name'], fromName);
3943
+ }
3944
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
3945
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
3946
+ }
3947
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
3948
+ throw new Error('willContinue parameter is not supported in Gemini API.');
3949
+ }
3950
+ return toObject;
3951
+ }
3952
+ function functionCallingConfigToMldev$2(fromObject) {
3953
+ const toObject = {};
3954
+ const fromMode = getValueByPath(fromObject, ['mode']);
3955
+ if (fromMode != null) {
3956
+ setValueByPath(toObject, ['mode'], fromMode);
3957
+ }
3958
+ const fromAllowedFunctionNames = getValueByPath(fromObject, [
3959
+ 'allowedFunctionNames',
3960
+ ]);
3961
+ if (fromAllowedFunctionNames != null) {
3962
+ setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
3963
+ }
3964
+ if (getValueByPath(fromObject, ['streamFunctionCallArguments']) !==
3965
+ undefined) {
3966
+ throw new Error('streamFunctionCallArguments parameter is not supported in Gemini API.');
3967
+ }
3968
+ return toObject;
3969
+ }
3894
3970
  function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
3895
3971
  const toObject = {};
3896
3972
  const fromSystemInstruction = getValueByPath(fromObject, [
@@ -4003,7 +4079,7 @@ function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
4003
4079
  }
4004
4080
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
4005
4081
  if (parentObject !== undefined && fromToolConfig != null) {
4006
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
4082
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev$2(fromToolConfig));
4007
4083
  }
4008
4084
  if (getValueByPath(fromObject, ['labels']) !== undefined) {
4009
4085
  throw new Error('labels parameter is not supported in Gemini API.');
@@ -4041,7 +4117,7 @@ function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
4041
4117
  }
4042
4118
  const fromImageConfig = getValueByPath(fromObject, ['imageConfig']);
4043
4119
  if (fromImageConfig != null) {
4044
- setValueByPath(toObject, ['imageConfig'], fromImageConfig);
4120
+ setValueByPath(toObject, ['imageConfig'], imageConfigToMldev$1(fromImageConfig));
4045
4121
  }
4046
4122
  return toObject;
4047
4123
  }
@@ -4128,6 +4204,25 @@ function googleSearchToMldev$4(fromObject) {
4128
4204
  }
4129
4205
  return toObject;
4130
4206
  }
4207
+ function imageConfigToMldev$1(fromObject) {
4208
+ const toObject = {};
4209
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
4210
+ if (fromAspectRatio != null) {
4211
+ setValueByPath(toObject, ['aspectRatio'], fromAspectRatio);
4212
+ }
4213
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
4214
+ if (fromImageSize != null) {
4215
+ setValueByPath(toObject, ['imageSize'], fromImageSize);
4216
+ }
4217
+ if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
4218
+ throw new Error('outputMimeType parameter is not supported in Gemini API.');
4219
+ }
4220
+ if (getValueByPath(fromObject, ['outputCompressionQuality']) !==
4221
+ undefined) {
4222
+ throw new Error('outputCompressionQuality parameter is not supported in Gemini API.');
4223
+ }
4224
+ return toObject;
4225
+ }
4131
4226
  function inlinedRequestToMldev(apiClient, fromObject) {
4132
4227
  const toObject = {};
4133
4228
  const fromModel = getValueByPath(fromObject, ['model']);
@@ -4269,9 +4364,11 @@ function listBatchJobsResponseFromVertex(fromObject) {
4269
4364
  }
4270
4365
  function partToMldev$4(fromObject) {
4271
4366
  const toObject = {};
4272
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
4273
- if (fromFunctionCall != null) {
4274
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
4367
+ const fromMediaResolution = getValueByPath(fromObject, [
4368
+ 'mediaResolution',
4369
+ ]);
4370
+ if (fromMediaResolution != null) {
4371
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
4275
4372
  }
4276
4373
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4277
4374
  'codeExecutionResult',
@@ -4289,6 +4386,10 @@ function partToMldev$4(fromObject) {
4289
4386
  if (fromFileData != null) {
4290
4387
  setValueByPath(toObject, ['fileData'], fileDataToMldev$4(fromFileData));
4291
4388
  }
4389
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
4390
+ if (fromFunctionCall != null) {
4391
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$4(fromFunctionCall));
4392
+ }
4292
4393
  const fromFunctionResponse = getValueByPath(fromObject, [
4293
4394
  'functionResponse',
4294
4395
  ]);
@@ -4336,6 +4437,22 @@ function safetySettingToMldev$1(fromObject) {
4336
4437
  }
4337
4438
  return toObject;
4338
4439
  }
4440
+ function toolConfigToMldev$2(fromObject) {
4441
+ const toObject = {};
4442
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
4443
+ 'functionCallingConfig',
4444
+ ]);
4445
+ if (fromFunctionCallingConfig != null) {
4446
+ setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$2(fromFunctionCallingConfig));
4447
+ }
4448
+ const fromRetrievalConfig = getValueByPath(fromObject, [
4449
+ 'retrievalConfig',
4450
+ ]);
4451
+ if (fromRetrievalConfig != null) {
4452
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
4453
+ }
4454
+ return toObject;
4455
+ }
4339
4456
  function toolToMldev$4(fromObject) {
4340
4457
  const toObject = {};
4341
4458
  const fromFunctionDeclarations = getValueByPath(fromObject, [
@@ -5158,7 +5275,7 @@ function createCachedContentConfigToMldev(fromObject, parentObject) {
5158
5275
  }
5159
5276
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
5160
5277
  if (parentObject !== undefined && fromToolConfig != null) {
5161
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
5278
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev$1(fromToolConfig));
5162
5279
  }
5163
5280
  if (getValueByPath(fromObject, ['kmsKeyName']) !== undefined) {
5164
5281
  throw new Error('kmsKeyName parameter is not supported in Gemini API.');
@@ -5290,6 +5407,46 @@ function fileDataToMldev$3(fromObject) {
5290
5407
  }
5291
5408
  return toObject;
5292
5409
  }
5410
+ function functionCallToMldev$3(fromObject) {
5411
+ const toObject = {};
5412
+ const fromId = getValueByPath(fromObject, ['id']);
5413
+ if (fromId != null) {
5414
+ setValueByPath(toObject, ['id'], fromId);
5415
+ }
5416
+ const fromArgs = getValueByPath(fromObject, ['args']);
5417
+ if (fromArgs != null) {
5418
+ setValueByPath(toObject, ['args'], fromArgs);
5419
+ }
5420
+ const fromName = getValueByPath(fromObject, ['name']);
5421
+ if (fromName != null) {
5422
+ setValueByPath(toObject, ['name'], fromName);
5423
+ }
5424
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
5425
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
5426
+ }
5427
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
5428
+ throw new Error('willContinue parameter is not supported in Gemini API.');
5429
+ }
5430
+ return toObject;
5431
+ }
5432
+ function functionCallingConfigToMldev$1(fromObject) {
5433
+ const toObject = {};
5434
+ const fromMode = getValueByPath(fromObject, ['mode']);
5435
+ if (fromMode != null) {
5436
+ setValueByPath(toObject, ['mode'], fromMode);
5437
+ }
5438
+ const fromAllowedFunctionNames = getValueByPath(fromObject, [
5439
+ 'allowedFunctionNames',
5440
+ ]);
5441
+ if (fromAllowedFunctionNames != null) {
5442
+ setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
5443
+ }
5444
+ if (getValueByPath(fromObject, ['streamFunctionCallArguments']) !==
5445
+ undefined) {
5446
+ throw new Error('streamFunctionCallArguments parameter is not supported in Gemini API.');
5447
+ }
5448
+ return toObject;
5449
+ }
5293
5450
  function functionDeclarationToVertex$2(fromObject) {
5294
5451
  const toObject = {};
5295
5452
  if (getValueByPath(fromObject, ['behavior']) !== undefined) {
@@ -5466,9 +5623,11 @@ function listCachedContentsResponseFromVertex(fromObject) {
5466
5623
  }
5467
5624
  function partToMldev$3(fromObject) {
5468
5625
  const toObject = {};
5469
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5470
- if (fromFunctionCall != null) {
5471
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
5626
+ const fromMediaResolution = getValueByPath(fromObject, [
5627
+ 'mediaResolution',
5628
+ ]);
5629
+ if (fromMediaResolution != null) {
5630
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
5472
5631
  }
5473
5632
  const fromCodeExecutionResult = getValueByPath(fromObject, [
5474
5633
  'codeExecutionResult',
@@ -5486,6 +5645,10 @@ function partToMldev$3(fromObject) {
5486
5645
  if (fromFileData != null) {
5487
5646
  setValueByPath(toObject, ['fileData'], fileDataToMldev$3(fromFileData));
5488
5647
  }
5648
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5649
+ if (fromFunctionCall != null) {
5650
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$3(fromFunctionCall));
5651
+ }
5489
5652
  const fromFunctionResponse = getValueByPath(fromObject, [
5490
5653
  'functionResponse',
5491
5654
  ]);
@@ -5518,6 +5681,22 @@ function partToMldev$3(fromObject) {
5518
5681
  }
5519
5682
  return toObject;
5520
5683
  }
5684
+ function toolConfigToMldev$1(fromObject) {
5685
+ const toObject = {};
5686
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
5687
+ 'functionCallingConfig',
5688
+ ]);
5689
+ if (fromFunctionCallingConfig != null) {
5690
+ setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(fromFunctionCallingConfig));
5691
+ }
5692
+ const fromRetrievalConfig = getValueByPath(fromObject, [
5693
+ 'retrievalConfig',
5694
+ ]);
5695
+ if (fromRetrievalConfig != null) {
5696
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
5697
+ }
5698
+ return toObject;
5699
+ }
5521
5700
  function toolToMldev$3(fromObject) {
5522
5701
  const toObject = {};
5523
5702
  const fromFunctionDeclarations = getValueByPath(fromObject, [
@@ -6881,6 +7060,28 @@ function fileDataToMldev$2(fromObject) {
6881
7060
  }
6882
7061
  return toObject;
6883
7062
  }
7063
+ function functionCallToMldev$2(fromObject) {
7064
+ const toObject = {};
7065
+ const fromId = getValueByPath(fromObject, ['id']);
7066
+ if (fromId != null) {
7067
+ setValueByPath(toObject, ['id'], fromId);
7068
+ }
7069
+ const fromArgs = getValueByPath(fromObject, ['args']);
7070
+ if (fromArgs != null) {
7071
+ setValueByPath(toObject, ['args'], fromArgs);
7072
+ }
7073
+ const fromName = getValueByPath(fromObject, ['name']);
7074
+ if (fromName != null) {
7075
+ setValueByPath(toObject, ['name'], fromName);
7076
+ }
7077
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
7078
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
7079
+ }
7080
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
7081
+ throw new Error('willContinue parameter is not supported in Gemini API.');
7082
+ }
7083
+ return toObject;
7084
+ }
6884
7085
  function functionDeclarationToVertex$1(fromObject) {
6885
7086
  const toObject = {};
6886
7087
  if (getValueByPath(fromObject, ['behavior']) !== undefined) {
@@ -7469,9 +7670,11 @@ function liveServerMessageFromVertex(fromObject) {
7469
7670
  }
7470
7671
  function partToMldev$2(fromObject) {
7471
7672
  const toObject = {};
7472
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
7473
- if (fromFunctionCall != null) {
7474
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
7673
+ const fromMediaResolution = getValueByPath(fromObject, [
7674
+ 'mediaResolution',
7675
+ ]);
7676
+ if (fromMediaResolution != null) {
7677
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
7475
7678
  }
7476
7679
  const fromCodeExecutionResult = getValueByPath(fromObject, [
7477
7680
  'codeExecutionResult',
@@ -7489,6 +7692,10 @@ function partToMldev$2(fromObject) {
7489
7692
  if (fromFileData != null) {
7490
7693
  setValueByPath(toObject, ['fileData'], fileDataToMldev$2(fromFileData));
7491
7694
  }
7695
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
7696
+ if (fromFunctionCall != null) {
7697
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$2(fromFunctionCall));
7698
+ }
7492
7699
  const fromFunctionResponse = getValueByPath(fromObject, [
7493
7700
  'functionResponse',
7494
7701
  ]);
@@ -8410,6 +8617,46 @@ function fileDataToMldev$1(fromObject) {
8410
8617
  }
8411
8618
  return toObject;
8412
8619
  }
8620
+ function functionCallToMldev$1(fromObject) {
8621
+ const toObject = {};
8622
+ const fromId = getValueByPath(fromObject, ['id']);
8623
+ if (fromId != null) {
8624
+ setValueByPath(toObject, ['id'], fromId);
8625
+ }
8626
+ const fromArgs = getValueByPath(fromObject, ['args']);
8627
+ if (fromArgs != null) {
8628
+ setValueByPath(toObject, ['args'], fromArgs);
8629
+ }
8630
+ const fromName = getValueByPath(fromObject, ['name']);
8631
+ if (fromName != null) {
8632
+ setValueByPath(toObject, ['name'], fromName);
8633
+ }
8634
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
8635
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
8636
+ }
8637
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
8638
+ throw new Error('willContinue parameter is not supported in Gemini API.');
8639
+ }
8640
+ return toObject;
8641
+ }
8642
+ function functionCallingConfigToMldev(fromObject) {
8643
+ const toObject = {};
8644
+ const fromMode = getValueByPath(fromObject, ['mode']);
8645
+ if (fromMode != null) {
8646
+ setValueByPath(toObject, ['mode'], fromMode);
8647
+ }
8648
+ const fromAllowedFunctionNames = getValueByPath(fromObject, [
8649
+ 'allowedFunctionNames',
8650
+ ]);
8651
+ if (fromAllowedFunctionNames != null) {
8652
+ setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
8653
+ }
8654
+ if (getValueByPath(fromObject, ['streamFunctionCallArguments']) !==
8655
+ undefined) {
8656
+ throw new Error('streamFunctionCallArguments parameter is not supported in Gemini API.');
8657
+ }
8658
+ return toObject;
8659
+ }
8413
8660
  function functionDeclarationToVertex(fromObject) {
8414
8661
  const toObject = {};
8415
8662
  if (getValueByPath(fromObject, ['behavior']) !== undefined) {
@@ -8557,7 +8804,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
8557
8804
  }
8558
8805
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
8559
8806
  if (parentObject !== undefined && fromToolConfig != null) {
8560
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
8807
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev(fromToolConfig));
8561
8808
  }
8562
8809
  if (getValueByPath(fromObject, ['labels']) !== undefined) {
8563
8810
  throw new Error('labels parameter is not supported in Gemini API.');
@@ -8595,7 +8842,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
8595
8842
  }
8596
8843
  const fromImageConfig = getValueByPath(fromObject, ['imageConfig']);
8597
8844
  if (fromImageConfig != null) {
8598
- setValueByPath(toObject, ['imageConfig'], fromImageConfig);
8845
+ setValueByPath(toObject, ['imageConfig'], imageConfigToMldev(fromImageConfig));
8599
8846
  }
8600
8847
  return toObject;
8601
8848
  }
@@ -8759,7 +9006,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
8759
9006
  }
8760
9007
  const fromImageConfig = getValueByPath(fromObject, ['imageConfig']);
8761
9008
  if (fromImageConfig != null) {
8762
- setValueByPath(toObject, ['imageConfig'], fromImageConfig);
9009
+ setValueByPath(toObject, ['imageConfig'], imageConfigToVertex(fromImageConfig));
8763
9010
  }
8764
9011
  return toObject;
8765
9012
  }
@@ -9760,6 +10007,49 @@ function googleSearchToMldev$1(fromObject) {
9760
10007
  }
9761
10008
  return toObject;
9762
10009
  }
10010
+ function imageConfigToMldev(fromObject) {
10011
+ const toObject = {};
10012
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
10013
+ if (fromAspectRatio != null) {
10014
+ setValueByPath(toObject, ['aspectRatio'], fromAspectRatio);
10015
+ }
10016
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
10017
+ if (fromImageSize != null) {
10018
+ setValueByPath(toObject, ['imageSize'], fromImageSize);
10019
+ }
10020
+ if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
10021
+ throw new Error('outputMimeType parameter is not supported in Gemini API.');
10022
+ }
10023
+ if (getValueByPath(fromObject, ['outputCompressionQuality']) !==
10024
+ undefined) {
10025
+ throw new Error('outputCompressionQuality parameter is not supported in Gemini API.');
10026
+ }
10027
+ return toObject;
10028
+ }
10029
+ function imageConfigToVertex(fromObject) {
10030
+ const toObject = {};
10031
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
10032
+ if (fromAspectRatio != null) {
10033
+ setValueByPath(toObject, ['aspectRatio'], fromAspectRatio);
10034
+ }
10035
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
10036
+ if (fromImageSize != null) {
10037
+ setValueByPath(toObject, ['imageSize'], fromImageSize);
10038
+ }
10039
+ const fromOutputMimeType = getValueByPath(fromObject, [
10040
+ 'outputMimeType',
10041
+ ]);
10042
+ if (fromOutputMimeType != null) {
10043
+ setValueByPath(toObject, ['imageOutputOptions', 'mimeType'], fromOutputMimeType);
10044
+ }
10045
+ const fromOutputCompressionQuality = getValueByPath(fromObject, [
10046
+ 'outputCompressionQuality',
10047
+ ]);
10048
+ if (fromOutputCompressionQuality != null) {
10049
+ setValueByPath(toObject, ['imageOutputOptions', 'compressionQuality'], fromOutputCompressionQuality);
10050
+ }
10051
+ return toObject;
10052
+ }
9763
10053
  function imageFromMldev(fromObject) {
9764
10054
  const toObject = {};
9765
10055
  const fromImageBytes = getValueByPath(fromObject, [
@@ -9989,6 +10279,28 @@ function modelFromMldev(fromObject) {
9989
10279
  if (fromSupportedActions != null) {
9990
10280
  setValueByPath(toObject, ['supportedActions'], fromSupportedActions);
9991
10281
  }
10282
+ const fromTemperature = getValueByPath(fromObject, ['temperature']);
10283
+ if (fromTemperature != null) {
10284
+ setValueByPath(toObject, ['temperature'], fromTemperature);
10285
+ }
10286
+ const fromMaxTemperature = getValueByPath(fromObject, [
10287
+ 'maxTemperature',
10288
+ ]);
10289
+ if (fromMaxTemperature != null) {
10290
+ setValueByPath(toObject, ['maxTemperature'], fromMaxTemperature);
10291
+ }
10292
+ const fromTopP = getValueByPath(fromObject, ['topP']);
10293
+ if (fromTopP != null) {
10294
+ setValueByPath(toObject, ['topP'], fromTopP);
10295
+ }
10296
+ const fromTopK = getValueByPath(fromObject, ['topK']);
10297
+ if (fromTopK != null) {
10298
+ setValueByPath(toObject, ['topK'], fromTopK);
10299
+ }
10300
+ const fromThinking = getValueByPath(fromObject, ['thinking']);
10301
+ if (fromThinking != null) {
10302
+ setValueByPath(toObject, ['thinking'], fromThinking);
10303
+ }
9992
10304
  return toObject;
9993
10305
  }
9994
10306
  function modelFromVertex(fromObject) {
@@ -10047,9 +10359,11 @@ function modelFromVertex(fromObject) {
10047
10359
  }
10048
10360
  function partToMldev$1(fromObject) {
10049
10361
  const toObject = {};
10050
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
10051
- if (fromFunctionCall != null) {
10052
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
10362
+ const fromMediaResolution = getValueByPath(fromObject, [
10363
+ 'mediaResolution',
10364
+ ]);
10365
+ if (fromMediaResolution != null) {
10366
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
10053
10367
  }
10054
10368
  const fromCodeExecutionResult = getValueByPath(fromObject, [
10055
10369
  'codeExecutionResult',
@@ -10067,6 +10381,10 @@ function partToMldev$1(fromObject) {
10067
10381
  if (fromFileData != null) {
10068
10382
  setValueByPath(toObject, ['fileData'], fileDataToMldev$1(fromFileData));
10069
10383
  }
10384
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
10385
+ if (fromFunctionCall != null) {
10386
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$1(fromFunctionCall));
10387
+ }
10070
10388
  const fromFunctionResponse = getValueByPath(fromObject, [
10071
10389
  'functionResponse',
10072
10390
  ]);
@@ -10117,7 +10435,7 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
10117
10435
  }
10118
10436
  const fromBaseSteps = getValueByPath(fromObject, ['baseSteps']);
10119
10437
  if (parentObject !== undefined && fromBaseSteps != null) {
10120
- setValueByPath(parentObject, ['parameters', 'editConfig', 'baseSteps'], fromBaseSteps);
10438
+ setValueByPath(parentObject, ['parameters', 'baseSteps'], fromBaseSteps);
10121
10439
  }
10122
10440
  const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
10123
10441
  if (parentObject !== undefined && fromOutputGcsUri != null) {
@@ -10431,6 +10749,22 @@ function speechConfigToVertex(fromObject) {
10431
10749
  }
10432
10750
  return toObject;
10433
10751
  }
10752
+ function toolConfigToMldev(fromObject) {
10753
+ const toObject = {};
10754
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
10755
+ 'functionCallingConfig',
10756
+ ]);
10757
+ if (fromFunctionCallingConfig != null) {
10758
+ setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(fromFunctionCallingConfig));
10759
+ }
10760
+ const fromRetrievalConfig = getValueByPath(fromObject, [
10761
+ 'retrievalConfig',
10762
+ ]);
10763
+ if (fromRetrievalConfig != null) {
10764
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
10765
+ }
10766
+ return toObject;
10767
+ }
10434
10768
  function toolToMldev$1(fromObject) {
10435
10769
  const toObject = {};
10436
10770
  const fromFunctionDeclarations = getValueByPath(fromObject, [
@@ -10861,7 +11195,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
10861
11195
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
10862
11196
  const USER_AGENT_HEADER = 'User-Agent';
10863
11197
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
10864
- const SDK_VERSION = '1.29.0'; // x-release-please-version
11198
+ const SDK_VERSION = '1.30.0'; // x-release-please-version
10865
11199
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
10866
11200
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
10867
11201
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -12518,6 +12852,7 @@ class Models extends BaseModule {
12518
12852
  * ```
12519
12853
  */
12520
12854
  this.generateContentStream = async (params) => {
12855
+ var _a, _b, _c, _d, _e;
12521
12856
  this.maybeMoveToResponseJsonSchem(params);
12522
12857
  if (shouldDisableAfc(params.config)) {
12523
12858
  const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
@@ -12530,6 +12865,17 @@ class Models extends BaseModule {
12530
12865
  .join(', ');
12531
12866
  throw new Error(`Incompatible tools found at ${formattedIndexes}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`);
12532
12867
  }
12868
+ // With tool compatibility confirmed, validate that the configuration are
12869
+ // compatible with each other and raise an error if invalid.
12870
+ const streamFunctionCall = (_c = (_b = (_a = params === null || params === void 0 ? void 0 : params.config) === null || _a === void 0 ? void 0 : _a.toolConfig) === null || _b === void 0 ? void 0 : _b.functionCallingConfig) === null || _c === void 0 ? void 0 : _c.streamFunctionCallArguments;
12871
+ const disableAfc = (_e = (_d = params === null || params === void 0 ? void 0 : params.config) === null || _d === void 0 ? void 0 : _d.automaticFunctionCalling) === null || _e === void 0 ? void 0 : _e.disable;
12872
+ if (streamFunctionCall && !disableAfc) {
12873
+ throw new Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, " +
12874
+ 'this feature is not compatible with automatic function calling (AFC). ' +
12875
+ "Please set 'config.automaticFunctionCalling.disable' to true to disable AFC " +
12876
+ "or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' " +
12877
+ 'to be undefined or set to false to disable streaming function call arguments feature.');
12878
+ }
12533
12879
  return await this.processAfcStream(params);
12534
12880
  };
12535
12881
  /**
@@ -14147,6 +14493,28 @@ function fileDataToMldev(fromObject) {
14147
14493
  }
14148
14494
  return toObject;
14149
14495
  }
14496
+ function functionCallToMldev(fromObject) {
14497
+ const toObject = {};
14498
+ const fromId = getValueByPath(fromObject, ['id']);
14499
+ if (fromId != null) {
14500
+ setValueByPath(toObject, ['id'], fromId);
14501
+ }
14502
+ const fromArgs = getValueByPath(fromObject, ['args']);
14503
+ if (fromArgs != null) {
14504
+ setValueByPath(toObject, ['args'], fromArgs);
14505
+ }
14506
+ const fromName = getValueByPath(fromObject, ['name']);
14507
+ if (fromName != null) {
14508
+ setValueByPath(toObject, ['name'], fromName);
14509
+ }
14510
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
14511
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
14512
+ }
14513
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
14514
+ throw new Error('willContinue parameter is not supported in Gemini API.');
14515
+ }
14516
+ return toObject;
14517
+ }
14150
14518
  function googleMapsToMldev(fromObject) {
14151
14519
  const toObject = {};
14152
14520
  if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
@@ -14298,9 +14666,11 @@ function liveConnectConstraintsToMldev(apiClient, fromObject) {
14298
14666
  }
14299
14667
  function partToMldev(fromObject) {
14300
14668
  const toObject = {};
14301
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
14302
- if (fromFunctionCall != null) {
14303
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
14669
+ const fromMediaResolution = getValueByPath(fromObject, [
14670
+ 'mediaResolution',
14671
+ ]);
14672
+ if (fromMediaResolution != null) {
14673
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
14304
14674
  }
14305
14675
  const fromCodeExecutionResult = getValueByPath(fromObject, [
14306
14676
  'codeExecutionResult',
@@ -14318,6 +14688,10 @@ function partToMldev(fromObject) {
14318
14688
  if (fromFileData != null) {
14319
14689
  setValueByPath(toObject, ['fileData'], fileDataToMldev(fromFileData));
14320
14690
  }
14691
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
14692
+ if (fromFunctionCall != null) {
14693
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev(fromFunctionCall));
14694
+ }
14321
14695
  const fromFunctionResponse = getValueByPath(fromObject, [
14322
14696
  'functionResponse',
14323
14697
  ]);
@@ -17076,5 +17450,5 @@ function getApiKeyFromEnv() {
17076
17450
  return envGoogleApiKey || envGeminiApiKey || undefined;
17077
17451
  }
17078
17452
 
17079
- export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PersonGeneration, PhishBlockThreshold, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TuningMethod, TuningMode, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
17453
+ export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, TrafficType, TuningMethod, TuningMode, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
17080
17454
  //# sourceMappingURL=index.mjs.map