@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.
package/dist/index.mjs CHANGED
@@ -756,6 +756,22 @@ var PhishBlockThreshold;
756
756
  */
757
757
  PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
758
758
  })(PhishBlockThreshold || (PhishBlockThreshold = {}));
759
+ /** The level of thoughts tokens that the model should generate. */
760
+ var ThinkingLevel;
761
+ (function (ThinkingLevel) {
762
+ /**
763
+ * Default value.
764
+ */
765
+ ThinkingLevel["THINKING_LEVEL_UNSPECIFIED"] = "THINKING_LEVEL_UNSPECIFIED";
766
+ /**
767
+ * Low thinking level.
768
+ */
769
+ ThinkingLevel["LOW"] = "LOW";
770
+ /**
771
+ * High thinking level.
772
+ */
773
+ ThinkingLevel["HIGH"] = "HIGH";
774
+ })(ThinkingLevel || (ThinkingLevel = {}));
759
775
  /** Harm category. */
760
776
  var HarmCategory;
761
777
  (function (HarmCategory) {
@@ -1198,6 +1214,26 @@ var TuningTask;
1198
1214
  */
1199
1215
  TuningTask["TUNING_TASK_R2V"] = "TUNING_TASK_R2V";
1200
1216
  })(TuningTask || (TuningTask = {}));
1217
+ /** The tokenization quality used for given media. */
1218
+ var PartMediaResolutionLevel;
1219
+ (function (PartMediaResolutionLevel) {
1220
+ /**
1221
+ * Media resolution has not been set.
1222
+ */
1223
+ PartMediaResolutionLevel["MEDIA_RESOLUTION_UNSPECIFIED"] = "MEDIA_RESOLUTION_UNSPECIFIED";
1224
+ /**
1225
+ * Media resolution set to low.
1226
+ */
1227
+ PartMediaResolutionLevel["MEDIA_RESOLUTION_LOW"] = "MEDIA_RESOLUTION_LOW";
1228
+ /**
1229
+ * Media resolution set to medium.
1230
+ */
1231
+ PartMediaResolutionLevel["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
1232
+ /**
1233
+ * Media resolution set to high.
1234
+ */
1235
+ PartMediaResolutionLevel["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
1236
+ })(PartMediaResolutionLevel || (PartMediaResolutionLevel = {}));
1201
1237
  /** Options for feature selection preference. */
1202
1238
  var FeatureSelectionPreference;
1203
1239
  (function (FeatureSelectionPreference) {
@@ -1732,13 +1768,11 @@ class FunctionResponse {
1732
1768
  /**
1733
1769
  * Creates a `Part` object from a `URI` string.
1734
1770
  */
1735
- function createPartFromUri(uri, mimeType) {
1736
- return {
1737
- fileData: {
1771
+ function createPartFromUri(uri, mimeType, mediaResolution) {
1772
+ return Object.assign({ fileData: {
1738
1773
  fileUri: uri,
1739
1774
  mimeType: mimeType,
1740
- },
1741
- };
1775
+ } }, (mediaResolution && { mediaResolution: { level: mediaResolution } }));
1742
1776
  }
1743
1777
  /**
1744
1778
  * Creates a `Part` object from a `text` string.
@@ -1770,13 +1804,11 @@ function createPartFromFunctionResponse(id, name, response, parts = []) {
1770
1804
  /**
1771
1805
  * Creates a `Part` object from a `base64` encoded `string`.
1772
1806
  */
1773
- function createPartFromBase64(data, mimeType) {
1774
- return {
1775
- inlineData: {
1807
+ function createPartFromBase64(data, mimeType, mediaResolution) {
1808
+ return Object.assign({ inlineData: {
1776
1809
  data: data,
1777
1810
  mimeType: mimeType,
1778
- },
1779
- };
1811
+ } }, (mediaResolution && { mediaResolution: { level: mediaResolution } }));
1780
1812
  }
1781
1813
  /**
1782
1814
  * Creates a `Part` object from the `outcome` and `output` of a `CodeExecutionResult` object.
@@ -1921,6 +1953,7 @@ class GenerateContentResponse {
1921
1953
  for (const [fieldName, fieldValue] of Object.entries(part)) {
1922
1954
  if (fieldName !== 'text' &&
1923
1955
  fieldName !== 'thought' &&
1956
+ fieldName !== 'thoughtSignature' &&
1924
1957
  (fieldValue !== null || fieldValue !== undefined)) {
1925
1958
  nonTextParts.push(fieldName);
1926
1959
  }
@@ -2454,6 +2487,9 @@ function tModel(apiClient, model) {
2454
2487
  if (!model || typeof model !== 'string') {
2455
2488
  throw new Error('model is required and must be a string');
2456
2489
  }
2490
+ if (model.includes('..') || model.includes('?') || model.includes('&')) {
2491
+ throw new Error('invalid model parameter');
2492
+ }
2457
2493
  if (apiClient.isVertexAI()) {
2458
2494
  if (model.startsWith('publishers/') ||
2459
2495
  model.startsWith('projects/') ||
@@ -3852,6 +3888,46 @@ function fileDataToMldev$4(fromObject) {
3852
3888
  }
3853
3889
  return toObject;
3854
3890
  }
3891
+ function functionCallToMldev$4(fromObject) {
3892
+ const toObject = {};
3893
+ const fromId = getValueByPath(fromObject, ['id']);
3894
+ if (fromId != null) {
3895
+ setValueByPath(toObject, ['id'], fromId);
3896
+ }
3897
+ const fromArgs = getValueByPath(fromObject, ['args']);
3898
+ if (fromArgs != null) {
3899
+ setValueByPath(toObject, ['args'], fromArgs);
3900
+ }
3901
+ const fromName = getValueByPath(fromObject, ['name']);
3902
+ if (fromName != null) {
3903
+ setValueByPath(toObject, ['name'], fromName);
3904
+ }
3905
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
3906
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
3907
+ }
3908
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
3909
+ throw new Error('willContinue parameter is not supported in Gemini API.');
3910
+ }
3911
+ return toObject;
3912
+ }
3913
+ function functionCallingConfigToMldev$2(fromObject) {
3914
+ const toObject = {};
3915
+ const fromMode = getValueByPath(fromObject, ['mode']);
3916
+ if (fromMode != null) {
3917
+ setValueByPath(toObject, ['mode'], fromMode);
3918
+ }
3919
+ const fromAllowedFunctionNames = getValueByPath(fromObject, [
3920
+ 'allowedFunctionNames',
3921
+ ]);
3922
+ if (fromAllowedFunctionNames != null) {
3923
+ setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
3924
+ }
3925
+ if (getValueByPath(fromObject, ['streamFunctionCallArguments']) !==
3926
+ undefined) {
3927
+ throw new Error('streamFunctionCallArguments parameter is not supported in Gemini API.');
3928
+ }
3929
+ return toObject;
3930
+ }
3855
3931
  function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
3856
3932
  const toObject = {};
3857
3933
  const fromSystemInstruction = getValueByPath(fromObject, [
@@ -3964,7 +4040,7 @@ function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
3964
4040
  }
3965
4041
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
3966
4042
  if (parentObject !== undefined && fromToolConfig != null) {
3967
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
4043
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev$2(fromToolConfig));
3968
4044
  }
3969
4045
  if (getValueByPath(fromObject, ['labels']) !== undefined) {
3970
4046
  throw new Error('labels parameter is not supported in Gemini API.');
@@ -4002,7 +4078,7 @@ function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
4002
4078
  }
4003
4079
  const fromImageConfig = getValueByPath(fromObject, ['imageConfig']);
4004
4080
  if (fromImageConfig != null) {
4005
- setValueByPath(toObject, ['imageConfig'], fromImageConfig);
4081
+ setValueByPath(toObject, ['imageConfig'], imageConfigToMldev$1(fromImageConfig));
4006
4082
  }
4007
4083
  return toObject;
4008
4084
  }
@@ -4089,6 +4165,25 @@ function googleSearchToMldev$4(fromObject) {
4089
4165
  }
4090
4166
  return toObject;
4091
4167
  }
4168
+ function imageConfigToMldev$1(fromObject) {
4169
+ const toObject = {};
4170
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
4171
+ if (fromAspectRatio != null) {
4172
+ setValueByPath(toObject, ['aspectRatio'], fromAspectRatio);
4173
+ }
4174
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
4175
+ if (fromImageSize != null) {
4176
+ setValueByPath(toObject, ['imageSize'], fromImageSize);
4177
+ }
4178
+ if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
4179
+ throw new Error('outputMimeType parameter is not supported in Gemini API.');
4180
+ }
4181
+ if (getValueByPath(fromObject, ['outputCompressionQuality']) !==
4182
+ undefined) {
4183
+ throw new Error('outputCompressionQuality parameter is not supported in Gemini API.');
4184
+ }
4185
+ return toObject;
4186
+ }
4092
4187
  function inlinedRequestToMldev(apiClient, fromObject) {
4093
4188
  const toObject = {};
4094
4189
  const fromModel = getValueByPath(fromObject, ['model']);
@@ -4230,9 +4325,11 @@ function listBatchJobsResponseFromVertex(fromObject) {
4230
4325
  }
4231
4326
  function partToMldev$4(fromObject) {
4232
4327
  const toObject = {};
4233
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
4234
- if (fromFunctionCall != null) {
4235
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
4328
+ const fromMediaResolution = getValueByPath(fromObject, [
4329
+ 'mediaResolution',
4330
+ ]);
4331
+ if (fromMediaResolution != null) {
4332
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
4236
4333
  }
4237
4334
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4238
4335
  'codeExecutionResult',
@@ -4250,6 +4347,10 @@ function partToMldev$4(fromObject) {
4250
4347
  if (fromFileData != null) {
4251
4348
  setValueByPath(toObject, ['fileData'], fileDataToMldev$4(fromFileData));
4252
4349
  }
4350
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
4351
+ if (fromFunctionCall != null) {
4352
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$4(fromFunctionCall));
4353
+ }
4253
4354
  const fromFunctionResponse = getValueByPath(fromObject, [
4254
4355
  'functionResponse',
4255
4356
  ]);
@@ -4297,6 +4398,22 @@ function safetySettingToMldev$1(fromObject) {
4297
4398
  }
4298
4399
  return toObject;
4299
4400
  }
4401
+ function toolConfigToMldev$2(fromObject) {
4402
+ const toObject = {};
4403
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
4404
+ 'functionCallingConfig',
4405
+ ]);
4406
+ if (fromFunctionCallingConfig != null) {
4407
+ setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$2(fromFunctionCallingConfig));
4408
+ }
4409
+ const fromRetrievalConfig = getValueByPath(fromObject, [
4410
+ 'retrievalConfig',
4411
+ ]);
4412
+ if (fromRetrievalConfig != null) {
4413
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
4414
+ }
4415
+ return toObject;
4416
+ }
4300
4417
  function toolToMldev$4(fromObject) {
4301
4418
  const toObject = {};
4302
4419
  const fromFunctionDeclarations = getValueByPath(fromObject, [
@@ -5119,7 +5236,7 @@ function createCachedContentConfigToMldev(fromObject, parentObject) {
5119
5236
  }
5120
5237
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
5121
5238
  if (parentObject !== undefined && fromToolConfig != null) {
5122
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
5239
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev$1(fromToolConfig));
5123
5240
  }
5124
5241
  if (getValueByPath(fromObject, ['kmsKeyName']) !== undefined) {
5125
5242
  throw new Error('kmsKeyName parameter is not supported in Gemini API.');
@@ -5251,6 +5368,46 @@ function fileDataToMldev$3(fromObject) {
5251
5368
  }
5252
5369
  return toObject;
5253
5370
  }
5371
+ function functionCallToMldev$3(fromObject) {
5372
+ const toObject = {};
5373
+ const fromId = getValueByPath(fromObject, ['id']);
5374
+ if (fromId != null) {
5375
+ setValueByPath(toObject, ['id'], fromId);
5376
+ }
5377
+ const fromArgs = getValueByPath(fromObject, ['args']);
5378
+ if (fromArgs != null) {
5379
+ setValueByPath(toObject, ['args'], fromArgs);
5380
+ }
5381
+ const fromName = getValueByPath(fromObject, ['name']);
5382
+ if (fromName != null) {
5383
+ setValueByPath(toObject, ['name'], fromName);
5384
+ }
5385
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
5386
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
5387
+ }
5388
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
5389
+ throw new Error('willContinue parameter is not supported in Gemini API.');
5390
+ }
5391
+ return toObject;
5392
+ }
5393
+ function functionCallingConfigToMldev$1(fromObject) {
5394
+ const toObject = {};
5395
+ const fromMode = getValueByPath(fromObject, ['mode']);
5396
+ if (fromMode != null) {
5397
+ setValueByPath(toObject, ['mode'], fromMode);
5398
+ }
5399
+ const fromAllowedFunctionNames = getValueByPath(fromObject, [
5400
+ 'allowedFunctionNames',
5401
+ ]);
5402
+ if (fromAllowedFunctionNames != null) {
5403
+ setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
5404
+ }
5405
+ if (getValueByPath(fromObject, ['streamFunctionCallArguments']) !==
5406
+ undefined) {
5407
+ throw new Error('streamFunctionCallArguments parameter is not supported in Gemini API.');
5408
+ }
5409
+ return toObject;
5410
+ }
5254
5411
  function functionDeclarationToVertex$2(fromObject) {
5255
5412
  const toObject = {};
5256
5413
  if (getValueByPath(fromObject, ['behavior']) !== undefined) {
@@ -5427,9 +5584,11 @@ function listCachedContentsResponseFromVertex(fromObject) {
5427
5584
  }
5428
5585
  function partToMldev$3(fromObject) {
5429
5586
  const toObject = {};
5430
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5431
- if (fromFunctionCall != null) {
5432
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
5587
+ const fromMediaResolution = getValueByPath(fromObject, [
5588
+ 'mediaResolution',
5589
+ ]);
5590
+ if (fromMediaResolution != null) {
5591
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
5433
5592
  }
5434
5593
  const fromCodeExecutionResult = getValueByPath(fromObject, [
5435
5594
  'codeExecutionResult',
@@ -5447,6 +5606,10 @@ function partToMldev$3(fromObject) {
5447
5606
  if (fromFileData != null) {
5448
5607
  setValueByPath(toObject, ['fileData'], fileDataToMldev$3(fromFileData));
5449
5608
  }
5609
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5610
+ if (fromFunctionCall != null) {
5611
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$3(fromFunctionCall));
5612
+ }
5450
5613
  const fromFunctionResponse = getValueByPath(fromObject, [
5451
5614
  'functionResponse',
5452
5615
  ]);
@@ -5479,6 +5642,22 @@ function partToMldev$3(fromObject) {
5479
5642
  }
5480
5643
  return toObject;
5481
5644
  }
5645
+ function toolConfigToMldev$1(fromObject) {
5646
+ const toObject = {};
5647
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
5648
+ 'functionCallingConfig',
5649
+ ]);
5650
+ if (fromFunctionCallingConfig != null) {
5651
+ setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(fromFunctionCallingConfig));
5652
+ }
5653
+ const fromRetrievalConfig = getValueByPath(fromObject, [
5654
+ 'retrievalConfig',
5655
+ ]);
5656
+ if (fromRetrievalConfig != null) {
5657
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
5658
+ }
5659
+ return toObject;
5660
+ }
5482
5661
  function toolToMldev$3(fromObject) {
5483
5662
  const toObject = {};
5484
5663
  const fromFunctionDeclarations = getValueByPath(fromObject, [
@@ -6424,7 +6603,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
6424
6603
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
6425
6604
  const USER_AGENT_HEADER = 'User-Agent';
6426
6605
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
6427
- const SDK_VERSION = '1.29.0'; // x-release-please-version
6606
+ const SDK_VERSION = '1.30.0'; // x-release-please-version
6428
6607
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
6429
6608
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
6430
6609
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -8349,6 +8528,28 @@ function fileDataToMldev$2(fromObject) {
8349
8528
  }
8350
8529
  return toObject;
8351
8530
  }
8531
+ function functionCallToMldev$2(fromObject) {
8532
+ const toObject = {};
8533
+ const fromId = getValueByPath(fromObject, ['id']);
8534
+ if (fromId != null) {
8535
+ setValueByPath(toObject, ['id'], fromId);
8536
+ }
8537
+ const fromArgs = getValueByPath(fromObject, ['args']);
8538
+ if (fromArgs != null) {
8539
+ setValueByPath(toObject, ['args'], fromArgs);
8540
+ }
8541
+ const fromName = getValueByPath(fromObject, ['name']);
8542
+ if (fromName != null) {
8543
+ setValueByPath(toObject, ['name'], fromName);
8544
+ }
8545
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
8546
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
8547
+ }
8548
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
8549
+ throw new Error('willContinue parameter is not supported in Gemini API.');
8550
+ }
8551
+ return toObject;
8552
+ }
8352
8553
  function functionDeclarationToVertex$1(fromObject) {
8353
8554
  const toObject = {};
8354
8555
  if (getValueByPath(fromObject, ['behavior']) !== undefined) {
@@ -8937,9 +9138,11 @@ function liveServerMessageFromVertex(fromObject) {
8937
9138
  }
8938
9139
  function partToMldev$2(fromObject) {
8939
9140
  const toObject = {};
8940
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8941
- if (fromFunctionCall != null) {
8942
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
9141
+ const fromMediaResolution = getValueByPath(fromObject, [
9142
+ 'mediaResolution',
9143
+ ]);
9144
+ if (fromMediaResolution != null) {
9145
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
8943
9146
  }
8944
9147
  const fromCodeExecutionResult = getValueByPath(fromObject, [
8945
9148
  'codeExecutionResult',
@@ -8957,6 +9160,10 @@ function partToMldev$2(fromObject) {
8957
9160
  if (fromFileData != null) {
8958
9161
  setValueByPath(toObject, ['fileData'], fileDataToMldev$2(fromFileData));
8959
9162
  }
9163
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9164
+ if (fromFunctionCall != null) {
9165
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$2(fromFunctionCall));
9166
+ }
8960
9167
  const fromFunctionResponse = getValueByPath(fromObject, [
8961
9168
  'functionResponse',
8962
9169
  ]);
@@ -9878,6 +10085,46 @@ function fileDataToMldev$1(fromObject) {
9878
10085
  }
9879
10086
  return toObject;
9880
10087
  }
10088
+ function functionCallToMldev$1(fromObject) {
10089
+ const toObject = {};
10090
+ const fromId = getValueByPath(fromObject, ['id']);
10091
+ if (fromId != null) {
10092
+ setValueByPath(toObject, ['id'], fromId);
10093
+ }
10094
+ const fromArgs = getValueByPath(fromObject, ['args']);
10095
+ if (fromArgs != null) {
10096
+ setValueByPath(toObject, ['args'], fromArgs);
10097
+ }
10098
+ const fromName = getValueByPath(fromObject, ['name']);
10099
+ if (fromName != null) {
10100
+ setValueByPath(toObject, ['name'], fromName);
10101
+ }
10102
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
10103
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
10104
+ }
10105
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
10106
+ throw new Error('willContinue parameter is not supported in Gemini API.');
10107
+ }
10108
+ return toObject;
10109
+ }
10110
+ function functionCallingConfigToMldev(fromObject) {
10111
+ const toObject = {};
10112
+ const fromMode = getValueByPath(fromObject, ['mode']);
10113
+ if (fromMode != null) {
10114
+ setValueByPath(toObject, ['mode'], fromMode);
10115
+ }
10116
+ const fromAllowedFunctionNames = getValueByPath(fromObject, [
10117
+ 'allowedFunctionNames',
10118
+ ]);
10119
+ if (fromAllowedFunctionNames != null) {
10120
+ setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
10121
+ }
10122
+ if (getValueByPath(fromObject, ['streamFunctionCallArguments']) !==
10123
+ undefined) {
10124
+ throw new Error('streamFunctionCallArguments parameter is not supported in Gemini API.');
10125
+ }
10126
+ return toObject;
10127
+ }
9881
10128
  function functionDeclarationToVertex(fromObject) {
9882
10129
  const toObject = {};
9883
10130
  if (getValueByPath(fromObject, ['behavior']) !== undefined) {
@@ -10025,7 +10272,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
10025
10272
  }
10026
10273
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
10027
10274
  if (parentObject !== undefined && fromToolConfig != null) {
10028
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
10275
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev(fromToolConfig));
10029
10276
  }
10030
10277
  if (getValueByPath(fromObject, ['labels']) !== undefined) {
10031
10278
  throw new Error('labels parameter is not supported in Gemini API.');
@@ -10063,7 +10310,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
10063
10310
  }
10064
10311
  const fromImageConfig = getValueByPath(fromObject, ['imageConfig']);
10065
10312
  if (fromImageConfig != null) {
10066
- setValueByPath(toObject, ['imageConfig'], fromImageConfig);
10313
+ setValueByPath(toObject, ['imageConfig'], imageConfigToMldev(fromImageConfig));
10067
10314
  }
10068
10315
  return toObject;
10069
10316
  }
@@ -10227,7 +10474,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
10227
10474
  }
10228
10475
  const fromImageConfig = getValueByPath(fromObject, ['imageConfig']);
10229
10476
  if (fromImageConfig != null) {
10230
- setValueByPath(toObject, ['imageConfig'], fromImageConfig);
10477
+ setValueByPath(toObject, ['imageConfig'], imageConfigToVertex(fromImageConfig));
10231
10478
  }
10232
10479
  return toObject;
10233
10480
  }
@@ -11228,6 +11475,49 @@ function googleSearchToMldev$1(fromObject) {
11228
11475
  }
11229
11476
  return toObject;
11230
11477
  }
11478
+ function imageConfigToMldev(fromObject) {
11479
+ const toObject = {};
11480
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
11481
+ if (fromAspectRatio != null) {
11482
+ setValueByPath(toObject, ['aspectRatio'], fromAspectRatio);
11483
+ }
11484
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
11485
+ if (fromImageSize != null) {
11486
+ setValueByPath(toObject, ['imageSize'], fromImageSize);
11487
+ }
11488
+ if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
11489
+ throw new Error('outputMimeType parameter is not supported in Gemini API.');
11490
+ }
11491
+ if (getValueByPath(fromObject, ['outputCompressionQuality']) !==
11492
+ undefined) {
11493
+ throw new Error('outputCompressionQuality parameter is not supported in Gemini API.');
11494
+ }
11495
+ return toObject;
11496
+ }
11497
+ function imageConfigToVertex(fromObject) {
11498
+ const toObject = {};
11499
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
11500
+ if (fromAspectRatio != null) {
11501
+ setValueByPath(toObject, ['aspectRatio'], fromAspectRatio);
11502
+ }
11503
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
11504
+ if (fromImageSize != null) {
11505
+ setValueByPath(toObject, ['imageSize'], fromImageSize);
11506
+ }
11507
+ const fromOutputMimeType = getValueByPath(fromObject, [
11508
+ 'outputMimeType',
11509
+ ]);
11510
+ if (fromOutputMimeType != null) {
11511
+ setValueByPath(toObject, ['imageOutputOptions', 'mimeType'], fromOutputMimeType);
11512
+ }
11513
+ const fromOutputCompressionQuality = getValueByPath(fromObject, [
11514
+ 'outputCompressionQuality',
11515
+ ]);
11516
+ if (fromOutputCompressionQuality != null) {
11517
+ setValueByPath(toObject, ['imageOutputOptions', 'compressionQuality'], fromOutputCompressionQuality);
11518
+ }
11519
+ return toObject;
11520
+ }
11231
11521
  function imageFromMldev(fromObject) {
11232
11522
  const toObject = {};
11233
11523
  const fromImageBytes = getValueByPath(fromObject, [
@@ -11457,6 +11747,28 @@ function modelFromMldev(fromObject) {
11457
11747
  if (fromSupportedActions != null) {
11458
11748
  setValueByPath(toObject, ['supportedActions'], fromSupportedActions);
11459
11749
  }
11750
+ const fromTemperature = getValueByPath(fromObject, ['temperature']);
11751
+ if (fromTemperature != null) {
11752
+ setValueByPath(toObject, ['temperature'], fromTemperature);
11753
+ }
11754
+ const fromMaxTemperature = getValueByPath(fromObject, [
11755
+ 'maxTemperature',
11756
+ ]);
11757
+ if (fromMaxTemperature != null) {
11758
+ setValueByPath(toObject, ['maxTemperature'], fromMaxTemperature);
11759
+ }
11760
+ const fromTopP = getValueByPath(fromObject, ['topP']);
11761
+ if (fromTopP != null) {
11762
+ setValueByPath(toObject, ['topP'], fromTopP);
11763
+ }
11764
+ const fromTopK = getValueByPath(fromObject, ['topK']);
11765
+ if (fromTopK != null) {
11766
+ setValueByPath(toObject, ['topK'], fromTopK);
11767
+ }
11768
+ const fromThinking = getValueByPath(fromObject, ['thinking']);
11769
+ if (fromThinking != null) {
11770
+ setValueByPath(toObject, ['thinking'], fromThinking);
11771
+ }
11460
11772
  return toObject;
11461
11773
  }
11462
11774
  function modelFromVertex(fromObject) {
@@ -11515,9 +11827,11 @@ function modelFromVertex(fromObject) {
11515
11827
  }
11516
11828
  function partToMldev$1(fromObject) {
11517
11829
  const toObject = {};
11518
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
11519
- if (fromFunctionCall != null) {
11520
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
11830
+ const fromMediaResolution = getValueByPath(fromObject, [
11831
+ 'mediaResolution',
11832
+ ]);
11833
+ if (fromMediaResolution != null) {
11834
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
11521
11835
  }
11522
11836
  const fromCodeExecutionResult = getValueByPath(fromObject, [
11523
11837
  'codeExecutionResult',
@@ -11535,6 +11849,10 @@ function partToMldev$1(fromObject) {
11535
11849
  if (fromFileData != null) {
11536
11850
  setValueByPath(toObject, ['fileData'], fileDataToMldev$1(fromFileData));
11537
11851
  }
11852
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
11853
+ if (fromFunctionCall != null) {
11854
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$1(fromFunctionCall));
11855
+ }
11538
11856
  const fromFunctionResponse = getValueByPath(fromObject, [
11539
11857
  'functionResponse',
11540
11858
  ]);
@@ -11585,7 +11903,7 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
11585
11903
  }
11586
11904
  const fromBaseSteps = getValueByPath(fromObject, ['baseSteps']);
11587
11905
  if (parentObject !== undefined && fromBaseSteps != null) {
11588
- setValueByPath(parentObject, ['parameters', 'editConfig', 'baseSteps'], fromBaseSteps);
11906
+ setValueByPath(parentObject, ['parameters', 'baseSteps'], fromBaseSteps);
11589
11907
  }
11590
11908
  const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
11591
11909
  if (parentObject !== undefined && fromOutputGcsUri != null) {
@@ -11899,6 +12217,22 @@ function speechConfigToVertex(fromObject) {
11899
12217
  }
11900
12218
  return toObject;
11901
12219
  }
12220
+ function toolConfigToMldev(fromObject) {
12221
+ const toObject = {};
12222
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
12223
+ 'functionCallingConfig',
12224
+ ]);
12225
+ if (fromFunctionCallingConfig != null) {
12226
+ setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(fromFunctionCallingConfig));
12227
+ }
12228
+ const fromRetrievalConfig = getValueByPath(fromObject, [
12229
+ 'retrievalConfig',
12230
+ ]);
12231
+ if (fromRetrievalConfig != null) {
12232
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
12233
+ }
12234
+ return toObject;
12235
+ }
11902
12236
  function toolToMldev$1(fromObject) {
11903
12237
  const toObject = {};
11904
12238
  const fromFunctionDeclarations = getValueByPath(fromObject, [
@@ -13374,6 +13708,7 @@ class Models extends BaseModule {
13374
13708
  * ```
13375
13709
  */
13376
13710
  this.generateContentStream = async (params) => {
13711
+ var _a, _b, _c, _d, _e;
13377
13712
  this.maybeMoveToResponseJsonSchem(params);
13378
13713
  if (shouldDisableAfc(params.config)) {
13379
13714
  const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
@@ -13386,6 +13721,17 @@ class Models extends BaseModule {
13386
13721
  .join(', ');
13387
13722
  throw new Error(`Incompatible tools found at ${formattedIndexes}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`);
13388
13723
  }
13724
+ // With tool compatibility confirmed, validate that the configuration are
13725
+ // compatible with each other and raise an error if invalid.
13726
+ 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;
13727
+ 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;
13728
+ if (streamFunctionCall && !disableAfc) {
13729
+ throw new Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, " +
13730
+ 'this feature is not compatible with automatic function calling (AFC). ' +
13731
+ "Please set 'config.automaticFunctionCalling.disable' to true to disable AFC " +
13732
+ "or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' " +
13733
+ 'to be undefined or set to false to disable streaming function call arguments feature.');
13734
+ }
13389
13735
  return await this.processAfcStream(params);
13390
13736
  };
13391
13737
  /**
@@ -15003,6 +15349,28 @@ function fileDataToMldev(fromObject) {
15003
15349
  }
15004
15350
  return toObject;
15005
15351
  }
15352
+ function functionCallToMldev(fromObject) {
15353
+ const toObject = {};
15354
+ const fromId = getValueByPath(fromObject, ['id']);
15355
+ if (fromId != null) {
15356
+ setValueByPath(toObject, ['id'], fromId);
15357
+ }
15358
+ const fromArgs = getValueByPath(fromObject, ['args']);
15359
+ if (fromArgs != null) {
15360
+ setValueByPath(toObject, ['args'], fromArgs);
15361
+ }
15362
+ const fromName = getValueByPath(fromObject, ['name']);
15363
+ if (fromName != null) {
15364
+ setValueByPath(toObject, ['name'], fromName);
15365
+ }
15366
+ if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
15367
+ throw new Error('partialArgs parameter is not supported in Gemini API.');
15368
+ }
15369
+ if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
15370
+ throw new Error('willContinue parameter is not supported in Gemini API.');
15371
+ }
15372
+ return toObject;
15373
+ }
15006
15374
  function googleMapsToMldev(fromObject) {
15007
15375
  const toObject = {};
15008
15376
  if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
@@ -15154,9 +15522,11 @@ function liveConnectConstraintsToMldev(apiClient, fromObject) {
15154
15522
  }
15155
15523
  function partToMldev(fromObject) {
15156
15524
  const toObject = {};
15157
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
15158
- if (fromFunctionCall != null) {
15159
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
15525
+ const fromMediaResolution = getValueByPath(fromObject, [
15526
+ 'mediaResolution',
15527
+ ]);
15528
+ if (fromMediaResolution != null) {
15529
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
15160
15530
  }
15161
15531
  const fromCodeExecutionResult = getValueByPath(fromObject, [
15162
15532
  'codeExecutionResult',
@@ -15174,6 +15544,10 @@ function partToMldev(fromObject) {
15174
15544
  if (fromFileData != null) {
15175
15545
  setValueByPath(toObject, ['fileData'], fileDataToMldev(fromFileData));
15176
15546
  }
15547
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
15548
+ if (fromFunctionCall != null) {
15549
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev(fromFunctionCall));
15550
+ }
15177
15551
  const fromFunctionResponse = getValueByPath(fromObject, [
15178
15552
  'functionResponse',
15179
15553
  ]);
@@ -16649,5 +17023,5 @@ class GoogleGenAI {
16649
17023
  }
16650
17024
  }
16651
17025
 
16652
- 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 };
17026
+ 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 };
16653
17027
  //# sourceMappingURL=index.mjs.map