Skip to content

Commit

Permalink
More lenient date searching (#481)
Browse files Browse the repository at this point in the history
* Modify DateFilter to use compiled entry key
* Instruct search to include date in query
* Minor prompt change
* Prompt fix
  • Loading branch information
Jonny-GM authored Sep 18, 2023
1 parent 16874e1 commit 34b202b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/khoj/processor/conversation/openai/gpt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Standard Packages
import logging
from datetime import datetime
from datetime import datetime, timedelta
from typing import Optional

# External Packages
Expand Down Expand Up @@ -70,6 +70,7 @@ def extract_questions(
bob_age={current_new_year.year - 1984},
chat_history=chat_history,
text=text,
yesterday_date=(today - timedelta(days=1)).strftime("%Y-%m-%d")
)
messages = [ChatMessage(content=prompt, role="assistant")]

Expand Down
6 changes: 6 additions & 0 deletions src/khoj/processor/conversation/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@
A: Bob is {bob_tom_age_difference} years older than Tom. As Bob is {bob_age} years old and Tom is 30 years old.
Q: What does yesterday's note say?
["Note from {yesterday_date} dt='{yesterday_date}'"]
A: Yesterday's note contains the following information: ...
{chat_history}
Q: {text}
Expand Down
2 changes: 1 addition & 1 deletion src/khoj/search_filter/date_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DateFilter(BaseFilter):
# - dt:"2 years ago"
date_regex = r"dt([:><=]{1,2})[\"'](.*?)[\"']"

def __init__(self, entry_key="raw"):
def __init__(self, entry_key="compiled"):
self.entry_key = entry_key
self.date_to_entry_ids = defaultdict(set)
self.cache = LRU()
Expand Down

0 comments on commit 34b202b

Please sign in to comment.