Merge branch 'zustand/io/migration' of github.com:logspace-ai/langflow into zustand/io/migration

This commit is contained in:
igorrCarvalho 2024-01-26 10:56:04 -03:00
commit fc1614c7c1
10 changed files with 31 additions and 60 deletions

View file

@ -28,23 +28,14 @@ def ungroup_node(group_node_data, base_flow):
g_edges = flow["data"]["edges"]
# Redirect edges to the correct proxy node
updated_edges = get_updated_edges(
base_flow, g_nodes, g_edges, group_node_data["id"]
)
updated_edges = get_updated_edges(base_flow, g_nodes, g_edges, group_node_data["id"])
# Update template values
update_template(template, g_nodes)
nodes = [
n for n in base_flow["nodes"] if n["id"] != group_node_data["id"]
] + g_nodes
nodes = [n for n in base_flow["nodes"] if n["id"] != group_node_data["id"]] + g_nodes
edges = (
[
e
for e in base_flow["edges"]
if e["target"] != group_node_data["id"]
and e["source"] != group_node_data["id"]
]
[e for e in base_flow["edges"] if e["target"] != group_node_data["id"] and e["source"] != group_node_data["id"]]
+ g_edges
+ updated_edges
)
@ -66,11 +57,7 @@ def process_flow(flow_object):
if node_id in processed_nodes:
return
if (
node.get("data")
and node["data"].get("node")
and node["data"]["node"].get("flow")
):
if node.get("data") and node["data"].get("node") and node["data"]["node"].get("flow"):
process_flow(node["data"]["node"]["flow"]["data"])
new_nodes = ungroup_node(node["data"], cloned_flow)
# Add new nodes to the queue for future processing
@ -108,26 +95,16 @@ def update_template(template, g_nodes):
if node_index != -1:
display_name = None
show = g_nodes[node_index]["data"]["node"]["template"][field]["show"]
advanced = g_nodes[node_index]["data"]["node"]["template"][field][
"advanced"
]
advanced = g_nodes[node_index]["data"]["node"]["template"][field]["advanced"]
if "display_name" in g_nodes[node_index]["data"]["node"]["template"][field]:
display_name = g_nodes[node_index]["data"]["node"]["template"][field][
"display_name"
]
display_name = g_nodes[node_index]["data"]["node"]["template"][field]["display_name"]
else:
display_name = g_nodes[node_index]["data"]["node"]["template"][field][
"name"
]
display_name = g_nodes[node_index]["data"]["node"]["template"][field]["name"]
g_nodes[node_index]["data"]["node"]["template"][field] = value
g_nodes[node_index]["data"]["node"]["template"][field]["show"] = show
g_nodes[node_index]["data"]["node"]["template"][field][
"advanced"
] = advanced
g_nodes[node_index]["data"]["node"]["template"][field][
"display_name"
] = display_name
g_nodes[node_index]["data"]["node"]["template"][field]["advanced"] = advanced
g_nodes[node_index]["data"]["node"]["template"][field]["display_name"] = display_name
def update_target_handle(new_edge, g_nodes, group_node_id):

View file

@ -80,6 +80,14 @@ class Vertex:
# If the Vertex.type is a power component
# then we need to return the built object
# instead of the result dict
if self.is_power_component and not isinstance(self._built_object, UnbuiltObject):
result = self._built_object
# if it is not a dict or a string and hasattr model_dump then
# return the model_dump
if not isinstance(result, (dict, str)) and hasattr(result, "content"):
return result.content
return result
if isinstance(self._built_result, UnbuiltResult):
return {}
return self._built_result if isinstance(self._built_result, dict) else {"result": self._built_result}

View file

@ -327,7 +327,7 @@ class ChatVertex(StatelessVertex):
message=str(self._built_object),
sender=sender,
sender_name=sender_name,
).dict()
).model_dump()
self._built_result = self._built_object
else:

View file

@ -141,7 +141,9 @@ class SeriesCharacterChainNode(FrontendNode):
),
],
)
description: str = "SeriesCharacterChain is a chain you can use to have a conversation with a character from a series." # noqa
description: str = (
"SeriesCharacterChain is a chain you can use to have a conversation with a character from a series." # noqa
)
base_classes: list[str] = [
"LLMChain",
"BaseCustomChain",

View file

@ -34,7 +34,7 @@ export default function newChatView(): JSX.Element {
const inputTypes = inputs.map((obj) => obj.type);
const inputIds = inputs.map((obj) => obj.id);
const outputIds = outputs.map((obj) => obj.id)
const outputIds = outputs.map((obj) => obj.id);
//build chat history
useEffect(() => {

View file

@ -35,8 +35,8 @@ export type FlowPoolType = {
export type FlowStoreType = {
flowPool: FlowPoolType;
inputs: Array<{ type: string; id: string; }>;
outputs: Array<{ type: string; id: string; }>;
inputs: Array<{ type: string; id: string }>;
outputs: Array<{ type: string; id: string }>;
hasIO: boolean;
setFlowPool: (flowPool: FlowPoolType) => void;
addDataToFlowPool: (data: any, nodeId: string) => void;