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,16 +81,18 @@ export const addDynamicPromptsToGraph = (
); );
// hook up positive prompt to metadata // hook up positive prompt to metadata
graph.edges.push({ if (metadataAccumulator) {
source: { graph.edges.push({
node_id: ITERATE, source: {
field: 'item', node_id: ITERATE,
}, field: 'item',
destination: { },
node_id: METADATA_ACCUMULATOR, destination: {
field: 'positive_prompt', node_id: METADATA_ACCUMULATOR,
}, 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' },
}); });
graph.edges.push({ if (metadataAccumulator) {
source: { node_id: RANDOM_INT, field: 'a' }, graph.edges.push({
destination: { node_id: METADATA_ACCUMULATOR, field: 'seed' }, source: { node_id: RANDOM_INT, field: 'a' },
}); 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,17 +168,18 @@ export const addDynamicPromptsToGraph = (
}); });
// hook up seed to metadata // hook up seed to metadata
graph.edges.push({ if (metadataAccumulator) {
source: { graph.edges.push({
node_id: ITERATE, source: {
field: 'item', node_id: ITERATE,
}, field: 'item',
destination: { },
node_id: METADATA_ACCUMULATOR, destination: {
field: 'seed', node_id: METADATA_ACCUMULATOR,
}, 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