Update replicate.yaml
Browse files- replicate.yaml +1037 -2
replicate.yaml
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
_id: replicate
|
2 |
author: Anton Breslavskii | https://github.com/breslavsky
|
3 |
description: Provides features to use AI models from Replicate AI
|
4 |
-
readme: ""
|
5 |
title: Replicate AI
|
6 |
url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/replicate.yaml
|
7 |
-
version:
|
8 |
nodes:
|
9 |
generate_on_flux_replicate:
|
10 |
_id: generate_on_flux_replicate
|
@@ -129,3 +128,1039 @@ nodes:
|
|
129 |
source: catalog
|
130 |
title: en=Generate on Flux;ru=Генерация Flux
|
131 |
version: 5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
_id: replicate
|
2 |
author: Anton Breslavskii | https://github.com/breslavsky
|
3 |
description: Provides features to use AI models from Replicate AI
|
|
|
4 |
title: Replicate AI
|
5 |
url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/replicate.yaml
|
6 |
+
version: 7
|
7 |
nodes:
|
8 |
generate_on_flux_replicate:
|
9 |
_id: generate_on_flux_replicate
|
|
|
128 |
source: catalog
|
129 |
title: en=Generate on Flux;ru=Генерация Flux
|
130 |
version: 5
|
131 |
+
execution: regular
|
132 |
+
kling_1_6_replicate:
|
133 |
+
_id: kling_1_6_replicate
|
134 |
+
arrange:
|
135 |
+
x: 460
|
136 |
+
y: 330
|
137 |
+
category:
|
138 |
+
_id: generate_videos
|
139 |
+
title: en=Generate video;ru=Генерация видео
|
140 |
+
environment:
|
141 |
+
REPLICATE_TOKEN:
|
142 |
+
title: Replicate token
|
143 |
+
description: Go to [Replicate](https://replicate.com/account/api-tokens) to get API key
|
144 |
+
type: string
|
145 |
+
scope: global
|
146 |
+
execution: regular
|
147 |
+
inputs:
|
148 |
+
image:
|
149 |
+
order: 1
|
150 |
+
title: en=Image;ru=Изображение
|
151 |
+
type: image
|
152 |
+
required: true
|
153 |
+
prompt:
|
154 |
+
order: 2
|
155 |
+
title: en=Prompt;ru=Подсказка
|
156 |
+
type: string
|
157 |
+
required: true
|
158 |
+
multiline: true
|
159 |
+
negativePrompt:
|
160 |
+
order: 3
|
161 |
+
title: en=Negative prompt;ru=Негативная подсказка
|
162 |
+
type: string
|
163 |
+
multiline: true
|
164 |
+
aspectRatio:
|
165 |
+
order: 4
|
166 |
+
title: en=Aspect ratio;ru=Соотношение сторон
|
167 |
+
type: string
|
168 |
+
default: 16:9
|
169 |
+
enum:
|
170 |
+
- 1:1
|
171 |
+
- 16:9
|
172 |
+
- 9:16
|
173 |
+
cfgScale:
|
174 |
+
order: 5
|
175 |
+
title: en=Creativity (CFG scale);ru=Креативность (CFG)
|
176 |
+
type: float
|
177 |
+
min: 0
|
178 |
+
max: 1
|
179 |
+
step: 0.1
|
180 |
+
default: 0.5
|
181 |
+
duration:
|
182 |
+
order: 6
|
183 |
+
title: en=Duration;ru=Длина
|
184 |
+
type: integer
|
185 |
+
min: 5
|
186 |
+
max: 10
|
187 |
+
step: 5
|
188 |
+
default: 5
|
189 |
+
outputs:
|
190 |
+
video:
|
191 |
+
title: en=Video;ru=Видео
|
192 |
+
type: video
|
193 |
+
package: replicate
|
194 |
+
script: |
|
195 |
+
export async function costs({ inputs }) {
|
196 |
+
const duration = Number(inputs?.duration || 5);
|
197 |
+
return Number((duration * 0.05).toFixed(3));
|
198 |
+
}
|
199 |
+
|
200 |
+
const MAX_RETRIES = 100;
|
201 |
+
export async function run({ inputs, state }) {
|
202 |
+
|
203 |
+
const { RepeatNode, NextNode, FatalError } = DEFINITIONS;
|
204 |
+
|
205 |
+
const REPLICATE_TOKEN = env?.variables?.get('REPLICATE_TOKEN');
|
206 |
+
if (!REPLICATE_TOKEN) {
|
207 |
+
throw new FatalError('Please, set your API token for Replicate AI');
|
208 |
+
}
|
209 |
+
|
210 |
+
const { image, prompt, negativePrompt, aspectRatio, cfgScale, duration } = inputs;
|
211 |
+
|
212 |
+
if (!state) {
|
213 |
+
const { data: { id: task } } = await httpClient({
|
214 |
+
method: 'post',
|
215 |
+
url: 'https://api.replicate.com/v1/models/kwaivgi/kling-v1.6-standard/predictions',
|
216 |
+
data: {
|
217 |
+
input: {
|
218 |
+
start_image: image,
|
219 |
+
prompt,
|
220 |
+
negative_prompt: negativePrompt,
|
221 |
+
aspect_ratio: aspectRatio,
|
222 |
+
cfg_scale: cfgScale,
|
223 |
+
duration
|
224 |
+
}
|
225 |
+
},
|
226 |
+
headers: {
|
227 |
+
'Authorization': `Bearer ${REPLICATE_TOKEN}`,
|
228 |
+
'Content-Type': 'application/json'
|
229 |
+
}
|
230 |
+
});
|
231 |
+
return RepeatNode.from({
|
232 |
+
state: {
|
233 |
+
task,
|
234 |
+
retries: 0
|
235 |
+
},
|
236 |
+
delay: 10000
|
237 |
+
});
|
238 |
+
} else {
|
239 |
+
const { task, retries } = state;
|
240 |
+
|
241 |
+
const { data } = await httpClient({
|
242 |
+
method: 'get',
|
243 |
+
url: `https://api.replicate.com/v1/predictions/${task}`,
|
244 |
+
headers: {
|
245 |
+
'Authorization': `Bearer ${REPLICATE_TOKEN}`,
|
246 |
+
'Content-Type': 'application/json'
|
247 |
+
}
|
248 |
+
});
|
249 |
+
|
250 |
+
const { status, error } = data;
|
251 |
+
switch (status) {
|
252 |
+
case 'starting':
|
253 |
+
case 'processing':
|
254 |
+
if (state.retries > MAX_RETRIES) {
|
255 |
+
throw new FatalError('Generation timeout exceeded');
|
256 |
+
}
|
257 |
+
return RepeatNode.from({
|
258 |
+
state: {
|
259 |
+
...state,
|
260 |
+
retries: retries + 1
|
261 |
+
},
|
262 |
+
progress: {
|
263 |
+
total: MAX_RETRIES,
|
264 |
+
processed: retries
|
265 |
+
},
|
266 |
+
delay: 5000
|
267 |
+
});
|
268 |
+
case 'failed':
|
269 |
+
throw new FatalError(error || 'Generation failed');
|
270 |
+
case 'succeeded':
|
271 |
+
const { output: video } = data;
|
272 |
+
return NextNode.from({ outputs: { video }, costs: await costs({ inputs }) });
|
273 |
+
default:
|
274 |
+
throw new FatalError(`Unknown status: ${status}`);
|
275 |
+
}
|
276 |
+
}
|
277 |
+
}
|
278 |
+
source: catalog
|
279 |
+
title: en=Generate video Kling 1.6;ru=Генерация видео Kling 1.6
|
280 |
+
version: 1
|
281 |
+
florence_vision_replicate:
|
282 |
+
_id: florence_vision_replicate
|
283 |
+
arrange:
|
284 |
+
x: 140
|
285 |
+
y: 80
|
286 |
+
category:
|
287 |
+
_id: computer_vision
|
288 |
+
title: Computer vision
|
289 |
+
environment:
|
290 |
+
REPLICATE_TOKEN:
|
291 |
+
title: Replicate token
|
292 |
+
description: Get your token from https://replicate.com/account/api-tokens
|
293 |
+
type: string
|
294 |
+
scope: global
|
295 |
+
execution: regular
|
296 |
+
inputs:
|
297 |
+
image:
|
298 |
+
order: 1
|
299 |
+
title: Image
|
300 |
+
type: image
|
301 |
+
required: true
|
302 |
+
mode:
|
303 |
+
order: 2
|
304 |
+
title: Mode
|
305 |
+
type: string
|
306 |
+
required: true
|
307 |
+
default: detailed_caption
|
308 |
+
enum:
|
309 |
+
- caption|Caption
|
310 |
+
- detailed_caption|Detailed caption
|
311 |
+
outputs:
|
312 |
+
caption:
|
313 |
+
title: Caption
|
314 |
+
type: string
|
315 |
+
package: replicate
|
316 |
+
script: |
|
317 |
+
export async function run({ inputs, state }) {
|
318 |
+
const { RepeatNode, NextNode, FatalError } = DEFINITIONS;
|
319 |
+
|
320 |
+
const REPLICATE_TOKEN = env?.variables?.get('REPLICATE_TOKEN');
|
321 |
+
if (!REPLICATE_TOKEN) {
|
322 |
+
throw new FatalError('Please, set REPLICATE_TOKEN environment variable');
|
323 |
+
}
|
324 |
+
|
325 |
+
const { image, mode } = inputs;
|
326 |
+
|
327 |
+
if (!state) {
|
328 |
+
const { data: { id: task } } = await httpClient({
|
329 |
+
method: 'post',
|
330 |
+
url: 'https://api.replicate.com/v1/predictions',
|
331 |
+
data: {
|
332 |
+
version: 'da53547e17d45b9cfb48174b2f18af8b83ca020fa76db62136bf9c6616762595',
|
333 |
+
input: {
|
334 |
+
image: image,
|
335 |
+
task_input: mode === 'caption' ? 'Caption' : 'Detailed Caption'
|
336 |
+
}
|
337 |
+
},
|
338 |
+
headers: {
|
339 |
+
'Authorization': `Token ${REPLICATE_TOKEN}`,
|
340 |
+
'Content-Type': 'application/json'
|
341 |
+
},
|
342 |
+
timeout: 10000
|
343 |
+
});
|
344 |
+
|
345 |
+
return RepeatNode.from({
|
346 |
+
state: {
|
347 |
+
task,
|
348 |
+
retries: 0
|
349 |
+
},
|
350 |
+
delay: 2000
|
351 |
+
});
|
352 |
+
} else {
|
353 |
+
const { data } = await httpClient({
|
354 |
+
method: 'get',
|
355 |
+
url: `https://api.replicate.com/v1/predictions/${state.task}`,
|
356 |
+
headers: {
|
357 |
+
'Authorization': `Token ${REPLICATE_TOKEN}`,
|
358 |
+
'Content-Type': 'application/json'
|
359 |
+
},
|
360 |
+
timeout: 5000
|
361 |
+
});
|
362 |
+
|
363 |
+
const { status, error } = data;
|
364 |
+
switch (status) {
|
365 |
+
case 'processing':
|
366 |
+
case 'starting':
|
367 |
+
if (state.retries > 30) {
|
368 |
+
throw new FatalError('Task timeout exceeded');
|
369 |
+
}
|
370 |
+
return RepeatNode.from({
|
371 |
+
state: {
|
372 |
+
...state,
|
373 |
+
retries: state.retries + 1
|
374 |
+
},
|
375 |
+
delay: 3000
|
376 |
+
});
|
377 |
+
case 'failed':
|
378 |
+
throw new FatalError(error || 'Task failed');
|
379 |
+
case 'succeeded':
|
380 |
+
let caption = data.output?.text ||
|
381 |
+
data.output?.['<CAPTION>'] ||
|
382 |
+
data.output?.['<DETAILED_CAPTION>'] ||
|
383 |
+
'No caption generated';
|
384 |
+
|
385 |
+
// Удаляем метки CAPTION/DETAILED_CAPTION если они есть в тексте
|
386 |
+
caption = String(caption)
|
387 |
+
.replace(/^[\s{:]*['']?<CAPTION>['']?|[''}]\s*$/gi, '')
|
388 |
+
.replace(/^[\s{:]*['']?<DETAILED_CAPTION>['']?|[''}]\s*$/gi, '')
|
389 |
+
.replace(/^[\s:]*['']+|['']+\s*$/g, '')
|
390 |
+
.trim();
|
391 |
+
|
392 |
+
return NextNode.from({
|
393 |
+
outputs: {
|
394 |
+
caption
|
395 |
+
}
|
396 |
+
});
|
397 |
+
default:
|
398 |
+
throw new FatalError(`Unknown status: ${status}`);
|
399 |
+
}
|
400 |
+
}
|
401 |
+
}
|
402 |
+
source: catalog
|
403 |
+
title: Florence-2 Vision
|
404 |
+
version: 5
|
405 |
+
generate_on_flux_fill_pro_replicate:
|
406 |
+
_id: generate_on_flux_fill_pro_replicate
|
407 |
+
arrange:
|
408 |
+
x: 1730
|
409 |
+
y: 90
|
410 |
+
category:
|
411 |
+
_id: generate_images
|
412 |
+
title: en=Generate images;ru=Генерация изображений
|
413 |
+
environment:
|
414 |
+
REPLICATE_TOKEN:
|
415 |
+
title: Replicate token
|
416 |
+
description: Go to [Replicate](https://replicate.com/account/api-tokens) to take a keys
|
417 |
+
type: string
|
418 |
+
scope: global
|
419 |
+
execution: regular
|
420 |
+
inputs:
|
421 |
+
prompt:
|
422 |
+
order: 2
|
423 |
+
title: en=Prompt;ru=Подсказка
|
424 |
+
description: |-
|
425 |
+
Text prompt for image generation
|
426 |
+
--- ru ---
|
427 |
+
Текстовая подсказка для генерации изображения
|
428 |
+
type: string
|
429 |
+
required: true
|
430 |
+
multiline: true
|
431 |
+
seed:
|
432 |
+
order: 5
|
433 |
+
title: en=Seed;ru=Начальный шум
|
434 |
+
description: |-
|
435 |
+
Seed "-1" is a random value, otherwise a fixed value
|
436 |
+
--- ru ---
|
437 |
+
Значение "-1" - случайное число, иначе фиксированное
|
438 |
+
type: integer
|
439 |
+
default: -1
|
440 |
+
guidance:
|
441 |
+
order: 8
|
442 |
+
title: en=Guidance;ru=Креативность
|
443 |
+
description: |-
|
444 |
+
Controls the balance between adherence to the text prompt and image quality/diversity. Higher values make the output more closely match the prompt but may reduce overall image quality. Lower values allow for more creative freedom but might produce results less relevant to the prompt
|
445 |
+
--- ru ---
|
446 |
+
Контролирует баланс между соответствием текстовой подсказке и качеством/разнообразием изображения. Более высокие значения делают вывод более соответствующим подсказке, но могут снизить общее качество изображения. Более низкие значения позволяют большую творческую свободу, но могут давать результаты, менее соответствующие подсказке
|
447 |
+
type: integer
|
448 |
+
min: 2
|
449 |
+
max: 100
|
450 |
+
step: 1
|
451 |
+
default: 60
|
452 |
+
output_format:
|
453 |
+
order: 10
|
454 |
+
title: en=Output Format;ru=Формат вывода
|
455 |
+
description: |-
|
456 |
+
Format of the output images
|
457 |
+
--- ru ---
|
458 |
+
Формат выходных изображений
|
459 |
+
type: string
|
460 |
+
default: jpg
|
461 |
+
enum:
|
462 |
+
- jpg
|
463 |
+
- png
|
464 |
+
image:
|
465 |
+
order: 1
|
466 |
+
title: en=Image;ru=Изображение
|
467 |
+
description: |-
|
468 |
+
The image to inpaint. Can contain an alpha mask. Must be jpeg, png, gif, or webp
|
469 |
+
--- ru ---
|
470 |
+
Изображение для дорисовки. Может содержать альфа-маску. Должно быть в формате jpeg, png, gif или webp
|
471 |
+
type: image
|
472 |
+
required: true
|
473 |
+
extensions:
|
474 |
+
- id: draw-mask
|
475 |
+
params:
|
476 |
+
mask: mask
|
477 |
+
mask:
|
478 |
+
order: 3
|
479 |
+
title: en=Mask;ru=Маска
|
480 |
+
description: |-
|
481 |
+
A black-and-white image that describes the part of the image to inpaint. Black areas will be preserved while white areas will be inpainted. Must have the same size as image. Optional if you provide an alpha mask in the original image
|
482 |
+
--- ru ---
|
483 |
+
Черно-белое изображение, описывающее часть изображения для дорисовки. Черные области будут сохранены, а белые области будут дорисованы. Должно иметь тот же размер, что и изображение. Необязательно, если вы предоставляете альфа-маску в исходном изображении
|
484 |
+
type: image
|
485 |
+
outpaint:
|
486 |
+
order: 4
|
487 |
+
title: en=Outpaint;ru=Расширение
|
488 |
+
description: |-
|
489 |
+
Outpainting an input image. Mask will be ignored
|
490 |
+
--- ru ---
|
491 |
+
Outpaint - расширения входного изображения. Маска будет проигнорирована
|
492 |
+
type: string
|
493 |
+
default: None
|
494 |
+
enum:
|
495 |
+
- None|en=None;ru=Ничего
|
496 |
+
- Zoom out 1.5x|en=Zoom out 1.5x;ru=Отдалить в 1,5 раза
|
497 |
+
- Zoom out 2x|en=Zoom out 2x;ru=Отдалить в 2 раза
|
498 |
+
- Make square|en=Make square;ru=Сделать квадратным
|
499 |
+
- Left outpaint|en=Left outpaint;ru=Расширить слева
|
500 |
+
- Right outpaint|en=Right outpaint;ru=Расширить справа
|
501 |
+
- Top outpaint|en=Top outpaint;ru=Расширить сверху
|
502 |
+
- Bottom outpaint|en=Bottom outpaint;ru=Расширить снизу
|
503 |
+
steps:
|
504 |
+
order: 6
|
505 |
+
title: en=Steps;ru=Шаги
|
506 |
+
description: |-
|
507 |
+
Range 15-50 (more=slower)
|
508 |
+
--- ru ---
|
509 |
+
Диапазон 15-50 (больше=медленнее)
|
510 |
+
type: integer
|
511 |
+
min: 15
|
512 |
+
max: 50
|
513 |
+
step: 1
|
514 |
+
default: 50
|
515 |
+
prompt_upsampling:
|
516 |
+
order: 7
|
517 |
+
title: en=Prompt Upsampling;ru=Улучшение подсказки
|
518 |
+
description: |-
|
519 |
+
Automatically modify the prompt for more creative generation
|
520 |
+
--- ru ---
|
521 |
+
Автоматически изменять подсказку для более креативной генерации
|
522 |
+
type: boolean
|
523 |
+
default: false
|
524 |
+
safety_tolerance:
|
525 |
+
order: 9
|
526 |
+
title: en=Safety Tolerance;ru=Цензура
|
527 |
+
description: |-
|
528 |
+
Safety tolerance, 1 is most strict and 6 is most permissive
|
529 |
+
--- ru ---
|
530 |
+
Цензура от 1 (строгая) до 6 (свободная)
|
531 |
+
type: integer
|
532 |
+
min: 1
|
533 |
+
max: 6
|
534 |
+
step: 1
|
535 |
+
default: 2
|
536 |
+
outputs:
|
537 |
+
image:
|
538 |
+
title: en=Image;ru=Изображение
|
539 |
+
type: image
|
540 |
+
package: replicate
|
541 |
+
script: |
|
542 |
+
export async function run({ inputs, state }) {
|
543 |
+
const { RepeatNode, NextNode, FatalError } = DEFINITIONS;
|
544 |
+
|
545 |
+
const REPLICATE_TOKEN = env?.variables?.get('REPLICATE_TOKEN');
|
546 |
+
if (!REPLICATE_TOKEN) {
|
547 |
+
throw new FatalError('Please, set your API token for Replicate AI');
|
548 |
+
}
|
549 |
+
|
550 |
+
const {
|
551 |
+
prompt,
|
552 |
+
image,
|
553 |
+
mask,
|
554 |
+
outpaint = 'None',
|
555 |
+
seed = -1,
|
556 |
+
steps = 50,
|
557 |
+
prompt_upsampling = false,
|
558 |
+
guidance = 60,
|
559 |
+
safety_tolerance = 2,
|
560 |
+
output_format = 'jpg'
|
561 |
+
} = inputs;
|
562 |
+
|
563 |
+
if (!state) {
|
564 |
+
const { data: { id: task } } = await httpClient({
|
565 |
+
method: 'post',
|
566 |
+
url: 'https://api.replicate.com/v1/models/black-forest-labs/flux-fill-pro/predictions',
|
567 |
+
data: {
|
568 |
+
input: {
|
569 |
+
prompt,
|
570 |
+
image,
|
571 |
+
mask,
|
572 |
+
outpaint,
|
573 |
+
seed,
|
574 |
+
steps,
|
575 |
+
prompt_upsampling,
|
576 |
+
guidance,
|
577 |
+
safety_tolerance,
|
578 |
+
output_format
|
579 |
+
}
|
580 |
+
},
|
581 |
+
headers: {
|
582 |
+
'Authorization': `Bearer ${REPLICATE_TOKEN}`,
|
583 |
+
'Content-Type': 'application/json'
|
584 |
+
},
|
585 |
+
timeout: 10000 // Увеличенный таймаут для старта
|
586 |
+
});
|
587 |
+
return RepeatNode.from({
|
588 |
+
state: {
|
589 |
+
task,
|
590 |
+
retries: 0
|
591 |
+
},
|
592 |
+
delay: 2000
|
593 |
+
});
|
594 |
+
} else {
|
595 |
+
|
596 |
+
const { data } = await httpClient({
|
597 |
+
method: 'get',
|
598 |
+
url: `https://api.replicate.com/v1/predictions/${state.task}`,
|
599 |
+
headers: {
|
600 |
+
'Authorization': `Bearer ${REPLICATE_TOKEN}`,
|
601 |
+
'Content-Type': 'application/json'
|
602 |
+
},
|
603 |
+
timeout: 5000 // Таймаут для проверки статуса
|
604 |
+
});
|
605 |
+
|
606 |
+
const { status, error } = data;
|
607 |
+
switch (status) {
|
608 |
+
case 'starting':
|
609 |
+
case 'processing':
|
610 |
+
if (state.retries > 30) { // Увеличенный лимит попыток
|
611 |
+
throw new FatalError('Generation timeout exceeded');
|
612 |
+
}
|
613 |
+
return RepeatNode.from({
|
614 |
+
state: {
|
615 |
+
...state,
|
616 |
+
retries: state.retries + 1
|
617 |
+
},
|
618 |
+
delay: 3000
|
619 |
+
});
|
620 |
+
|
621 |
+
case 'failed':
|
622 |
+
throw new FatalError(error || 'Generation failed');
|
623 |
+
case 'succeeded':
|
624 |
+
const imageOutput = data.output;
|
625 |
+
return NextNode.from({
|
626 |
+
outputs: {
|
627 |
+
image: imageOutput
|
628 |
+
}
|
629 |
+
});
|
630 |
+
default:
|
631 |
+
throw new FatalError(`Unknown status: ${status}`);
|
632 |
+
}
|
633 |
+
}
|
634 |
+
}
|
635 |
+
source: catalog
|
636 |
+
title: en=Generate Flux Fill;ru=Генерация Flux Fill
|
637 |
+
version: 1
|
638 |
+
generate_on_flux_redux_replicate:
|
639 |
+
_id: generate_on_flux_redux_replicate
|
640 |
+
arrange:
|
641 |
+
x: 1430
|
642 |
+
y: 90
|
643 |
+
category:
|
644 |
+
_id: generate_images
|
645 |
+
title: en=Generate images;ru=Генерация изображений
|
646 |
+
environment:
|
647 |
+
REPLICATE_TOKEN:
|
648 |
+
title: Replicate token
|
649 |
+
description: Go to [Replicate](https://replicate.com/account/api-tokens) to take a keys
|
650 |
+
type: string
|
651 |
+
scope: global
|
652 |
+
execution: regular
|
653 |
+
inputs:
|
654 |
+
seed:
|
655 |
+
order: 6
|
656 |
+
title: en=Seed;ru=Начальный шум
|
657 |
+
description: |-
|
658 |
+
Seed "-1" is a random value, otherwise a fixed value
|
659 |
+
--- ru ---
|
660 |
+
Значение "-1" - случайное число, иначе фиксированное
|
661 |
+
type: integer
|
662 |
+
default: -1
|
663 |
+
num_outputs:
|
664 |
+
order: 3
|
665 |
+
title: en=Images count;ru=Кол-во изображений
|
666 |
+
description: |-
|
667 |
+
Number of outputs to generate
|
668 |
+
--- ru ---
|
669 |
+
Количество изображений для генерации
|
670 |
+
type: integer
|
671 |
+
min: 1
|
672 |
+
max: 4
|
673 |
+
step: 1
|
674 |
+
default: 1
|
675 |
+
guidance:
|
676 |
+
order: 5
|
677 |
+
title: en=Guidance;ru=Креативность
|
678 |
+
description: |-
|
679 |
+
The larger the value, the greater the strength of the prompt (1-10)
|
680 |
+
--- ru ---
|
681 |
+
Чем больше значение, тем сильнее влияет подсказка (1-10)
|
682 |
+
type: integer
|
683 |
+
min: 1
|
684 |
+
max: 10
|
685 |
+
step: 0.5
|
686 |
+
default: 3.5
|
687 |
+
num_inference_steps:
|
688 |
+
order: 4
|
689 |
+
title: en=Generation steps;ru=Шагов генерации
|
690 |
+
description: |-
|
691 |
+
Range 15-50 (more=slower)
|
692 |
+
--- ru ---
|
693 |
+
Диапазон 15-50 (больше=медленнее)
|
694 |
+
type: integer
|
695 |
+
min: 15
|
696 |
+
max: 50
|
697 |
+
step: 1
|
698 |
+
default: 28
|
699 |
+
megapixels:
|
700 |
+
order: 9
|
701 |
+
title: en=Megapixels;ru=Мегапиксели
|
702 |
+
description: |-
|
703 |
+
Approximate number of megapixels for generated image
|
704 |
+
--- ru ---
|
705 |
+
Приблизительное количество мегапикселей для сгенерированного изображения
|
706 |
+
type: string
|
707 |
+
default: "1"
|
708 |
+
enum:
|
709 |
+
- "1"
|
710 |
+
- "0.25"
|
711 |
+
output_format:
|
712 |
+
order: 7
|
713 |
+
title: en=Output Format;ru=Формат вывода
|
714 |
+
description: |-
|
715 |
+
Format of the output images
|
716 |
+
--- ru ---
|
717 |
+
Формат выходного изображения
|
718 |
+
type: string
|
719 |
+
default: png
|
720 |
+
enum:
|
721 |
+
- webp
|
722 |
+
- jpg
|
723 |
+
- png
|
724 |
+
output_quality:
|
725 |
+
order: 8
|
726 |
+
title: en=Quality;ru=Качество
|
727 |
+
description: |-
|
728 |
+
Quality when saving the output images, from 0 to 100. 100 is best quality, 0 is lowest quality. Not relevant for .png outputs
|
729 |
+
--- ru ---
|
730 |
+
Качество при сохранении изображений, от 0 до 100. 100 - наилучшее качество, 0 - наименьшее. Не актуально для выходных изображений в формате .png
|
731 |
+
type: integer
|
732 |
+
min: 0
|
733 |
+
max: 100
|
734 |
+
step: 1
|
735 |
+
default: 80
|
736 |
+
disable_safety_checker:
|
737 |
+
order: 10
|
738 |
+
title: en=Disable Safety Checker;ru=Отключить проверку
|
739 |
+
description: |-
|
740 |
+
Disable safety checker for generated images
|
741 |
+
--- ru ---
|
742 |
+
Отключить проверку безопасности для сгенерированных изображений
|
743 |
+
type: boolean
|
744 |
+
default: false
|
745 |
+
redux_image:
|
746 |
+
order: 1
|
747 |
+
title: en=Image;ru=Изображение
|
748 |
+
type: image
|
749 |
+
required: true
|
750 |
+
aspect_ratio:
|
751 |
+
order: 2
|
752 |
+
title: en=Aspect Ratio;ru=Соотношение сторон
|
753 |
+
description: |-
|
754 |
+
Aspect ratio for the generated image
|
755 |
+
--- ru ---
|
756 |
+
Соотношение сторон для сгенерированного изображения
|
757 |
+
type: string
|
758 |
+
default: 1:1
|
759 |
+
enum:
|
760 |
+
- 1:1
|
761 |
+
- 16:9
|
762 |
+
- 21:9
|
763 |
+
- 3:2
|
764 |
+
- 2:3
|
765 |
+
- 4:5
|
766 |
+
- 5:4
|
767 |
+
- 3:4
|
768 |
+
- 4:3
|
769 |
+
- 9:16
|
770 |
+
- 9:21
|
771 |
+
outputs:
|
772 |
+
images:
|
773 |
+
title: Images
|
774 |
+
type: image[]
|
775 |
+
image1:
|
776 |
+
title: Image 1
|
777 |
+
type: image
|
778 |
+
image2:
|
779 |
+
title: Image 2
|
780 |
+
type: image
|
781 |
+
image3:
|
782 |
+
title: Image 3
|
783 |
+
type: image
|
784 |
+
image4:
|
785 |
+
title: Image 4
|
786 |
+
type: image
|
787 |
+
package: replicate
|
788 |
+
script: |
|
789 |
+
export async function run({ inputs, state }) {
|
790 |
+
const { RepeatNode, NextNode, FatalError } = DEFINITIONS;
|
791 |
+
|
792 |
+
const REPLICATE_TOKEN = env?.variables?.get('REPLICATE_TOKEN');
|
793 |
+
if (!REPLICATE_TOKEN) {
|
794 |
+
throw new FatalError('Please, set your API token for Replicate AI');
|
795 |
+
}
|
796 |
+
|
797 |
+
const {
|
798 |
+
redux_image,
|
799 |
+
aspect_ratio = '1:1',
|
800 |
+
num_outputs = 1,
|
801 |
+
num_inference_steps = 28,
|
802 |
+
guidance = 3,
|
803 |
+
seed = -1,
|
804 |
+
output_format = 'webp',
|
805 |
+
output_quality = 80,
|
806 |
+
megapixels = '1',
|
807 |
+
disable_safety_checker = false
|
808 |
+
} = inputs;
|
809 |
+
|
810 |
+
if (!state) {
|
811 |
+
const { data: { id: task } } = await httpClient({
|
812 |
+
method: 'post',
|
813 |
+
url: 'https://api.replicate.com/v1/models/black-forest-labs/flux-redux-dev/predictions',
|
814 |
+
data: {
|
815 |
+
input: {
|
816 |
+
redux_image,
|
817 |
+
aspect_ratio,
|
818 |
+
num_outputs,
|
819 |
+
num_inference_steps,
|
820 |
+
guidance,
|
821 |
+
seed,
|
822 |
+
output_format,
|
823 |
+
output_quality,
|
824 |
+
megapixels,
|
825 |
+
disable_safety_checker
|
826 |
+
}
|
827 |
+
},
|
828 |
+
headers: {
|
829 |
+
'Authorization': `Bearer ${REPLICATE_TOKEN}`,
|
830 |
+
'Content-Type': 'application/json'
|
831 |
+
},
|
832 |
+
timeout: 10000
|
833 |
+
});
|
834 |
+
return RepeatNode.from({
|
835 |
+
state: {
|
836 |
+
task,
|
837 |
+
retries: 0
|
838 |
+
},
|
839 |
+
delay: 2000
|
840 |
+
});
|
841 |
+
} else {
|
842 |
+
const { data } = await httpClient({
|
843 |
+
method: 'get',
|
844 |
+
url: `https://api.replicate.com/v1/predictions/${state.task}`,
|
845 |
+
headers: {
|
846 |
+
'Authorization': `Bearer ${REPLICATE_TOKEN}`,
|
847 |
+
'Content-Type': 'application/json'
|
848 |
+
},
|
849 |
+
timeout: 5000
|
850 |
+
});
|
851 |
+
|
852 |
+
const { status, error } = data;
|
853 |
+
switch (status) {
|
854 |
+
case 'starting':
|
855 |
+
case 'processing':
|
856 |
+
if (state.retries > 20) {
|
857 |
+
throw new FatalError('Generation timeout exceeded');
|
858 |
+
}
|
859 |
+
return RepeatNode.from({
|
860 |
+
state: {
|
861 |
+
...state,
|
862 |
+
retries: state.retries + 1
|
863 |
+
},
|
864 |
+
delay: 3000
|
865 |
+
});
|
866 |
+
|
867 |
+
case 'failed':
|
868 |
+
throw new FatalError(error || 'Generation failed');
|
869 |
+
case 'succeeded':
|
870 |
+
const { output: images } = data;
|
871 |
+
const [image1, image2, image3, image4] = images;
|
872 |
+
return NextNode.from({
|
873 |
+
outputs: {
|
874 |
+
images,
|
875 |
+
image1,
|
876 |
+
image2,
|
877 |
+
image3,
|
878 |
+
image4
|
879 |
+
}
|
880 |
+
});
|
881 |
+
default:
|
882 |
+
throw new FatalError(`Unknown status: ${status}`);
|
883 |
+
}
|
884 |
+
}
|
885 |
+
}
|
886 |
+
source: catalog
|
887 |
+
title: en=Generate Flux Redux;ru=Генерация Flux Redux
|
888 |
+
version: 1
|
889 |
+
llava_1_5_13b_replicate:
|
890 |
+
_id: llava_1_5_13b_replicate
|
891 |
+
arrange:
|
892 |
+
x: 130
|
893 |
+
y: 420
|
894 |
+
category:
|
895 |
+
_id: computer_vision
|
896 |
+
title: Computer vision
|
897 |
+
environment:
|
898 |
+
REPLICATE_TOKEN:
|
899 |
+
title: Replicate token
|
900 |
+
description: Get your token from https://replicate.com/account/api-tokens
|
901 |
+
type: string
|
902 |
+
scope: global
|
903 |
+
execution: regular
|
904 |
+
inputs:
|
905 |
+
image:
|
906 |
+
order: 1
|
907 |
+
title: Image
|
908 |
+
type: image
|
909 |
+
required: true
|
910 |
+
prompt:
|
911 |
+
order: 2
|
912 |
+
title: Prompt
|
913 |
+
type: string
|
914 |
+
required: true
|
915 |
+
multiline: true
|
916 |
+
default: describe this image
|
917 |
+
maxTokens:
|
918 |
+
order: 4
|
919 |
+
title: Max tokens
|
920 |
+
type: integer
|
921 |
+
required: true
|
922 |
+
default: 1024
|
923 |
+
temperature:
|
924 |
+
order: 3
|
925 |
+
title: Temperature
|
926 |
+
type: float
|
927 |
+
required: true
|
928 |
+
min: 0
|
929 |
+
max: 1
|
930 |
+
step: 0.1
|
931 |
+
default: 0.2
|
932 |
+
topP:
|
933 |
+
order: 3
|
934 |
+
title: Nucleus sampling
|
935 |
+
type: float
|
936 |
+
required: true
|
937 |
+
min: 0
|
938 |
+
max: 1
|
939 |
+
step: 0.1
|
940 |
+
default: 1
|
941 |
+
outputs:
|
942 |
+
description:
|
943 |
+
title: Description
|
944 |
+
type: string
|
945 |
+
package: replicate
|
946 |
+
script: |
|
947 |
+
export async function run({ inputs, state }) {
|
948 |
+
const { RepeatNode, NextNode, FatalError } = DEFINITIONS;
|
949 |
+
|
950 |
+
const REPLICATE_TOKEN = env?.variables?.get('REPLICATE_TOKEN');
|
951 |
+
if (!REPLICATE_TOKEN) {
|
952 |
+
throw new FatalError('Please, set REPLICATE_TOKEN environment variable');
|
953 |
+
}
|
954 |
+
|
955 |
+
const { image, prompt = 'describe this image', topP, temperature, maxTokens } = inputs;
|
956 |
+
|
957 |
+
if (!state) {
|
958 |
+
const { data: { id: task } } = await httpClient({
|
959 |
+
method: 'post',
|
960 |
+
url: 'https://api.replicate.com/v1/predictions',
|
961 |
+
data: {
|
962 |
+
version: '80537f9eead1a5bfa72d5ac6ea6414379be41d4d4f6679fd776e9535d1eb58bb',
|
963 |
+
"stream": false,
|
964 |
+
input: {
|
965 |
+
image,
|
966 |
+
prompt,
|
967 |
+
top_p: topP,
|
968 |
+
temperature,
|
969 |
+
max_tokens: maxTokens
|
970 |
+
}
|
971 |
+
},
|
972 |
+
headers: {
|
973 |
+
'Authorization': `Token ${REPLICATE_TOKEN}`,
|
974 |
+
'Content-Type': 'application/json'
|
975 |
+
},
|
976 |
+
timeout: 10000
|
977 |
+
});
|
978 |
+
|
979 |
+
return RepeatNode.from({
|
980 |
+
state: {
|
981 |
+
task,
|
982 |
+
retries: 0
|
983 |
+
},
|
984 |
+
delay: 2000
|
985 |
+
});
|
986 |
+
} else {
|
987 |
+
const { data } = await httpClient({
|
988 |
+
method: 'get',
|
989 |
+
url: `https://api.replicate.com/v1/predictions/${state.task}`,
|
990 |
+
headers: {
|
991 |
+
'Authorization': `Token ${REPLICATE_TOKEN}`,
|
992 |
+
'Content-Type': 'application/json'
|
993 |
+
},
|
994 |
+
timeout: 5000
|
995 |
+
});
|
996 |
+
|
997 |
+
const { status, error } = data;
|
998 |
+
switch (status) {
|
999 |
+
case 'processing':
|
1000 |
+
case 'starting':
|
1001 |
+
if (state.retries > 30) {
|
1002 |
+
throw new FatalError('Task timeout exceeded');
|
1003 |
+
}
|
1004 |
+
return RepeatNode.from({
|
1005 |
+
state: {
|
1006 |
+
...state,
|
1007 |
+
retries: state.retries + 1
|
1008 |
+
},
|
1009 |
+
delay: 3000
|
1010 |
+
});
|
1011 |
+
case 'failed':
|
1012 |
+
throw new FatalError(error || 'Task failed');
|
1013 |
+
case 'succeeded':
|
1014 |
+
let description = data.output.join('');
|
1015 |
+
return NextNode.from({
|
1016 |
+
outputs: {
|
1017 |
+
description
|
1018 |
+
}
|
1019 |
+
});
|
1020 |
+
default:
|
1021 |
+
throw new FatalError(`Unknown status: ${status}`);
|
1022 |
+
}
|
1023 |
+
}
|
1024 |
+
}
|
1025 |
+
source: catalog
|
1026 |
+
title: LLaVA-1.5-13B
|
1027 |
+
version: 1
|
1028 |
+
kling_2_1_replicate:
|
1029 |
+
_id: kling_2_1_replicate
|
1030 |
+
arrange:
|
1031 |
+
x: 460
|
1032 |
+
y: 610
|
1033 |
+
category:
|
1034 |
+
_id: generate_videos
|
1035 |
+
title: en=Generate video;ru=Генерация видео
|
1036 |
+
environment:
|
1037 |
+
REPLICATE_TOKEN:
|
1038 |
+
title: Replicate token
|
1039 |
+
description: Go to [Replicate](https://replicate.com/account/api-tokens) to get API key
|
1040 |
+
type: string
|
1041 |
+
scope: global
|
1042 |
+
execution: regular
|
1043 |
+
inputs:
|
1044 |
+
image:
|
1045 |
+
order: 1
|
1046 |
+
title: en=Image;ru=Изображение
|
1047 |
+
type: image
|
1048 |
+
required: true
|
1049 |
+
prompt:
|
1050 |
+
order: 2
|
1051 |
+
title: en=Prompt;ru=Подсказка
|
1052 |
+
type: string
|
1053 |
+
required: true
|
1054 |
+
multiline: true
|
1055 |
+
negativePrompt:
|
1056 |
+
order: 3
|
1057 |
+
title: en=Negative prompt;ru=Негативная подсказка
|
1058 |
+
type: string
|
1059 |
+
multiline: true
|
1060 |
+
duration:
|
1061 |
+
order: 5
|
1062 |
+
title: en=Duration;ru=Длина
|
1063 |
+
type: integer
|
1064 |
+
min: 5
|
1065 |
+
max: 10
|
1066 |
+
step: 5
|
1067 |
+
default: 5
|
1068 |
+
mode:
|
1069 |
+
order: 4
|
1070 |
+
title: en=Mode;ru=Режим
|
1071 |
+
type: string
|
1072 |
+
default: standard
|
1073 |
+
enum:
|
1074 |
+
- standard
|
1075 |
+
- pro
|
1076 |
+
outputs:
|
1077 |
+
video:
|
1078 |
+
title: en=Video;ru=Видео
|
1079 |
+
type: video
|
1080 |
+
package: replicate
|
1081 |
+
script: |
|
1082 |
+
export async function costs({ inputs }) {
|
1083 |
+
const duration = Number(inputs?.duration || 5);
|
1084 |
+
return Number((duration * 0.1).toFixed(3));
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
const MAX_RETRIES = 100;
|
1088 |
+
export async function run({ inputs, state }) {
|
1089 |
+
|
1090 |
+
const { RepeatNode, NextNode, FatalError } = DEFINITIONS;
|
1091 |
+
|
1092 |
+
const REPLICATE_TOKEN = env?.variables?.get('REPLICATE_TOKEN');
|
1093 |
+
if (!REPLICATE_TOKEN) {
|
1094 |
+
throw new FatalError('Please, set your API token for Replicate AI');
|
1095 |
+
}
|
1096 |
+
|
1097 |
+
const { image, prompt, negativePrompt, mode, duration } = inputs;
|
1098 |
+
|
1099 |
+
if (!state) {
|
1100 |
+
const { data: { id: task } } = await httpClient({
|
1101 |
+
method: 'post',
|
1102 |
+
url: 'https://api.replicate.com/v1/models/kwaivgi/kling-v2.1/predictions',
|
1103 |
+
data: {
|
1104 |
+
input: {
|
1105 |
+
start_image: image,
|
1106 |
+
prompt,
|
1107 |
+
negative_prompt: negativePrompt,
|
1108 |
+
mode,
|
1109 |
+
duration
|
1110 |
+
}
|
1111 |
+
},
|
1112 |
+
headers: {
|
1113 |
+
'Authorization': `Bearer ${REPLICATE_TOKEN}`,
|
1114 |
+
'Content-Type': 'application/json'
|
1115 |
+
}
|
1116 |
+
});
|
1117 |
+
return RepeatNode.from({
|
1118 |
+
state: {
|
1119 |
+
task,
|
1120 |
+
retries: 0
|
1121 |
+
},
|
1122 |
+
delay: 10000
|
1123 |
+
});
|
1124 |
+
} else {
|
1125 |
+
const { task, retries } = state;
|
1126 |
+
|
1127 |
+
const { data } = await httpClient({
|
1128 |
+
method: 'get',
|
1129 |
+
url: `https://api.replicate.com/v1/predictions/${task}`,
|
1130 |
+
headers: {
|
1131 |
+
'Authorization': `Bearer ${REPLICATE_TOKEN}`,
|
1132 |
+
'Content-Type': 'application/json'
|
1133 |
+
}
|
1134 |
+
});
|
1135 |
+
|
1136 |
+
const { status, error } = data;
|
1137 |
+
switch (status) {
|
1138 |
+
case 'starting':
|
1139 |
+
case 'processing':
|
1140 |
+
if (state.retries > MAX_RETRIES) {
|
1141 |
+
throw new FatalError('Generation timeout exceeded');
|
1142 |
+
}
|
1143 |
+
return RepeatNode.from({
|
1144 |
+
state: {
|
1145 |
+
...state,
|
1146 |
+
retries: retries + 1
|
1147 |
+
},
|
1148 |
+
progress: {
|
1149 |
+
total: MAX_RETRIES,
|
1150 |
+
processed: retries
|
1151 |
+
},
|
1152 |
+
delay: 5000
|
1153 |
+
});
|
1154 |
+
case 'failed':
|
1155 |
+
throw new FatalError(error || 'Generation failed');
|
1156 |
+
case 'succeeded':
|
1157 |
+
const { output: video } = data;
|
1158 |
+
return NextNode.from({ outputs: { video }, costs: await costs({ inputs }) });
|
1159 |
+
default:
|
1160 |
+
throw new FatalError(`Unknown status: ${status}`);
|
1161 |
+
}
|
1162 |
+
}
|
1163 |
+
}
|
1164 |
+
source: catalog
|
1165 |
+
title: en=Generate video Kling 2.1;ru=Генерация видео Kling 2.1
|
1166 |
+
version: 1
|