Skip to content

Commit

Permalink
Fix process for generating embeddings for Notion entries (#648)
Browse files Browse the repository at this point in the history
* Fix process for generating embeddings for Notion entries
* If no title field found, just log a warning and set the title to
  • Loading branch information
sabaimran authored Feb 20, 2024
1 parent 43013c4 commit 138f522
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/khoj/processor/content/notion/notion_to_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ def process(
page_entries = self.process_page(p_or_d)
current_entries.extend(page_entries)

return self.update_entries_with_ids(current_entries, user)
current_entries = TextToEntries.split_entries_by_max_tokens(current_entries, max_tokens=256)

return self.update_entries_with_ids(current_entries, user=user)

def process_page(self, page):
page_id = page["id"]
Expand Down Expand Up @@ -232,8 +234,9 @@ def get_page_content(self, page_id):
elif "Event" in properties:
title_field = "Event"
elif title_field not in properties:
logger.error(f"Page {page_id} does not have a title field")
return None, None
logger.warning(f"Title field not found for page {page_id}. Setting title as None...")
title = None
return title, content
try:
title = page["properties"][title_field]["title"][0]["text"]["content"]
except Exception as e:
Expand Down

0 comments on commit 138f522

Please sign in to comment.