From c9bb88933bdb8a6ee9a01eb7aa3b9fa2c877ff27 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 28 Jun 2023 16:51:02 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(chat.py):=20reset=20chat?= =?UTF-8?q?=20history=20when=20building=20a=20flow=20to=20ensure=20a=20cle?= =?UTF-8?q?an=20state=20The=20chat=20history=20is=20now=20reset=20when=20b?= =?UTF-8?q?uilding=20a=20flow=20to=20ensure=20that=20the=20chat=20starts?= =?UTF-8?q?=20with=20a=20clean=20state.=20This=20helps=20prevent=20any=20p?= =?UTF-8?q?otential=20issues=20or=20conflicts=20that=20may=20arise=20from?= =?UTF-8?q?=20previous=20chat=20interactions.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/chat.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/langflow/api/v1/chat.py b/src/backend/langflow/api/v1/chat.py index 44ea0ca8a..de3c33e01 100644 --- a/src/backend/langflow/api/v1/chat.py +++ b/src/backend/langflow/api/v1/chat.py @@ -128,6 +128,8 @@ async def stream_build(flow_id: str): yield str(StreamData(event="message", data=input_keys_response)) chat_manager.set_cache(flow_id, langchain_object) + # We need to reset the chat history + chat_manager.chat_history.empty_history(flow_id) except Exception as exc: logger.error("Error while building the flow: %s", exc) yield str(StreamData(event="error", data={"error": str(exc)}))