"""Insta-AutoApp Configuration — single source of truth for all constants.""" import os from dotenv import load_dotenv load_dotenv() # ── LLM Provider ───────────────────────────────────────────────────── LLM_PROVIDER = os.getenv("LLM_PROVIDER", "huggingface") # "huggingface" or "anthropic" LLM_MODEL = os.getenv("LLM_MODEL", "Qwen/Qwen2.5-7B-Instruct") HF_TOKEN = os.getenv("HF_TOKEN", "") ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY", "") MAX_RETRIES = 3 RETRY_DELAY = 2.5 REQUEST_TIMEOUT = 30 # ── FAISS / Retrieval ──────────────────────────────────────────────── def _find_data_file(filename: str) -> str: """Locate a data file. Checks root first (HF Spaces flat upload), then data/ subfolder (local dev). Falls back to root if neither exists yet.""" if os.path.exists(filename): return filename sub = os.path.join("data", filename) if os.path.exists(sub): return sub # Neither exists yet — prefer data/ if dir exists, else root return sub if os.path.isdir("data") else filename FAISS_INDEX_PATH = _find_data_file("index.faiss") FAISS_DOCSTORE_PATH = _find_data_file("index.pkl") EMBEDDING_MODEL = "sentence-transformers/all-MiniLM-L6-v2" TOP_K = 5 CHUNK_SIZE = 500 CHUNK_OVERLAP = 50 # ── Vehicle Profile ────────────────────────────────────────────────── TRIM_OPTIONS = ["Base", "Big Bend", "Black Diamond", "Badlands", "Outer Banks", "Wildtrak", "Raptor"] ENGINE_OPTIONS = ["2.3L EcoBoost", "2.7L EcoBoost"] PACKAGE_OPTIONS = ["None", "Sasquatch", "Lux", "Sasquatch + Lux"] TOP_TYPE_OPTIONS = ["Soft Top", "Hard Top", "Modular Top"] MILEAGE_MIN = 0 MILEAGE_MAX = 300_000 MILEAGE_DEFAULT = 0 # ── Urgency & Safety ───────────────────────────────────────────────── URGENCY_LEVELS = ["Safe", "Monitor", "Urgent", "Do Not Drive"] SAFETY_CRITICAL_KEYWORDS = [ "brake", "braking", "stopping", "steering", "steer", "overheat", "overheating", "temperature", "drivetrain", "transmission", "4x4", "4wd", "burning", "smoke", "fire", "airbag", "abs", "coolant", "oil pressure", ] FALLBACK_FOLLOWUP_QUESTIONS = [ "What driving mode were you in when this occurred? (2H, 4H, 4L, or a GOAT mode)", "Approximately how long has this symptom been occurring?", ] # ── UI Text ────────────────────────────────────────────────────────── APP_TITLE = "Insta-AutoApp" APP_SUBTITLE = "OEM-grounded symptom triage for 2023 Ford Bronco owners." DISCLAIMER_BANNER = ( "Insta-AutoApp provides triage guidance only, not professional mechanical diagnosis. " "Always consult a Ford-certified mechanic for safety-critical issues." ) DISCLAIMER_RESPONSE = ( "This is triage guidance only, not a professional mechanical diagnosis. " "For safety-critical issues, consult a Ford-certified mechanic." ) ERROR_API_UNAVAILABLE = ( "The AI triage service is temporarily unavailable. " "Please try again in a few minutes." ) ERROR_NOT_IN_MANUAL = ( "This issue is not clearly covered in the OEM manual. " "For your safety, we recommend contacting a Ford dealer or certified mechanic for inspection." ) # ── Data Source ─────────────────────────────────────────────────────── MANUAL_PDF_FILENAME = "2023_Ford_Bronco_Owners_Manual_version_1_om_EN-US.pdf" MANUAL_PDF_PATH = _find_data_file(MANUAL_PDF_FILENAME)