From 963ebc8875c5ba5524d5ea79c795013ea8201fa8 Mon Sep 17 00:00:00 2001 From: Debanjum Date: Wed, 11 Jun 2025 17:54:55 -0700 Subject: [PATCH] Pass query params to doc search function before user, chat history Makes document search arg ordering more consistent with other tools like online search, run code etc. --- src/khoj/routers/api_chat.py | 4 ++-- src/khoj/routers/helpers.py | 4 ++-- src/khoj/routers/research.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/khoj/routers/api_chat.py b/src/khoj/routers/api_chat.py index d971bf4b..da52746a 100644 --- a/src/khoj/routers/api_chat.py +++ b/src/khoj/routers/api_chat.py @@ -1064,11 +1064,11 @@ async def chat( if not ConversationCommand.Research in conversation_commands: try: async for result in search_documents( - user, - chat_history, q, (n or 7), d, + user, + chat_history, conversation_id, conversation_commands, location, diff --git a/src/khoj/routers/helpers.py b/src/khoj/routers/helpers.py index e1a7f812..11e729cf 100644 --- a/src/khoj/routers/helpers.py +++ b/src/khoj/routers/helpers.py @@ -1159,11 +1159,11 @@ async def generate_better_image_prompt( async def search_documents( - user: KhojUser, - chat_history: list[ChatMessageModel], q: str, n: int, d: float, + user: KhojUser, + chat_history: list[ChatMessageModel], conversation_id: str, conversation_commands: List[ConversationCommand] = [ConversationCommand.Default], location_data: LocationData = None, diff --git a/src/khoj/routers/research.py b/src/khoj/routers/research.py index 2e9a1b79..8cb415cb 100644 --- a/src/khoj/routers/research.py +++ b/src/khoj/routers/research.py @@ -313,11 +313,11 @@ async def research( c["query"] for iteration in previous_iterations if iteration.context for c in iteration.context } async for result in search_documents( - user, - construct_tool_chat_history(previous_iterations, ConversationCommand.Notes), this_iteration.query, max_document_searches, None, + user, + construct_tool_chat_history(previous_iterations, ConversationCommand.Notes), conversation_id, [ConversationCommand.Default], location,