feat(chat_manager.py): add empty_history method to ChatHistory class

fix(chat_manager.py): empty chat history for a client when an exception is raised
fix(GenericNode): fix useEffect dependencies to avoid unnecessary re-renders
This commit is contained in:
Gabriel Almeida 2023-04-28 20:31:53 -03:00
commit c3dffa3508
2 changed files with 13 additions and 8 deletions

View file

@ -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 ""