Fix to use agent chat model for research model planning

Previously the research mode planner ignored the current agent or
conversation specific chat model the user was chatting with. Only the
server chat settings, user default chat model, first created chat model
were considered to decide the planner chat model.

This change considers the agent chat model to be used for the planner
as well. The actual chat model picked is decided by the existing
prioritization of server > agent > user > first chat model.
This commit is contained in:
Debanjum
2025-03-25 15:29:56 +05:30
parent df090e5226
commit c337c53452
2 changed files with 3 additions and 1 deletions

View File

@@ -1182,7 +1182,7 @@ class ConversationAdapters:
@staticmethod
async def aget_default_chat_model(user: KhojUser = None, fallback_chat_model: Optional[ChatModel] = None):
"""Get default conversation config. Prefer chat model by server admin > user > first created chat model"""
"""Get default conversation config. Prefer chat model by server admin > agent > user > first created chat model"""
# Get the server chat settings
server_chat_settings: ServerChatSettings = (
await ServerChatSettings.objects.filter()

View File

@@ -113,6 +113,7 @@ async def apick_next_tool(
today = datetime.today()
location_data = f"{location}" if location else "Unknown"
agent_chat_model = agent.chat_model if agent else None
personality_context = (
prompts.personality_context.format(personality=agent.personality) if agent and agent.personality else ""
)
@@ -140,6 +141,7 @@ async def apick_next_tool(
user=user,
query_images=query_images,
query_files=query_files,
agent_chat_model=agent_chat_model,
tracer=tracer,
)
except Exception as e: