fixed the delete

This commit is contained in:
Yannick Stephan
2025-02-13 20:45:24 +01:00
parent 5730987349
commit cf0b9ce6be
2 changed files with 4 additions and 7 deletions

View File

@@ -101,6 +101,7 @@ def estimate_tokens(text: str) -> int:
return int(tokens) return int(tokens)
def get_default_host(binding_type: str) -> str: def get_default_host(binding_type: str) -> str:
default_hosts = { default_hosts = {
"ollama": os.getenv("LLM_BINDING_HOST", "http://localhost:11434"), "ollama": os.getenv("LLM_BINDING_HOST", "http://localhost:11434"),

View File

@@ -1259,7 +1259,7 @@ class LightRAG:
""" """
try: try:
# 1. Get the document status and related data # 1. Get the document status and related data
doc_status = await self.doc_status.get(doc_id) doc_status = await self.doc_status.get_by_id(doc_id)
if not doc_status: if not doc_status:
logger.warning(f"Document {doc_id} not found") logger.warning(f"Document {doc_id} not found")
return return
@@ -1267,9 +1267,7 @@ class LightRAG:
logger.debug(f"Starting deletion for document {doc_id}") logger.debug(f"Starting deletion for document {doc_id}")
# 2. Get all related chunks # 2. Get all related chunks
chunks = await self.text_chunks.filter( chunks = await self.text_chunks.get_by_id(doc_id)
lambda x: x.get("full_doc_id") == doc_id
)
chunk_ids = list(chunks.keys()) chunk_ids = list(chunks.keys())
logger.debug(f"Found {len(chunk_ids)} chunks to delete") logger.debug(f"Found {len(chunk_ids)} chunks to delete")
@@ -1405,9 +1403,7 @@ class LightRAG:
logger.error(f"Document {doc_id} still exists in full_docs") logger.error(f"Document {doc_id} still exists in full_docs")
# Verify if chunks have been deleted # Verify if chunks have been deleted
remaining_chunks = await self.text_chunks.filter( remaining_chunks = await self.text_chunks.get_by_id(doc_id)
lambda x: x.get("full_doc_id") == doc_id
)
if remaining_chunks: if remaining_chunks:
logger.error(f"Found {len(remaining_chunks)} remaining chunks") logger.error(f"Found {len(remaining_chunks)} remaining chunks")