Refactor LLM cache config to use argparse and add status display

This commit is contained in:
yangdx
2025-03-09 16:45:57 +08:00
parent c854aabde0
commit 020a6b5ae0
2 changed files with 13 additions and 6 deletions

View File

@@ -50,9 +50,6 @@ from .auth import auth_handler
# This update allows the user to put a different.env file for each lightrag folder
load_dotenv(".env", override=True)
# Read entity extraction cache config
enable_llm_cache = os.getenv("ENABLE_LLM_CACHE_FOR_EXTRACT", "false").lower() == "true"
# Initialize config parser
config = configparser.ConfigParser()
config.read("config.ini")
@@ -326,7 +323,7 @@ def create_app(args):
vector_db_storage_cls_kwargs={
"cosine_better_than_threshold": args.cosine_threshold
},
enable_llm_cache_for_entity_extract=enable_llm_cache, # Read from environment variable
enable_llm_cache_for_entity_extract=args.enable_llm_cache, # Read from args
embedding_cache_config={
"enabled": True,
"similarity_threshold": 0.95,
@@ -355,7 +352,7 @@ def create_app(args):
vector_db_storage_cls_kwargs={
"cosine_better_than_threshold": args.cosine_threshold
},
enable_llm_cache_for_entity_extract=enable_llm_cache, # Read from environment variable
enable_llm_cache_for_entity_extract=args.enable_llm_cache, # Read from args
embedding_cache_config={
"enabled": True,
"similarity_threshold": 0.95,
@@ -419,6 +416,7 @@ def create_app(args):
"doc_status_storage": args.doc_status_storage,
"graph_storage": args.graph_storage,
"vector_storage": args.vector_storage,
"enable_llm_cache": args.enable_llm_cache,
},
"update_status": update_status,
}