From 5b248e8515d59c9aa59151adeca5ed541e2d4de7 Mon Sep 17 00:00:00 2001 From: Debanjum Date: Wed, 9 Apr 2025 18:16:44 +0530 Subject: [PATCH] Fix fallback to default agent if none set for conversation Previous change to fallback to default agent was not functional. It would error out if the conversation agent wasn't set when trying to get conversation.agent.slug for calling aget_agent_by_slug func --- src/khoj/routers/api_agents.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/khoj/routers/api_agents.py b/src/khoj/routers/api_agents.py index 1f20b5fa..71514025 100644 --- a/src/khoj/routers/api_agents.py +++ b/src/khoj/routers/api_agents.py @@ -119,11 +119,11 @@ async def get_agent_by_conversation( media_type="application/json", status_code=404, ) - if not conversation.agent: + if conversation.agent: + agent = await AgentAdapters.aget_agent_by_slug(conversation.agent.slug, user) + else: agent = await AgentAdapters.aget_default_agent() - agent = await AgentAdapters.aget_agent_by_slug(conversation.agent.slug, user) - has_files = agent.fileobject_set.exists() agents_packet = {