yangdx
commited on
Commit
Β·
9ce7e55
1
Parent(s):
5b87097
Refactor LLM cache config to use argparse and add status display
Browse files- lightrag/api/lightrag_server.py +3 -5
- lightrag/api/utils_api.py +10 -1
lightrag/api/lightrag_server.py
CHANGED
@@ -50,9 +50,6 @@ 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 |
-
# 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,7 +323,7 @@ def create_app(args):
|
|
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
|
330 |
embedding_cache_config={
|
331 |
"enabled": True,
|
332 |
"similarity_threshold": 0.95,
|
@@ -355,7 +352,7 @@ def create_app(args):
|
|
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
|
359 |
embedding_cache_config={
|
360 |
"enabled": True,
|
361 |
"similarity_threshold": 0.95,
|
@@ -419,6 +416,7 @@ def create_app(args):
|
|
419 |
"doc_status_storage": args.doc_status_storage,
|
420 |
"graph_storage": args.graph_storage,
|
421 |
"vector_storage": args.vector_storage,
|
|
|
422 |
},
|
423 |
"update_status": update_status,
|
424 |
}
|
|
|
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 |
vector_db_storage_cls_kwargs={
|
324 |
"cosine_better_than_threshold": args.cosine_threshold
|
325 |
},
|
326 |
+
enable_llm_cache_for_entity_extract=args.enable_llm_cache, # Read from args
|
327 |
embedding_cache_config={
|
328 |
"enabled": True,
|
329 |
"similarity_threshold": 0.95,
|
|
|
352 |
vector_db_storage_cls_kwargs={
|
353 |
"cosine_better_than_threshold": args.cosine_threshold
|
354 |
},
|
355 |
+
enable_llm_cache_for_entity_extract=args.enable_llm_cache, # Read from args
|
356 |
embedding_cache_config={
|
357 |
"enabled": True,
|
358 |
"similarity_threshold": 0.95,
|
|
|
416 |
"doc_status_storage": args.doc_status_storage,
|
417 |
"graph_storage": args.graph_storage,
|
418 |
"vector_storage": args.vector_storage,
|
419 |
+
"enable_llm_cache": args.enable_llm_cache,
|
420 |
},
|
421 |
"update_status": update_status,
|
422 |
}
|
lightrag/api/utils_api.py
CHANGED
@@ -359,6 +359,13 @@ def parse_args(is_uvicorn_mode: bool = False) -> argparse.Namespace:
|
|
359 |
# Inject chunk configuration
|
360 |
args.chunk_size = get_env_value("CHUNK_SIZE", 1200, int)
|
361 |
args.chunk_overlap_size = get_env_value("CHUNK_OVERLAP_SIZE", 100, int)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
|
363 |
ollama_server_infos.LIGHTRAG_MODEL = args.simulated_model_name
|
364 |
|
@@ -451,8 +458,10 @@ def display_splash_screen(args: argparse.Namespace) -> None:
|
|
451 |
ASCIIColors.yellow(f"{args.history_turns}")
|
452 |
ASCIIColors.white(" ββ Cosine Threshold: ", end="")
|
453 |
ASCIIColors.yellow(f"{args.cosine_threshold}")
|
454 |
-
ASCIIColors.white("
|
455 |
ASCIIColors.yellow(f"{args.top_k}")
|
|
|
|
|
456 |
|
457 |
# System Configuration
|
458 |
ASCIIColors.magenta("\nπΎ Storage Configuration:")
|
|
|
359 |
# Inject chunk configuration
|
360 |
args.chunk_size = get_env_value("CHUNK_SIZE", 1200, int)
|
361 |
args.chunk_overlap_size = get_env_value("CHUNK_OVERLAP_SIZE", 100, int)
|
362 |
+
|
363 |
+
# Inject LLM cache configuration
|
364 |
+
args.enable_llm_cache = get_env_value(
|
365 |
+
"ENABLE_LLM_CACHE_FOR_EXTRACT",
|
366 |
+
False,
|
367 |
+
bool
|
368 |
+
)
|
369 |
|
370 |
ollama_server_infos.LIGHTRAG_MODEL = args.simulated_model_name
|
371 |
|
|
|
458 |
ASCIIColors.yellow(f"{args.history_turns}")
|
459 |
ASCIIColors.white(" ββ Cosine Threshold: ", end="")
|
460 |
ASCIIColors.yellow(f"{args.cosine_threshold}")
|
461 |
+
ASCIIColors.white(" ββ Top-K: ", end="")
|
462 |
ASCIIColors.yellow(f"{args.top_k}")
|
463 |
+
ASCIIColors.white(" ββ LLM Cache Enabled: ", end="")
|
464 |
+
ASCIIColors.yellow(f"{args.enable_llm_cache}")
|
465 |
|
466 |
# System Configuration
|
467 |
ASCIIColors.magenta("\nπΎ Storage Configuration:")
|