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
This commit is contained in:
Debanjum
2025-04-09 18:16:44 +05:30
parent 4012a6372f
commit 5b248e8515

View File

@@ -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 = {