climage 0.6.0 → 0.6.2
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/cli.js +25 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.js +25 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -417,6 +417,11 @@ function isKlingV3Model(model) {
|
|
|
417
417
|
function isViduModel(model) {
|
|
418
418
|
return model.includes("/vidu/");
|
|
419
419
|
}
|
|
420
|
+
function usesImageUrlsArray(model) {
|
|
421
|
+
if (model.includes("/hunyuan-image/") && model.includes("/edit")) return true;
|
|
422
|
+
if (model.includes("/kling-image/")) return true;
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
420
425
|
function selectVideoModel(req) {
|
|
421
426
|
if (req.model) return req.model;
|
|
422
427
|
if (req.startFrame && req.endFrame) {
|
|
@@ -504,8 +509,13 @@ function buildImageInput(req) {
|
|
|
504
509
|
if (imageSize) input.image_size = imageSize;
|
|
505
510
|
if (req.n) input.num_images = req.n;
|
|
506
511
|
if (req.inputImages?.[0]) {
|
|
507
|
-
|
|
508
|
-
|
|
512
|
+
const model = req.model ?? "";
|
|
513
|
+
if (usesImageUrlsArray(model)) {
|
|
514
|
+
input.image_urls = req.inputImages.slice(0, 3);
|
|
515
|
+
} else {
|
|
516
|
+
input.image_url = req.inputImages[0];
|
|
517
|
+
input.strength = 0.75;
|
|
518
|
+
}
|
|
509
519
|
}
|
|
510
520
|
return input;
|
|
511
521
|
}
|
|
@@ -1284,11 +1294,22 @@ async function generateVercelImage(req, apiKey) {
|
|
|
1284
1294
|
const gw = makeGateway(apiKey);
|
|
1285
1295
|
const model = req.model ?? DEFAULT_IMAGE_MODEL2;
|
|
1286
1296
|
log5("Starting image generation, model:", model);
|
|
1297
|
+
const hasInputImages = req.inputImages && req.inputImages.length > 0;
|
|
1298
|
+
let prompt;
|
|
1299
|
+
if (hasInputImages) {
|
|
1300
|
+
const images2 = req.inputImages.map(
|
|
1301
|
+
(img) => img.startsWith("data:") ? dataUriToUint8Array(img) : Uint8Array.from(Buffer.from(img))
|
|
1302
|
+
);
|
|
1303
|
+
prompt = { images: images2, text: req.prompt };
|
|
1304
|
+
log5("Using image editing mode with", images2.length, "input image(s)");
|
|
1305
|
+
} else {
|
|
1306
|
+
prompt = req.prompt;
|
|
1307
|
+
}
|
|
1287
1308
|
log5("Calling generateImage...");
|
|
1288
1309
|
const startTime = Date.now();
|
|
1289
1310
|
const result = await sdkGenerateImage({
|
|
1290
1311
|
model: gw.image(model),
|
|
1291
|
-
prompt
|
|
1312
|
+
prompt,
|
|
1292
1313
|
...req.aspectRatio ? { aspectRatio: req.aspectRatio } : {},
|
|
1293
1314
|
n: req.n
|
|
1294
1315
|
});
|
|
@@ -1312,7 +1333,7 @@ var vercelCapabilities = {
|
|
|
1312
1333
|
supportsCustomAspectRatio: true,
|
|
1313
1334
|
supportsVideoInterpolation: false,
|
|
1314
1335
|
videoDurationRange: [1, 15],
|
|
1315
|
-
supportsImageEditing:
|
|
1336
|
+
supportsImageEditing: true
|
|
1316
1337
|
};
|
|
1317
1338
|
var vercelProvider = {
|
|
1318
1339
|
id: "vercel",
|