mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): fix edge case in nodes graph building
Inputs with explicit values are validated by pydantic even if they also have a connection (which is the actual value that is used). Fix this by omitting explicit values for inputs that have a connection.
This commit is contained in:
parent
2067757fab
commit
33e5ed7180
@ -1,8 +1,9 @@
|
|||||||
import { Graph } from 'services/api';
|
import { Graph } from 'services/api';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { cloneDeep, reduce } from 'lodash-es';
|
import { cloneDeep, forEach, omit, reduce, values } from 'lodash-es';
|
||||||
import { RootState } from 'app/store/store';
|
import { RootState } from 'app/store/store';
|
||||||
import { InputFieldValue } from 'features/nodes/types/types';
|
import { InputFieldValue } from 'features/nodes/types/types';
|
||||||
|
import { AnyInvocation } from 'services/events/types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We need to do special handling for some fields
|
* We need to do special handling for some fields
|
||||||
@ -89,6 +90,24 @@ export const buildNodesGraph = (state: RootState): Graph => {
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Omit all inputs that have edges connected.
|
||||||
|
*
|
||||||
|
* Fixes edge case where the user has connected an input, but also provided an invalid explicit,
|
||||||
|
* value.
|
||||||
|
*
|
||||||
|
* In this edge case, pydantic will invalidate the node based on the invalid explicit value,
|
||||||
|
* even though the actual value that will be used comes from the connection.
|
||||||
|
*/
|
||||||
|
parsedEdges.forEach((edge) => {
|
||||||
|
const destination_node = parsedNodes[edge.destination.node_id];
|
||||||
|
const field = edge.destination.field;
|
||||||
|
parsedNodes[edge.destination.node_id] = omit(
|
||||||
|
destination_node,
|
||||||
|
field
|
||||||
|
) as AnyInvocation;
|
||||||
|
});
|
||||||
|
|
||||||
// Assemble!
|
// Assemble!
|
||||||
const graph = {
|
const graph = {
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
|
Loading…
Reference in New Issue
Block a user