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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user