🔧 chore(chat.py): reset chat history when building a flow to ensure a clean state

The chat history is now reset when building a flow to ensure that the chat starts with a clean state. This helps prevent any potential issues or conflicts that may arise from previous chat interactions.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-28 16:51:02 -03:00
commit c9bb88933b

View file

@ -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)}))