from pydantic_settings import BaseSettings from pydantic import BaseModel import os class ServerConfig(BaseModel): port: int = 5050 host: str = "0.0.0.0" class DatabaseConfig(BaseModel): name: str = "medical_diagnosis" host: str = "localhost" driver: str = "postgresql" user: str = "user" password: str = "password" class BucketConfig(BaseModel): """Hugging Face bucket configuration for user and conversation storage""" repo_id: str = "ryanxely/HealthCare-Storage" repo_type: str = "space" bucket_path: str = "data/" # Storage paths in bucket users_file: str = "data/users.jsonl" conversations_base: str = "data/conversations/" class LLMConfig(BaseModel): # Endpoints hf_url: str = "https://router.huggingface.co/v1/chat/completions" groq_url: str = "https://api.groq.com/openai/v1/chat/completions" groq_whisper_url: str = "https://api.groq.com/openai/v1/audio/transcriptions" # API Keys hf_token: str = os.environ.get("HF_TOKEN", "") groq_token: str = os.environ.get("GROQ_TOKEN", "") # Models ocr_model: str = "meta-llama/llama-4-scout-17b-16e-instruct" chat_model: str = "meta-llama/llama-4-scout-17b-16e-instruct" whisper_model: str = "whisper-large-v3-turbo" # Generation defaults max_tokens: int = 1024 temperature: float = 0.7 ocr_temperature: float = 0.1 # ── Main settings (env-driven) ──────────────────────────────────────────────── class Settings(BaseSettings): # Tokens — set these in HF Space Secrets secret_key: str = os.environ.get("SECRET_KEY", "your-secret-key-change-in-production") hf_token: str = os.environ.get("HF_TOKEN", "") model_path: str = "" # Runtime flags debug_mode: bool = False robust_mode: bool = True # Auth settings jwt_algorithm: str = "HS256" jwt_expiration_hours: int = 24 # Nested configs server: ServerConfig = ServerConfig() database: DatabaseConfig = DatabaseConfig() llm: LLMConfig = LLMConfig() bucket: BucketConfig = BucketConfig() class Config: env_file = ".env" # loads a local .env file when running locally settings = Settings()