fix(ui): check for metadataAccumulator before connecting to it

Fixes an edge case in graph building.
This commit is contained in:
psychedelicious 2023-07-14 10:08:04 +10:00
parent 536a397b12
commit 14587464d5

View File

@ -81,6 +81,7 @@ export const addDynamicPromptsToGraph = (
); );
// hook up positive prompt to metadata // hook up positive prompt to metadata
if (metadataAccumulator) {
graph.edges.push({ graph.edges.push({
source: { source: {
node_id: ITERATE, node_id: ITERATE,
@ -91,6 +92,7 @@ export const addDynamicPromptsToGraph = (
field: 'positive_prompt', field: 'positive_prompt',
}, },
}); });
}
if (shouldRandomizeSeed) { if (shouldRandomizeSeed) {
// Random int node to generate the starting seed // Random int node to generate the starting seed
@ -107,10 +109,12 @@ export const addDynamicPromptsToGraph = (
destination: { node_id: NOISE, field: 'seed' }, destination: { node_id: NOISE, field: 'seed' },
}); });
if (metadataAccumulator) {
graph.edges.push({ graph.edges.push({
source: { node_id: RANDOM_INT, field: 'a' }, source: { node_id: RANDOM_INT, field: 'a' },
destination: { node_id: METADATA_ACCUMULATOR, field: 'seed' }, destination: { node_id: METADATA_ACCUMULATOR, field: 'seed' },
}); });
}
} else { } else {
// User specified seed, so set the start of the range of size to the seed // User specified seed, so set the start of the range of size to the seed
(graph.nodes[NOISE] as NoiseInvocation).seed = seed; (graph.nodes[NOISE] as NoiseInvocation).seed = seed;
@ -164,6 +168,7 @@ export const addDynamicPromptsToGraph = (
}); });
// hook up seed to metadata // hook up seed to metadata
if (metadataAccumulator) {
graph.edges.push({ graph.edges.push({
source: { source: {
node_id: ITERATE, node_id: ITERATE,
@ -174,7 +179,7 @@ export const addDynamicPromptsToGraph = (
field: 'seed', field: 'seed',
}, },
}); });
}
// handle seed // handle seed
if (shouldRandomizeSeed) { if (shouldRandomizeSeed) {
// Random int node to generate the starting seed // Random int node to generate the starting seed