yangdx commited on
Commit
c5022d3
·
1 Parent(s): 74d902f

Settign LLM cache option for entity extraction from env

Browse files
env.example CHANGED
@@ -50,6 +50,7 @@
50
  # MAX_TOKEN_SUMMARY=500 # Max tokens for entity or relations summary
51
  # SUMMARY_LANGUAGE=English
52
  # MAX_EMBED_TOKENS=8192
 
53
 
54
  ### LLM Configuration (Use valid host. For local services installed with docker, you can use host.docker.internal)
55
  LLM_BINDING=ollama
 
50
  # MAX_TOKEN_SUMMARY=500 # Max tokens for entity or relations summary
51
  # SUMMARY_LANGUAGE=English
52
  # MAX_EMBED_TOKENS=8192
53
+ # ENABLE_LLM_CACHE_FOR_EXTRACT=false # Enable LLM cache for entity extraction, defaults to false
54
 
55
  ### LLM Configuration (Use valid host. For local services installed with docker, you can use host.docker.internal)
56
  LLM_BINDING=ollama
lightrag/api/README.md CHANGED
@@ -223,6 +223,9 @@ LightRAG supports binding to various LLM/Embedding backends:
223
 
224
  Use environment variables `LLM_BINDING` or CLI argument `--llm-binding` to select LLM backend type. Use environment variables `EMBEDDING_BINDING` or CLI argument `--embedding-binding` to select LLM backend type.
225
 
 
 
 
226
  ### Storage Types Supported
227
 
228
  LightRAG uses 4 types of storage for difference purposes:
 
223
 
224
  Use environment variables `LLM_BINDING` or CLI argument `--llm-binding` to select LLM backend type. Use environment variables `EMBEDDING_BINDING` or CLI argument `--embedding-binding` to select LLM backend type.
225
 
226
+ ### Entity Extraction Configuration
227
+ - ENABLE_LLM_CACHE_FOR_EXTRACT: Enable LLM cache for entity extraction (default: false)
228
+
229
  ### Storage Types Supported
230
 
231
  LightRAG uses 4 types of storage for difference purposes:
lightrag/api/lightrag_server.py CHANGED
@@ -50,6 +50,9 @@ from .auth import auth_handler
50
  # This update allows the user to put a different.env file for each lightrag folder
51
  load_dotenv(".env", override=True)
52
 
 
 
 
53
  # Initialize config parser
54
  config = configparser.ConfigParser()
55
  config.read("config.ini")
@@ -323,7 +326,7 @@ def create_app(args):
323
  vector_db_storage_cls_kwargs={
324
  "cosine_better_than_threshold": args.cosine_threshold
325
  },
326
- enable_llm_cache_for_entity_extract=False, # set to True for debuging to reduce llm fee
327
  embedding_cache_config={
328
  "enabled": True,
329
  "similarity_threshold": 0.95,
@@ -352,7 +355,7 @@ def create_app(args):
352
  vector_db_storage_cls_kwargs={
353
  "cosine_better_than_threshold": args.cosine_threshold
354
  },
355
- enable_llm_cache_for_entity_extract=False, # set to True for debuging to reduce llm fee
356
  embedding_cache_config={
357
  "enabled": True,
358
  "similarity_threshold": 0.95,
 
50
  # This update allows the user to put a different.env file for each lightrag folder
51
  load_dotenv(".env", override=True)
52
 
53
+ # Read entity extraction cache config
54
+ enable_llm_cache = os.getenv("ENABLE_LLM_CACHE_FOR_EXTRACT", "false").lower() == "true"
55
+
56
  # Initialize config parser
57
  config = configparser.ConfigParser()
58
  config.read("config.ini")
 
326
  vector_db_storage_cls_kwargs={
327
  "cosine_better_than_threshold": args.cosine_threshold
328
  },
329
+ enable_llm_cache_for_entity_extract=enable_llm_cache, # Read from environment variable
330
  embedding_cache_config={
331
  "enabled": True,
332
  "similarity_threshold": 0.95,
 
355
  vector_db_storage_cls_kwargs={
356
  "cosine_better_than_threshold": args.cosine_threshold
357
  },
358
+ enable_llm_cache_for_entity_extract=enable_llm_cache, # Read from environment variable
359
  embedding_cache_config={
360
  "enabled": True,
361
  "similarity_threshold": 0.95,