hackathon-advisor / data /quest_labels /in /Trollsona.json
JacobLinCool's picture
feat: add live project atlas
4791c0a verified
Raw
History Blame Contribute Delete
3.77 kB
{
"id": "build-small-hackathon/Trollsona",
"slug": "Trollsona",
"title": "Trollsona",
"sdk": "gradio",
"declared_models": [],
"tags": [
"gradio",
"region:us"
],
"app_file": "app.py",
"README": "# Trollsona / Your Troll Alterego **Tagline:** Summon the little menace living behind your respectable personality. **Track:** An Adventure in Thousand Token Wood **Build target:** Hugging Face Space, Gradio app, small-model constraint `<=32B`. **GitHub repo:** https://github.com/rthgit/Trollsona **Official Build Small Space:** https://huggingface.co/spaces/build-small-hackathon/Trollsona **Backup Space:** https://huggingface.co/spaces/RthItalia/Trollsona Trollsona is a playful Gradio experience that turns a short user confession into a theatrical troll alter ego. The app returns a dossier-style result card with a trollsona name, a warm roast, one useful slap, and a goblin meter. Built with a compact RthItalia model derived from `Qwen/Qwen2.5-3B-Instruct`, under `32B` parameters. The deployed Space is configured to try that model first, then a lightweight Qwen 0.5B model, then the deterministic local fallback if model loading or generation is unavailable. The official public Space currently runs the lightweight Qwen fallback on CPU, while the custom RthItalia compact 3B path is enabled automatically when CUDA is available. ## Features - Immersive Gradio UI for Hugging Face Spaces - Theatrical trollsona result card - Local Hugging Face Transformers generation path for the primary AI runtime - Secondary lightweight Transformers model fallback - Deterministic fallback generator for final resilience - Safe roast guard for non-hateful, non-identity-targeted humor - Persona dropdow ...",
"APP_FILE": "from __future__ import annotations\nfrom functools import lru_cache\nfrom typing import Any\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\nfrom __future__ import annotations\n\nimport hashlib\nimport html\nimport json\nimport os\nimport re\nfrom functools import lru_cache\nfrom typing import Any\n\n\nAPP_TITLE = \"Trollsona\"\nAPP_SUBTITLE = \"Summon the little menace living behind your respectable personality.\"\nTRACK_NAME = \"An Adventure in Thousand Token Wood\"\nDEFAULT_MODEL_ID = \"RthItalia/nano_compact_3b_qkvfp16\"\nDEFAULT_FALLBACK_MODEL_ID = \"Qwen/Qwen2.5-0.5B-Instruct\"\nMAX_PROFILE_CHARS = 700\nMAX_NAME_CHARS = 36\n\n\ndef parse_bool_env(name: str, default: bool) -> bool:\n raw_value = os.getenv(name)\n if raw_value is None:\n return default\n normalized = raw_value.strip().lower()\n if normalized in {\"1\", \"true\", \"yes\", \"on\"}:\n return True\n if normalized in {\"0\", \"false\", \"no\", \"off\"}:\n return False\n return default\n\n\ndef parse_int_env(name: str, default: int, min_value: int, max_value: int) -> int:\n raw_value = os.getenv(name)\n if raw_value is None:\n return default\n try:\n value = int(raw_value)\n except ValueError:\n return default\n return max(min_value, min(max_value, value))\n\n\nMODEL_ID = os.getenv(\"TROLLSONA_MODEL_ID\", DEFAULT_MODEL_ID)\nFALLBACK_MODEL_ID = os.getenv(\"TROLLSONA_FALLBACK_MODEL_ID\", DEFAULT_FALLBACK_MODEL_ID)\nMODEL_ENABLED = parse_bool_env(\"TROLLSONA_ENABLE_MODEL\", default=False)\nMAX_NEW_TOKENS = parse_int_env(\"TROLLSONA_MAX_NEW_TOKENS\", 200, 32, 512)\n\n\nPERSONA_STYLES = {\n \"Back-Alley Oracle\": {\n \"flavor\": \"candlelit prophecy from a very suspicious side street\",\n \"noun_pool\": [\"Candle\", \"Omen\", \"Alley\", \"Brass\", \"Whisper\", \"Ledger\"],\n },\n \"Basement Prince\": {\n \"flavor\": \"royal delusion wrapped in dust, snacks, and old cables\",\n \"noun_pool\": [\"Basement\" ..."
}