from pydantic_settings import BaseSettings # Each entry: full metadata shown in the model picker UI # First entry = default model loaded at startup AVAILABLE_MODELS: list[dict] = [ { "id": "dslim/bert-base-NER", "label": "Standard", "quality": "good", "quality_score": 2, "speed": "fast", "is_default": False, "entity_types": ["PER", "ORG", "LOC"], "description": "The recommended starting point. Reliably finds names, companies and places — and also catches emails, phone numbers, IBANs and tax codes. Fast and accurate, with very few false alarms. Good for most everyday documents.", }, { "id": "Jean-Baptiste/roberta-large-ner-english", "label": "Thorough", "quality": "best", "quality_score": 3, "speed": "slow", "is_default": True, "entity_types": ["PER", "ORG", "LOC", "MISC"], "description": "A more powerful mode that catches sensitive data even in complex or messy documents — think CVs, contracts, mixed-language content. It finds more than Standard, but takes a bit longer to process. Use this when thoroughness matters more than speed.", }, { "id": "iiiorg/piiranha-v1-detect-personal-information", "label": "Light", "quality": "limited", "quality_score": 1, "speed": "fast", "is_default": False, "entity_types": ["PER", "EMAIL", "PHONE", "ADDRESS", "ORG", "LOC", "DATE", "ID"], "description": "A fast, lightweight scan covering a wide range of data types including dates and IDs. It may occasionally miss part of a name or produce false positives. Best for quick, informal checks rather than critical documents.", }, ] DEFAULT_MODEL_ID: str = AVAILABLE_MODELS[1]["id"] class Settings(BaseSettings): # Environment: "local" | "staging" | "production" app_env: str = "local" default_model_name: str = DEFAULT_MODEL_ID host: str = "0.0.0.0" port: int = 8000 # Set FRONTEND_URL in HF Space secrets for production (e.g. https://sanitizemydata.com) frontend_url: str = "https://sanitizemydata.com" # Base origins always allowed; production frontend URL added from env or default @property def allowed_origins(self) -> list[str]: origins = ["http://localhost:3000", "http://127.0.0.1:3000"] if self.frontend_url: origins.append(self.frontend_url) return origins model_config = {"env_file": ".env", "env_file_encoding": "utf-8"} settings = Settings()