runtime.py
Ricky/RAG_project/config/runtime.py
"""
Runtime configuration: all RAG_* environment-variable accessors in one place.
Import from here instead of scattering os.getenv calls across modules.
"""
import os
def get_llm_timeout() -> int:
return int(os.getenv("RAG_LLM_TIMEOUT", "300"))
def get_retriever_k() -> int:
return int(os.getenv("RAG_RETRIEVER_K", "4"))
def get_max_tokens() -> int:
return int(os.getenv("RAG_MAX_TOKENS", "160"))
def get_image_top_n() -> int:
return max(1, int(os.getenv("RAG_IMAGE_TOP_N", "1")))
def get_confidence_threshold() -> float:
value = float(os.getenv("RAG_CONFIDENCE_THRESHOLD", "0.7"))
return min(max(value, 0.0), 1.0)
def is_keyword_enabled() -> bool:
return os.getenv("RAG_ENABLE_KEYWORD", "1") == "1"
def is_force_rebuild() -> bool:
return os.getenv("RAG_FORCE_REBUILD", "0") == "1"
def is_warmup_enabled() -> bool:
return os.getenv("RAG_WARMUP", "0") == "1"
def is_voice_input_enabled() -> bool:
return os.getenv("RAG_VOICE_INPUT", "0") == "1"
def prefer_openrouter() -> bool:
return os.getenv("RAG_PREFER_OPENROUTER", "1") == "1"
def is_auto_open_image() -> bool:
return os.getenv("RAG_AUTO_OPEN_IMAGE", "1") == "1"
def get_open_image_count() -> int:
return max(1, int(os.getenv("RAG_OPEN_IMAGE_COUNT", "1")))
def get_voice_language() -> str:
return os.getenv("RAG_VOICE_LANGUAGE", "yue-Hant-HK")
def get_voice_timeout() -> int:
return int(os.getenv("RAG_VOICE_TIMEOUT", "6"))
def get_voice_phrase_time_limit() -> int:
return int(os.getenv("RAG_VOICE_PHRASE_TIME_LIMIT", "20"))
관련 글
__init__.py
__init__.py — python source code from the Ricky learning materials (Ricky/Cat Project Final/back_web-4/app/__init__.py).
글 읽기 →auth.py
auth.py — python source code from the Ricky learning materials (Ricky/Cat Project Final/back_web-4/app/admin/auth.py).
글 읽기 →routes.py
routes.py — python source code from the Ricky learning materials (Ricky/Cat Project Final/back_web-4/app/admin/routes.py).
글 읽기 →config.py
config.py — python source code from the Ricky learning materials (Ricky/Cat Project Final/back_web-4/app/config.py).
글 읽기 →admin_ingest.py
admin_ingest.py — python source code from the Ricky learning materials (Ricky/Cat Project Final/back_web-4/app/routes/admin_ingest.py).
글 읽기 →admin_stats.py
admin_stats.py — python source code from the Ricky learning materials (Ricky/Cat Project Final/back_web-4/app/routes/admin_stats.py).
글 읽기 →