diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index fe52f592..a442074d 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -101,6 +101,7 @@ def estimate_tokens(text: str) -> int: return int(tokens) + def get_default_host(binding_type: str) -> str: default_hosts = { "ollama": os.getenv("LLM_BINDING_HOST", "http://localhost:11434"), diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index d53a252d..2ae68235 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -1259,7 +1259,7 @@ class LightRAG: """ try: # 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: logger.warning(f"Document {doc_id} not found") return @@ -1267,9 +1267,7 @@ class LightRAG: logger.debug(f"Starting deletion for document {doc_id}") # 2. Get all related chunks - chunks = await self.text_chunks.filter( - lambda x: x.get("full_doc_id") == doc_id - ) + chunks = await self.text_chunks.get_by_id(doc_id) chunk_ids = list(chunks.keys()) 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") # Verify if chunks have been deleted - remaining_chunks = await self.text_chunks.filter( - lambda x: x.get("full_doc_id") == doc_id - ) + remaining_chunks = await self.text_chunks.get_by_id(doc_id) if remaining_chunks: logger.error(f"Found {len(remaining_chunks)} remaining chunks")