""" PRODUCTION CONFIGURATION Track Design Copilot - Configuration Management """ import os from pathlib import Path from typing import Dict, Any class ProductionConfig: """Production configuration settings.""" APP_NAME = "Track Design Copilot" APP_VERSION = "5.1.0" APP_ENV = os.environ.get("APP_ENV", "production") BASE_DIR = Path(__file__).parent.parent DATA_DIR = BASE_DIR / "data" LOG_DIR = BASE_DIR / "logs" CACHE_DIR = BASE_DIR / ".cache" TEMP_DIR = BASE_DIR / "temp" for dir_path in [DATA_DIR, LOG_DIR, CACHE_DIR, TEMP_DIR]: dir_path.mkdir(parents=True, exist_ok=True) LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO") LOG_FILE = LOG_DIR / "track_design.log" LLM_MODEL = os.environ.get("LLM_MODEL", "qwen2:1.5b") EMBEDDING_MODEL = os.environ.get("EMBEDDING_MODEL", "all-MiniLM-L6-v2") EMBEDDING_DIM = 384 CHROMA_PATH = BASE_DIR / "knowledge" / "chroma_db" CHROMA_COLLECTION = os.environ.get("CHROMA_COLLECTION", "track_design_knowledge") TRACK_CATEGORY = os.environ.get("TRACK_CATEGORY", "C") DESIGN_SPEED = int(os.environ.get("DESIGN_SPEED", "75")) MAX_TOKENS = int(os.environ.get("MAX_TOKENS", "4000")) SEARCH_TOP_K = int(os.environ.get("SEARCH_TOP_K", "5")) SIMILARITY_THRESHOLD = float(os.environ.get("SIMILARITY_THRESHOLD", "0.7")) CHUNK_SIZE = int(os.environ.get("CHUNK_SIZE", "800")) CHUNK_OVERLAP = int(os.environ.get("CHUNK_OVERLAP", "120")) # NR/L2/TRK/2102 equilibrium radius with V in mph and Ea in mm: # R (m) = 11.82 * V_kph^2 / Ea ≈ 30.6 * V_mph^2 / (applied cant + cant deficiency). RADIUS_SPEED_COEFFICIENT = 30.6 NR_ASSISTANT_SYSTEM_PROMPT = """You are NR Standards assistant. Answer ONLY from retrieved context. Cite source file + page + clause (e.g., NR/L2/TRK/2500 Sec 4.2, REPW4210.pdf p2). If answer not in context, say "Not found in knowledge base — do not hallucinate". Never invent clause numbers.""" STREAMLIT_PORT = int(os.environ.get("STREAMLIT_SERVER_PORT", "8501")) @classmethod def get_limits(cls) -> Dict[str, float]: try: from core.engineering import NR_LIMITS return NR_LIMITS.copy() except ImportError: return { "disp_lift": 30.0, "disp_slue": 50.0, "geom_min_radius": 150.0, "geom_max_cant": 150.0, "geom_max_cant_def": 110.0, "geom_max_roc": 55.0 } @classmethod def is_production(cls) -> bool: return cls.APP_ENV == "production" @classmethod def is_development(cls) -> bool: return cls.APP_ENV == "development" config = ProductionConfig() __all__ = ['ProductionConfig', 'config']