mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Make Notes Search Natural Language Date Aware
- Pass Scheduled, Closed Dates of Entries to Include in Embeddings - The (new?) model seems to understand dates. So can give more relevant entries if date in natural language mentioned in query - E.g "Went Surfing with Friends" vs "Went Surfing with Friends in 1984" will give different results, with the second prioritizing entries mentioning any entries with closed, scheduled dates from 1984
This commit is contained in:
@@ -115,6 +115,16 @@ def convert_org_entries_to_jsonl(entries, verbose=0):
|
||||
if verbose > 2:
|
||||
print(f"Tags: {tags_str}")
|
||||
|
||||
if entry.Closed():
|
||||
entry_dict["Closed"] = entry.Closed().strftime("%Y-%m-%d")
|
||||
if verbose > 2:
|
||||
print(f'Closed: {entry.Closed().strftime("%Y-%m-%d")}')
|
||||
|
||||
if entry.Scheduled():
|
||||
entry_dict["Scheduled"] = entry.Scheduled().strftime("%Y-%m-%d")
|
||||
if verbose > 2:
|
||||
print(f'Scheduled: {entry.Scheduled().strftime("%Y-%m-%d")}')
|
||||
|
||||
if entry.Body():
|
||||
entry_dict["Body"] = entry.Body()
|
||||
if verbose > 2:
|
||||
|
||||
@@ -60,9 +60,12 @@ def extract_entries(notesfile, verbose=0):
|
||||
if not "Body" in note or note["Body"].strip(empty_escape_sequences) == "":
|
||||
continue
|
||||
|
||||
note_string = f'{note["Title"]}' \
|
||||
f'\t{note["Tags"] if "Tags" in note else ""}' \
|
||||
f'\n{note["Body"] if "Body" in note else ""}'
|
||||
scheduled_str = f'\t Scheduled for {note["Scheduled"]}' if "Scheduled" in note else ""
|
||||
closed_str = f'\t Closed on {note["Closed"]}' if "Closed" in note else ""
|
||||
tags_str = f'\t {note["Tags"]}' if "Tags" in note else ""
|
||||
body_str = f'\n {note["Body"]}' if "Body" in note else ""
|
||||
|
||||
note_string = f'{note["Title"]}{tags_str}{closed_str}{scheduled_str}{body_str}'
|
||||
entries.append({'compiled': note_string, 'raw': note["Raw"]})
|
||||
|
||||
# Close File
|
||||
|
||||
Reference in New Issue
Block a user