From 9ab76ccaf108d1413b6b781fcca3c4965883ffed Mon Sep 17 00:00:00 2001 From: Debanjum Date: Tue, 19 Nov 2024 21:08:49 -0800 Subject: [PATCH] Skip adding agent to chat metadata when chat unset to avoids null ref --- src/khoj/routers/api_chat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/khoj/routers/api_chat.py b/src/khoj/routers/api_chat.py index a9086dd0..e9f31ea9 100644 --- a/src/khoj/routers/api_chat.py +++ b/src/khoj/routers/api_chat.py @@ -682,7 +682,7 @@ async def chat( cmd_set = set([cmd.value for cmd in conversation_commands]) chat_metadata = chat_metadata or {} chat_metadata["conversation_command"] = cmd_set - chat_metadata["agent"] = conversation.agent.slug if conversation.agent else None + chat_metadata["agent"] = conversation.agent.slug if conversation and conversation.agent else None chat_metadata["latency"] = f"{latency:.3f}" chat_metadata["ttft_latency"] = f"{ttft:.3f}"