@google/genai 1.29.1 → 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/genai.d.ts +94 -8
- package/dist/index.cjs +380 -32
- package/dist/index.mjs +381 -33
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +380 -32
- package/dist/node/index.mjs +381 -33
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +94 -8
- package/dist/web/index.mjs +381 -33
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +94 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -758,6 +758,22 @@ exports.PhishBlockThreshold = void 0;
|
|
|
758
758
|
*/
|
|
759
759
|
PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
|
|
760
760
|
})(exports.PhishBlockThreshold || (exports.PhishBlockThreshold = {}));
|
|
761
|
+
/** The level of thoughts tokens that the model should generate. */
|
|
762
|
+
exports.ThinkingLevel = void 0;
|
|
763
|
+
(function (ThinkingLevel) {
|
|
764
|
+
/**
|
|
765
|
+
* Default value.
|
|
766
|
+
*/
|
|
767
|
+
ThinkingLevel["THINKING_LEVEL_UNSPECIFIED"] = "THINKING_LEVEL_UNSPECIFIED";
|
|
768
|
+
/**
|
|
769
|
+
* Low thinking level.
|
|
770
|
+
*/
|
|
771
|
+
ThinkingLevel["LOW"] = "LOW";
|
|
772
|
+
/**
|
|
773
|
+
* High thinking level.
|
|
774
|
+
*/
|
|
775
|
+
ThinkingLevel["HIGH"] = "HIGH";
|
|
776
|
+
})(exports.ThinkingLevel || (exports.ThinkingLevel = {}));
|
|
761
777
|
/** Harm category. */
|
|
762
778
|
exports.HarmCategory = void 0;
|
|
763
779
|
(function (HarmCategory) {
|
|
@@ -1200,6 +1216,26 @@ exports.TuningTask = void 0;
|
|
|
1200
1216
|
*/
|
|
1201
1217
|
TuningTask["TUNING_TASK_R2V"] = "TUNING_TASK_R2V";
|
|
1202
1218
|
})(exports.TuningTask || (exports.TuningTask = {}));
|
|
1219
|
+
/** The tokenization quality used for given media. */
|
|
1220
|
+
exports.PartMediaResolutionLevel = void 0;
|
|
1221
|
+
(function (PartMediaResolutionLevel) {
|
|
1222
|
+
/**
|
|
1223
|
+
* Media resolution has not been set.
|
|
1224
|
+
*/
|
|
1225
|
+
PartMediaResolutionLevel["MEDIA_RESOLUTION_UNSPECIFIED"] = "MEDIA_RESOLUTION_UNSPECIFIED";
|
|
1226
|
+
/**
|
|
1227
|
+
* Media resolution set to low.
|
|
1228
|
+
*/
|
|
1229
|
+
PartMediaResolutionLevel["MEDIA_RESOLUTION_LOW"] = "MEDIA_RESOLUTION_LOW";
|
|
1230
|
+
/**
|
|
1231
|
+
* Media resolution set to medium.
|
|
1232
|
+
*/
|
|
1233
|
+
PartMediaResolutionLevel["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
|
|
1234
|
+
/**
|
|
1235
|
+
* Media resolution set to high.
|
|
1236
|
+
*/
|
|
1237
|
+
PartMediaResolutionLevel["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
1238
|
+
})(exports.PartMediaResolutionLevel || (exports.PartMediaResolutionLevel = {}));
|
|
1203
1239
|
/** Options for feature selection preference. */
|
|
1204
1240
|
exports.FeatureSelectionPreference = void 0;
|
|
1205
1241
|
(function (FeatureSelectionPreference) {
|
|
@@ -1734,13 +1770,11 @@ class FunctionResponse {
|
|
|
1734
1770
|
/**
|
|
1735
1771
|
* Creates a `Part` object from a `URI` string.
|
|
1736
1772
|
*/
|
|
1737
|
-
function createPartFromUri(uri, mimeType) {
|
|
1738
|
-
return {
|
|
1739
|
-
fileData: {
|
|
1773
|
+
function createPartFromUri(uri, mimeType, mediaResolution) {
|
|
1774
|
+
return Object.assign({ fileData: {
|
|
1740
1775
|
fileUri: uri,
|
|
1741
1776
|
mimeType: mimeType,
|
|
1742
|
-
},
|
|
1743
|
-
};
|
|
1777
|
+
} }, (mediaResolution && { mediaResolution: { level: mediaResolution } }));
|
|
1744
1778
|
}
|
|
1745
1779
|
/**
|
|
1746
1780
|
* Creates a `Part` object from a `text` string.
|
|
@@ -1772,13 +1806,11 @@ function createPartFromFunctionResponse(id, name, response, parts = []) {
|
|
|
1772
1806
|
/**
|
|
1773
1807
|
* Creates a `Part` object from a `base64` encoded `string`.
|
|
1774
1808
|
*/
|
|
1775
|
-
function createPartFromBase64(data, mimeType) {
|
|
1776
|
-
return {
|
|
1777
|
-
inlineData: {
|
|
1809
|
+
function createPartFromBase64(data, mimeType, mediaResolution) {
|
|
1810
|
+
return Object.assign({ inlineData: {
|
|
1778
1811
|
data: data,
|
|
1779
1812
|
mimeType: mimeType,
|
|
1780
|
-
},
|
|
1781
|
-
};
|
|
1813
|
+
} }, (mediaResolution && { mediaResolution: { level: mediaResolution } }));
|
|
1782
1814
|
}
|
|
1783
1815
|
/**
|
|
1784
1816
|
* Creates a `Part` object from the `outcome` and `output` of a `CodeExecutionResult` object.
|
|
@@ -3858,6 +3890,46 @@ function fileDataToMldev$4(fromObject) {
|
|
|
3858
3890
|
}
|
|
3859
3891
|
return toObject;
|
|
3860
3892
|
}
|
|
3893
|
+
function functionCallToMldev$4(fromObject) {
|
|
3894
|
+
const toObject = {};
|
|
3895
|
+
const fromId = getValueByPath(fromObject, ['id']);
|
|
3896
|
+
if (fromId != null) {
|
|
3897
|
+
setValueByPath(toObject, ['id'], fromId);
|
|
3898
|
+
}
|
|
3899
|
+
const fromArgs = getValueByPath(fromObject, ['args']);
|
|
3900
|
+
if (fromArgs != null) {
|
|
3901
|
+
setValueByPath(toObject, ['args'], fromArgs);
|
|
3902
|
+
}
|
|
3903
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
3904
|
+
if (fromName != null) {
|
|
3905
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
3906
|
+
}
|
|
3907
|
+
if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
|
|
3908
|
+
throw new Error('partialArgs parameter is not supported in Gemini API.');
|
|
3909
|
+
}
|
|
3910
|
+
if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
|
|
3911
|
+
throw new Error('willContinue parameter is not supported in Gemini API.');
|
|
3912
|
+
}
|
|
3913
|
+
return toObject;
|
|
3914
|
+
}
|
|
3915
|
+
function functionCallingConfigToMldev$2(fromObject) {
|
|
3916
|
+
const toObject = {};
|
|
3917
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
3918
|
+
if (fromMode != null) {
|
|
3919
|
+
setValueByPath(toObject, ['mode'], fromMode);
|
|
3920
|
+
}
|
|
3921
|
+
const fromAllowedFunctionNames = getValueByPath(fromObject, [
|
|
3922
|
+
'allowedFunctionNames',
|
|
3923
|
+
]);
|
|
3924
|
+
if (fromAllowedFunctionNames != null) {
|
|
3925
|
+
setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
|
|
3926
|
+
}
|
|
3927
|
+
if (getValueByPath(fromObject, ['streamFunctionCallArguments']) !==
|
|
3928
|
+
undefined) {
|
|
3929
|
+
throw new Error('streamFunctionCallArguments parameter is not supported in Gemini API.');
|
|
3930
|
+
}
|
|
3931
|
+
return toObject;
|
|
3932
|
+
}
|
|
3861
3933
|
function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
|
|
3862
3934
|
const toObject = {};
|
|
3863
3935
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
@@ -3970,7 +4042,7 @@ function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
|
|
|
3970
4042
|
}
|
|
3971
4043
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
3972
4044
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
3973
|
-
setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
|
|
4045
|
+
setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev$2(fromToolConfig));
|
|
3974
4046
|
}
|
|
3975
4047
|
if (getValueByPath(fromObject, ['labels']) !== undefined) {
|
|
3976
4048
|
throw new Error('labels parameter is not supported in Gemini API.');
|
|
@@ -4008,7 +4080,7 @@ function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
|
|
|
4008
4080
|
}
|
|
4009
4081
|
const fromImageConfig = getValueByPath(fromObject, ['imageConfig']);
|
|
4010
4082
|
if (fromImageConfig != null) {
|
|
4011
|
-
setValueByPath(toObject, ['imageConfig'], fromImageConfig);
|
|
4083
|
+
setValueByPath(toObject, ['imageConfig'], imageConfigToMldev$1(fromImageConfig));
|
|
4012
4084
|
}
|
|
4013
4085
|
return toObject;
|
|
4014
4086
|
}
|
|
@@ -4095,6 +4167,25 @@ function googleSearchToMldev$4(fromObject) {
|
|
|
4095
4167
|
}
|
|
4096
4168
|
return toObject;
|
|
4097
4169
|
}
|
|
4170
|
+
function imageConfigToMldev$1(fromObject) {
|
|
4171
|
+
const toObject = {};
|
|
4172
|
+
const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
|
|
4173
|
+
if (fromAspectRatio != null) {
|
|
4174
|
+
setValueByPath(toObject, ['aspectRatio'], fromAspectRatio);
|
|
4175
|
+
}
|
|
4176
|
+
const fromImageSize = getValueByPath(fromObject, ['imageSize']);
|
|
4177
|
+
if (fromImageSize != null) {
|
|
4178
|
+
setValueByPath(toObject, ['imageSize'], fromImageSize);
|
|
4179
|
+
}
|
|
4180
|
+
if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
|
|
4181
|
+
throw new Error('outputMimeType parameter is not supported in Gemini API.');
|
|
4182
|
+
}
|
|
4183
|
+
if (getValueByPath(fromObject, ['outputCompressionQuality']) !==
|
|
4184
|
+
undefined) {
|
|
4185
|
+
throw new Error('outputCompressionQuality parameter is not supported in Gemini API.');
|
|
4186
|
+
}
|
|
4187
|
+
return toObject;
|
|
4188
|
+
}
|
|
4098
4189
|
function inlinedRequestToMldev(apiClient, fromObject) {
|
|
4099
4190
|
const toObject = {};
|
|
4100
4191
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
@@ -4236,9 +4327,11 @@ function listBatchJobsResponseFromVertex(fromObject) {
|
|
|
4236
4327
|
}
|
|
4237
4328
|
function partToMldev$4(fromObject) {
|
|
4238
4329
|
const toObject = {};
|
|
4239
|
-
const
|
|
4240
|
-
|
|
4241
|
-
|
|
4330
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
4331
|
+
'mediaResolution',
|
|
4332
|
+
]);
|
|
4333
|
+
if (fromMediaResolution != null) {
|
|
4334
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
4242
4335
|
}
|
|
4243
4336
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
4244
4337
|
'codeExecutionResult',
|
|
@@ -4256,6 +4349,10 @@ function partToMldev$4(fromObject) {
|
|
|
4256
4349
|
if (fromFileData != null) {
|
|
4257
4350
|
setValueByPath(toObject, ['fileData'], fileDataToMldev$4(fromFileData));
|
|
4258
4351
|
}
|
|
4352
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
4353
|
+
if (fromFunctionCall != null) {
|
|
4354
|
+
setValueByPath(toObject, ['functionCall'], functionCallToMldev$4(fromFunctionCall));
|
|
4355
|
+
}
|
|
4259
4356
|
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
4260
4357
|
'functionResponse',
|
|
4261
4358
|
]);
|
|
@@ -4303,6 +4400,22 @@ function safetySettingToMldev$1(fromObject) {
|
|
|
4303
4400
|
}
|
|
4304
4401
|
return toObject;
|
|
4305
4402
|
}
|
|
4403
|
+
function toolConfigToMldev$2(fromObject) {
|
|
4404
|
+
const toObject = {};
|
|
4405
|
+
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
4406
|
+
'functionCallingConfig',
|
|
4407
|
+
]);
|
|
4408
|
+
if (fromFunctionCallingConfig != null) {
|
|
4409
|
+
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$2(fromFunctionCallingConfig));
|
|
4410
|
+
}
|
|
4411
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
4412
|
+
'retrievalConfig',
|
|
4413
|
+
]);
|
|
4414
|
+
if (fromRetrievalConfig != null) {
|
|
4415
|
+
setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
|
|
4416
|
+
}
|
|
4417
|
+
return toObject;
|
|
4418
|
+
}
|
|
4306
4419
|
function toolToMldev$4(fromObject) {
|
|
4307
4420
|
const toObject = {};
|
|
4308
4421
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -5125,7 +5238,7 @@ function createCachedContentConfigToMldev(fromObject, parentObject) {
|
|
|
5125
5238
|
}
|
|
5126
5239
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
5127
5240
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
5128
|
-
setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
|
|
5241
|
+
setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev$1(fromToolConfig));
|
|
5129
5242
|
}
|
|
5130
5243
|
if (getValueByPath(fromObject, ['kmsKeyName']) !== undefined) {
|
|
5131
5244
|
throw new Error('kmsKeyName parameter is not supported in Gemini API.');
|
|
@@ -5257,6 +5370,46 @@ function fileDataToMldev$3(fromObject) {
|
|
|
5257
5370
|
}
|
|
5258
5371
|
return toObject;
|
|
5259
5372
|
}
|
|
5373
|
+
function functionCallToMldev$3(fromObject) {
|
|
5374
|
+
const toObject = {};
|
|
5375
|
+
const fromId = getValueByPath(fromObject, ['id']);
|
|
5376
|
+
if (fromId != null) {
|
|
5377
|
+
setValueByPath(toObject, ['id'], fromId);
|
|
5378
|
+
}
|
|
5379
|
+
const fromArgs = getValueByPath(fromObject, ['args']);
|
|
5380
|
+
if (fromArgs != null) {
|
|
5381
|
+
setValueByPath(toObject, ['args'], fromArgs);
|
|
5382
|
+
}
|
|
5383
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
5384
|
+
if (fromName != null) {
|
|
5385
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
5386
|
+
}
|
|
5387
|
+
if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
|
|
5388
|
+
throw new Error('partialArgs parameter is not supported in Gemini API.');
|
|
5389
|
+
}
|
|
5390
|
+
if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
|
|
5391
|
+
throw new Error('willContinue parameter is not supported in Gemini API.');
|
|
5392
|
+
}
|
|
5393
|
+
return toObject;
|
|
5394
|
+
}
|
|
5395
|
+
function functionCallingConfigToMldev$1(fromObject) {
|
|
5396
|
+
const toObject = {};
|
|
5397
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
5398
|
+
if (fromMode != null) {
|
|
5399
|
+
setValueByPath(toObject, ['mode'], fromMode);
|
|
5400
|
+
}
|
|
5401
|
+
const fromAllowedFunctionNames = getValueByPath(fromObject, [
|
|
5402
|
+
'allowedFunctionNames',
|
|
5403
|
+
]);
|
|
5404
|
+
if (fromAllowedFunctionNames != null) {
|
|
5405
|
+
setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
|
|
5406
|
+
}
|
|
5407
|
+
if (getValueByPath(fromObject, ['streamFunctionCallArguments']) !==
|
|
5408
|
+
undefined) {
|
|
5409
|
+
throw new Error('streamFunctionCallArguments parameter is not supported in Gemini API.');
|
|
5410
|
+
}
|
|
5411
|
+
return toObject;
|
|
5412
|
+
}
|
|
5260
5413
|
function functionDeclarationToVertex$2(fromObject) {
|
|
5261
5414
|
const toObject = {};
|
|
5262
5415
|
if (getValueByPath(fromObject, ['behavior']) !== undefined) {
|
|
@@ -5433,9 +5586,11 @@ function listCachedContentsResponseFromVertex(fromObject) {
|
|
|
5433
5586
|
}
|
|
5434
5587
|
function partToMldev$3(fromObject) {
|
|
5435
5588
|
const toObject = {};
|
|
5436
|
-
const
|
|
5437
|
-
|
|
5438
|
-
|
|
5589
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
5590
|
+
'mediaResolution',
|
|
5591
|
+
]);
|
|
5592
|
+
if (fromMediaResolution != null) {
|
|
5593
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
5439
5594
|
}
|
|
5440
5595
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
5441
5596
|
'codeExecutionResult',
|
|
@@ -5453,6 +5608,10 @@ function partToMldev$3(fromObject) {
|
|
|
5453
5608
|
if (fromFileData != null) {
|
|
5454
5609
|
setValueByPath(toObject, ['fileData'], fileDataToMldev$3(fromFileData));
|
|
5455
5610
|
}
|
|
5611
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
5612
|
+
if (fromFunctionCall != null) {
|
|
5613
|
+
setValueByPath(toObject, ['functionCall'], functionCallToMldev$3(fromFunctionCall));
|
|
5614
|
+
}
|
|
5456
5615
|
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
5457
5616
|
'functionResponse',
|
|
5458
5617
|
]);
|
|
@@ -5485,6 +5644,22 @@ function partToMldev$3(fromObject) {
|
|
|
5485
5644
|
}
|
|
5486
5645
|
return toObject;
|
|
5487
5646
|
}
|
|
5647
|
+
function toolConfigToMldev$1(fromObject) {
|
|
5648
|
+
const toObject = {};
|
|
5649
|
+
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
5650
|
+
'functionCallingConfig',
|
|
5651
|
+
]);
|
|
5652
|
+
if (fromFunctionCallingConfig != null) {
|
|
5653
|
+
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(fromFunctionCallingConfig));
|
|
5654
|
+
}
|
|
5655
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
5656
|
+
'retrievalConfig',
|
|
5657
|
+
]);
|
|
5658
|
+
if (fromRetrievalConfig != null) {
|
|
5659
|
+
setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
|
|
5660
|
+
}
|
|
5661
|
+
return toObject;
|
|
5662
|
+
}
|
|
5488
5663
|
function toolToMldev$3(fromObject) {
|
|
5489
5664
|
const toObject = {};
|
|
5490
5665
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -6430,7 +6605,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6430
6605
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6431
6606
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6432
6607
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6433
|
-
const SDK_VERSION = '1.
|
|
6608
|
+
const SDK_VERSION = '1.30.0'; // x-release-please-version
|
|
6434
6609
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6435
6610
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6436
6611
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -8355,6 +8530,28 @@ function fileDataToMldev$2(fromObject) {
|
|
|
8355
8530
|
}
|
|
8356
8531
|
return toObject;
|
|
8357
8532
|
}
|
|
8533
|
+
function functionCallToMldev$2(fromObject) {
|
|
8534
|
+
const toObject = {};
|
|
8535
|
+
const fromId = getValueByPath(fromObject, ['id']);
|
|
8536
|
+
if (fromId != null) {
|
|
8537
|
+
setValueByPath(toObject, ['id'], fromId);
|
|
8538
|
+
}
|
|
8539
|
+
const fromArgs = getValueByPath(fromObject, ['args']);
|
|
8540
|
+
if (fromArgs != null) {
|
|
8541
|
+
setValueByPath(toObject, ['args'], fromArgs);
|
|
8542
|
+
}
|
|
8543
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
8544
|
+
if (fromName != null) {
|
|
8545
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
8546
|
+
}
|
|
8547
|
+
if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
|
|
8548
|
+
throw new Error('partialArgs parameter is not supported in Gemini API.');
|
|
8549
|
+
}
|
|
8550
|
+
if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
|
|
8551
|
+
throw new Error('willContinue parameter is not supported in Gemini API.');
|
|
8552
|
+
}
|
|
8553
|
+
return toObject;
|
|
8554
|
+
}
|
|
8358
8555
|
function functionDeclarationToVertex$1(fromObject) {
|
|
8359
8556
|
const toObject = {};
|
|
8360
8557
|
if (getValueByPath(fromObject, ['behavior']) !== undefined) {
|
|
@@ -8943,9 +9140,11 @@ function liveServerMessageFromVertex(fromObject) {
|
|
|
8943
9140
|
}
|
|
8944
9141
|
function partToMldev$2(fromObject) {
|
|
8945
9142
|
const toObject = {};
|
|
8946
|
-
const
|
|
8947
|
-
|
|
8948
|
-
|
|
9143
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
9144
|
+
'mediaResolution',
|
|
9145
|
+
]);
|
|
9146
|
+
if (fromMediaResolution != null) {
|
|
9147
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
8949
9148
|
}
|
|
8950
9149
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
8951
9150
|
'codeExecutionResult',
|
|
@@ -8963,6 +9162,10 @@ function partToMldev$2(fromObject) {
|
|
|
8963
9162
|
if (fromFileData != null) {
|
|
8964
9163
|
setValueByPath(toObject, ['fileData'], fileDataToMldev$2(fromFileData));
|
|
8965
9164
|
}
|
|
9165
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
9166
|
+
if (fromFunctionCall != null) {
|
|
9167
|
+
setValueByPath(toObject, ['functionCall'], functionCallToMldev$2(fromFunctionCall));
|
|
9168
|
+
}
|
|
8966
9169
|
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
8967
9170
|
'functionResponse',
|
|
8968
9171
|
]);
|
|
@@ -9884,6 +10087,46 @@ function fileDataToMldev$1(fromObject) {
|
|
|
9884
10087
|
}
|
|
9885
10088
|
return toObject;
|
|
9886
10089
|
}
|
|
10090
|
+
function functionCallToMldev$1(fromObject) {
|
|
10091
|
+
const toObject = {};
|
|
10092
|
+
const fromId = getValueByPath(fromObject, ['id']);
|
|
10093
|
+
if (fromId != null) {
|
|
10094
|
+
setValueByPath(toObject, ['id'], fromId);
|
|
10095
|
+
}
|
|
10096
|
+
const fromArgs = getValueByPath(fromObject, ['args']);
|
|
10097
|
+
if (fromArgs != null) {
|
|
10098
|
+
setValueByPath(toObject, ['args'], fromArgs);
|
|
10099
|
+
}
|
|
10100
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
10101
|
+
if (fromName != null) {
|
|
10102
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
10103
|
+
}
|
|
10104
|
+
if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
|
|
10105
|
+
throw new Error('partialArgs parameter is not supported in Gemini API.');
|
|
10106
|
+
}
|
|
10107
|
+
if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
|
|
10108
|
+
throw new Error('willContinue parameter is not supported in Gemini API.');
|
|
10109
|
+
}
|
|
10110
|
+
return toObject;
|
|
10111
|
+
}
|
|
10112
|
+
function functionCallingConfigToMldev(fromObject) {
|
|
10113
|
+
const toObject = {};
|
|
10114
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
10115
|
+
if (fromMode != null) {
|
|
10116
|
+
setValueByPath(toObject, ['mode'], fromMode);
|
|
10117
|
+
}
|
|
10118
|
+
const fromAllowedFunctionNames = getValueByPath(fromObject, [
|
|
10119
|
+
'allowedFunctionNames',
|
|
10120
|
+
]);
|
|
10121
|
+
if (fromAllowedFunctionNames != null) {
|
|
10122
|
+
setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
|
|
10123
|
+
}
|
|
10124
|
+
if (getValueByPath(fromObject, ['streamFunctionCallArguments']) !==
|
|
10125
|
+
undefined) {
|
|
10126
|
+
throw new Error('streamFunctionCallArguments parameter is not supported in Gemini API.');
|
|
10127
|
+
}
|
|
10128
|
+
return toObject;
|
|
10129
|
+
}
|
|
9887
10130
|
function functionDeclarationToVertex(fromObject) {
|
|
9888
10131
|
const toObject = {};
|
|
9889
10132
|
if (getValueByPath(fromObject, ['behavior']) !== undefined) {
|
|
@@ -10031,7 +10274,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
10031
10274
|
}
|
|
10032
10275
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
10033
10276
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
10034
|
-
setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
|
|
10277
|
+
setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev(fromToolConfig));
|
|
10035
10278
|
}
|
|
10036
10279
|
if (getValueByPath(fromObject, ['labels']) !== undefined) {
|
|
10037
10280
|
throw new Error('labels parameter is not supported in Gemini API.');
|
|
@@ -10069,7 +10312,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
10069
10312
|
}
|
|
10070
10313
|
const fromImageConfig = getValueByPath(fromObject, ['imageConfig']);
|
|
10071
10314
|
if (fromImageConfig != null) {
|
|
10072
|
-
setValueByPath(toObject, ['imageConfig'], fromImageConfig);
|
|
10315
|
+
setValueByPath(toObject, ['imageConfig'], imageConfigToMldev(fromImageConfig));
|
|
10073
10316
|
}
|
|
10074
10317
|
return toObject;
|
|
10075
10318
|
}
|
|
@@ -10233,7 +10476,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
10233
10476
|
}
|
|
10234
10477
|
const fromImageConfig = getValueByPath(fromObject, ['imageConfig']);
|
|
10235
10478
|
if (fromImageConfig != null) {
|
|
10236
|
-
setValueByPath(toObject, ['imageConfig'], fromImageConfig);
|
|
10479
|
+
setValueByPath(toObject, ['imageConfig'], imageConfigToVertex(fromImageConfig));
|
|
10237
10480
|
}
|
|
10238
10481
|
return toObject;
|
|
10239
10482
|
}
|
|
@@ -11234,6 +11477,49 @@ function googleSearchToMldev$1(fromObject) {
|
|
|
11234
11477
|
}
|
|
11235
11478
|
return toObject;
|
|
11236
11479
|
}
|
|
11480
|
+
function imageConfigToMldev(fromObject) {
|
|
11481
|
+
const toObject = {};
|
|
11482
|
+
const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
|
|
11483
|
+
if (fromAspectRatio != null) {
|
|
11484
|
+
setValueByPath(toObject, ['aspectRatio'], fromAspectRatio);
|
|
11485
|
+
}
|
|
11486
|
+
const fromImageSize = getValueByPath(fromObject, ['imageSize']);
|
|
11487
|
+
if (fromImageSize != null) {
|
|
11488
|
+
setValueByPath(toObject, ['imageSize'], fromImageSize);
|
|
11489
|
+
}
|
|
11490
|
+
if (getValueByPath(fromObject, ['outputMimeType']) !== undefined) {
|
|
11491
|
+
throw new Error('outputMimeType parameter is not supported in Gemini API.');
|
|
11492
|
+
}
|
|
11493
|
+
if (getValueByPath(fromObject, ['outputCompressionQuality']) !==
|
|
11494
|
+
undefined) {
|
|
11495
|
+
throw new Error('outputCompressionQuality parameter is not supported in Gemini API.');
|
|
11496
|
+
}
|
|
11497
|
+
return toObject;
|
|
11498
|
+
}
|
|
11499
|
+
function imageConfigToVertex(fromObject) {
|
|
11500
|
+
const toObject = {};
|
|
11501
|
+
const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
|
|
11502
|
+
if (fromAspectRatio != null) {
|
|
11503
|
+
setValueByPath(toObject, ['aspectRatio'], fromAspectRatio);
|
|
11504
|
+
}
|
|
11505
|
+
const fromImageSize = getValueByPath(fromObject, ['imageSize']);
|
|
11506
|
+
if (fromImageSize != null) {
|
|
11507
|
+
setValueByPath(toObject, ['imageSize'], fromImageSize);
|
|
11508
|
+
}
|
|
11509
|
+
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
11510
|
+
'outputMimeType',
|
|
11511
|
+
]);
|
|
11512
|
+
if (fromOutputMimeType != null) {
|
|
11513
|
+
setValueByPath(toObject, ['imageOutputOptions', 'mimeType'], fromOutputMimeType);
|
|
11514
|
+
}
|
|
11515
|
+
const fromOutputCompressionQuality = getValueByPath(fromObject, [
|
|
11516
|
+
'outputCompressionQuality',
|
|
11517
|
+
]);
|
|
11518
|
+
if (fromOutputCompressionQuality != null) {
|
|
11519
|
+
setValueByPath(toObject, ['imageOutputOptions', 'compressionQuality'], fromOutputCompressionQuality);
|
|
11520
|
+
}
|
|
11521
|
+
return toObject;
|
|
11522
|
+
}
|
|
11237
11523
|
function imageFromMldev(fromObject) {
|
|
11238
11524
|
const toObject = {};
|
|
11239
11525
|
const fromImageBytes = getValueByPath(fromObject, [
|
|
@@ -11543,9 +11829,11 @@ function modelFromVertex(fromObject) {
|
|
|
11543
11829
|
}
|
|
11544
11830
|
function partToMldev$1(fromObject) {
|
|
11545
11831
|
const toObject = {};
|
|
11546
|
-
const
|
|
11547
|
-
|
|
11548
|
-
|
|
11832
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
11833
|
+
'mediaResolution',
|
|
11834
|
+
]);
|
|
11835
|
+
if (fromMediaResolution != null) {
|
|
11836
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
11549
11837
|
}
|
|
11550
11838
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
11551
11839
|
'codeExecutionResult',
|
|
@@ -11563,6 +11851,10 @@ function partToMldev$1(fromObject) {
|
|
|
11563
11851
|
if (fromFileData != null) {
|
|
11564
11852
|
setValueByPath(toObject, ['fileData'], fileDataToMldev$1(fromFileData));
|
|
11565
11853
|
}
|
|
11854
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
11855
|
+
if (fromFunctionCall != null) {
|
|
11856
|
+
setValueByPath(toObject, ['functionCall'], functionCallToMldev$1(fromFunctionCall));
|
|
11857
|
+
}
|
|
11566
11858
|
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
11567
11859
|
'functionResponse',
|
|
11568
11860
|
]);
|
|
@@ -11927,6 +12219,22 @@ function speechConfigToVertex(fromObject) {
|
|
|
11927
12219
|
}
|
|
11928
12220
|
return toObject;
|
|
11929
12221
|
}
|
|
12222
|
+
function toolConfigToMldev(fromObject) {
|
|
12223
|
+
const toObject = {};
|
|
12224
|
+
const fromFunctionCallingConfig = getValueByPath(fromObject, [
|
|
12225
|
+
'functionCallingConfig',
|
|
12226
|
+
]);
|
|
12227
|
+
if (fromFunctionCallingConfig != null) {
|
|
12228
|
+
setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(fromFunctionCallingConfig));
|
|
12229
|
+
}
|
|
12230
|
+
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
12231
|
+
'retrievalConfig',
|
|
12232
|
+
]);
|
|
12233
|
+
if (fromRetrievalConfig != null) {
|
|
12234
|
+
setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
|
|
12235
|
+
}
|
|
12236
|
+
return toObject;
|
|
12237
|
+
}
|
|
11930
12238
|
function toolToMldev$1(fromObject) {
|
|
11931
12239
|
const toObject = {};
|
|
11932
12240
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -13402,6 +13710,7 @@ class Models extends BaseModule {
|
|
|
13402
13710
|
* ```
|
|
13403
13711
|
*/
|
|
13404
13712
|
this.generateContentStream = async (params) => {
|
|
13713
|
+
var _a, _b, _c, _d, _e;
|
|
13405
13714
|
this.maybeMoveToResponseJsonSchem(params);
|
|
13406
13715
|
if (shouldDisableAfc(params.config)) {
|
|
13407
13716
|
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
@@ -13414,6 +13723,17 @@ class Models extends BaseModule {
|
|
|
13414
13723
|
.join(', ');
|
|
13415
13724
|
throw new Error(`Incompatible tools found at ${formattedIndexes}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`);
|
|
13416
13725
|
}
|
|
13726
|
+
// With tool compatibility confirmed, validate that the configuration are
|
|
13727
|
+
// compatible with each other and raise an error if invalid.
|
|
13728
|
+
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;
|
|
13729
|
+
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;
|
|
13730
|
+
if (streamFunctionCall && !disableAfc) {
|
|
13731
|
+
throw new Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, " +
|
|
13732
|
+
'this feature is not compatible with automatic function calling (AFC). ' +
|
|
13733
|
+
"Please set 'config.automaticFunctionCalling.disable' to true to disable AFC " +
|
|
13734
|
+
"or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' " +
|
|
13735
|
+
'to be undefined or set to false to disable streaming function call arguments feature.');
|
|
13736
|
+
}
|
|
13417
13737
|
return await this.processAfcStream(params);
|
|
13418
13738
|
};
|
|
13419
13739
|
/**
|
|
@@ -15031,6 +15351,28 @@ function fileDataToMldev(fromObject) {
|
|
|
15031
15351
|
}
|
|
15032
15352
|
return toObject;
|
|
15033
15353
|
}
|
|
15354
|
+
function functionCallToMldev(fromObject) {
|
|
15355
|
+
const toObject = {};
|
|
15356
|
+
const fromId = getValueByPath(fromObject, ['id']);
|
|
15357
|
+
if (fromId != null) {
|
|
15358
|
+
setValueByPath(toObject, ['id'], fromId);
|
|
15359
|
+
}
|
|
15360
|
+
const fromArgs = getValueByPath(fromObject, ['args']);
|
|
15361
|
+
if (fromArgs != null) {
|
|
15362
|
+
setValueByPath(toObject, ['args'], fromArgs);
|
|
15363
|
+
}
|
|
15364
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
15365
|
+
if (fromName != null) {
|
|
15366
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
15367
|
+
}
|
|
15368
|
+
if (getValueByPath(fromObject, ['partialArgs']) !== undefined) {
|
|
15369
|
+
throw new Error('partialArgs parameter is not supported in Gemini API.');
|
|
15370
|
+
}
|
|
15371
|
+
if (getValueByPath(fromObject, ['willContinue']) !== undefined) {
|
|
15372
|
+
throw new Error('willContinue parameter is not supported in Gemini API.');
|
|
15373
|
+
}
|
|
15374
|
+
return toObject;
|
|
15375
|
+
}
|
|
15034
15376
|
function googleMapsToMldev(fromObject) {
|
|
15035
15377
|
const toObject = {};
|
|
15036
15378
|
if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
|
|
@@ -15182,9 +15524,11 @@ function liveConnectConstraintsToMldev(apiClient, fromObject) {
|
|
|
15182
15524
|
}
|
|
15183
15525
|
function partToMldev(fromObject) {
|
|
15184
15526
|
const toObject = {};
|
|
15185
|
-
const
|
|
15186
|
-
|
|
15187
|
-
|
|
15527
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
15528
|
+
'mediaResolution',
|
|
15529
|
+
]);
|
|
15530
|
+
if (fromMediaResolution != null) {
|
|
15531
|
+
setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
|
|
15188
15532
|
}
|
|
15189
15533
|
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
15190
15534
|
'codeExecutionResult',
|
|
@@ -15202,6 +15546,10 @@ function partToMldev(fromObject) {
|
|
|
15202
15546
|
if (fromFileData != null) {
|
|
15203
15547
|
setValueByPath(toObject, ['fileData'], fileDataToMldev(fromFileData));
|
|
15204
15548
|
}
|
|
15549
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
15550
|
+
if (fromFunctionCall != null) {
|
|
15551
|
+
setValueByPath(toObject, ['functionCall'], functionCallToMldev(fromFunctionCall));
|
|
15552
|
+
}
|
|
15205
15553
|
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
15206
15554
|
'functionResponse',
|
|
15207
15555
|
]);
|