diff --git a/src/backend/langflow/api/chat_manager.py b/src/backend/langflow/api/chat_manager.py index dccd0381b..5c490c43c 100644 --- a/src/backend/langflow/api/chat_manager.py +++ b/src/backend/langflow/api/chat_manager.py @@ -36,6 +36,10 @@ class ChatHistory(Subject): else: return [] + def empty_history(self, client_id: str): + """Empty the chat history for a client.""" + self.history[client_id] = [] + class ChatManager: def __init__(self): @@ -119,6 +123,7 @@ class ChatManager: except Exception as e: # Log stack trace logger.exception(e) + self.chat_history.empty_history(client_id) raise e # Send a response back to the frontend, if needed intermediate_steps = intermediate_steps or "" diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index ec864f8d7..b6d9b78ee 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -29,6 +29,13 @@ export default function GenericNode({ const [isGreenOutline, setIsGreenOutline] = useState(false); const [isRedOutline, setIsRedOutline] = useState(false); const { reactFlowInstance } = useContext(typesContext); + const [params, setParams] = useState([]); + + useEffect(() => { + if (reactFlowInstance) { + setParams(Object.values(reactFlowInstance.toObject())); + } + }, [reactFlowInstance]); const debouncedValidateNode = useDebouncedCallback(async () => { // Check if the validationStatus is "success" @@ -60,14 +67,7 @@ export default function GenericNode({ useEffect(() => { validateNode(); - }, [ - validateNode, - // Use the result of ...reactFlowInstance.toObject() - // to determine if the node has changed - // turn into an array of nodes and edges - // and compare the length of the array - ...Object.values(reactFlowInstance.toObject()), - ]); + }, [validateNode, params]); useEffect(() => { if (validationStatus === "success") {