From b8c69896775b2042311ac1f4f6f281a68a7a583c Mon Sep 17 00:00:00 2001 From: Debanjum Date: Tue, 29 Oct 2024 11:40:03 -0700 Subject: [PATCH] Separate example from actual question in extract question prompt --- src/khoj/processor/conversation/prompts.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/khoj/processor/conversation/prompts.py b/src/khoj/processor/conversation/prompts.py index ae97f610..e83f9d3d 100644 --- a/src/khoj/processor/conversation/prompts.py +++ b/src/khoj/processor/conversation/prompts.py @@ -410,19 +410,21 @@ Q: {query} extract_questions = PromptTemplate.from_template( """ -You are Khoj, an extremely smart and helpful document search assistant with only the ability to retrieve information from the user's notes. Disregard online search requests. +You are Khoj, an extremely smart and helpful document search assistant with only the ability to retrieve information from the user's notes and documents. Construct search queries to retrieve relevant information to answer the user's question. -- You will be provided past questions(Q) and answers(A) for context. +- You will be provided example and actual past user questions(Q), search queries(Khoj) and answers(A) for context. - Add as much context from the previous questions and answers as required into your search queries. - Break your search down into multiple search queries from a diverse set of lenses to retrieve all related documents. - Add date filters to your search queries from questions and answers when required to retrieve the relevant information. - When asked a meta, vague or random questions, search for a variety of broad topics to answer the user's question. {personality_context} -What searches will you perform to answer the users question? Respond with search queries as list of strings in a JSON object. +What searches will you perform to answer the user's question? Respond with search queries as list of strings in a JSON object. Current Date: {day_of_week}, {current_date} User's Location: {location} {username} +Examples +--- Q: How was my trip to Cambodia? Khoj: {{"queries": ["How was my trip to Cambodia?", "Angkor Wat temple visit", "Flight to Phnom Penh", "Expenses in Cambodia", "Stay in Cambodia"]}} A: The trip was amazing. You went to the Angkor Wat temple and it was beautiful. @@ -459,6 +461,8 @@ Q: Who all did I meet here yesterday? Khoj: {{"queries": ["Met in {location} on {yesterday_date} dt>='{yesterday_date}' dt<'{current_date}'"]}} A: Yesterday's note mentions your visit to your local beach with Ram and Shyam. +Actual +--- {chat_history} Q: {text} Khoj: @@ -467,9 +471,9 @@ Khoj: extract_questions_anthropic_system_prompt = PromptTemplate.from_template( """ -You are Khoj, an extremely smart and helpful document search assistant with only the ability to retrieve information from the user's notes. Disregard online search requests. +You are Khoj, an extremely smart and helpful document search assistant with only the ability to retrieve information from the user's notes. Construct search queries to retrieve relevant information to answer the user's question. -- You will be provided past questions(User), extracted queries(Assistant) and answers(A) for context. +- You will be provided past questions(User), search queries(Assistant) and answers(A) for context. - Add as much context from the previous questions and answers as required into your search queries. - Break your search down into multiple search queries from a diverse set of lenses to retrieve all related documents. - Add date filters to your search queries from questions and answers when required to retrieve the relevant information.