mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01: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:
parent
d50bfb5188
commit
4ead79d272
2 changed files with 16 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue