diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index bf4f11f5..0930c1cd 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -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)) diff --git a/lightrag/api/routers/document_routes.py b/lightrag/api/routers/document_routes.py index 2d66ae1c..813bdc48 100644 --- a/lightrag/api/routers/document_routes.py +++ b/lightrag/api/routers/document_routes.py @@ -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,