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:
parent
177ffb3ea5
commit
c3dffa3508
2 changed files with 13 additions and 8 deletions
|
|
@ -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 ""
|
||||
|
|
|
|||
|
|
@ -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") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue