diff --git a/src/khoj/database/adapters/__init__.py b/src/khoj/database/adapters/__init__.py index 1dce9c8e..b939b38f 100644 --- a/src/khoj/database/adapters/__init__.py +++ b/src/khoj/database/adapters/__init__.py @@ -394,8 +394,9 @@ class ClientApplicationAdapters: class AgentAdapters: - DEFAULT_AGENT_NAME = "khoj" + DEFAULT_AGENT_NAME = "Khoj" DEFAULT_AGENT_AVATAR = "https://khoj-web-bucket.s3.amazonaws.com/lamp-128.png" + DEFAULT_AGENT_SLUG = "khoj" @staticmethod async def aget_agent_by_id(agent_id: int): @@ -447,6 +448,8 @@ class AgentAdapters: agent = Agent.objects.filter(name=AgentAdapters.DEFAULT_AGENT_NAME).first() agent.tuning = default_personality agent.chat_model = default_conversation_config + agent.slug = AgentAdapters.DEFAULT_AGENT_SLUG + agent.name = AgentAdapters.DEFAULT_AGENT_NAME agent.save() return agent @@ -459,6 +462,7 @@ class AgentAdapters: tuning=default_personality, tools=["*"], avatar=AgentAdapters.DEFAULT_AGENT_AVATAR, + slug=AgentAdapters.DEFAULT_AGENT_SLUG, ) @staticmethod diff --git a/src/khoj/routers/api_agents.py b/src/khoj/routers/api_agents.py index 3465a21f..fd8d6f1b 100644 --- a/src/khoj/routers/api_agents.py +++ b/src/khoj/routers/api_agents.py @@ -36,4 +36,8 @@ async def all_agents( "managed_by_admin": agent.managed_by_admin, } ) + + # Make sure that the agent named 'khoj' is first in the list. Everything else is sorted by name. + agents_packet.sort(key=lambda x: x["name"]) + agents_packet.sort(key=lambda x: x["slug"] == "khoj", reverse=True) return Response(content=json.dumps(agents_packet), media_type="application/json", status_code=200)