Spaces:
Running
Running
| from config.database import get_supabase_admin | |
| def get_site_setting(key: str, default: any = None): | |
| """ | |
| Fetches a site-wide setting from the 'site_settings' table. | |
| """ | |
| try: | |
| db = get_supabase_admin() | |
| result = db.table("site_settings").select("value").eq("key", key).single().execute() | |
| if result.data: | |
| return result.data.get("value") | |
| except Exception: | |
| pass | |
| return default | |
| def is_ai_enabled() -> bool: | |
| """ | |
| Convenience function to check if AI features are globally enabled. | |
| """ | |
| return get_site_setting("ai_features_enabled", True) | |