replace existing file records on re-import
build / build (push) Successful in 9s
pytest / pytest (push) Successful in 25s

This commit is contained in:
Matteo Rosati
2026-04-29 14:46:41 +02:00
parent d1b1238897
commit 74e48fbcd5
3 changed files with 79 additions and 1 deletions
+4 -1
View File
@@ -4,12 +4,15 @@ from pathlib import Path
from chromadb import QueryResult
from chromy.chroma_functions import add_data, query_data
from chromy.chroma_functions import add_data, delete_data, has_data_for_file, query_data
from chromy.chunk_functions import chunk_file
from chromy.embed import embed
def ingest_file(collection_name: str, file_path: str) -> int:
if has_data_for_file(collection_name, file_path):
delete_data(collection_name, {"file_name": file_path})
chunks = chunk_file(file_path)
embeddings = embed(chunks)
add_data(collection_name, embeddings, file_path)