From 0eacc0b2b094cacfec7637a408587adde897d131 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 10 Oct 2024 03:54:31 -0700 Subject: [PATCH] Use consistent name for user, planner to not miss current user query Previously Khoj would start answering the previous query. This maybe because the prompt uses User for prompt in chat history but was using Q for current user prompt. --- src/khoj/processor/conversation/prompts.py | 6 +++--- src/khoj/routers/research.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/khoj/processor/conversation/prompts.py b/src/khoj/processor/conversation/prompts.py index cc9cb2af..c72122e6 100644 --- a/src/khoj/processor/conversation/prompts.py +++ b/src/khoj/processor/conversation/prompts.py @@ -484,7 +484,7 @@ Khoj: plan_function_execution = PromptTemplate.from_template( """ -You are a smart, methodical researcher. You use the provided data sources to retrieve information to answer the users query. +You are Khoj, a smart, methodical researcher. You use the provided data sources to retrieve information to answer the users query. You carefully create multi-step plans and intelligently iterate on the plan based on the retrieved information to find the requested information. {personality_context} - Use the data sources provided below, one at a time, if you need to find more information. Their output will be shown to you in the next iteration. @@ -523,8 +523,8 @@ Response format: Chat History: {chat_history} -Q: {query} -Response: +User: {query} +Khoj: """.strip() ) diff --git a/src/khoj/routers/research.py b/src/khoj/routers/research.py index 6f479a77..7bae6c7d 100644 --- a/src/khoj/routers/research.py +++ b/src/khoj/routers/research.py @@ -59,7 +59,7 @@ async def apick_next_tool( if len(agent_tools) == 0 or tool.value in agent_tools: tool_options_str += f'- "{tool.value}": "{description}"\n' - chat_history = construct_chat_history(conversation_history) + chat_history = construct_chat_history(conversation_history, agent_name=agent.name if agent else "Khoj") if uploaded_image_url: query = f"[placeholder for user attached image]\n{query}"