mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-06-09 15:47:14 +00:00
Remove seed widget from nodes supporting dynamic prompting
This commit is contained in:
parent
e2e5c4c5b0
commit
f6df7ce075
@ -176,14 +176,6 @@ function onObjectInfo(json) {
|
|||||||
if (multiline == undefined) multiline = false;
|
if (multiline == undefined) multiline = false;
|
||||||
if (dynamic_prompt == undefined) dynamic_prompt = false;
|
if (dynamic_prompt == undefined) dynamic_prompt = false;
|
||||||
|
|
||||||
if (dynamic_prompt)
|
|
||||||
{
|
|
||||||
w1 = this.addWidget("number", "seed", 0, function(v){let s = this.options.step / 10;this.value = Math.round( v / s ) * s;}, { min: min_val, max: max_val, step: 10.0 * step_val} );
|
|
||||||
w2 = this.addWidget("toggle", "Random seed after every gen", true, function(v){}, { on: "enabled", off:"disabled"} );
|
|
||||||
w2.to_randomize = w1;
|
|
||||||
this._widgets += [w1, w2];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (multiline) {
|
if (multiline) {
|
||||||
var w = {
|
var w = {
|
||||||
type: "customtext",
|
type: "customtext",
|
||||||
@ -312,16 +304,6 @@ graph.onNodeRemoved = function(n) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// from https://stackoverflow.com/a/47593316
|
|
||||||
function rng_mulberry32(a) {
|
|
||||||
return function() {
|
|
||||||
var t = a += 0x6D2B79F5;
|
|
||||||
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
||||||
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
||||||
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function graphToPrompt() {
|
function graphToPrompt() {
|
||||||
let s = graph.serialize();
|
let s = graph.serialize();
|
||||||
let output = {};
|
let output = {};
|
||||||
@ -337,9 +319,6 @@ function graphToPrompt() {
|
|||||||
// find widgets declared as supporting dynamic prompting
|
// find widgets declared as supporting dynamic prompting
|
||||||
var supportedWidgets = n.widgets.filter(e => e.dynamic_prompt === true);
|
var supportedWidgets = n.widgets.filter(e => e.dynamic_prompt === true);
|
||||||
if (supportedWidgets.length > 0) {
|
if (supportedWidgets.length > 0) {
|
||||||
// find the seed widget to use for this node
|
|
||||||
var seed = n.widgets.filter(e => e.name === "seed")[0].value;
|
|
||||||
var rng = rng_mulberry32(seed);
|
|
||||||
|
|
||||||
// resolve dynamic prompts for all widgets supporting it in this node
|
// resolve dynamic prompts for all widgets supporting it in this node
|
||||||
for (let i in supportedWidgets)
|
for (let i in supportedWidgets)
|
||||||
@ -359,7 +338,7 @@ function graphToPrompt() {
|
|||||||
const optionsString = prompt.substring(startIndex + 1, endIndex);
|
const optionsString = prompt.substring(startIndex + 1, endIndex);
|
||||||
const options = optionsString.split('|');
|
const options = optionsString.split('|');
|
||||||
|
|
||||||
const randomIndex = Math.floor(rng() * (options.length));
|
const randomIndex = Math.floor(Math.random() * options.length);
|
||||||
const randomOption = options[randomIndex];
|
const randomOption = options[randomIndex];
|
||||||
|
|
||||||
prompt = prompt.substring(0, startIndex) + randomOption + prompt.substring(endIndex + 1);
|
prompt = prompt.substring(0, startIndex) + randomOption + prompt.substring(endIndex + 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user