@google/genai 1.12.0 → 1.13.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 +152 -4
- package/dist/index.cjs +278 -9
- package/dist/index.mjs +278 -10
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +278 -9
- package/dist/node/index.mjs +278 -10
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +152 -4
- package/dist/web/index.mjs +278 -10
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +152 -4
- package/package.json +14 -5
package/dist/index.mjs
CHANGED
|
@@ -414,6 +414,14 @@ var UrlRetrievalStatus;
|
|
|
414
414
|
* Url retrieval is failed due to error.
|
|
415
415
|
*/
|
|
416
416
|
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_ERROR"] = "URL_RETRIEVAL_STATUS_ERROR";
|
|
417
|
+
/**
|
|
418
|
+
* Url retrieval is failed because the content is behind paywall.
|
|
419
|
+
*/
|
|
420
|
+
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_PAYWALL"] = "URL_RETRIEVAL_STATUS_PAYWALL";
|
|
421
|
+
/**
|
|
422
|
+
* Url retrieval is failed because the content is unsafe.
|
|
423
|
+
*/
|
|
424
|
+
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_UNSAFE"] = "URL_RETRIEVAL_STATUS_UNSAFE";
|
|
417
425
|
})(UrlRetrievalStatus || (UrlRetrievalStatus = {}));
|
|
418
426
|
/** Output only. The reason why the model stopped generating tokens.
|
|
419
427
|
|
|
@@ -1040,6 +1048,29 @@ var Scale;
|
|
|
1040
1048
|
*/
|
|
1041
1049
|
Scale["B_MAJOR_A_FLAT_MINOR"] = "B_MAJOR_A_FLAT_MINOR";
|
|
1042
1050
|
})(Scale || (Scale = {}));
|
|
1051
|
+
/** The mode of music generation. */
|
|
1052
|
+
var MusicGenerationMode;
|
|
1053
|
+
(function (MusicGenerationMode) {
|
|
1054
|
+
/**
|
|
1055
|
+
* Rely on the server default generation mode.
|
|
1056
|
+
*/
|
|
1057
|
+
MusicGenerationMode["MUSIC_GENERATION_MODE_UNSPECIFIED"] = "MUSIC_GENERATION_MODE_UNSPECIFIED";
|
|
1058
|
+
/**
|
|
1059
|
+
* Steer text prompts to regions of latent space with higher quality
|
|
1060
|
+
music.
|
|
1061
|
+
*/
|
|
1062
|
+
MusicGenerationMode["QUALITY"] = "QUALITY";
|
|
1063
|
+
/**
|
|
1064
|
+
* Steer text prompts to regions of latent space with a larger
|
|
1065
|
+
diversity of music.
|
|
1066
|
+
*/
|
|
1067
|
+
MusicGenerationMode["DIVERSITY"] = "DIVERSITY";
|
|
1068
|
+
/**
|
|
1069
|
+
* Steer text prompts to regions of latent space more likely to
|
|
1070
|
+
generate music with vocals.
|
|
1071
|
+
*/
|
|
1072
|
+
MusicGenerationMode["VOCALIZATION"] = "VOCALIZATION";
|
|
1073
|
+
})(MusicGenerationMode || (MusicGenerationMode = {}));
|
|
1043
1074
|
/** The playback control signal to apply to the music generation. */
|
|
1044
1075
|
var LiveMusicPlaybackControl;
|
|
1045
1076
|
(function (LiveMusicPlaybackControl) {
|
|
@@ -1463,6 +1494,9 @@ class EditImageResponse {
|
|
|
1463
1494
|
}
|
|
1464
1495
|
class UpscaleImageResponse {
|
|
1465
1496
|
}
|
|
1497
|
+
/** The output images response. */
|
|
1498
|
+
class RecontextImageResponse {
|
|
1499
|
+
}
|
|
1466
1500
|
class ListModelsResponse {
|
|
1467
1501
|
}
|
|
1468
1502
|
class DeleteModelResponse {
|
|
@@ -3668,6 +3702,10 @@ function generateContentResponseFromMldev$1(fromObject) {
|
|
|
3668
3702
|
if (fromPromptFeedback != null) {
|
|
3669
3703
|
setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
|
|
3670
3704
|
}
|
|
3705
|
+
const fromResponseId = getValueByPath(fromObject, ['responseId']);
|
|
3706
|
+
if (fromResponseId != null) {
|
|
3707
|
+
setValueByPath(toObject, ['responseId'], fromResponseId);
|
|
3708
|
+
}
|
|
3671
3709
|
const fromUsageMetadata = getValueByPath(fromObject, [
|
|
3672
3710
|
'usageMetadata',
|
|
3673
3711
|
]);
|
|
@@ -3801,6 +3839,12 @@ function listBatchJobsResponseFromMldev(fromObject) {
|
|
|
3801
3839
|
}
|
|
3802
3840
|
function deleteResourceJobFromMldev(fromObject) {
|
|
3803
3841
|
const toObject = {};
|
|
3842
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3843
|
+
'sdkHttpResponse',
|
|
3844
|
+
]);
|
|
3845
|
+
if (fromSdkHttpResponse != null) {
|
|
3846
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3847
|
+
}
|
|
3804
3848
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
3805
3849
|
if (fromName != null) {
|
|
3806
3850
|
setValueByPath(toObject, ['name'], fromName);
|
|
@@ -3950,6 +3994,12 @@ function listBatchJobsResponseFromVertex(fromObject) {
|
|
|
3950
3994
|
}
|
|
3951
3995
|
function deleteResourceJobFromVertex(fromObject) {
|
|
3952
3996
|
const toObject = {};
|
|
3997
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3998
|
+
'sdkHttpResponse',
|
|
3999
|
+
]);
|
|
4000
|
+
if (fromSdkHttpResponse != null) {
|
|
4001
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
4002
|
+
}
|
|
3953
4003
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
3954
4004
|
if (fromName != null) {
|
|
3955
4005
|
setValueByPath(toObject, ['name'], fromName);
|
|
@@ -4495,7 +4545,13 @@ class Batches extends BaseModule {
|
|
|
4495
4545
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4496
4546
|
})
|
|
4497
4547
|
.then((httpResponse) => {
|
|
4498
|
-
return httpResponse.json()
|
|
4548
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4549
|
+
const response = jsonResponse;
|
|
4550
|
+
response.sdkHttpResponse = {
|
|
4551
|
+
headers: httpResponse.headers,
|
|
4552
|
+
};
|
|
4553
|
+
return response;
|
|
4554
|
+
});
|
|
4499
4555
|
});
|
|
4500
4556
|
return response.then((apiResponse) => {
|
|
4501
4557
|
const resp = deleteResourceJobFromVertex(apiResponse);
|
|
@@ -4519,7 +4575,13 @@ class Batches extends BaseModule {
|
|
|
4519
4575
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
4520
4576
|
})
|
|
4521
4577
|
.then((httpResponse) => {
|
|
4522
|
-
return httpResponse.json()
|
|
4578
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4579
|
+
const response = jsonResponse;
|
|
4580
|
+
response.sdkHttpResponse = {
|
|
4581
|
+
headers: httpResponse.headers,
|
|
4582
|
+
};
|
|
4583
|
+
return response;
|
|
4584
|
+
});
|
|
4523
4585
|
});
|
|
4524
4586
|
return response.then((apiResponse) => {
|
|
4525
4587
|
const resp = deleteResourceJobFromMldev(apiResponse);
|
|
@@ -6390,7 +6452,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6390
6452
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6391
6453
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6392
6454
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6393
|
-
const SDK_VERSION = '1.
|
|
6455
|
+
const SDK_VERSION = '1.13.0'; // x-release-please-version
|
|
6394
6456
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6395
6457
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6396
6458
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -8277,6 +8339,12 @@ function liveMusicGenerationConfigToMldev(fromObject) {
|
|
|
8277
8339
|
if (fromOnlyBassAndDrums != null) {
|
|
8278
8340
|
setValueByPath(toObject, ['onlyBassAndDrums'], fromOnlyBassAndDrums);
|
|
8279
8341
|
}
|
|
8342
|
+
const fromMusicGenerationMode = getValueByPath(fromObject, [
|
|
8343
|
+
'musicGenerationMode',
|
|
8344
|
+
]);
|
|
8345
|
+
if (fromMusicGenerationMode != null) {
|
|
8346
|
+
setValueByPath(toObject, ['musicGenerationMode'], fromMusicGenerationMode);
|
|
8347
|
+
}
|
|
8280
8348
|
return toObject;
|
|
8281
8349
|
}
|
|
8282
8350
|
function liveMusicSetConfigParametersToMldev(fromObject) {
|
|
@@ -9435,6 +9503,12 @@ function liveMusicGenerationConfigFromMldev(fromObject) {
|
|
|
9435
9503
|
if (fromOnlyBassAndDrums != null) {
|
|
9436
9504
|
setValueByPath(toObject, ['onlyBassAndDrums'], fromOnlyBassAndDrums);
|
|
9437
9505
|
}
|
|
9506
|
+
const fromMusicGenerationMode = getValueByPath(fromObject, [
|
|
9507
|
+
'musicGenerationMode',
|
|
9508
|
+
]);
|
|
9509
|
+
if (fromMusicGenerationMode != null) {
|
|
9510
|
+
setValueByPath(toObject, ['musicGenerationMode'], fromMusicGenerationMode);
|
|
9511
|
+
}
|
|
9438
9512
|
return toObject;
|
|
9439
9513
|
}
|
|
9440
9514
|
function liveMusicSourceMetadataFromMldev(fromObject) {
|
|
@@ -10701,8 +10775,9 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
|
|
|
10701
10775
|
if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
|
|
10702
10776
|
throw new Error('addWatermark parameter is not supported in Gemini API.');
|
|
10703
10777
|
}
|
|
10704
|
-
|
|
10705
|
-
|
|
10778
|
+
const fromImageSize = getValueByPath(fromObject, ['imageSize']);
|
|
10779
|
+
if (parentObject !== undefined && fromImageSize != null) {
|
|
10780
|
+
setValueByPath(parentObject, ['parameters', 'sampleImageSize'], fromImageSize);
|
|
10706
10781
|
}
|
|
10707
10782
|
if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
|
|
10708
10783
|
throw new Error('enhancePrompt parameter is not supported in Gemini API.');
|
|
@@ -12104,6 +12179,106 @@ function upscaleImageAPIParametersInternalToVertex(apiClient, fromObject) {
|
|
|
12104
12179
|
}
|
|
12105
12180
|
return toObject;
|
|
12106
12181
|
}
|
|
12182
|
+
function productImageToVertex(fromObject) {
|
|
12183
|
+
const toObject = {};
|
|
12184
|
+
const fromProductImage = getValueByPath(fromObject, ['productImage']);
|
|
12185
|
+
if (fromProductImage != null) {
|
|
12186
|
+
setValueByPath(toObject, ['image'], imageToVertex(fromProductImage));
|
|
12187
|
+
}
|
|
12188
|
+
return toObject;
|
|
12189
|
+
}
|
|
12190
|
+
function recontextImageSourceToVertex(fromObject, parentObject) {
|
|
12191
|
+
const toObject = {};
|
|
12192
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12193
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12194
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12195
|
+
}
|
|
12196
|
+
const fromPersonImage = getValueByPath(fromObject, ['personImage']);
|
|
12197
|
+
if (parentObject !== undefined && fromPersonImage != null) {
|
|
12198
|
+
setValueByPath(parentObject, ['instances[0]', 'personImage', 'image'], imageToVertex(fromPersonImage));
|
|
12199
|
+
}
|
|
12200
|
+
const fromProductImages = getValueByPath(fromObject, [
|
|
12201
|
+
'productImages',
|
|
12202
|
+
]);
|
|
12203
|
+
if (parentObject !== undefined && fromProductImages != null) {
|
|
12204
|
+
let transformedList = fromProductImages;
|
|
12205
|
+
if (Array.isArray(transformedList)) {
|
|
12206
|
+
transformedList = transformedList.map((item) => {
|
|
12207
|
+
return productImageToVertex(item);
|
|
12208
|
+
});
|
|
12209
|
+
}
|
|
12210
|
+
setValueByPath(parentObject, ['instances[0]', 'productImages'], transformedList);
|
|
12211
|
+
}
|
|
12212
|
+
return toObject;
|
|
12213
|
+
}
|
|
12214
|
+
function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
12215
|
+
const toObject = {};
|
|
12216
|
+
const fromNumberOfImages = getValueByPath(fromObject, [
|
|
12217
|
+
'numberOfImages',
|
|
12218
|
+
]);
|
|
12219
|
+
if (parentObject !== undefined && fromNumberOfImages != null) {
|
|
12220
|
+
setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
|
|
12221
|
+
}
|
|
12222
|
+
const fromBaseSteps = getValueByPath(fromObject, ['baseSteps']);
|
|
12223
|
+
if (parentObject !== undefined && fromBaseSteps != null) {
|
|
12224
|
+
setValueByPath(parentObject, ['parameters', 'editConfig', 'baseSteps'], fromBaseSteps);
|
|
12225
|
+
}
|
|
12226
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
12227
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
12228
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
12229
|
+
}
|
|
12230
|
+
const fromSeed = getValueByPath(fromObject, ['seed']);
|
|
12231
|
+
if (parentObject !== undefined && fromSeed != null) {
|
|
12232
|
+
setValueByPath(parentObject, ['parameters', 'seed'], fromSeed);
|
|
12233
|
+
}
|
|
12234
|
+
const fromSafetyFilterLevel = getValueByPath(fromObject, [
|
|
12235
|
+
'safetyFilterLevel',
|
|
12236
|
+
]);
|
|
12237
|
+
if (parentObject !== undefined && fromSafetyFilterLevel != null) {
|
|
12238
|
+
setValueByPath(parentObject, ['parameters', 'safetySetting'], fromSafetyFilterLevel);
|
|
12239
|
+
}
|
|
12240
|
+
const fromPersonGeneration = getValueByPath(fromObject, [
|
|
12241
|
+
'personGeneration',
|
|
12242
|
+
]);
|
|
12243
|
+
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
12244
|
+
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
12245
|
+
}
|
|
12246
|
+
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
12247
|
+
'outputMimeType',
|
|
12248
|
+
]);
|
|
12249
|
+
if (parentObject !== undefined && fromOutputMimeType != null) {
|
|
12250
|
+
setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
|
|
12251
|
+
}
|
|
12252
|
+
const fromOutputCompressionQuality = getValueByPath(fromObject, [
|
|
12253
|
+
'outputCompressionQuality',
|
|
12254
|
+
]);
|
|
12255
|
+
if (parentObject !== undefined && fromOutputCompressionQuality != null) {
|
|
12256
|
+
setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
|
|
12257
|
+
}
|
|
12258
|
+
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
12259
|
+
'enhancePrompt',
|
|
12260
|
+
]);
|
|
12261
|
+
if (parentObject !== undefined && fromEnhancePrompt != null) {
|
|
12262
|
+
setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
|
|
12263
|
+
}
|
|
12264
|
+
return toObject;
|
|
12265
|
+
}
|
|
12266
|
+
function recontextImageParametersToVertex(apiClient, fromObject) {
|
|
12267
|
+
const toObject = {};
|
|
12268
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
12269
|
+
if (fromModel != null) {
|
|
12270
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
12271
|
+
}
|
|
12272
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12273
|
+
if (fromSource != null) {
|
|
12274
|
+
setValueByPath(toObject, ['config'], recontextImageSourceToVertex(fromSource, toObject));
|
|
12275
|
+
}
|
|
12276
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12277
|
+
if (fromConfig != null) {
|
|
12278
|
+
setValueByPath(toObject, ['config'], recontextImageConfigToVertex(fromConfig, toObject));
|
|
12279
|
+
}
|
|
12280
|
+
return toObject;
|
|
12281
|
+
}
|
|
12107
12282
|
function getModelParametersToVertex(apiClient, fromObject) {
|
|
12108
12283
|
const toObject = {};
|
|
12109
12284
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
@@ -12600,6 +12775,10 @@ function generateContentResponseFromMldev(fromObject) {
|
|
|
12600
12775
|
if (fromPromptFeedback != null) {
|
|
12601
12776
|
setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
|
|
12602
12777
|
}
|
|
12778
|
+
const fromResponseId = getValueByPath(fromObject, ['responseId']);
|
|
12779
|
+
if (fromResponseId != null) {
|
|
12780
|
+
setValueByPath(toObject, ['responseId'], fromResponseId);
|
|
12781
|
+
}
|
|
12603
12782
|
const fromUsageMetadata = getValueByPath(fromObject, [
|
|
12604
12783
|
'usageMetadata',
|
|
12605
12784
|
]);
|
|
@@ -13150,10 +13329,6 @@ function generateContentResponseFromVertex(fromObject) {
|
|
|
13150
13329
|
if (fromCreateTime != null) {
|
|
13151
13330
|
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
13152
13331
|
}
|
|
13153
|
-
const fromResponseId = getValueByPath(fromObject, ['responseId']);
|
|
13154
|
-
if (fromResponseId != null) {
|
|
13155
|
-
setValueByPath(toObject, ['responseId'], fromResponseId);
|
|
13156
|
-
}
|
|
13157
13332
|
const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
|
|
13158
13333
|
if (fromModelVersion != null) {
|
|
13159
13334
|
setValueByPath(toObject, ['modelVersion'], fromModelVersion);
|
|
@@ -13164,6 +13339,10 @@ function generateContentResponseFromVertex(fromObject) {
|
|
|
13164
13339
|
if (fromPromptFeedback != null) {
|
|
13165
13340
|
setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
|
|
13166
13341
|
}
|
|
13342
|
+
const fromResponseId = getValueByPath(fromObject, ['responseId']);
|
|
13343
|
+
if (fromResponseId != null) {
|
|
13344
|
+
setValueByPath(toObject, ['responseId'], fromResponseId);
|
|
13345
|
+
}
|
|
13167
13346
|
const fromUsageMetadata = getValueByPath(fromObject, [
|
|
13168
13347
|
'usageMetadata',
|
|
13169
13348
|
]);
|
|
@@ -13367,6 +13546,22 @@ function upscaleImageResponseFromVertex(fromObject) {
|
|
|
13367
13546
|
}
|
|
13368
13547
|
return toObject;
|
|
13369
13548
|
}
|
|
13549
|
+
function recontextImageResponseFromVertex(fromObject) {
|
|
13550
|
+
const toObject = {};
|
|
13551
|
+
const fromGeneratedImages = getValueByPath(fromObject, [
|
|
13552
|
+
'predictions',
|
|
13553
|
+
]);
|
|
13554
|
+
if (fromGeneratedImages != null) {
|
|
13555
|
+
let transformedList = fromGeneratedImages;
|
|
13556
|
+
if (Array.isArray(transformedList)) {
|
|
13557
|
+
transformedList = transformedList.map((item) => {
|
|
13558
|
+
return generatedImageFromVertex(item);
|
|
13559
|
+
});
|
|
13560
|
+
}
|
|
13561
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
13562
|
+
}
|
|
13563
|
+
return toObject;
|
|
13564
|
+
}
|
|
13370
13565
|
function endpointFromVertex(fromObject) {
|
|
13371
13566
|
const toObject = {};
|
|
13372
13567
|
const fromName = getValueByPath(fromObject, ['endpoint']);
|
|
@@ -15410,6 +15605,79 @@ class Models extends BaseModule {
|
|
|
15410
15605
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
15411
15606
|
}
|
|
15412
15607
|
}
|
|
15608
|
+
/**
|
|
15609
|
+
* Recontextualizes an image.
|
|
15610
|
+
*
|
|
15611
|
+
* There are two types of recontextualization currently supported:
|
|
15612
|
+
* 1) Imagen Product Recontext - Generate images of products in new scenes
|
|
15613
|
+
* and contexts.
|
|
15614
|
+
* 2) Virtual Try-On: Generate images of persons modeling fashion products.
|
|
15615
|
+
*
|
|
15616
|
+
* @param params - The parameters for recontextualizing an image.
|
|
15617
|
+
* @return The response from the API.
|
|
15618
|
+
*
|
|
15619
|
+
* @example
|
|
15620
|
+
* ```ts
|
|
15621
|
+
* const response1 = await ai.models.recontextImage({
|
|
15622
|
+
* model: 'imagen-product-recontext-preview-06-30',
|
|
15623
|
+
* source: {
|
|
15624
|
+
* prompt: 'In a modern kitchen setting.',
|
|
15625
|
+
* productImages: [productImage],
|
|
15626
|
+
* },
|
|
15627
|
+
* config: {
|
|
15628
|
+
* numberOfImages: 1,
|
|
15629
|
+
* },
|
|
15630
|
+
* });
|
|
15631
|
+
* console.log(response1?.generatedImages?.[0]?.image?.imageBytes);
|
|
15632
|
+
*
|
|
15633
|
+
* const response2 = await ai.models.recontextImage({
|
|
15634
|
+
* model: 'virtual-try-on-preview-08-04',
|
|
15635
|
+
* source: {
|
|
15636
|
+
* personImage: personImage,
|
|
15637
|
+
* productImages: [productImage],
|
|
15638
|
+
* },
|
|
15639
|
+
* config: {
|
|
15640
|
+
* numberOfImages: 1,
|
|
15641
|
+
* },
|
|
15642
|
+
* });
|
|
15643
|
+
* console.log(response2?.generatedImages?.[0]?.image?.imageBytes);
|
|
15644
|
+
* ```
|
|
15645
|
+
*/
|
|
15646
|
+
async recontextImage(params) {
|
|
15647
|
+
var _a, _b;
|
|
15648
|
+
let response;
|
|
15649
|
+
let path = '';
|
|
15650
|
+
let queryParams = {};
|
|
15651
|
+
if (this.apiClient.isVertexAI()) {
|
|
15652
|
+
const body = recontextImageParametersToVertex(this.apiClient, params);
|
|
15653
|
+
path = formatMap('{model}:predict', body['_url']);
|
|
15654
|
+
queryParams = body['_query'];
|
|
15655
|
+
delete body['config'];
|
|
15656
|
+
delete body['_url'];
|
|
15657
|
+
delete body['_query'];
|
|
15658
|
+
response = this.apiClient
|
|
15659
|
+
.request({
|
|
15660
|
+
path: path,
|
|
15661
|
+
queryParams: queryParams,
|
|
15662
|
+
body: JSON.stringify(body),
|
|
15663
|
+
httpMethod: 'POST',
|
|
15664
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15665
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15666
|
+
})
|
|
15667
|
+
.then((httpResponse) => {
|
|
15668
|
+
return httpResponse.json();
|
|
15669
|
+
});
|
|
15670
|
+
return response.then((apiResponse) => {
|
|
15671
|
+
const resp = recontextImageResponseFromVertex(apiResponse);
|
|
15672
|
+
const typedResp = new RecontextImageResponse();
|
|
15673
|
+
Object.assign(typedResp, resp);
|
|
15674
|
+
return typedResp;
|
|
15675
|
+
});
|
|
15676
|
+
}
|
|
15677
|
+
else {
|
|
15678
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
15679
|
+
}
|
|
15680
|
+
}
|
|
15413
15681
|
/**
|
|
15414
15682
|
* Fetches information about a model by name.
|
|
15415
15683
|
*
|
|
@@ -17963,5 +18231,5 @@ class GoogleGenAI {
|
|
|
17963
18231
|
}
|
|
17964
18232
|
}
|
|
17965
18233
|
|
|
17966
|
-
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
18234
|
+
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
17967
18235
|
//# sourceMappingURL=index.mjs.map
|