Skip adding agent to chat metadata when chat unset to avoids null ref

This commit is contained in:
Debanjum 2024-11-19 21:08:49 -08:00
parent 4da0499cd7
commit 9ab76ccaf1

View file

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