gzdaniel commited on
Commit
f75614b
·
1 Parent(s): 1317364

Disable document deletion when LLM cache for extraction is off

Browse files
lightrag/api/lightrag_server.py CHANGED
@@ -355,7 +355,13 @@ def create_app(args):
355
  )
356
 
357
  # Add routes
358
- app.include_router(create_document_routes(rag, doc_manager, api_key))
 
 
 
 
 
 
359
  app.include_router(create_query_routes(rag, api_key, args.top_k))
360
  app.include_router(create_graph_routes(rag, api_key))
361
 
 
355
  )
356
 
357
  # Add routes
358
+ app.include_router(
359
+ create_document_routes(
360
+ rag,
361
+ doc_manager,
362
+ api_key,
363
+ )
364
+ )
365
  app.include_router(create_query_routes(rag, api_key, args.top_k))
366
  app.include_router(create_graph_routes(rag, api_key))
367
 
lightrag/api/routers/document_routes.py CHANGED
@@ -1382,6 +1382,7 @@ def create_document_routes(
1382
  """
1383
  Deletes a specific document and all its associated data, including its status,
1384
  text chunks, vector embeddings, and any related graph data.
 
1385
 
1386
  This operation is irreversible and will interact with the pipeline status.
1387
 
@@ -1399,6 +1400,13 @@ def create_document_routes(
1399
  HTTPException:
1400
  - 500: If an unexpected internal error occurs.
1401
  """
 
 
 
 
 
 
 
1402
  from lightrag.kg.shared_storage import (
1403
  get_namespace_data,
1404
  get_pipeline_status_lock,
 
1382
  """
1383
  Deletes a specific document and all its associated data, including its status,
1384
  text chunks, vector embeddings, and any related graph data.
1385
+ It is disabled when llm cache for entity extraction is disabled.
1386
 
1387
  This operation is irreversible and will interact with the pipeline status.
1388
 
 
1400
  HTTPException:
1401
  - 500: If an unexpected internal error occurs.
1402
  """
1403
+ # The rag object is initialized from the server startup args,
1404
+ # so we can access its properties here.
1405
+ if not rag.enable_llm_cache_for_entity_extract:
1406
+ raise HTTPException(
1407
+ status_code=403,
1408
+ detail="Operation not allowed when LLM cache for entity extraction is disabled.",
1409
+ )
1410
  from lightrag.kg.shared_storage import (
1411
  get_namespace_data,
1412
  get_pipeline_status_lock,