From 2667ef45449eb408ce1d7c393be04845be31e15f Mon Sep 17 00:00:00 2001 From: sabaimran Date: Fri, 31 May 2024 16:15:56 +0530 Subject: [PATCH] Refresh the conversation from the db in the websocket flow --- src/khoj/routers/api_chat.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/khoj/routers/api_chat.py b/src/khoj/routers/api_chat.py index 172ebba3..ce167713 100644 --- a/src/khoj/routers/api_chat.py +++ b/src/khoj/routers/api_chat.py @@ -487,6 +487,10 @@ async def websocket_endpoint( if conversation: await sync_to_async(conversation.refresh_from_db)(fields=["conversation_log"]) q = await websocket.receive_text() + + # Refresh these because the connection to the database might have been closed + await conversation.arefresh_from_db() + except WebSocketDisconnect: logger.debug(f"User {user} disconnected web socket") break