From 9a93e5e417a0e45c837e26e51563c2583f6aa803 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 3 Mar 2024 23:19:23 -0300 Subject: [PATCH] Add GetNotified and Notify components --- .../{GetNotifified.py => GetNotified.py} | 0 .../langflow/components/utilities/Notify.py | 21 ++++++++++--------- src/backend/langflow/graph/graph/base.py | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) rename src/backend/langflow/components/utilities/{GetNotifified.py => GetNotified.py} (100%) diff --git a/src/backend/langflow/components/utilities/GetNotifified.py b/src/backend/langflow/components/utilities/GetNotified.py similarity index 100% rename from src/backend/langflow/components/utilities/GetNotifified.py rename to src/backend/langflow/components/utilities/GetNotified.py diff --git a/src/backend/langflow/components/utilities/Notify.py b/src/backend/langflow/components/utilities/Notify.py index a43a4bb0c..2155b079e 100644 --- a/src/backend/langflow/components/utilities/Notify.py +++ b/src/backend/langflow/components/utilities/Notify.py @@ -21,20 +21,21 @@ class NotifyComponent(CustomComponent): def build( self, name: str, record: Optional[Record] = None, append: bool = False ) -> Record: - if state and not isinstance(state, Record): - if isinstance(state, str): - state = Record(text=state) - elif isinstance(state, dict): - state = Record(data=state) + if record and not isinstance(record, Record): + if isinstance(record, str): + record = Record(text=record) + elif isinstance(record, dict): + record = Record(data=record) else: - state = Record(text=str(state)) - elif not state: - state = Record(text="") + record = Record(text=str(record)) + elif not record: + record = Record(text="") if record: if append: self.append_state(name, record) else: self.update_state(name, record) else: - state = "No record provided." - self.status = state + self.status = "No record provided." + self.status = record + return record diff --git a/src/backend/langflow/graph/graph/base.py b/src/backend/langflow/graph/graph/base.py index 06d917eb5..06ae4ee8f 100644 --- a/src/backend/langflow/graph/graph/base.py +++ b/src/backend/langflow/graph/graph/base.py @@ -699,7 +699,7 @@ class Graph: return ChatVertex elif node_name in ["ShouldRunNext"]: return RoutingVertex - elif node_name in ["SharedState"]: + elif node_name in ["SharedState", "Notify", "GetNotified"]: return StateVertex elif node_base_type in lazy_load_vertex_dict.VERTEX_TYPE_MAP: return lazy_load_vertex_dict.VERTEX_TYPE_MAP[node_base_type]