From 6707ccc4633b66469e2a0f821cf1bb562d25ae44 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 15 Apr 2024 21:06:47 +0530 Subject: [PATCH] Check before updating "chat" key in meta_log in chat history API endpoint --- src/khoj/routers/api_chat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/khoj/routers/api_chat.py b/src/khoj/routers/api_chat.py index 5b8910bb..867319ed 100644 --- a/src/khoj/routers/api_chat.py +++ b/src/khoj/routers/api_chat.py @@ -111,10 +111,10 @@ def chat_history( ) # Get latest N messages if N > 0 - if n > 0: + if n > 0 and meta_log.get("chat"): meta_log["chat"] = meta_log["chat"][-n:] # Else return all messages except latest N - elif n < 0: + elif n < 0 and meta_log.get("chat"): meta_log["chat"] = meta_log["chat"][:n] update_telemetry_state(