Fix vertex sorting issue in Graph class

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-02-20 10:47:44 -03:00
commit b308183f0d

View file

@ -94,6 +94,7 @@ class Graph:
or vertex.__repr__() != other.get_vertex(vertex.id).__repr__() or vertex.__repr__() != other.get_vertex(vertex.id).__repr__()
): ):
vertex.data = other.get_vertex(vertex.id).data vertex.data = other.get_vertex(vertex.id).data
vertex.params = {}
vertex._build_params() vertex._build_params()
vertex.graph = self vertex.graph = self
vertex._built = False vertex._built = False
@ -461,11 +462,12 @@ class Graph:
# we just need to check if the vertex id contains ChatInput or ChatOutput # we just need to check if the vertex id contains ChatInput or ChatOutput
# and sort the layers accordingly # and sort the layers accordingly
# InterfaceComponentTypes is an enum # InterfaceComponentTypes is an enum
# check all values of the enum and sort the layers
for layer in vertices: for layer in vertices:
layer.sort( layer.sort(
key=lambda x: any( key=lambda x: any(
InterfaceComponentTypes.CHAT_INPUT.value in x, comp_type.value in x
InterfaceComponentTypes.CHAT_OUTPUT.value in x, for comp_type in InterfaceComponentTypes.__members__.values()
) )
) )
return self.sort_chat_inputs_first(vertices) return self.sort_chat_inputs_first(vertices)