From 9f51dc3cdbcbb91d730d255eefeeb9ce704ce280 Mon Sep 17 00:00:00 2001 From: Ryan Chen Date: Sun, 31 May 2026 07:16:28 -0400 Subject: [PATCH] Fix NOT NULL violation on empty splits and increase search results to k=6 Empty documents after sanitization caused aadd_documents to issue a DEFAULT VALUES insert. Guard with an emptiness check. Also increase similarity search k from 2 to 6 so multi-word queries like full names have better recall. Co-Authored-By: Claude Opus 4.6 --- blueprints/rag/logic.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/blueprints/rag/logic.py b/blueprints/rag/logic.py index 21f02c3..5c2d46a 100644 --- a/blueprints/rag/logic.py +++ b/blueprints/rag/logic.py @@ -325,8 +325,9 @@ async def sync_obsidian_documents() -> dict[str, int]: if documents: splits = text_splitter.split_documents(documents) splits = _sanitize_documents(splits) - vector_store = _get_vector_store() - await vector_store.aadd_documents(documents=splits) + if splits: + vector_store = _get_vector_store() + await vector_store.aadd_documents(documents=splits) logger.info( f"Obsidian sync complete: {added} added, {updated} updated, {deleted} deleted" @@ -336,7 +337,7 @@ async def sync_obsidian_documents() -> dict[str, int]: async def query_vector_store(query: str): vector_store = _get_vector_store() - retrieved_docs = await vector_store.asimilarity_search(query, k=2) + retrieved_docs = await vector_store.asimilarity_search(query, k=6) serialized = "\n\n".join( (f"Source: {doc.metadata}\nContent: {doc.page_content}") for doc in retrieved_docs