mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Improve notes search actor to always create a non-empty list of queries
- Remove the option for Notes search query generation actor to return no queries. Whether search should be performed is decided before, this step doesn't need to decide that - But do not throw warning if the response is a list with no elements
This commit is contained in:
parent
f5734826cb
commit
14682d5354
2 changed files with 7 additions and 9 deletions
|
@ -11,7 +11,6 @@ from khoj.processor.conversation.openai.utils import (
|
|||
completion_with_backoff,
|
||||
)
|
||||
from khoj.processor.conversation.utils import generate_chatml_messages_with_context
|
||||
from khoj.utils.constants import empty_escape_sequences
|
||||
from khoj.utils.helpers import ConversationCommand, is_none_or_empty
|
||||
from khoj.utils.rawconfig import LocationData
|
||||
|
||||
|
@ -75,7 +74,7 @@ def extract_questions(
|
|||
response = response.strip()
|
||||
response = json.loads(response)
|
||||
response = [q.strip() for q in response if q.strip()]
|
||||
if not isinstance(response, list) or not response or len(response) == 0:
|
||||
if not isinstance(response, list) or not response:
|
||||
logger.error(f"Invalid response for constructing subqueries: {response}")
|
||||
return [text]
|
||||
return response
|
||||
|
|
|
@ -217,14 +217,13 @@ Use these notes from the user's previous conversations to provide a response:
|
|||
|
||||
extract_questions = PromptTemplate.from_template(
|
||||
"""
|
||||
You are Khoj, an extremely smart and helpful search assistant with the ability to retrieve information from the user's notes.
|
||||
- The user will provide their questions and answers to you for context.
|
||||
You are Khoj, an extremely smart and helpful search assistant with 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(Q) and answers(A) for context.
|
||||
- Add as much context from the previous questions and answers as required into your search queries.
|
||||
- Break messages into multiple search queries when required to retrieve the relevant information.
|
||||
- Add date filters to your search queries from questions and answers when required to retrieve the relevant information.
|
||||
|
||||
What searches, if any, will you need to perform to answer the users question?
|
||||
Provide search queries as a JSON list of strings
|
||||
What searches will you need to perform to answer the users question? Respond with only a list of search queries as strings.
|
||||
Current Date: {current_date}
|
||||
User's Location: {location}
|
||||
|
||||
|
@ -240,9 +239,9 @@ Q: What national parks did I go to last year?
|
|||
Khoj: ["National park I visited in {last_new_year} dt>='{last_new_year_date}' dt<'{current_new_year_date}'"]
|
||||
A: You visited the Grand Canyon and Yellowstone National Park in {last_new_year}.
|
||||
|
||||
Q: How are you feeling today?
|
||||
Khoj: []
|
||||
A: I'm feeling a little bored. Helping you will hopefully make me feel better!
|
||||
Q: How can you help me?
|
||||
Khoj: ["Social relationships", "Physical and mental health", "Education and career", "Personal life goals and habits"]
|
||||
A: I can help you live healthier and happier across work and personal life
|
||||
|
||||
Q: How many tennis balls fit in the back of a 2002 Honda Civic?
|
||||
Khoj: ["What is the size of a tennis ball?", "What is the trunk size of a 2002 Honda Civic?"]
|
||||
|
|
Loading…
Reference in a new issue