Disable document deletion when LLM cache for extraction is off

This commit is contained in:
yangdx 2025-06-23 22:41:27 +08:00
parent 1973c80dca
commit c18065a912
2 changed files with 15 additions and 1 deletions

View File

@ -355,7 +355,13 @@ def create_app(args):
)
# Add routes
app.include_router(create_document_routes(rag, doc_manager, api_key))
app.include_router(
create_document_routes(
rag,
doc_manager,
api_key,
)
)
app.include_router(create_query_routes(rag, api_key, args.top_k))
app.include_router(create_graph_routes(rag, api_key))

View File

@ -1382,6 +1382,7 @@ def create_document_routes(
"""
Deletes a specific document and all its associated data, including its status,
text chunks, vector embeddings, and any related graph data.
It is disabled when llm cache for entity extraction is disabled.
This operation is irreversible and will interact with the pipeline status.
@ -1399,6 +1400,13 @@ def create_document_routes(
HTTPException:
- 500: If an unexpected internal error occurs.
"""
# The rag object is initialized from the server startup args,
# so we can access its properties here.
if not rag.enable_llm_cache_for_entity_extract:
raise HTTPException(
status_code=403,
detail="Operation not allowed when LLM cache for entity extraction is disabled.",
)
from lightrag.kg.shared_storage import (
get_namespace_data,
get_pipeline_status_lock,