@google/genai 1.48.0 → 1.50.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 +812 -85
- package/dist/index.cjs +348 -203
- package/dist/index.mjs +348 -203
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +348 -200
- package/dist/node/index.mjs +348 -200
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +812 -85
- package/dist/tokenizer/node.cjs +100 -0
- package/dist/tokenizer/node.d.ts +5 -1
- package/dist/tokenizer/node.mjs +100 -0
- package/dist/tokenizer/node.mjs.map +1 -1
- package/dist/vertex_internal/index.cjs +103 -2
- package/dist/vertex_internal/index.cjs.map +1 -1
- package/dist/vertex_internal/index.d.ts +169 -3
- package/dist/vertex_internal/index.js +103 -2
- package/dist/vertex_internal/index.js.map +1 -1
- package/dist/web/index.mjs +349 -200
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +812 -85
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1221,6 +1221,10 @@ var Modality;
|
|
|
1221
1221
|
* Indicates the model should return audio.
|
|
1222
1222
|
*/
|
|
1223
1223
|
Modality["AUDIO"] = "AUDIO";
|
|
1224
|
+
/**
|
|
1225
|
+
* Indicates the model should return video.
|
|
1226
|
+
*/
|
|
1227
|
+
Modality["VIDEO"] = "VIDEO";
|
|
1224
1228
|
})(Modality || (Modality = {}));
|
|
1225
1229
|
/** The stage of the underlying model. This enum is not supported in Vertex AI. */
|
|
1226
1230
|
var ModelStage;
|
|
@@ -1815,6 +1819,102 @@ var TurnCompleteReason;
|
|
|
1815
1819
|
* Needs more input from the user.
|
|
1816
1820
|
*/
|
|
1817
1821
|
TurnCompleteReason["NEED_MORE_INPUT"] = "NEED_MORE_INPUT";
|
|
1822
|
+
/**
|
|
1823
|
+
* Input content is prohibited.
|
|
1824
|
+
*/
|
|
1825
|
+
TurnCompleteReason["PROHIBITED_INPUT_CONTENT"] = "PROHIBITED_INPUT_CONTENT";
|
|
1826
|
+
/**
|
|
1827
|
+
* Input image contains prohibited content.
|
|
1828
|
+
*/
|
|
1829
|
+
TurnCompleteReason["IMAGE_PROHIBITED_INPUT_CONTENT"] = "IMAGE_PROHIBITED_INPUT_CONTENT";
|
|
1830
|
+
/**
|
|
1831
|
+
* Input text contains prominent person reference.
|
|
1832
|
+
*/
|
|
1833
|
+
TurnCompleteReason["INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED"] = "INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED";
|
|
1834
|
+
/**
|
|
1835
|
+
* Input image contains celebrity.
|
|
1836
|
+
*/
|
|
1837
|
+
TurnCompleteReason["INPUT_IMAGE_CELEBRITY"] = "INPUT_IMAGE_CELEBRITY";
|
|
1838
|
+
/**
|
|
1839
|
+
* Input image contains photo realistic child.
|
|
1840
|
+
*/
|
|
1841
|
+
TurnCompleteReason["INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED"] = "INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED";
|
|
1842
|
+
/**
|
|
1843
|
+
* Input text contains NCII content.
|
|
1844
|
+
*/
|
|
1845
|
+
TurnCompleteReason["INPUT_TEXT_NCII_PROHIBITED"] = "INPUT_TEXT_NCII_PROHIBITED";
|
|
1846
|
+
/**
|
|
1847
|
+
* Other input safety issue.
|
|
1848
|
+
*/
|
|
1849
|
+
TurnCompleteReason["INPUT_OTHER"] = "INPUT_OTHER";
|
|
1850
|
+
/**
|
|
1851
|
+
* Input contains IP violation.
|
|
1852
|
+
*/
|
|
1853
|
+
TurnCompleteReason["INPUT_IP_PROHIBITED"] = "INPUT_IP_PROHIBITED";
|
|
1854
|
+
/**
|
|
1855
|
+
* Input matched blocklist.
|
|
1856
|
+
*/
|
|
1857
|
+
TurnCompleteReason["BLOCKLIST"] = "BLOCKLIST";
|
|
1858
|
+
/**
|
|
1859
|
+
* Input is unsafe for image generation.
|
|
1860
|
+
*/
|
|
1861
|
+
TurnCompleteReason["UNSAFE_PROMPT_FOR_IMAGE_GENERATION"] = "UNSAFE_PROMPT_FOR_IMAGE_GENERATION";
|
|
1862
|
+
/**
|
|
1863
|
+
* Generated image failed safety check.
|
|
1864
|
+
*/
|
|
1865
|
+
TurnCompleteReason["GENERATED_IMAGE_SAFETY"] = "GENERATED_IMAGE_SAFETY";
|
|
1866
|
+
/**
|
|
1867
|
+
* Generated content failed safety check.
|
|
1868
|
+
*/
|
|
1869
|
+
TurnCompleteReason["GENERATED_CONTENT_SAFETY"] = "GENERATED_CONTENT_SAFETY";
|
|
1870
|
+
/**
|
|
1871
|
+
* Generated audio failed safety check.
|
|
1872
|
+
*/
|
|
1873
|
+
TurnCompleteReason["GENERATED_AUDIO_SAFETY"] = "GENERATED_AUDIO_SAFETY";
|
|
1874
|
+
/**
|
|
1875
|
+
* Generated video failed safety check.
|
|
1876
|
+
*/
|
|
1877
|
+
TurnCompleteReason["GENERATED_VIDEO_SAFETY"] = "GENERATED_VIDEO_SAFETY";
|
|
1878
|
+
/**
|
|
1879
|
+
* Generated content is prohibited.
|
|
1880
|
+
*/
|
|
1881
|
+
TurnCompleteReason["GENERATED_CONTENT_PROHIBITED"] = "GENERATED_CONTENT_PROHIBITED";
|
|
1882
|
+
/**
|
|
1883
|
+
* Generated content matched blocklist.
|
|
1884
|
+
*/
|
|
1885
|
+
TurnCompleteReason["GENERATED_CONTENT_BLOCKLIST"] = "GENERATED_CONTENT_BLOCKLIST";
|
|
1886
|
+
/**
|
|
1887
|
+
* Generated image is prohibited.
|
|
1888
|
+
*/
|
|
1889
|
+
TurnCompleteReason["GENERATED_IMAGE_PROHIBITED"] = "GENERATED_IMAGE_PROHIBITED";
|
|
1890
|
+
/**
|
|
1891
|
+
* Generated image contains celebrity.
|
|
1892
|
+
*/
|
|
1893
|
+
TurnCompleteReason["GENERATED_IMAGE_CELEBRITY"] = "GENERATED_IMAGE_CELEBRITY";
|
|
1894
|
+
/**
|
|
1895
|
+
* Generated image contains prominent people detected by rewriter.
|
|
1896
|
+
*/
|
|
1897
|
+
TurnCompleteReason["GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER"] = "GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER";
|
|
1898
|
+
/**
|
|
1899
|
+
* Generated image contains identifiable people.
|
|
1900
|
+
*/
|
|
1901
|
+
TurnCompleteReason["GENERATED_IMAGE_IDENTIFIABLE_PEOPLE"] = "GENERATED_IMAGE_IDENTIFIABLE_PEOPLE";
|
|
1902
|
+
/**
|
|
1903
|
+
* Generated image contains minors.
|
|
1904
|
+
*/
|
|
1905
|
+
TurnCompleteReason["GENERATED_IMAGE_MINORS"] = "GENERATED_IMAGE_MINORS";
|
|
1906
|
+
/**
|
|
1907
|
+
* Generated image contains IP violation.
|
|
1908
|
+
*/
|
|
1909
|
+
TurnCompleteReason["OUTPUT_IMAGE_IP_PROHIBITED"] = "OUTPUT_IMAGE_IP_PROHIBITED";
|
|
1910
|
+
/**
|
|
1911
|
+
* Other generated content issue.
|
|
1912
|
+
*/
|
|
1913
|
+
TurnCompleteReason["GENERATED_OTHER"] = "GENERATED_OTHER";
|
|
1914
|
+
/**
|
|
1915
|
+
* Max regeneration attempts reached.
|
|
1916
|
+
*/
|
|
1917
|
+
TurnCompleteReason["MAX_REGENERATION_REACHED"] = "MAX_REGENERATION_REACHED";
|
|
1818
1918
|
})(TurnCompleteReason || (TurnCompleteReason = {}));
|
|
1819
1919
|
/** Server content modalities. */
|
|
1820
1920
|
var MediaModality;
|
|
@@ -4060,6 +4160,12 @@ function createBatchJobConfigToMldev(fromObject, parentObject) {
|
|
|
4060
4160
|
if (getValueByPath(fromObject, ['dest']) !== undefined) {
|
|
4061
4161
|
throw new Error('dest parameter is not supported in Gemini API.');
|
|
4062
4162
|
}
|
|
4163
|
+
const fromWebhookConfig = getValueByPath(fromObject, [
|
|
4164
|
+
'webhookConfig',
|
|
4165
|
+
]);
|
|
4166
|
+
if (parentObject !== undefined && fromWebhookConfig != null) {
|
|
4167
|
+
setValueByPath(parentObject, ['batch', 'webhookConfig'], fromWebhookConfig);
|
|
4168
|
+
}
|
|
4063
4169
|
return toObject;
|
|
4064
4170
|
}
|
|
4065
4171
|
function createBatchJobConfigToVertex(fromObject, parentObject) {
|
|
@@ -4072,6 +4178,9 @@ function createBatchJobConfigToVertex(fromObject, parentObject) {
|
|
|
4072
4178
|
if (parentObject !== undefined && fromDest != null) {
|
|
4073
4179
|
setValueByPath(parentObject, ['outputConfig'], batchJobDestinationToVertex(tBatchJobDestination(fromDest)));
|
|
4074
4180
|
}
|
|
4181
|
+
if (getValueByPath(fromObject, ['webhookConfig']) !== undefined) {
|
|
4182
|
+
throw new Error('webhookConfig parameter is not supported in Vertex AI.');
|
|
4183
|
+
}
|
|
4075
4184
|
return toObject;
|
|
4076
4185
|
}
|
|
4077
4186
|
function createBatchJobParametersToMldev(apiClient, fromObject) {
|
|
@@ -4231,6 +4340,12 @@ function embedContentConfigToMldev$1(fromObject, parentObject) {
|
|
|
4231
4340
|
if (getValueByPath(fromObject, ['autoTruncate']) !== undefined) {
|
|
4232
4341
|
throw new Error('autoTruncate parameter is not supported in Gemini API.');
|
|
4233
4342
|
}
|
|
4343
|
+
if (getValueByPath(fromObject, ['documentOcr']) !== undefined) {
|
|
4344
|
+
throw new Error('documentOcr parameter is not supported in Gemini API.');
|
|
4345
|
+
}
|
|
4346
|
+
if (getValueByPath(fromObject, ['audioTrackExtraction']) !== undefined) {
|
|
4347
|
+
throw new Error('audioTrackExtraction parameter is not supported in Gemini API.');
|
|
4348
|
+
}
|
|
4234
4349
|
return toObject;
|
|
4235
4350
|
}
|
|
4236
4351
|
function embeddingsBatchJobSourceToMldev(apiClient, fromObject) {
|
|
@@ -4397,7 +4512,7 @@ function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
|
|
|
4397
4512
|
let transformedList = fromSafetySettings;
|
|
4398
4513
|
if (Array.isArray(transformedList)) {
|
|
4399
4514
|
transformedList = transformedList.map((item) => {
|
|
4400
|
-
return safetySettingToMldev$
|
|
4515
|
+
return safetySettingToMldev$3(item);
|
|
4401
4516
|
});
|
|
4402
4517
|
}
|
|
4403
4518
|
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
@@ -4804,7 +4919,7 @@ function partToMldev$4(fromObject) {
|
|
|
4804
4919
|
}
|
|
4805
4920
|
return toObject;
|
|
4806
4921
|
}
|
|
4807
|
-
function safetySettingToMldev$
|
|
4922
|
+
function safetySettingToMldev$3(fromObject) {
|
|
4808
4923
|
const toObject = {};
|
|
4809
4924
|
const fromCategory = getValueByPath(fromObject, ['category']);
|
|
4810
4925
|
if (fromCategory != null) {
|
|
@@ -7922,7 +8037,7 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
7922
8037
|
}
|
|
7923
8038
|
const fromSpeechConfig = getValueByPath(fromObject, ['speechConfig']);
|
|
7924
8039
|
if (fromSpeechConfig != null) {
|
|
7925
|
-
setValueByPath(toObject, ['speechConfig'],
|
|
8040
|
+
setValueByPath(toObject, ['speechConfig'], fromSpeechConfig);
|
|
7926
8041
|
}
|
|
7927
8042
|
const fromStopSequences = getValueByPath(fromObject, [
|
|
7928
8043
|
'stopSequences',
|
|
@@ -8097,6 +8212,22 @@ function liveConnectConfigToMldev$1(fromObject, parentObject) {
|
|
|
8097
8212
|
if (getValueByPath(fromObject, ['explicitVadSignal']) !== undefined) {
|
|
8098
8213
|
throw new Error('explicitVadSignal parameter is not supported in Gemini API.');
|
|
8099
8214
|
}
|
|
8215
|
+
const fromAvatarConfig = getValueByPath(fromObject, ['avatarConfig']);
|
|
8216
|
+
if (parentObject !== undefined && fromAvatarConfig != null) {
|
|
8217
|
+
setValueByPath(parentObject, ['setup', 'avatarConfig'], fromAvatarConfig);
|
|
8218
|
+
}
|
|
8219
|
+
const fromSafetySettings = getValueByPath(fromObject, [
|
|
8220
|
+
'safetySettings',
|
|
8221
|
+
]);
|
|
8222
|
+
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
8223
|
+
let transformedList = fromSafetySettings;
|
|
8224
|
+
if (Array.isArray(transformedList)) {
|
|
8225
|
+
transformedList = transformedList.map((item) => {
|
|
8226
|
+
return safetySettingToMldev$2(item);
|
|
8227
|
+
});
|
|
8228
|
+
}
|
|
8229
|
+
setValueByPath(parentObject, ['setup', 'safetySettings'], transformedList);
|
|
8230
|
+
}
|
|
8100
8231
|
return toObject;
|
|
8101
8232
|
}
|
|
8102
8233
|
function liveConnectConfigToVertex(fromObject, parentObject) {
|
|
@@ -8143,7 +8274,7 @@ function liveConnectConfigToVertex(fromObject, parentObject) {
|
|
|
8143
8274
|
}
|
|
8144
8275
|
const fromSpeechConfig = getValueByPath(fromObject, ['speechConfig']);
|
|
8145
8276
|
if (parentObject !== undefined && fromSpeechConfig != null) {
|
|
8146
|
-
setValueByPath(parentObject, ['setup', 'generationConfig', 'speechConfig'],
|
|
8277
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'speechConfig'], tLiveSpeechConfig(fromSpeechConfig));
|
|
8147
8278
|
}
|
|
8148
8279
|
const fromThinkingConfig = getValueByPath(fromObject, [
|
|
8149
8280
|
'thinkingConfig',
|
|
@@ -8213,6 +8344,22 @@ function liveConnectConfigToVertex(fromObject, parentObject) {
|
|
|
8213
8344
|
if (parentObject !== undefined && fromExplicitVadSignal != null) {
|
|
8214
8345
|
setValueByPath(parentObject, ['setup', 'explicitVadSignal'], fromExplicitVadSignal);
|
|
8215
8346
|
}
|
|
8347
|
+
const fromAvatarConfig = getValueByPath(fromObject, ['avatarConfig']);
|
|
8348
|
+
if (parentObject !== undefined && fromAvatarConfig != null) {
|
|
8349
|
+
setValueByPath(parentObject, ['setup', 'avatarConfig'], fromAvatarConfig);
|
|
8350
|
+
}
|
|
8351
|
+
const fromSafetySettings = getValueByPath(fromObject, [
|
|
8352
|
+
'safetySettings',
|
|
8353
|
+
]);
|
|
8354
|
+
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
8355
|
+
let transformedList = fromSafetySettings;
|
|
8356
|
+
if (Array.isArray(transformedList)) {
|
|
8357
|
+
transformedList = transformedList.map((item) => {
|
|
8358
|
+
return item;
|
|
8359
|
+
});
|
|
8360
|
+
}
|
|
8361
|
+
setValueByPath(parentObject, ['setup', 'safetySettings'], transformedList);
|
|
8362
|
+
}
|
|
8216
8363
|
return toObject;
|
|
8217
8364
|
}
|
|
8218
8365
|
function liveConnectParametersToMldev(apiClient, fromObject) {
|
|
@@ -8403,22 +8550,6 @@ function liveServerMessageFromVertex(fromObject) {
|
|
|
8403
8550
|
}
|
|
8404
8551
|
return toObject;
|
|
8405
8552
|
}
|
|
8406
|
-
function multiSpeakerVoiceConfigToVertex$1(fromObject) {
|
|
8407
|
-
const toObject = {};
|
|
8408
|
-
const fromSpeakerVoiceConfigs = getValueByPath(fromObject, [
|
|
8409
|
-
'speakerVoiceConfigs',
|
|
8410
|
-
]);
|
|
8411
|
-
if (fromSpeakerVoiceConfigs != null) {
|
|
8412
|
-
let transformedList = fromSpeakerVoiceConfigs;
|
|
8413
|
-
if (Array.isArray(transformedList)) {
|
|
8414
|
-
transformedList = transformedList.map((item) => {
|
|
8415
|
-
return speakerVoiceConfigToVertex$1(item);
|
|
8416
|
-
});
|
|
8417
|
-
}
|
|
8418
|
-
setValueByPath(toObject, ['speakerVoiceConfigs'], transformedList);
|
|
8419
|
-
}
|
|
8420
|
-
return toObject;
|
|
8421
|
-
}
|
|
8422
8553
|
function partToMldev$2(fromObject) {
|
|
8423
8554
|
const toObject = {};
|
|
8424
8555
|
const fromMediaResolution = getValueByPath(fromObject, [
|
|
@@ -8560,17 +8691,18 @@ function partToVertex$1(fromObject) {
|
|
|
8560
8691
|
}
|
|
8561
8692
|
return toObject;
|
|
8562
8693
|
}
|
|
8563
|
-
function
|
|
8694
|
+
function safetySettingToMldev$2(fromObject) {
|
|
8564
8695
|
const toObject = {};
|
|
8565
|
-
const
|
|
8566
|
-
if (
|
|
8567
|
-
setValueByPath(toObject, ['
|
|
8696
|
+
const fromCategory = getValueByPath(fromObject, ['category']);
|
|
8697
|
+
if (fromCategory != null) {
|
|
8698
|
+
setValueByPath(toObject, ['category'], fromCategory);
|
|
8568
8699
|
}
|
|
8569
|
-
|
|
8570
|
-
'
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8700
|
+
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
8701
|
+
throw new Error('method parameter is not supported in Gemini API.');
|
|
8702
|
+
}
|
|
8703
|
+
const fromThreshold = getValueByPath(fromObject, ['threshold']);
|
|
8704
|
+
if (fromThreshold != null) {
|
|
8705
|
+
setValueByPath(toObject, ['threshold'], fromThreshold);
|
|
8574
8706
|
}
|
|
8575
8707
|
return toObject;
|
|
8576
8708
|
}
|
|
@@ -8585,36 +8717,6 @@ function sessionResumptionConfigToMldev$1(fromObject) {
|
|
|
8585
8717
|
}
|
|
8586
8718
|
return toObject;
|
|
8587
8719
|
}
|
|
8588
|
-
function speakerVoiceConfigToVertex$1(fromObject) {
|
|
8589
|
-
const toObject = {};
|
|
8590
|
-
const fromSpeaker = getValueByPath(fromObject, ['speaker']);
|
|
8591
|
-
if (fromSpeaker != null) {
|
|
8592
|
-
setValueByPath(toObject, ['speaker'], fromSpeaker);
|
|
8593
|
-
}
|
|
8594
|
-
const fromVoiceConfig = getValueByPath(fromObject, ['voiceConfig']);
|
|
8595
|
-
if (fromVoiceConfig != null) {
|
|
8596
|
-
setValueByPath(toObject, ['voiceConfig'], voiceConfigToVertex$1(fromVoiceConfig));
|
|
8597
|
-
}
|
|
8598
|
-
return toObject;
|
|
8599
|
-
}
|
|
8600
|
-
function speechConfigToVertex$1(fromObject) {
|
|
8601
|
-
const toObject = {};
|
|
8602
|
-
const fromVoiceConfig = getValueByPath(fromObject, ['voiceConfig']);
|
|
8603
|
-
if (fromVoiceConfig != null) {
|
|
8604
|
-
setValueByPath(toObject, ['voiceConfig'], voiceConfigToVertex$1(fromVoiceConfig));
|
|
8605
|
-
}
|
|
8606
|
-
const fromLanguageCode = getValueByPath(fromObject, ['languageCode']);
|
|
8607
|
-
if (fromLanguageCode != null) {
|
|
8608
|
-
setValueByPath(toObject, ['languageCode'], fromLanguageCode);
|
|
8609
|
-
}
|
|
8610
|
-
const fromMultiSpeakerVoiceConfig = getValueByPath(fromObject, [
|
|
8611
|
-
'multiSpeakerVoiceConfig',
|
|
8612
|
-
]);
|
|
8613
|
-
if (fromMultiSpeakerVoiceConfig != null) {
|
|
8614
|
-
setValueByPath(toObject, ['multiSpeakerVoiceConfig'], multiSpeakerVoiceConfigToVertex$1(fromMultiSpeakerVoiceConfig));
|
|
8615
|
-
}
|
|
8616
|
-
return toObject;
|
|
8617
|
-
}
|
|
8618
8720
|
function toolToMldev$2(fromObject) {
|
|
8619
8721
|
const toObject = {};
|
|
8620
8722
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
@@ -8848,22 +8950,6 @@ function voiceActivityFromVertex(fromObject) {
|
|
|
8848
8950
|
}
|
|
8849
8951
|
return toObject;
|
|
8850
8952
|
}
|
|
8851
|
-
function voiceConfigToVertex$1(fromObject) {
|
|
8852
|
-
const toObject = {};
|
|
8853
|
-
const fromReplicatedVoiceConfig = getValueByPath(fromObject, [
|
|
8854
|
-
'replicatedVoiceConfig',
|
|
8855
|
-
]);
|
|
8856
|
-
if (fromReplicatedVoiceConfig != null) {
|
|
8857
|
-
setValueByPath(toObject, ['replicatedVoiceConfig'], replicatedVoiceConfigToVertex$1(fromReplicatedVoiceConfig));
|
|
8858
|
-
}
|
|
8859
|
-
const fromPrebuiltVoiceConfig = getValueByPath(fromObject, [
|
|
8860
|
-
'prebuiltVoiceConfig',
|
|
8861
|
-
]);
|
|
8862
|
-
if (fromPrebuiltVoiceConfig != null) {
|
|
8863
|
-
setValueByPath(toObject, ['prebuiltVoiceConfig'], fromPrebuiltVoiceConfig);
|
|
8864
|
-
}
|
|
8865
|
-
return toObject;
|
|
8866
|
-
}
|
|
8867
8953
|
|
|
8868
8954
|
/**
|
|
8869
8955
|
* @license
|
|
@@ -9413,6 +9499,12 @@ function embedContentConfigToMldev(fromObject, parentObject, _rootObject) {
|
|
|
9413
9499
|
if (getValueByPath(fromObject, ['autoTruncate']) !== undefined) {
|
|
9414
9500
|
throw new Error('autoTruncate parameter is not supported in Gemini API.');
|
|
9415
9501
|
}
|
|
9502
|
+
if (getValueByPath(fromObject, ['documentOcr']) !== undefined) {
|
|
9503
|
+
throw new Error('documentOcr parameter is not supported in Gemini API.');
|
|
9504
|
+
}
|
|
9505
|
+
if (getValueByPath(fromObject, ['audioTrackExtraction']) !== undefined) {
|
|
9506
|
+
throw new Error('audioTrackExtraction parameter is not supported in Gemini API.');
|
|
9507
|
+
}
|
|
9416
9508
|
return toObject;
|
|
9417
9509
|
}
|
|
9418
9510
|
function embedContentConfigToVertex(fromObject, parentObject, rootObject) {
|
|
@@ -9432,7 +9524,7 @@ function embedContentConfigToVertex(fromObject, parentObject, rootObject) {
|
|
|
9432
9524
|
else if (discriminatorTaskType === 'EMBED_CONTENT') {
|
|
9433
9525
|
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
9434
9526
|
if (parentObject !== undefined && fromTaskType != null) {
|
|
9435
|
-
setValueByPath(parentObject, ['taskType'], fromTaskType);
|
|
9527
|
+
setValueByPath(parentObject, ['embedContentConfig', 'taskType'], fromTaskType);
|
|
9436
9528
|
}
|
|
9437
9529
|
}
|
|
9438
9530
|
let discriminatorTitle = getValueByPath(rootObject, [
|
|
@@ -9450,7 +9542,7 @@ function embedContentConfigToVertex(fromObject, parentObject, rootObject) {
|
|
|
9450
9542
|
else if (discriminatorTitle === 'EMBED_CONTENT') {
|
|
9451
9543
|
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
9452
9544
|
if (parentObject !== undefined && fromTitle != null) {
|
|
9453
|
-
setValueByPath(parentObject, ['title'], fromTitle);
|
|
9545
|
+
setValueByPath(parentObject, ['embedContentConfig', 'title'], fromTitle);
|
|
9454
9546
|
}
|
|
9455
9547
|
}
|
|
9456
9548
|
let discriminatorOutputDimensionality = getValueByPath(rootObject, [
|
|
@@ -9472,7 +9564,7 @@ function embedContentConfigToVertex(fromObject, parentObject, rootObject) {
|
|
|
9472
9564
|
'outputDimensionality',
|
|
9473
9565
|
]);
|
|
9474
9566
|
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
9475
|
-
setValueByPath(parentObject, ['outputDimensionality'], fromOutputDimensionality);
|
|
9567
|
+
setValueByPath(parentObject, ['embedContentConfig', 'outputDimensionality'], fromOutputDimensionality);
|
|
9476
9568
|
}
|
|
9477
9569
|
}
|
|
9478
9570
|
let discriminatorMimeType = getValueByPath(rootObject, [
|
|
@@ -9506,7 +9598,33 @@ function embedContentConfigToVertex(fromObject, parentObject, rootObject) {
|
|
|
9506
9598
|
'autoTruncate',
|
|
9507
9599
|
]);
|
|
9508
9600
|
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
9509
|
-
setValueByPath(parentObject, ['autoTruncate'], fromAutoTruncate);
|
|
9601
|
+
setValueByPath(parentObject, ['embedContentConfig', 'autoTruncate'], fromAutoTruncate);
|
|
9602
|
+
}
|
|
9603
|
+
}
|
|
9604
|
+
let discriminatorDocumentOcr = getValueByPath(rootObject, [
|
|
9605
|
+
'embeddingApiType',
|
|
9606
|
+
]);
|
|
9607
|
+
if (discriminatorDocumentOcr === undefined) {
|
|
9608
|
+
discriminatorDocumentOcr = 'PREDICT';
|
|
9609
|
+
}
|
|
9610
|
+
if (discriminatorDocumentOcr === 'EMBED_CONTENT') {
|
|
9611
|
+
const fromDocumentOcr = getValueByPath(fromObject, ['documentOcr']);
|
|
9612
|
+
if (parentObject !== undefined && fromDocumentOcr != null) {
|
|
9613
|
+
setValueByPath(parentObject, ['embedContentConfig', 'documentOcr'], fromDocumentOcr);
|
|
9614
|
+
}
|
|
9615
|
+
}
|
|
9616
|
+
let discriminatorAudioTrackExtraction = getValueByPath(rootObject, [
|
|
9617
|
+
'embeddingApiType',
|
|
9618
|
+
]);
|
|
9619
|
+
if (discriminatorAudioTrackExtraction === undefined) {
|
|
9620
|
+
discriminatorAudioTrackExtraction = 'PREDICT';
|
|
9621
|
+
}
|
|
9622
|
+
if (discriminatorAudioTrackExtraction === 'EMBED_CONTENT') {
|
|
9623
|
+
const fromAudioTrackExtraction = getValueByPath(fromObject, [
|
|
9624
|
+
'audioTrackExtraction',
|
|
9625
|
+
]);
|
|
9626
|
+
if (parentObject !== undefined && fromAudioTrackExtraction != null) {
|
|
9627
|
+
setValueByPath(parentObject, ['embedContentConfig', 'audioTrackExtraction'], fromAudioTrackExtraction);
|
|
9510
9628
|
}
|
|
9511
9629
|
}
|
|
9512
9630
|
return toObject;
|
|
@@ -9851,7 +9969,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject, rootO
|
|
|
9851
9969
|
let transformedList = fromSafetySettings;
|
|
9852
9970
|
if (Array.isArray(transformedList)) {
|
|
9853
9971
|
transformedList = transformedList.map((item) => {
|
|
9854
|
-
return safetySettingToMldev(item);
|
|
9972
|
+
return safetySettingToMldev$1(item);
|
|
9855
9973
|
});
|
|
9856
9974
|
}
|
|
9857
9975
|
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
@@ -10067,7 +10185,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
|
|
|
10067
10185
|
}
|
|
10068
10186
|
const fromSpeechConfig = getValueByPath(fromObject, ['speechConfig']);
|
|
10069
10187
|
if (fromSpeechConfig != null) {
|
|
10070
|
-
setValueByPath(toObject, ['speechConfig'],
|
|
10188
|
+
setValueByPath(toObject, ['speechConfig'], tSpeechConfig(fromSpeechConfig));
|
|
10071
10189
|
}
|
|
10072
10190
|
const fromAudioTimestamp = getValueByPath(fromObject, [
|
|
10073
10191
|
'audioTimestamp',
|
|
@@ -10575,6 +10693,12 @@ function generateVideosConfigToMldev(fromObject, parentObject, rootObject) {
|
|
|
10575
10693
|
if (getValueByPath(fromObject, ['labels']) !== undefined) {
|
|
10576
10694
|
throw new Error('labels parameter is not supported in Gemini API.');
|
|
10577
10695
|
}
|
|
10696
|
+
const fromWebhookConfig = getValueByPath(fromObject, [
|
|
10697
|
+
'webhookConfig',
|
|
10698
|
+
]);
|
|
10699
|
+
if (parentObject !== undefined && fromWebhookConfig != null) {
|
|
10700
|
+
setValueByPath(parentObject, ['webhookConfig'], fromWebhookConfig);
|
|
10701
|
+
}
|
|
10578
10702
|
return toObject;
|
|
10579
10703
|
}
|
|
10580
10704
|
function generateVideosConfigToVertex(fromObject, parentObject, rootObject) {
|
|
@@ -10669,6 +10793,9 @@ function generateVideosConfigToVertex(fromObject, parentObject, rootObject) {
|
|
|
10669
10793
|
if (parentObject !== undefined && fromLabels != null) {
|
|
10670
10794
|
setValueByPath(parentObject, ['labels'], fromLabels);
|
|
10671
10795
|
}
|
|
10796
|
+
if (getValueByPath(fromObject, ['webhookConfig']) !== undefined) {
|
|
10797
|
+
throw new Error('webhookConfig parameter is not supported in Vertex AI.');
|
|
10798
|
+
}
|
|
10672
10799
|
return toObject;
|
|
10673
10800
|
}
|
|
10674
10801
|
function generateVideosOperationFromMldev(fromObject, rootObject) {
|
|
@@ -10938,7 +11065,7 @@ function generatedVideoFromVertex(fromObject, rootObject) {
|
|
|
10938
11065
|
}
|
|
10939
11066
|
return toObject;
|
|
10940
11067
|
}
|
|
10941
|
-
function generationConfigToVertex(fromObject,
|
|
11068
|
+
function generationConfigToVertex(fromObject, _rootObject) {
|
|
10942
11069
|
const toObject = {};
|
|
10943
11070
|
const fromModelSelectionConfig = getValueByPath(fromObject, [
|
|
10944
11071
|
'modelSelectionConfig',
|
|
@@ -11034,7 +11161,7 @@ function generationConfigToVertex(fromObject, rootObject) {
|
|
|
11034
11161
|
}
|
|
11035
11162
|
const fromSpeechConfig = getValueByPath(fromObject, ['speechConfig']);
|
|
11036
11163
|
if (fromSpeechConfig != null) {
|
|
11037
|
-
setValueByPath(toObject, ['speechConfig'],
|
|
11164
|
+
setValueByPath(toObject, ['speechConfig'], fromSpeechConfig);
|
|
11038
11165
|
}
|
|
11039
11166
|
const fromStopSequences = getValueByPath(fromObject, [
|
|
11040
11167
|
'stopSequences',
|
|
@@ -11491,22 +11618,6 @@ function modelFromVertex(fromObject, rootObject) {
|
|
|
11491
11618
|
}
|
|
11492
11619
|
return toObject;
|
|
11493
11620
|
}
|
|
11494
|
-
function multiSpeakerVoiceConfigToVertex(fromObject, rootObject) {
|
|
11495
|
-
const toObject = {};
|
|
11496
|
-
const fromSpeakerVoiceConfigs = getValueByPath(fromObject, [
|
|
11497
|
-
'speakerVoiceConfigs',
|
|
11498
|
-
]);
|
|
11499
|
-
if (fromSpeakerVoiceConfigs != null) {
|
|
11500
|
-
let transformedList = fromSpeakerVoiceConfigs;
|
|
11501
|
-
if (Array.isArray(transformedList)) {
|
|
11502
|
-
transformedList = transformedList.map((item) => {
|
|
11503
|
-
return speakerVoiceConfigToVertex(item);
|
|
11504
|
-
});
|
|
11505
|
-
}
|
|
11506
|
-
setValueByPath(toObject, ['speakerVoiceConfigs'], transformedList);
|
|
11507
|
-
}
|
|
11508
|
-
return toObject;
|
|
11509
|
-
}
|
|
11510
11621
|
function partToMldev$1(fromObject, rootObject) {
|
|
11511
11622
|
const toObject = {};
|
|
11512
11623
|
const fromMediaResolution = getValueByPath(fromObject, [
|
|
@@ -11816,20 +11927,6 @@ function referenceImageAPIInternalToVertex(fromObject, rootObject) {
|
|
|
11816
11927
|
}
|
|
11817
11928
|
return toObject;
|
|
11818
11929
|
}
|
|
11819
|
-
function replicatedVoiceConfigToVertex(fromObject, _rootObject) {
|
|
11820
|
-
const toObject = {};
|
|
11821
|
-
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
11822
|
-
if (fromMimeType != null) {
|
|
11823
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
11824
|
-
}
|
|
11825
|
-
const fromVoiceSampleAudio = getValueByPath(fromObject, [
|
|
11826
|
-
'voiceSampleAudio',
|
|
11827
|
-
]);
|
|
11828
|
-
if (fromVoiceSampleAudio != null) {
|
|
11829
|
-
setValueByPath(toObject, ['voiceSampleAudio'], fromVoiceSampleAudio);
|
|
11830
|
-
}
|
|
11831
|
-
return toObject;
|
|
11832
|
-
}
|
|
11833
11930
|
function safetyAttributesFromMldev(fromObject, _rootObject) {
|
|
11834
11931
|
const toObject = {};
|
|
11835
11932
|
const fromCategories = getValueByPath(fromObject, [
|
|
@@ -11874,7 +11971,7 @@ function safetyAttributesFromVertex(fromObject, _rootObject) {
|
|
|
11874
11971
|
}
|
|
11875
11972
|
return toObject;
|
|
11876
11973
|
}
|
|
11877
|
-
function safetySettingToMldev(fromObject, _rootObject) {
|
|
11974
|
+
function safetySettingToMldev$1(fromObject, _rootObject) {
|
|
11878
11975
|
const toObject = {};
|
|
11879
11976
|
const fromCategory = getValueByPath(fromObject, ['category']);
|
|
11880
11977
|
if (fromCategory != null) {
|
|
@@ -11979,36 +12076,6 @@ function segmentImageSourceToVertex(fromObject, parentObject, rootObject) {
|
|
|
11979
12076
|
}
|
|
11980
12077
|
return toObject;
|
|
11981
12078
|
}
|
|
11982
|
-
function speakerVoiceConfigToVertex(fromObject, rootObject) {
|
|
11983
|
-
const toObject = {};
|
|
11984
|
-
const fromSpeaker = getValueByPath(fromObject, ['speaker']);
|
|
11985
|
-
if (fromSpeaker != null) {
|
|
11986
|
-
setValueByPath(toObject, ['speaker'], fromSpeaker);
|
|
11987
|
-
}
|
|
11988
|
-
const fromVoiceConfig = getValueByPath(fromObject, ['voiceConfig']);
|
|
11989
|
-
if (fromVoiceConfig != null) {
|
|
11990
|
-
setValueByPath(toObject, ['voiceConfig'], voiceConfigToVertex(fromVoiceConfig));
|
|
11991
|
-
}
|
|
11992
|
-
return toObject;
|
|
11993
|
-
}
|
|
11994
|
-
function speechConfigToVertex(fromObject, rootObject) {
|
|
11995
|
-
const toObject = {};
|
|
11996
|
-
const fromVoiceConfig = getValueByPath(fromObject, ['voiceConfig']);
|
|
11997
|
-
if (fromVoiceConfig != null) {
|
|
11998
|
-
setValueByPath(toObject, ['voiceConfig'], voiceConfigToVertex(fromVoiceConfig));
|
|
11999
|
-
}
|
|
12000
|
-
const fromLanguageCode = getValueByPath(fromObject, ['languageCode']);
|
|
12001
|
-
if (fromLanguageCode != null) {
|
|
12002
|
-
setValueByPath(toObject, ['languageCode'], fromLanguageCode);
|
|
12003
|
-
}
|
|
12004
|
-
const fromMultiSpeakerVoiceConfig = getValueByPath(fromObject, [
|
|
12005
|
-
'multiSpeakerVoiceConfig',
|
|
12006
|
-
]);
|
|
12007
|
-
if (fromMultiSpeakerVoiceConfig != null) {
|
|
12008
|
-
setValueByPath(toObject, ['multiSpeakerVoiceConfig'], multiSpeakerVoiceConfigToVertex(fromMultiSpeakerVoiceConfig));
|
|
12009
|
-
}
|
|
12010
|
-
return toObject;
|
|
12011
|
-
}
|
|
12012
12079
|
function toolConfigToMldev(fromObject, rootObject) {
|
|
12013
12080
|
const toObject = {};
|
|
12014
12081
|
const fromRetrievalConfig = getValueByPath(fromObject, [
|
|
@@ -12491,22 +12558,6 @@ function videoToVertex(fromObject, _rootObject) {
|
|
|
12491
12558
|
}
|
|
12492
12559
|
return toObject;
|
|
12493
12560
|
}
|
|
12494
|
-
function voiceConfigToVertex(fromObject, rootObject) {
|
|
12495
|
-
const toObject = {};
|
|
12496
|
-
const fromReplicatedVoiceConfig = getValueByPath(fromObject, [
|
|
12497
|
-
'replicatedVoiceConfig',
|
|
12498
|
-
]);
|
|
12499
|
-
if (fromReplicatedVoiceConfig != null) {
|
|
12500
|
-
setValueByPath(toObject, ['replicatedVoiceConfig'], replicatedVoiceConfigToVertex(fromReplicatedVoiceConfig));
|
|
12501
|
-
}
|
|
12502
|
-
const fromPrebuiltVoiceConfig = getValueByPath(fromObject, [
|
|
12503
|
-
'prebuiltVoiceConfig',
|
|
12504
|
-
]);
|
|
12505
|
-
if (fromPrebuiltVoiceConfig != null) {
|
|
12506
|
-
setValueByPath(toObject, ['prebuiltVoiceConfig'], fromPrebuiltVoiceConfig);
|
|
12507
|
-
}
|
|
12508
|
-
return toObject;
|
|
12509
|
-
}
|
|
12510
12561
|
|
|
12511
12562
|
/**
|
|
12512
12563
|
* @license
|
|
@@ -12752,10 +12803,11 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12752
12803
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12753
12804
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12754
12805
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12755
|
-
const SDK_VERSION = '1.
|
|
12806
|
+
const SDK_VERSION = '1.50.0'; // x-release-please-version
|
|
12756
12807
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12757
12808
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12758
12809
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
12810
|
+
const MULTI_REGIONAL_LOCATIONS = new Set(['us', 'eu']);
|
|
12759
12811
|
// Default retry options.
|
|
12760
12812
|
// The config is based on https://cloud.google.com/storage/docs/retry-strategy.
|
|
12761
12813
|
const DEFAULT_RETRY_ATTEMPTS = 5; // Including the initial call
|
|
@@ -12814,7 +12866,7 @@ class ApiClient {
|
|
|
12814
12866
|
}
|
|
12815
12867
|
else if (this.clientOptions.project &&
|
|
12816
12868
|
this.clientOptions.location &&
|
|
12817
|
-
this.clientOptions.location
|
|
12869
|
+
MULTI_REGIONAL_LOCATIONS.has(this.clientOptions.location)) {
|
|
12818
12870
|
initHttpOptions.baseUrl = `https://aiplatform.${this.clientOptions.location}.rep.googleapis.com/`;
|
|
12819
12871
|
}
|
|
12820
12872
|
else if (this.clientOptions.project && this.clientOptions.location) {
|
|
@@ -14381,6 +14433,10 @@ class Models extends BaseModule {
|
|
|
14381
14433
|
*/
|
|
14382
14434
|
this.embedContent = async (params) => {
|
|
14383
14435
|
if (!this.apiClient.isVertexAI()) {
|
|
14436
|
+
const isGeminiEmbedding2Model = params.model.includes('gemini-embedding-2');
|
|
14437
|
+
if (isGeminiEmbedding2Model) {
|
|
14438
|
+
params.contents = tContents(params.contents);
|
|
14439
|
+
}
|
|
14384
14440
|
return await this.embedContentInternal(params);
|
|
14385
14441
|
}
|
|
14386
14442
|
const isVertexEmbedContentModel = (params.model.includes('gemini') &&
|
|
@@ -15317,29 +15373,15 @@ class Models extends BaseModule {
|
|
|
15317
15373
|
/**
|
|
15318
15374
|
* Recontextualizes an image.
|
|
15319
15375
|
*
|
|
15320
|
-
* There
|
|
15321
|
-
* 1)
|
|
15322
|
-
* and contexts.
|
|
15323
|
-
* 2) Virtual Try-On: Generate images of persons modeling fashion products.
|
|
15376
|
+
* There is one type of recontextualization currently supported:
|
|
15377
|
+
* 1) Virtual Try-On: Generate images of persons modeling fashion products.
|
|
15324
15378
|
*
|
|
15325
15379
|
* @param params - The parameters for recontextualizing an image.
|
|
15326
15380
|
* @return The response from the API.
|
|
15327
15381
|
*
|
|
15328
15382
|
* @example
|
|
15329
15383
|
* ```ts
|
|
15330
|
-
* const
|
|
15331
|
-
* model: 'imagen-product-recontext-preview-06-30',
|
|
15332
|
-
* source: {
|
|
15333
|
-
* prompt: 'In a modern kitchen setting.',
|
|
15334
|
-
* productImages: [productImage],
|
|
15335
|
-
* },
|
|
15336
|
-
* config: {
|
|
15337
|
-
* numberOfImages: 1,
|
|
15338
|
-
* },
|
|
15339
|
-
* });
|
|
15340
|
-
* console.log(response1?.generatedImages?.[0]?.image?.imageBytes);
|
|
15341
|
-
*
|
|
15342
|
-
* const response2 = await ai.models.recontextImage({
|
|
15384
|
+
* const response = await ai.models.recontextImage({
|
|
15343
15385
|
* model: 'virtual-try-on-001',
|
|
15344
15386
|
* source: {
|
|
15345
15387
|
* personImage: personImage,
|
|
@@ -15349,7 +15391,7 @@ class Models extends BaseModule {
|
|
|
15349
15391
|
* numberOfImages: 1,
|
|
15350
15392
|
* },
|
|
15351
15393
|
* });
|
|
15352
|
-
* console.log(
|
|
15394
|
+
* console.log(response?.generatedImages?.[0]?.image?.imageBytes);
|
|
15353
15395
|
* ```
|
|
15354
15396
|
*/
|
|
15355
15397
|
async recontextImage(params) {
|
|
@@ -16374,6 +16416,22 @@ function liveConnectConfigToMldev(fromObject, parentObject) {
|
|
|
16374
16416
|
if (getValueByPath(fromObject, ['explicitVadSignal']) !== undefined) {
|
|
16375
16417
|
throw new Error('explicitVadSignal parameter is not supported in Gemini API.');
|
|
16376
16418
|
}
|
|
16419
|
+
const fromAvatarConfig = getValueByPath(fromObject, ['avatarConfig']);
|
|
16420
|
+
if (parentObject !== undefined && fromAvatarConfig != null) {
|
|
16421
|
+
setValueByPath(parentObject, ['setup', 'avatarConfig'], fromAvatarConfig);
|
|
16422
|
+
}
|
|
16423
|
+
const fromSafetySettings = getValueByPath(fromObject, [
|
|
16424
|
+
'safetySettings',
|
|
16425
|
+
]);
|
|
16426
|
+
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
16427
|
+
let transformedList = fromSafetySettings;
|
|
16428
|
+
if (Array.isArray(transformedList)) {
|
|
16429
|
+
transformedList = transformedList.map((item) => {
|
|
16430
|
+
return safetySettingToMldev(item);
|
|
16431
|
+
});
|
|
16432
|
+
}
|
|
16433
|
+
setValueByPath(parentObject, ['setup', 'safetySettings'], transformedList);
|
|
16434
|
+
}
|
|
16377
16435
|
return toObject;
|
|
16378
16436
|
}
|
|
16379
16437
|
function liveConnectConstraintsToMldev(apiClient, fromObject) {
|
|
@@ -16460,6 +16518,21 @@ function partToMldev(fromObject) {
|
|
|
16460
16518
|
}
|
|
16461
16519
|
return toObject;
|
|
16462
16520
|
}
|
|
16521
|
+
function safetySettingToMldev(fromObject) {
|
|
16522
|
+
const toObject = {};
|
|
16523
|
+
const fromCategory = getValueByPath(fromObject, ['category']);
|
|
16524
|
+
if (fromCategory != null) {
|
|
16525
|
+
setValueByPath(toObject, ['category'], fromCategory);
|
|
16526
|
+
}
|
|
16527
|
+
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
16528
|
+
throw new Error('method parameter is not supported in Gemini API.');
|
|
16529
|
+
}
|
|
16530
|
+
const fromThreshold = getValueByPath(fromObject, ['threshold']);
|
|
16531
|
+
if (fromThreshold != null) {
|
|
16532
|
+
setValueByPath(toObject, ['threshold'], fromThreshold);
|
|
16533
|
+
}
|
|
16534
|
+
return toObject;
|
|
16535
|
+
}
|
|
16463
16536
|
function sessionResumptionConfigToMldev(fromObject) {
|
|
16464
16537
|
const toObject = {};
|
|
16465
16538
|
const fromHandle = getValueByPath(fromObject, ['handle']);
|
|
@@ -17929,7 +18002,8 @@ class BaseInteractions extends APIResource {
|
|
|
17929
18002
|
return this._client.delete(path `/${api_version}/interactions/${id}`, options);
|
|
17930
18003
|
}
|
|
17931
18004
|
/**
|
|
17932
|
-
* Cancels an interaction by id. This only applies to background interactions that
|
|
18005
|
+
* Cancels an interaction by id. This only applies to background interactions that
|
|
18006
|
+
* are still running.
|
|
17933
18007
|
*
|
|
17934
18008
|
* @example
|
|
17935
18009
|
* ```ts
|
|
@@ -17952,6 +18026,66 @@ BaseInteractions._key = Object.freeze(['interactions']);
|
|
|
17952
18026
|
class Interactions extends BaseInteractions {
|
|
17953
18027
|
}
|
|
17954
18028
|
|
|
18029
|
+
/**
|
|
18030
|
+
* @license
|
|
18031
|
+
* Copyright 2025 Google LLC
|
|
18032
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
18033
|
+
*/
|
|
18034
|
+
class BaseWebhooks extends APIResource {
|
|
18035
|
+
/**
|
|
18036
|
+
* Creates a new Webhook.
|
|
18037
|
+
*/
|
|
18038
|
+
create(params, options) {
|
|
18039
|
+
const { api_version = this._client.apiVersion, webhook_id } = params, body = __rest(params, ["api_version", "webhook_id"]);
|
|
18040
|
+
return this._client.post(path `/${api_version}/webhooks`, Object.assign({ query: { webhook_id }, body }, options));
|
|
18041
|
+
}
|
|
18042
|
+
/**
|
|
18043
|
+
* Gets a specific Webhook.
|
|
18044
|
+
*/
|
|
18045
|
+
retrieve(id, params = {}, options) {
|
|
18046
|
+
const { api_version = this._client.apiVersion } = params !== null && params !== void 0 ? params : {};
|
|
18047
|
+
return this._client.get(path `/${api_version}/webhooks/${id}`, options);
|
|
18048
|
+
}
|
|
18049
|
+
/**
|
|
18050
|
+
* Updates an existing Webhook.
|
|
18051
|
+
*/
|
|
18052
|
+
update(id, params, options) {
|
|
18053
|
+
const { api_version = this._client.apiVersion, update_mask } = params, body = __rest(params, ["api_version", "update_mask"]);
|
|
18054
|
+
return this._client.patch(path `/${api_version}/webhooks/${id}`, Object.assign({ query: { update_mask }, body }, options));
|
|
18055
|
+
}
|
|
18056
|
+
/**
|
|
18057
|
+
* Lists all Webhooks.
|
|
18058
|
+
*/
|
|
18059
|
+
list(params = {}, options) {
|
|
18060
|
+
const _a = params !== null && params !== void 0 ? params : {}, { api_version = this._client.apiVersion } = _a, query = __rest(_a, ["api_version"]);
|
|
18061
|
+
return this._client.get(path `/${api_version}/webhooks`, Object.assign({ query }, options));
|
|
18062
|
+
}
|
|
18063
|
+
/**
|
|
18064
|
+
* Deletes a Webhook.
|
|
18065
|
+
*/
|
|
18066
|
+
delete(id, params = {}, options) {
|
|
18067
|
+
const { api_version = this._client.apiVersion } = params !== null && params !== void 0 ? params : {};
|
|
18068
|
+
return this._client.delete(path `/${api_version}/webhooks/${id}`, options);
|
|
18069
|
+
}
|
|
18070
|
+
/**
|
|
18071
|
+
* Sends a ping event to a Webhook.
|
|
18072
|
+
*/
|
|
18073
|
+
ping(id, params = undefined, options) {
|
|
18074
|
+
const { api_version = this._client.apiVersion, body } = params !== null && params !== void 0 ? params : {};
|
|
18075
|
+
return this._client.post(path `/${api_version}/webhooks/${id}:ping`, Object.assign({ body: body }, options));
|
|
18076
|
+
}
|
|
18077
|
+
/**
|
|
18078
|
+
* Generates a new signing secret for a Webhook.
|
|
18079
|
+
*/
|
|
18080
|
+
rotateSigningSecret(id, params = {}, options) {
|
|
18081
|
+
const _a = params !== null && params !== void 0 ? params : {}, { api_version = this._client.apiVersion } = _a, body = __rest(_a, ["api_version"]);
|
|
18082
|
+
return this._client.post(path `/${api_version}/webhooks/${id}:rotateSigningSecret`, Object.assign({ body }, options));
|
|
18083
|
+
}
|
|
18084
|
+
}
|
|
18085
|
+
BaseWebhooks._key = Object.freeze(['webhooks']);
|
|
18086
|
+
class Webhooks extends BaseWebhooks {
|
|
18087
|
+
}
|
|
18088
|
+
|
|
17955
18089
|
/**
|
|
17956
18090
|
* @license
|
|
17957
18091
|
* Copyright 2025 Google LLC
|
|
@@ -18693,12 +18827,12 @@ const buildHeaders = (newHeaders) => {
|
|
|
18693
18827
|
* Will return undefined if the environment variable doesn't exist or cannot be accessed.
|
|
18694
18828
|
*/
|
|
18695
18829
|
const readEnv = (env) => {
|
|
18696
|
-
var _a, _b, _c, _d, _e
|
|
18830
|
+
var _a, _b, _c, _d, _e;
|
|
18697
18831
|
if (typeof globalThis.process !== 'undefined') {
|
|
18698
|
-
return (
|
|
18832
|
+
return ((_b = (_a = globalThis.process.env) === null || _a === void 0 ? void 0 : _a[env]) === null || _b === void 0 ? void 0 : _b.trim()) || undefined;
|
|
18699
18833
|
}
|
|
18700
18834
|
if (typeof globalThis.Deno !== 'undefined') {
|
|
18701
|
-
return (
|
|
18835
|
+
return ((_e = (_d = (_c = globalThis.Deno.env) === null || _c === void 0 ? void 0 : _c.get) === null || _d === void 0 ? void 0 : _d.call(_c, env)) === null || _e === void 0 ? void 0 : _e.trim()) || undefined;
|
|
18702
18836
|
}
|
|
18703
18837
|
return undefined;
|
|
18704
18838
|
};
|
|
@@ -18785,7 +18919,7 @@ class BaseGeminiNextGenAPIClient {
|
|
|
18785
18919
|
if (this.apiKey) {
|
|
18786
18920
|
return buildHeaders([{ 'x-goog-api-key': this.apiKey }]);
|
|
18787
18921
|
}
|
|
18788
|
-
if (this.clientAdapter.isVertexAI()) {
|
|
18922
|
+
if (this.clientAdapter && this.clientAdapter.isVertexAI()) {
|
|
18789
18923
|
return buildHeaders([await this.clientAdapter.getAuthHeaders()]);
|
|
18790
18924
|
}
|
|
18791
18925
|
return undefined;
|
|
@@ -19139,6 +19273,7 @@ class GeminiNextGenAPIClient extends BaseGeminiNextGenAPIClient {
|
|
|
19139
19273
|
constructor() {
|
|
19140
19274
|
super(...arguments);
|
|
19141
19275
|
this.interactions = new Interactions(this);
|
|
19276
|
+
this.webhooks = new Webhooks(this);
|
|
19142
19277
|
}
|
|
19143
19278
|
}
|
|
19144
19279
|
_a = GeminiNextGenAPIClient;
|
|
@@ -19158,6 +19293,7 @@ GeminiNextGenAPIClient.PermissionDeniedError = PermissionDeniedError;
|
|
|
19158
19293
|
GeminiNextGenAPIClient.UnprocessableEntityError = UnprocessableEntityError;
|
|
19159
19294
|
GeminiNextGenAPIClient.toFile = toFile;
|
|
19160
19295
|
GeminiNextGenAPIClient.Interactions = Interactions;
|
|
19296
|
+
GeminiNextGenAPIClient.Webhooks = Webhooks;
|
|
19161
19297
|
|
|
19162
19298
|
/**
|
|
19163
19299
|
* @license
|
|
@@ -21003,29 +21139,41 @@ const LANGUAGE_LABEL_PREFIX = 'gl-node/';
|
|
|
21003
21139
|
*
|
|
21004
21140
|
*/
|
|
21005
21141
|
class GoogleGenAI {
|
|
21006
|
-
|
|
21142
|
+
getNextGenClient() {
|
|
21007
21143
|
var _a;
|
|
21008
|
-
if (this._interactions !== undefined) {
|
|
21009
|
-
return this._interactions;
|
|
21010
|
-
}
|
|
21011
|
-
console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
|
|
21012
21144
|
const httpOpts = this.httpOptions;
|
|
21145
|
+
if (this._nextGenClient === undefined) {
|
|
21146
|
+
this._nextGenClient = new GeminiNextGenAPIClient({
|
|
21147
|
+
baseURL: this.apiClient.getBaseUrl(),
|
|
21148
|
+
apiKey: this.apiKey,
|
|
21149
|
+
apiVersion: this.apiClient.getApiVersion(),
|
|
21150
|
+
clientAdapter: this.apiClient,
|
|
21151
|
+
defaultHeaders: this.apiClient.getDefaultHeaders(),
|
|
21152
|
+
timeout: httpOpts === null || httpOpts === void 0 ? void 0 : httpOpts.timeout,
|
|
21153
|
+
maxRetries: (_a = httpOpts === null || httpOpts === void 0 ? void 0 : httpOpts.retryOptions) === null || _a === void 0 ? void 0 : _a.attempts,
|
|
21154
|
+
});
|
|
21155
|
+
}
|
|
21013
21156
|
// Unsupported Options Warnings
|
|
21014
21157
|
if (httpOpts === null || httpOpts === void 0 ? void 0 : httpOpts.extraBody) {
|
|
21015
21158
|
console.warn('GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.');
|
|
21016
21159
|
}
|
|
21017
|
-
|
|
21018
|
-
|
|
21019
|
-
|
|
21020
|
-
|
|
21021
|
-
|
|
21022
|
-
|
|
21023
|
-
|
|
21024
|
-
|
|
21025
|
-
});
|
|
21026
|
-
this._interactions = nextGenClient.interactions;
|
|
21160
|
+
return this._nextGenClient;
|
|
21161
|
+
}
|
|
21162
|
+
get interactions() {
|
|
21163
|
+
if (this._interactions !== undefined) {
|
|
21164
|
+
return this._interactions;
|
|
21165
|
+
}
|
|
21166
|
+
console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
|
|
21167
|
+
this._interactions = this.getNextGenClient().interactions;
|
|
21027
21168
|
return this._interactions;
|
|
21028
21169
|
}
|
|
21170
|
+
get webhooks() {
|
|
21171
|
+
if (this._webhooks !== undefined) {
|
|
21172
|
+
return this._webhooks;
|
|
21173
|
+
}
|
|
21174
|
+
this._webhooks = this.getNextGenClient().webhooks;
|
|
21175
|
+
return this._webhooks;
|
|
21176
|
+
}
|
|
21029
21177
|
constructor(options) {
|
|
21030
21178
|
var _a, _b, _c, _d, _e, _f;
|
|
21031
21179
|
// Validate explicitly set initializer values.
|