@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/node/index.mjs
CHANGED
|
@@ -450,6 +450,14 @@ var UrlRetrievalStatus;
|
|
|
450
450
|
* Url retrieval is failed due to error.
|
|
451
451
|
*/
|
|
452
452
|
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_ERROR"] = "URL_RETRIEVAL_STATUS_ERROR";
|
|
453
|
+
/**
|
|
454
|
+
* Url retrieval is failed because the content is behind paywall.
|
|
455
|
+
*/
|
|
456
|
+
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_PAYWALL"] = "URL_RETRIEVAL_STATUS_PAYWALL";
|
|
457
|
+
/**
|
|
458
|
+
* Url retrieval is failed because the content is unsafe.
|
|
459
|
+
*/
|
|
460
|
+
UrlRetrievalStatus["URL_RETRIEVAL_STATUS_UNSAFE"] = "URL_RETRIEVAL_STATUS_UNSAFE";
|
|
453
461
|
})(UrlRetrievalStatus || (UrlRetrievalStatus = {}));
|
|
454
462
|
/** Output only. The reason why the model stopped generating tokens.
|
|
455
463
|
|
|
@@ -1076,6 +1084,29 @@ var Scale;
|
|
|
1076
1084
|
*/
|
|
1077
1085
|
Scale["B_MAJOR_A_FLAT_MINOR"] = "B_MAJOR_A_FLAT_MINOR";
|
|
1078
1086
|
})(Scale || (Scale = {}));
|
|
1087
|
+
/** The mode of music generation. */
|
|
1088
|
+
var MusicGenerationMode;
|
|
1089
|
+
(function (MusicGenerationMode) {
|
|
1090
|
+
/**
|
|
1091
|
+
* Rely on the server default generation mode.
|
|
1092
|
+
*/
|
|
1093
|
+
MusicGenerationMode["MUSIC_GENERATION_MODE_UNSPECIFIED"] = "MUSIC_GENERATION_MODE_UNSPECIFIED";
|
|
1094
|
+
/**
|
|
1095
|
+
* Steer text prompts to regions of latent space with higher quality
|
|
1096
|
+
music.
|
|
1097
|
+
*/
|
|
1098
|
+
MusicGenerationMode["QUALITY"] = "QUALITY";
|
|
1099
|
+
/**
|
|
1100
|
+
* Steer text prompts to regions of latent space with a larger
|
|
1101
|
+
diversity of music.
|
|
1102
|
+
*/
|
|
1103
|
+
MusicGenerationMode["DIVERSITY"] = "DIVERSITY";
|
|
1104
|
+
/**
|
|
1105
|
+
* Steer text prompts to regions of latent space more likely to
|
|
1106
|
+
generate music with vocals.
|
|
1107
|
+
*/
|
|
1108
|
+
MusicGenerationMode["VOCALIZATION"] = "VOCALIZATION";
|
|
1109
|
+
})(MusicGenerationMode || (MusicGenerationMode = {}));
|
|
1079
1110
|
/** The playback control signal to apply to the music generation. */
|
|
1080
1111
|
var LiveMusicPlaybackControl;
|
|
1081
1112
|
(function (LiveMusicPlaybackControl) {
|
|
@@ -1499,6 +1530,9 @@ class EditImageResponse {
|
|
|
1499
1530
|
}
|
|
1500
1531
|
class UpscaleImageResponse {
|
|
1501
1532
|
}
|
|
1533
|
+
/** The output images response. */
|
|
1534
|
+
class RecontextImageResponse {
|
|
1535
|
+
}
|
|
1502
1536
|
class ListModelsResponse {
|
|
1503
1537
|
}
|
|
1504
1538
|
class DeleteModelResponse {
|
|
@@ -3704,6 +3738,10 @@ function generateContentResponseFromMldev$1(fromObject) {
|
|
|
3704
3738
|
if (fromPromptFeedback != null) {
|
|
3705
3739
|
setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
|
|
3706
3740
|
}
|
|
3741
|
+
const fromResponseId = getValueByPath(fromObject, ['responseId']);
|
|
3742
|
+
if (fromResponseId != null) {
|
|
3743
|
+
setValueByPath(toObject, ['responseId'], fromResponseId);
|
|
3744
|
+
}
|
|
3707
3745
|
const fromUsageMetadata = getValueByPath(fromObject, [
|
|
3708
3746
|
'usageMetadata',
|
|
3709
3747
|
]);
|
|
@@ -3837,6 +3875,12 @@ function listBatchJobsResponseFromMldev(fromObject) {
|
|
|
3837
3875
|
}
|
|
3838
3876
|
function deleteResourceJobFromMldev(fromObject) {
|
|
3839
3877
|
const toObject = {};
|
|
3878
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3879
|
+
'sdkHttpResponse',
|
|
3880
|
+
]);
|
|
3881
|
+
if (fromSdkHttpResponse != null) {
|
|
3882
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3883
|
+
}
|
|
3840
3884
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
3841
3885
|
if (fromName != null) {
|
|
3842
3886
|
setValueByPath(toObject, ['name'], fromName);
|
|
@@ -3986,6 +4030,12 @@ function listBatchJobsResponseFromVertex(fromObject) {
|
|
|
3986
4030
|
}
|
|
3987
4031
|
function deleteResourceJobFromVertex(fromObject) {
|
|
3988
4032
|
const toObject = {};
|
|
4033
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
4034
|
+
'sdkHttpResponse',
|
|
4035
|
+
]);
|
|
4036
|
+
if (fromSdkHttpResponse != null) {
|
|
4037
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
4038
|
+
}
|
|
3989
4039
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
3990
4040
|
if (fromName != null) {
|
|
3991
4041
|
setValueByPath(toObject, ['name'], fromName);
|
|
@@ -4531,7 +4581,13 @@ class Batches extends BaseModule {
|
|
|
4531
4581
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4532
4582
|
})
|
|
4533
4583
|
.then((httpResponse) => {
|
|
4534
|
-
return httpResponse.json()
|
|
4584
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4585
|
+
const response = jsonResponse;
|
|
4586
|
+
response.sdkHttpResponse = {
|
|
4587
|
+
headers: httpResponse.headers,
|
|
4588
|
+
};
|
|
4589
|
+
return response;
|
|
4590
|
+
});
|
|
4535
4591
|
});
|
|
4536
4592
|
return response.then((apiResponse) => {
|
|
4537
4593
|
const resp = deleteResourceJobFromVertex(apiResponse);
|
|
@@ -4555,7 +4611,13 @@ class Batches extends BaseModule {
|
|
|
4555
4611
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
4556
4612
|
})
|
|
4557
4613
|
.then((httpResponse) => {
|
|
4558
|
-
return httpResponse.json()
|
|
4614
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4615
|
+
const response = jsonResponse;
|
|
4616
|
+
response.sdkHttpResponse = {
|
|
4617
|
+
headers: httpResponse.headers,
|
|
4618
|
+
};
|
|
4619
|
+
return response;
|
|
4620
|
+
});
|
|
4559
4621
|
});
|
|
4560
4622
|
return response.then((apiResponse) => {
|
|
4561
4623
|
const resp = deleteResourceJobFromMldev(apiResponse);
|
|
@@ -7616,6 +7678,12 @@ function liveMusicGenerationConfigToMldev(fromObject) {
|
|
|
7616
7678
|
if (fromOnlyBassAndDrums != null) {
|
|
7617
7679
|
setValueByPath(toObject, ['onlyBassAndDrums'], fromOnlyBassAndDrums);
|
|
7618
7680
|
}
|
|
7681
|
+
const fromMusicGenerationMode = getValueByPath(fromObject, [
|
|
7682
|
+
'musicGenerationMode',
|
|
7683
|
+
]);
|
|
7684
|
+
if (fromMusicGenerationMode != null) {
|
|
7685
|
+
setValueByPath(toObject, ['musicGenerationMode'], fromMusicGenerationMode);
|
|
7686
|
+
}
|
|
7619
7687
|
return toObject;
|
|
7620
7688
|
}
|
|
7621
7689
|
function liveMusicSetConfigParametersToMldev(fromObject) {
|
|
@@ -8774,6 +8842,12 @@ function liveMusicGenerationConfigFromMldev(fromObject) {
|
|
|
8774
8842
|
if (fromOnlyBassAndDrums != null) {
|
|
8775
8843
|
setValueByPath(toObject, ['onlyBassAndDrums'], fromOnlyBassAndDrums);
|
|
8776
8844
|
}
|
|
8845
|
+
const fromMusicGenerationMode = getValueByPath(fromObject, [
|
|
8846
|
+
'musicGenerationMode',
|
|
8847
|
+
]);
|
|
8848
|
+
if (fromMusicGenerationMode != null) {
|
|
8849
|
+
setValueByPath(toObject, ['musicGenerationMode'], fromMusicGenerationMode);
|
|
8850
|
+
}
|
|
8777
8851
|
return toObject;
|
|
8778
8852
|
}
|
|
8779
8853
|
function liveMusicSourceMetadataFromMldev(fromObject) {
|
|
@@ -10040,8 +10114,9 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
|
|
|
10040
10114
|
if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
|
|
10041
10115
|
throw new Error('addWatermark parameter is not supported in Gemini API.');
|
|
10042
10116
|
}
|
|
10043
|
-
|
|
10044
|
-
|
|
10117
|
+
const fromImageSize = getValueByPath(fromObject, ['imageSize']);
|
|
10118
|
+
if (parentObject !== undefined && fromImageSize != null) {
|
|
10119
|
+
setValueByPath(parentObject, ['parameters', 'sampleImageSize'], fromImageSize);
|
|
10045
10120
|
}
|
|
10046
10121
|
if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
|
|
10047
10122
|
throw new Error('enhancePrompt parameter is not supported in Gemini API.');
|
|
@@ -11443,6 +11518,106 @@ function upscaleImageAPIParametersInternalToVertex(apiClient, fromObject) {
|
|
|
11443
11518
|
}
|
|
11444
11519
|
return toObject;
|
|
11445
11520
|
}
|
|
11521
|
+
function productImageToVertex(fromObject) {
|
|
11522
|
+
const toObject = {};
|
|
11523
|
+
const fromProductImage = getValueByPath(fromObject, ['productImage']);
|
|
11524
|
+
if (fromProductImage != null) {
|
|
11525
|
+
setValueByPath(toObject, ['image'], imageToVertex(fromProductImage));
|
|
11526
|
+
}
|
|
11527
|
+
return toObject;
|
|
11528
|
+
}
|
|
11529
|
+
function recontextImageSourceToVertex(fromObject, parentObject) {
|
|
11530
|
+
const toObject = {};
|
|
11531
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
11532
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
11533
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
11534
|
+
}
|
|
11535
|
+
const fromPersonImage = getValueByPath(fromObject, ['personImage']);
|
|
11536
|
+
if (parentObject !== undefined && fromPersonImage != null) {
|
|
11537
|
+
setValueByPath(parentObject, ['instances[0]', 'personImage', 'image'], imageToVertex(fromPersonImage));
|
|
11538
|
+
}
|
|
11539
|
+
const fromProductImages = getValueByPath(fromObject, [
|
|
11540
|
+
'productImages',
|
|
11541
|
+
]);
|
|
11542
|
+
if (parentObject !== undefined && fromProductImages != null) {
|
|
11543
|
+
let transformedList = fromProductImages;
|
|
11544
|
+
if (Array.isArray(transformedList)) {
|
|
11545
|
+
transformedList = transformedList.map((item) => {
|
|
11546
|
+
return productImageToVertex(item);
|
|
11547
|
+
});
|
|
11548
|
+
}
|
|
11549
|
+
setValueByPath(parentObject, ['instances[0]', 'productImages'], transformedList);
|
|
11550
|
+
}
|
|
11551
|
+
return toObject;
|
|
11552
|
+
}
|
|
11553
|
+
function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
11554
|
+
const toObject = {};
|
|
11555
|
+
const fromNumberOfImages = getValueByPath(fromObject, [
|
|
11556
|
+
'numberOfImages',
|
|
11557
|
+
]);
|
|
11558
|
+
if (parentObject !== undefined && fromNumberOfImages != null) {
|
|
11559
|
+
setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
|
|
11560
|
+
}
|
|
11561
|
+
const fromBaseSteps = getValueByPath(fromObject, ['baseSteps']);
|
|
11562
|
+
if (parentObject !== undefined && fromBaseSteps != null) {
|
|
11563
|
+
setValueByPath(parentObject, ['parameters', 'editConfig', 'baseSteps'], fromBaseSteps);
|
|
11564
|
+
}
|
|
11565
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
11566
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
11567
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
11568
|
+
}
|
|
11569
|
+
const fromSeed = getValueByPath(fromObject, ['seed']);
|
|
11570
|
+
if (parentObject !== undefined && fromSeed != null) {
|
|
11571
|
+
setValueByPath(parentObject, ['parameters', 'seed'], fromSeed);
|
|
11572
|
+
}
|
|
11573
|
+
const fromSafetyFilterLevel = getValueByPath(fromObject, [
|
|
11574
|
+
'safetyFilterLevel',
|
|
11575
|
+
]);
|
|
11576
|
+
if (parentObject !== undefined && fromSafetyFilterLevel != null) {
|
|
11577
|
+
setValueByPath(parentObject, ['parameters', 'safetySetting'], fromSafetyFilterLevel);
|
|
11578
|
+
}
|
|
11579
|
+
const fromPersonGeneration = getValueByPath(fromObject, [
|
|
11580
|
+
'personGeneration',
|
|
11581
|
+
]);
|
|
11582
|
+
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
11583
|
+
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
11584
|
+
}
|
|
11585
|
+
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
11586
|
+
'outputMimeType',
|
|
11587
|
+
]);
|
|
11588
|
+
if (parentObject !== undefined && fromOutputMimeType != null) {
|
|
11589
|
+
setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
|
|
11590
|
+
}
|
|
11591
|
+
const fromOutputCompressionQuality = getValueByPath(fromObject, [
|
|
11592
|
+
'outputCompressionQuality',
|
|
11593
|
+
]);
|
|
11594
|
+
if (parentObject !== undefined && fromOutputCompressionQuality != null) {
|
|
11595
|
+
setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
|
|
11596
|
+
}
|
|
11597
|
+
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
11598
|
+
'enhancePrompt',
|
|
11599
|
+
]);
|
|
11600
|
+
if (parentObject !== undefined && fromEnhancePrompt != null) {
|
|
11601
|
+
setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
|
|
11602
|
+
}
|
|
11603
|
+
return toObject;
|
|
11604
|
+
}
|
|
11605
|
+
function recontextImageParametersToVertex(apiClient, fromObject) {
|
|
11606
|
+
const toObject = {};
|
|
11607
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
11608
|
+
if (fromModel != null) {
|
|
11609
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
11610
|
+
}
|
|
11611
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
11612
|
+
if (fromSource != null) {
|
|
11613
|
+
setValueByPath(toObject, ['config'], recontextImageSourceToVertex(fromSource, toObject));
|
|
11614
|
+
}
|
|
11615
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
11616
|
+
if (fromConfig != null) {
|
|
11617
|
+
setValueByPath(toObject, ['config'], recontextImageConfigToVertex(fromConfig, toObject));
|
|
11618
|
+
}
|
|
11619
|
+
return toObject;
|
|
11620
|
+
}
|
|
11446
11621
|
function getModelParametersToVertex(apiClient, fromObject) {
|
|
11447
11622
|
const toObject = {};
|
|
11448
11623
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
@@ -11939,6 +12114,10 @@ function generateContentResponseFromMldev(fromObject) {
|
|
|
11939
12114
|
if (fromPromptFeedback != null) {
|
|
11940
12115
|
setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
|
|
11941
12116
|
}
|
|
12117
|
+
const fromResponseId = getValueByPath(fromObject, ['responseId']);
|
|
12118
|
+
if (fromResponseId != null) {
|
|
12119
|
+
setValueByPath(toObject, ['responseId'], fromResponseId);
|
|
12120
|
+
}
|
|
11942
12121
|
const fromUsageMetadata = getValueByPath(fromObject, [
|
|
11943
12122
|
'usageMetadata',
|
|
11944
12123
|
]);
|
|
@@ -12489,10 +12668,6 @@ function generateContentResponseFromVertex(fromObject) {
|
|
|
12489
12668
|
if (fromCreateTime != null) {
|
|
12490
12669
|
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
12491
12670
|
}
|
|
12492
|
-
const fromResponseId = getValueByPath(fromObject, ['responseId']);
|
|
12493
|
-
if (fromResponseId != null) {
|
|
12494
|
-
setValueByPath(toObject, ['responseId'], fromResponseId);
|
|
12495
|
-
}
|
|
12496
12671
|
const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
|
|
12497
12672
|
if (fromModelVersion != null) {
|
|
12498
12673
|
setValueByPath(toObject, ['modelVersion'], fromModelVersion);
|
|
@@ -12503,6 +12678,10 @@ function generateContentResponseFromVertex(fromObject) {
|
|
|
12503
12678
|
if (fromPromptFeedback != null) {
|
|
12504
12679
|
setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
|
|
12505
12680
|
}
|
|
12681
|
+
const fromResponseId = getValueByPath(fromObject, ['responseId']);
|
|
12682
|
+
if (fromResponseId != null) {
|
|
12683
|
+
setValueByPath(toObject, ['responseId'], fromResponseId);
|
|
12684
|
+
}
|
|
12506
12685
|
const fromUsageMetadata = getValueByPath(fromObject, [
|
|
12507
12686
|
'usageMetadata',
|
|
12508
12687
|
]);
|
|
@@ -12706,6 +12885,22 @@ function upscaleImageResponseFromVertex(fromObject) {
|
|
|
12706
12885
|
}
|
|
12707
12886
|
return toObject;
|
|
12708
12887
|
}
|
|
12888
|
+
function recontextImageResponseFromVertex(fromObject) {
|
|
12889
|
+
const toObject = {};
|
|
12890
|
+
const fromGeneratedImages = getValueByPath(fromObject, [
|
|
12891
|
+
'predictions',
|
|
12892
|
+
]);
|
|
12893
|
+
if (fromGeneratedImages != null) {
|
|
12894
|
+
let transformedList = fromGeneratedImages;
|
|
12895
|
+
if (Array.isArray(transformedList)) {
|
|
12896
|
+
transformedList = transformedList.map((item) => {
|
|
12897
|
+
return generatedImageFromVertex(item);
|
|
12898
|
+
});
|
|
12899
|
+
}
|
|
12900
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
12901
|
+
}
|
|
12902
|
+
return toObject;
|
|
12903
|
+
}
|
|
12709
12904
|
function endpointFromVertex(fromObject) {
|
|
12710
12905
|
const toObject = {};
|
|
12711
12906
|
const fromName = getValueByPath(fromObject, ['endpoint']);
|
|
@@ -12953,7 +13148,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12953
13148
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12954
13149
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12955
13150
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12956
|
-
const SDK_VERSION = '1.
|
|
13151
|
+
const SDK_VERSION = '1.13.0'; // x-release-please-version
|
|
12957
13152
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12958
13153
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12959
13154
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -15323,6 +15518,79 @@ class Models extends BaseModule {
|
|
|
15323
15518
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
15324
15519
|
}
|
|
15325
15520
|
}
|
|
15521
|
+
/**
|
|
15522
|
+
* Recontextualizes an image.
|
|
15523
|
+
*
|
|
15524
|
+
* There are two types of recontextualization currently supported:
|
|
15525
|
+
* 1) Imagen Product Recontext - Generate images of products in new scenes
|
|
15526
|
+
* and contexts.
|
|
15527
|
+
* 2) Virtual Try-On: Generate images of persons modeling fashion products.
|
|
15528
|
+
*
|
|
15529
|
+
* @param params - The parameters for recontextualizing an image.
|
|
15530
|
+
* @return The response from the API.
|
|
15531
|
+
*
|
|
15532
|
+
* @example
|
|
15533
|
+
* ```ts
|
|
15534
|
+
* const response1 = await ai.models.recontextImage({
|
|
15535
|
+
* model: 'imagen-product-recontext-preview-06-30',
|
|
15536
|
+
* source: {
|
|
15537
|
+
* prompt: 'In a modern kitchen setting.',
|
|
15538
|
+
* productImages: [productImage],
|
|
15539
|
+
* },
|
|
15540
|
+
* config: {
|
|
15541
|
+
* numberOfImages: 1,
|
|
15542
|
+
* },
|
|
15543
|
+
* });
|
|
15544
|
+
* console.log(response1?.generatedImages?.[0]?.image?.imageBytes);
|
|
15545
|
+
*
|
|
15546
|
+
* const response2 = await ai.models.recontextImage({
|
|
15547
|
+
* model: 'virtual-try-on-preview-08-04',
|
|
15548
|
+
* source: {
|
|
15549
|
+
* personImage: personImage,
|
|
15550
|
+
* productImages: [productImage],
|
|
15551
|
+
* },
|
|
15552
|
+
* config: {
|
|
15553
|
+
* numberOfImages: 1,
|
|
15554
|
+
* },
|
|
15555
|
+
* });
|
|
15556
|
+
* console.log(response2?.generatedImages?.[0]?.image?.imageBytes);
|
|
15557
|
+
* ```
|
|
15558
|
+
*/
|
|
15559
|
+
async recontextImage(params) {
|
|
15560
|
+
var _a, _b;
|
|
15561
|
+
let response;
|
|
15562
|
+
let path = '';
|
|
15563
|
+
let queryParams = {};
|
|
15564
|
+
if (this.apiClient.isVertexAI()) {
|
|
15565
|
+
const body = recontextImageParametersToVertex(this.apiClient, params);
|
|
15566
|
+
path = formatMap('{model}:predict', body['_url']);
|
|
15567
|
+
queryParams = body['_query'];
|
|
15568
|
+
delete body['config'];
|
|
15569
|
+
delete body['_url'];
|
|
15570
|
+
delete body['_query'];
|
|
15571
|
+
response = this.apiClient
|
|
15572
|
+
.request({
|
|
15573
|
+
path: path,
|
|
15574
|
+
queryParams: queryParams,
|
|
15575
|
+
body: JSON.stringify(body),
|
|
15576
|
+
httpMethod: 'POST',
|
|
15577
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
15578
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15579
|
+
})
|
|
15580
|
+
.then((httpResponse) => {
|
|
15581
|
+
return httpResponse.json();
|
|
15582
|
+
});
|
|
15583
|
+
return response.then((apiResponse) => {
|
|
15584
|
+
const resp = recontextImageResponseFromVertex(apiResponse);
|
|
15585
|
+
const typedResp = new RecontextImageResponse();
|
|
15586
|
+
Object.assign(typedResp, resp);
|
|
15587
|
+
return typedResp;
|
|
15588
|
+
});
|
|
15589
|
+
}
|
|
15590
|
+
else {
|
|
15591
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
15592
|
+
}
|
|
15593
|
+
}
|
|
15326
15594
|
/**
|
|
15327
15595
|
* Fetches information about a model by name.
|
|
15328
15596
|
*
|
|
@@ -18361,5 +18629,5 @@ function getApiKeyFromEnv() {
|
|
|
18361
18629
|
return envGoogleApiKey || envGeminiApiKey;
|
|
18362
18630
|
}
|
|
18363
18631
|
|
|
18364
|
-
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 };
|
|
18632
|
+
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 };
|
|
18365
18633
|
//# sourceMappingURL=index.mjs.map
|