kingkont 0.19.3 → 0.20.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/index.html +3 -1
- package/lib/providers.js +42 -2
- package/package.json +1 -1
- package/renderer/generate.js +4 -0
package/index.html
CHANGED
|
@@ -389,9 +389,11 @@
|
|
|
389
389
|
</div>
|
|
390
390
|
</div>
|
|
391
391
|
<div class="field-row" id="imageModelRow">Модель для картинки
|
|
392
|
-
<div class="seg-control">
|
|
392
|
+
<div class="seg-control" style="flex-wrap:wrap;">
|
|
393
393
|
<button class="seg active" data-img-model="nano-banana-2" type="button" title="Высокое качество, медленно">Nano Banana 2</button>
|
|
394
394
|
<button class="seg" data-img-model="nano-banana-pro" type="button" title="Pro-версия nano-banana, выше качество">Nano Banana Pro</button>
|
|
395
|
+
<button class="seg" data-img-model="gpt-image-2" type="button" title="OpenAI GPT Image 2 — text-to-image и edit">GPT Image 2</button>
|
|
396
|
+
<button class="seg" data-img-model="gpt-image-1.5" type="button" title="OpenAI GPT Image 1.5 — старее, дешевле">GPT Image 1.5</button>
|
|
395
397
|
<button class="seg" data-img-model="grok" type="button">Grok</button>
|
|
396
398
|
<button class="seg" data-img-model="seedream" type="button">Seedream 4.5</button>
|
|
397
399
|
<button class="seg" data-img-model="seedream-5-lite" type="button">Seedream 5 Lite</button>
|
package/lib/providers.js
CHANGED
|
@@ -70,6 +70,11 @@ const KIE_IMAGE_MODELS = {
|
|
|
70
70
|
'seedream-5-lite': 'seedream/5-lite-text-to-image',
|
|
71
71
|
'flux-schnell': 'flux/schnell',
|
|
72
72
|
'sdxl-lightning': 'sdxl/lightning',
|
|
73
|
+
// OpenAI gpt-image (через KIE — другие провайдеры не выкладывают).
|
|
74
|
+
// KIE автоматически переключает text-to-image vs image-to-image по
|
|
75
|
+
// наличию image_input — оба ходят через один и тот же jobs/createTask.
|
|
76
|
+
'gpt-image-2': 'gpt-image-2-text-to-image',
|
|
77
|
+
'gpt-image-1.5': 'gpt-image/1.5-text-to-image',
|
|
73
78
|
};
|
|
74
79
|
const KIE_VIDEO_MODELS = {
|
|
75
80
|
'seedance-2': 'bytedance/seedance-2',
|
|
@@ -106,6 +111,20 @@ function resolveModel(map, key, fallback) {
|
|
|
106
111
|
return map[key] || (Object.values(map).includes(key) ? key : null);
|
|
107
112
|
}
|
|
108
113
|
|
|
114
|
+
// gpt-image поддерживает только 3 размера: квадрат, портрет, ландшафт.
|
|
115
|
+
// Маппим наши aspectRatio'ы в ближайший подходящий size string.
|
|
116
|
+
function _gptImageAspectToSize(aspectRatio) {
|
|
117
|
+
if (!aspectRatio) return '1024x1024';
|
|
118
|
+
// Парсим "W:H".
|
|
119
|
+
const m = String(aspectRatio).match(/^(\d+):(\d+)$/);
|
|
120
|
+
if (!m) return '1024x1024';
|
|
121
|
+
const w = +m[1], h = +m[2];
|
|
122
|
+
const ratio = w / h;
|
|
123
|
+
if (ratio > 1.15) return '1536x1024'; // ландшафт (16:9, 3:2, 4:3)
|
|
124
|
+
if (ratio < 0.87) return '1024x1536'; // портрет (9:16, 2:3, 3:4)
|
|
125
|
+
return '1024x1024'; // квадрат (1:1)
|
|
126
|
+
}
|
|
127
|
+
|
|
109
128
|
// =============================================================================
|
|
110
129
|
// Chatium HTTP helpers (text/audio/image/video дёргают одни и те же).
|
|
111
130
|
// =============================================================================
|
|
@@ -454,6 +473,19 @@ async function _startGenerationViaKie({ kind, prompt, key, imageInputs, videoInp
|
|
|
454
473
|
if (aspectRatio) input.aspect_ratio = aspectRatio;
|
|
455
474
|
input.output_format = 'jpg';
|
|
456
475
|
// flux/sdxl быстрые, quality для них N/A — пропускаем.
|
|
476
|
+
} else if (key === 'gpt-image-2' || key === 'gpt-image-1.5') {
|
|
477
|
+
// OpenAI gpt-image-2 / 1.5 через KIE. Если есть imageInputs —
|
|
478
|
+
// переключаемся на image-to-image вариант slug'а (KIE использует
|
|
479
|
+
// отдельные модели для t2i vs i2i).
|
|
480
|
+
if (imageInputs?.length) {
|
|
481
|
+
// gpt-image-2-image-to-image — same input.image_input format,
|
|
482
|
+
// нужно сменить fullModel ниже.
|
|
483
|
+
}
|
|
484
|
+
if (aspectRatio) input.size = _gptImageAspectToSize(aspectRatio);
|
|
485
|
+
if (imageInputs?.length) input.image_input = imageInputs;
|
|
486
|
+
// quality: 'low' | 'medium' | 'high' — gpt-image поддерживает.
|
|
487
|
+
if (quality) input.quality = quality;
|
|
488
|
+
input.output_format = 'jpg';
|
|
457
489
|
}
|
|
458
490
|
} else {
|
|
459
491
|
if (imageInputs?.length) input.reference_image_urls = imageInputs;
|
|
@@ -463,10 +495,18 @@ async function _startGenerationViaKie({ kind, prompt, key, imageInputs, videoInp
|
|
|
463
495
|
if (duration) input.duration = +duration;
|
|
464
496
|
}
|
|
465
497
|
|
|
466
|
-
|
|
498
|
+
// gpt-image-* — переключаем slug на image-to-image variant если есть refs.
|
|
499
|
+
let actualModel = fullModel;
|
|
500
|
+
if ((key === 'gpt-image-2' || key === 'gpt-image-1.5') && imageInputs?.length) {
|
|
501
|
+
actualModel = key === 'gpt-image-2'
|
|
502
|
+
? 'gpt-image-2-image-to-image'
|
|
503
|
+
: 'gpt-image/1.5-image-to-image';
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
logCall('POST', 'KIE', `${KIE_BASE}/api/v1/jobs/createTask`, `model=${actualModel} kind=${kind}`);
|
|
467
507
|
const data = await kieFetch('/api/v1/jobs/createTask', {
|
|
468
508
|
method: 'POST',
|
|
469
|
-
body: JSON.stringify({ model:
|
|
509
|
+
body: JSON.stringify({ model: actualModel, input }),
|
|
470
510
|
});
|
|
471
511
|
// Защита: KIE иногда возвращает 200 с code=200 но без data.taskId (например
|
|
472
512
|
// когда модель не поддерживает текущий input — null aspect_ratio для grok,
|
package/package.json
CHANGED
package/renderer/generate.js
CHANGED
|
@@ -1687,6 +1687,10 @@ $('genSubmit').addEventListener('click', async () => {
|
|
|
1687
1687
|
'seedream-5-lite': 'seedream/5-lite-text-to-image',
|
|
1688
1688
|
'nano-banana-2': 'nano-banana-2',
|
|
1689
1689
|
'nano-banana-pro': 'nano-banana-pro',
|
|
1690
|
+
'gpt-image-2': 'gpt-image-2-text-to-image',
|
|
1691
|
+
'gpt-image-1.5': 'gpt-image/1.5-text-to-image',
|
|
1692
|
+
'flux-schnell': 'flux/schnell',
|
|
1693
|
+
'sdxl-lightning': 'sdxl/lightning',
|
|
1690
1694
|
}[state.imageModel] || 'nano-banana-2')
|
|
1691
1695
|
: ({
|
|
1692
1696
|
'seedance-2': 'bytedance/seedance-2',
|