mirror of
https://github.com/HKUDS/LightRAG.git
synced 2025-12-24 13:22:21 +00:00
feat: add environment variables to /health endpoint and centralize defaults
- Add 9 environment variables to /health endpoint configuration section - Centralize default constants in lightrag/constants.py for consistency - Update config.py to use centralized defaults for better maintainability
This commit is contained in:
parent
9c4e98ec3b
commit
d0d57a45b6
@ -20,6 +20,12 @@ from lightrag.constants import (
|
||||
DEFAULT_COSINE_THRESHOLD,
|
||||
DEFAULT_RELATED_CHUNK_NUMBER,
|
||||
DEFAULT_MIN_RERANK_SCORE,
|
||||
DEFAULT_FORCE_LLM_SUMMARY_ON_MERGE,
|
||||
DEFAULT_MAX_ASYNC,
|
||||
DEFAULT_MAX_TOKENS,
|
||||
DEFAULT_SUMMARY_LANGUAGE,
|
||||
DEFAULT_EMBEDDING_FUNC_MAX_ASYNC,
|
||||
DEFAULT_EMBEDDING_BATCH_NUM,
|
||||
)
|
||||
|
||||
# use the .env that is inside the current folder
|
||||
@ -111,14 +117,14 @@ def parse_args() -> argparse.Namespace:
|
||||
parser.add_argument(
|
||||
"--max-async",
|
||||
type=int,
|
||||
default=get_env_value("MAX_ASYNC", 4, int),
|
||||
default=get_env_value("MAX_ASYNC", DEFAULT_MAX_ASYNC, int),
|
||||
help="Maximum async operations (default: from env or 4)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--max-tokens",
|
||||
type=int,
|
||||
default=get_env_value("MAX_TOKENS", 32000, int),
|
||||
help="Maximum token size (default: from env or 32768)",
|
||||
default=get_env_value("MAX_TOKENS", DEFAULT_MAX_TOKENS, int),
|
||||
help="Maximum token size (default: from env or 32000)",
|
||||
)
|
||||
|
||||
# Logging configuration
|
||||
@ -276,7 +282,7 @@ def parse_args() -> argparse.Namespace:
|
||||
|
||||
# Add environment variables that were previously read directly
|
||||
args.cors_origins = get_env_value("CORS_ORIGINS", "*")
|
||||
args.summary_language = get_env_value("SUMMARY_LANGUAGE", "English")
|
||||
args.summary_language = get_env_value("SUMMARY_LANGUAGE", DEFAULT_SUMMARY_LANGUAGE)
|
||||
args.whitelist_paths = get_env_value("WHITELIST_PATHS", "/health,/api/*")
|
||||
|
||||
# For JWT Auth
|
||||
@ -316,6 +322,17 @@ def parse_args() -> argparse.Namespace:
|
||||
"RELATED_CHUNK_NUMBER", DEFAULT_RELATED_CHUNK_NUMBER, int
|
||||
)
|
||||
|
||||
# Add missing environment variables for health endpoint
|
||||
args.force_llm_summary_on_merge = get_env_value(
|
||||
"FORCE_LLM_SUMMARY_ON_MERGE", DEFAULT_FORCE_LLM_SUMMARY_ON_MERGE, int
|
||||
)
|
||||
args.embedding_func_max_async = get_env_value(
|
||||
"EMBEDDING_FUNC_MAX_ASYNC", DEFAULT_EMBEDDING_FUNC_MAX_ASYNC, int
|
||||
)
|
||||
args.embedding_batch_num = get_env_value(
|
||||
"EMBEDDING_BATCH_NUM", DEFAULT_EMBEDDING_BATCH_NUM, int
|
||||
)
|
||||
|
||||
ollama_server_infos.LIGHTRAG_MODEL = args.simulated_model_name
|
||||
|
||||
return args
|
||||
|
||||
@ -535,6 +535,16 @@ def create_app(args):
|
||||
"rerank_binding_host": args.rerank_binding_host
|
||||
if rerank_model_func is not None
|
||||
else None,
|
||||
# Environment variable status (requested configuration)
|
||||
"summary_language": args.summary_language,
|
||||
"force_llm_summary_on_merge": args.force_llm_summary_on_merge,
|
||||
"max_parallel_insert": args.max_parallel_insert,
|
||||
"cosine_threshold": args.cosine_threshold,
|
||||
"min_rerank_score": args.min_rerank_score,
|
||||
"related_chunk_number": args.related_chunk_number,
|
||||
"max_async": args.max_async,
|
||||
"embedding_func_max_async": args.embedding_func_max_async,
|
||||
"embedding_batch_num": args.embedding_batch_num,
|
||||
},
|
||||
"auth_mode": auth_mode,
|
||||
"pipeline_busy": pipeline_status.get("busy", False),
|
||||
|
||||
@ -6,12 +6,19 @@ different parts of the LightRAG system. Centralizing these values ensures
|
||||
consistency and makes maintenance easier.
|
||||
"""
|
||||
|
||||
# Default values for environment variables
|
||||
DEFAULT_MAX_GLEANING = 1
|
||||
DEFAULT_FORCE_LLM_SUMMARY_ON_MERGE = 4
|
||||
# Default values for server settings
|
||||
DEFAULT_WOKERS = 2
|
||||
DEFAULT_TIMEOUT = 150
|
||||
|
||||
# Default values for extraction settings
|
||||
DEFAULT_SUMMARY_LANGUAGE = "English" # Default language for summaries
|
||||
DEFAULT_FORCE_LLM_SUMMARY_ON_MERGE = 4
|
||||
DEFAULT_MAX_GLEANING = 1
|
||||
DEFAULT_MAX_TOKENS = 10000 # Default maximum token size
|
||||
|
||||
# Separator for graph fields
|
||||
GRAPH_FIELD_SEP = "<SEP>"
|
||||
|
||||
# Query and retrieval configuration defaults
|
||||
DEFAULT_TOP_K = 40
|
||||
DEFAULT_CHUNK_TOP_K = 10
|
||||
@ -26,12 +33,16 @@ DEFAULT_RELATED_CHUNK_NUMBER = 5
|
||||
DEFAULT_ENABLE_RERANK = True
|
||||
DEFAULT_MIN_RERANK_SCORE = 0.0
|
||||
|
||||
# Separator for graph fields
|
||||
GRAPH_FIELD_SEP = "<SEP>"
|
||||
|
||||
# File path configuration for vector and graph database
|
||||
DEFAULT_MAX_FILE_PATH_LENGTH = 4090
|
||||
|
||||
# Async configuration defaults
|
||||
DEFAULT_MAX_ASYNC = 4 # Default maximum async operations
|
||||
|
||||
# Embedding configuration defaults
|
||||
DEFAULT_EMBEDDING_FUNC_MAX_ASYNC = 8 # Default max async for embedding functions
|
||||
DEFAULT_EMBEDDING_BATCH_NUM = 10 # Default batch size for embedding computations
|
||||
|
||||
# Logging configuration defaults
|
||||
DEFAULT_LOG_MAX_BYTES = 10485760 # Default 10MB
|
||||
DEFAULT_LOG_BACKUP_COUNT = 5 # Default 5 backups
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user