Spaces:
Runtime error
Runtime error
Download backend/core/config.py from Amitkasar/ai-api-testing: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/spaces/Amitkasar/ai-api-testing/resolve/main/backend/core/config.py
- Command line
-
hf download hf://spaces/Amitkasar/ai-api-testing/backend/core/config.py
-
curl -L -o config.py https://huggingface.co/spaces/Amitkasar/ai-api-testing/resolve/main/backend/core/config.py
1.78 kB
| import os | |
| from backend import config_local as _local | |
| def _cfg(key: str, default): | |
| # Priority: environment variable > config_local.py > hardcoded default | |
| if key in os.environ: | |
| raw = os.environ[key] | |
| # Coerce to the same type as the default (e.g. int for JWT_EXPIRE_HOURS) | |
| if isinstance(default, int): | |
| return int(raw) | |
| return raw | |
| return getattr(_local, key, default) | |
| class Settings: | |
| MISTRAL_API_KEY: str = _cfg("MISTRAL_API_KEY", "") | |
| DATABASE_URL: str = _cfg("DATABASE_URL", "") | |
| ALLOWED_ORIGINS: str = _cfg("ALLOWED_ORIGINS", "http://localhost:5173,http://localhost:3000") | |
| UPLOAD_DIR: str = "backend/uploads" | |
| LLM_TIMEOUT: int = 60 | |
| HTTP_TIMEOUT: int = 120 | |
| RESPONSE_TRUNCATION_LIMIT: int = 4000 | |
| LLM_MODEL: str = _cfg("LLM_MODEL", "mistral-large-latest") | |
| LLM_FALLBACK_MODEL: str = _cfg("LLM_FALLBACK_MODEL", "open-mistral-7b") | |
| MAX_TOKENS_PER_SESSION: int = _cfg("MAX_TOKENS_PER_SESSION", 0) | |
| AUTH_USERNAME: str = _cfg("AUTH_USERNAME", "admin") | |
| AUTH_PASSWORD: str = _cfg("AUTH_PASSWORD", "changeme") | |
| JWT_SECRET: str = _cfg("JWT_SECRET", "change-this-secret-in-production") | |
| JWT_EXPIRE_HOURS: int = _cfg("JWT_EXPIRE_HOURS", 24) | |
| ENCRYPTION_KEY: str = _cfg("ENCRYPTION_KEY", "") | |
| # Supabase — read from config_local.py first, then env vars | |
| SUPABASE_URL: str = _cfg("SUPABASE_URL", "") | |
| SUPABASE_KEY: str = _cfg("SUPABASE_KEY", "") | |
| SUPABASE_SERVICE_ROLE_KEY: str = _cfg("SUPABASE_SERVICE_ROLE_KEY", "") | |
| SUPABASE_STORAGE_BUCKET: str = _cfg("SUPABASE_STORAGE_BUCKET", "assets") | |
| def allowed_origins_list(self) -> list[str]: | |
| return [o.strip() for o in self.ALLOWED_ORIGINS.split(",") if o.strip()] | |
| settings = Settings() | |