Simplify deleting all chunks
This commit is contained in:
parent
b73949c784
commit
75e878308e
1 changed files with 6 additions and 15 deletions
|
|
@ -51,7 +51,6 @@ class ChunkRepository:
|
||||||
embedding = entity.embedding
|
embedding = entity.embedding
|
||||||
else:
|
else:
|
||||||
embedding = await self.embedder.embed(entity.content)
|
embedding = await self.embedder.embed(entity.content)
|
||||||
|
|
||||||
chunk_record = self.store.ChunkRecord(
|
chunk_record = self.store.ChunkRecord(
|
||||||
id=chunk_id,
|
id=chunk_id,
|
||||||
document_id=entity.document_id,
|
document_id=entity.document_id,
|
||||||
|
|
@ -179,14 +178,6 @@ class ChunkRepository:
|
||||||
|
|
||||||
async def delete_all(self) -> None:
|
async def delete_all(self) -> None:
|
||||||
"""Delete all chunks from the database."""
|
"""Delete all chunks from the database."""
|
||||||
count = len(
|
|
||||||
list(
|
|
||||||
self.store.chunks_table.search()
|
|
||||||
.limit(1)
|
|
||||||
.to_pydantic(self.store.ChunkRecord)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if count > 0:
|
|
||||||
# Drop and recreate table to clear all data
|
# Drop and recreate table to clear all data
|
||||||
self.store.db.drop_table("chunks")
|
self.store.db.drop_table("chunks")
|
||||||
self.store.chunks_table = self.store.db.create_table(
|
self.store.chunks_table = self.store.db.create_table(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue