diff --git a/src/backend/langflow/components/utilities/SharedState.py b/src/backend/langflow/components/utilities/SharedState.py index 7d29da9bb..845252dab 100644 --- a/src/backend/langflow/components/utilities/SharedState.py +++ b/src/backend/langflow/components/utilities/SharedState.py @@ -28,7 +28,7 @@ class SharedState(CustomComponent): self.update_state(name, record) state = self.get_state(name) - if not isinstance(state, Record): + if state and not isinstance(state, Record): if isinstance(state, str): state = Record(text=state) elif isinstance(state, dict): diff --git a/src/backend/langflow/interface/custom/custom_component/custom_component.py b/src/backend/langflow/interface/custom/custom_component/custom_component.py index b8ec433f3..fd8cd7cd2 100644 --- a/src/backend/langflow/interface/custom/custom_component/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component/custom_component.py @@ -76,13 +76,17 @@ class CustomComponent(Component): def update_state(self, name: str, value: Any): try: - self.vertex.graph.state_manager.update_state(key=name, new_state=value) + self.vertex.graph.update_state( + name=name, record=value, caller=self.vertex.id + ) except Exception as e: raise ValueError(f"Error updating state: {e}") def append_state(self, name: str, value: Any): try: - self.vertex.graph.state_manager.append_state(key=name, new_state=value) + self.vertex.graph.append_state( + key=name, record=value, caller=self.vertex.id + ) except Exception as e: raise ValueError(f"Error appending state: {e}")