Spaces:
Sleeping
Sleeping
Deploy Trollsona to Build Small org with Codex
Browse filesFiles changed (7)
- .env.exampleAdded+4
- .gitignoreAdded+12
- README.md+201-6
- SUBMISSION.mdAdded+92
- app.pyAdded+848
- assets/style.cssAdded+446
- requirements.txtAdded+4
1234TROLLSONA_ENABLE_MODEL=1TROLLSONA_MODEL_ID=RthItalia/nano_compact_3b_qkvfp16TROLLSONA_FALLBACK_MODEL_ID=Qwen/Qwen2.5-0.5B-InstructTROLLSONA_MAX_NEW_TOKENS=200123456789101112.env.env.*!.env.example__pycache__/*.py[cod].gradio/.pytest_cache/.playwright-mcp/.codex_launch_gradio.pygradio.out.loggradio.err.logtrollsona-*.png12345678910111213---title: Trollsonaemoji: 🦀colorFrom: bluecolorTo: purplesdk: gradiosdk_version: 6.16.0python_version: '3.13'app_file: app.pypinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208---title: Trollsonaemoji: 🧌colorFrom: yellowcolorTo: redsdk: gradiosdk_version: 5.50.0app_file: app.pypinned: false---# 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**Hugging Face Space:** https://huggingface.co/spaces/RthItalia/TrollsonaTrollsona 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 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 dropdown, sting slider, and useful-truth checkbox- Source/fallback notes hidden behind `See the cursed paperwork`## Model RuntimeTrollsona uses a small-model cascade:1. `RthItalia/nano_compact_3b_qkvfp16`- compact `Qwen/Qwen2.5-3B-Instruct`-derived model by RthItalia- preferred runtime when CUDA is available- loaded with `trust_remote_code=True`2. `Qwen/Qwen2.5-0.5B-Instruct`- lightweight hosted CPU fallback model- currently active on the public Hugging Face Space running on `cpu-basic`3. Deterministic fallback- used only if both model paths are unavailable or return unsafe/invalid output- keeps the demo stable and reproducibleConstraint:```textsmall model only, <=32B parameters```Space model-first behavior:```bashTROLLSONA_ENABLE_MODEL=1```Recommended Hugging Face Space variables:```textTROLLSONA_ENABLE_MODEL=1TROLLSONA_MODEL_ID=RthItalia/nano_compact_3b_qkvfp16TROLLSONA_FALLBACK_MODEL_ID=Qwen/Qwen2.5-0.5B-InstructTROLLSONA_MAX_NEW_TOKENS=200```Local fallback-safe behavior if no variable is set:```bashTROLLSONA_ENABLE_MODEL=0```Deterministic fallback only:```bashTROLLSONA_ENABLE_MODEL=0```Implementation notes:- `bitsandbytes` is not required- primary RthItalia path expects CUDA- CPU-only Spaces use the Qwen 0.5B model before the deterministic fallback- source/runtime/fallback details are hidden in `See the cursed paperwork`## Stack- Python- Gradio- Hugging Face Spaces- Hugging Face Transformers, primary model path- PyTorch, model backendRequired secrets:```text[ASSENTE]```## Run Locally```bashpip install -r requirements.txtpython app.py```Open:```texthttp://127.0.0.1:7860```Model-first run:```bashTROLLSONA_ENABLE_MODEL=1 python app.py```Deterministic fallback run:```bashTROLLSONA_ENABLE_MODEL=0 python app.py```## Hugging Face SpaceRequired files:- `app.py`- `requirements.txt`- `README.md`- `assets/style.css`Space SDK:```textGradio```Space URL:```texthttps://huggingface.co/spaces/RthItalia/Trollsona```## SafetyTrollsona roasts habits, vibe, wording, overthinking, productivity rituals, internet behavior, startup energy, and harmless personal lore.It avoids:- protected-class targeting- identity-based insults- appearance insults- threats or self-harm content- sexual content- profanity or slurs- cruelty or humiliationIf generated model output fails the safety guard, the app replaces it with a safe fallback card.## Hackathon Fit- Built as a Gradio app for Hugging Face Space- Fits `An Adventure in Thousand Token Wood`- Supports the `<=32B` small-model constraint- Uses `RthItalia/nano_compact_3b_qkvfp16` as the primary AI path when CUDA is available- Keeps `Qwen/Qwen2.5-0.5B-Instruct` as a secondary model fallback- Runs without mandatory cloud APIs- Keeps deterministic fallback as a reliability guard- Produces short, whimsical, shareable output## Codex TrackBuilt with OpenAI Codex.Public GitHub repo: https://github.com/rthgit/TrollsonaCodex-attributed commits include:- `3fe2db1` Polish Trollsona dossier UI and grotesque prompt voice with Codex- `4f196a6` Add RthItalia model cascade with Codex- `8a1b09d` Document hosted model cascade QA with Codex- Space README repo link: present- Demo video: [DA COMPLETARE]- Social post: [DA COMPLETARE]## Known Limits- Public Space link: https://huggingface.co/spaces/RthItalia/Trollsona- Demo video: [DA COMPLETARE]- Social post URL: [DA COMPLETARE]- Primary RthItalia model path requires CUDA; CPU-only Spaces use the secondary model fallback before deterministic fallback- First model-backed generation can be slower on cold Spaces while model files load- Exact model-backed behavior on upgraded Space hardware: [AMBIGUO], because upgraded hardware has not been tested
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192# Trollsona Submission Pack
## Submission Checklist
| requirement | status | proof | missing action ||---|---|---|---|| Public GitHub repo | DONE | https://github.com/rthgit/Trollsona | None || Codex-attributed commits | DONE | `3fe2db1`, `4f196a6`, `8a1b09d` | None || Space README links to repo | DONE | `README.md` contains repo URL | None || Hugging Face Space deploy | DONE | https://huggingface.co/spaces/RthItalia/Trollsona | None || Space link | DONE | `README.md` contains https://huggingface.co/spaces/RthItalia/Trollsona | None || Space model variables | DONE | `.env.example` documents `TROLLSONA_ENABLE_MODEL=1`, `TROLLSONA_MODEL_ID=RthItalia/nano_compact_3b_qkvfp16`, `TROLLSONA_FALLBACK_MODEL_ID=Qwen/Qwen2.5-0.5B-Instruct` | Configure the same variables in Space settings if overriding defaults || Demo video | [DA COMPLETARE] | No video link/file present | Record 45-60s demo || Social post | [DA COMPLETARE] | Draft below contains Space/GitHub URLs | Publish and add final link if required || Gradio app | DONE | `app.py` defines `gr.Blocks` app | None || Small model <=32B | DONE | Primary model id: `RthItalia/nano_compact_3b_qkvfp16`; fallback model id: `Qwen/Qwen2.5-0.5B-Instruct` | None || Transformers model path | DONE | `TROLLSONA_ENABLE_MODEL=1` in Space variables; `AutoModelForCausalLM.from_pretrained(..., trust_remote_code=True)` implemented | None || Deterministic fallback | DONE | Fallback remains available with `TROLLSONA_ENABLE_MODEL=0`, unavailable CUDA, model failure, or invalid model output | None || Debug hidden by default | DONE | Source/fallback live in `See the cursed paperwork` | None || No mandatory cloud API | DONE | Public HF model path and fallback require no app secrets | None |
## Demo Video Script
Target length: 45-60 seconds.
Recommended tested input:
```textName: AlexLore: I start productivity systems and then reorganize the labels forever.Persona: Dungeon InternSpice: 4Advice: on```
Hosted test result: `Source: transformers_model`; runtime `Qwen/Qwen2.5-0.5B-Instruct` as CPU fallback model.
| timestamp | action | what it shows | suggested line ||---|---|---|---|| 0:00-0:05 | Open the Space | Trollsona hero, badges, dark ritual UI | "This is Trollsona: a small-model goblin that turns your personal lore into a cursed alter ego." || 0:05-0:15 | Enter name and lore | `What do they call you?`, `Confess your little lore` | "I give it a name and a very specific little confession." || 0:15-0:23 | Pick menace and sting | `Dungeon Intern`, spice `4`, advice on | "Then I choose the resident menace and how hard it should sting." || 0:23-0:32 | Click `Summon Trollsona` | End-to-end generation | "It summons a theatrical dossier instead of a plain chatbot answer." || 0:32-0:42 | Show result card | Trollsona name, roast, useful slap, goblin meter | "You get a name, a roast, one useful slap, and the goblin meter." || 0:42-0:50 | Open paperwork | `Source: transformers_model` and CPU runtime | "The model details stay hidden in the cursed paperwork until you ask for them." || 0:50-0:58 | Show README/Codex Track | Space, GitHub, model cascade, Codex commits | "Built as a Gradio Space with a small-model cascade and Codex-tracked commits." || 0:58-1:00 | Close on Space | Final result card or Space URL | "Tiny model, giant attitude." |
## Social Post Draft
Hook: I built a little ritual that summons the troll living behind your respectable personality.
Description: Trollsona turns a short confession into a theatrical alter-ego dossier: trollsona name, playful roast, one useful slap, and a goblin meter.
Tech note: Built for Build Small Hackathon as a Gradio Hugging Face Space. The primary model is `RthItalia/nano_compact_3b_qkvfp16`, derived from `Qwen/Qwen2.5-3B-Instruct` and under the `<=32B` small-model constraint. A Qwen 0.5B model and deterministic fallback remain as reliability guards.
Links:
- Space: https://huggingface.co/spaces/RthItalia/Trollsona- GitHub: https://github.com/rthgit/Trollsona
CTA: Try it, summon your menace, and share the dossier.
## Release QA
| test | command/action | expected result | status ||---|---|---|---|| Python compile | `python -B -m py_compile app.py` | no syntax errors | DONE || Model path implemented | inspect `app.py` | Space sets `TROLLSONA_ENABLE_MODEL=1`; `from_pretrained(..., trust_remote_code=True)` path present | DONE || Deterministic fallback | run `generate_trollsona(...)` twice | identical structured output | DONE || Local Gradio launch | `python app.py` | app opens on `127.0.0.1:7860` | DONE in local QA || Input-full generation | fill name + lore + summon | result card renders | DONE in local QA || Input-minimal generation | empty name/lore | output still complete | DONE || Debug default | load page | source/fallback hidden | DONE || Visual contrast | inspect input/dropdown/checkbox/CTA/card | readable UI | DONE || Git status | `git status --short --ignored` | only ignored `.env` / QA screenshot remain | DONE || README repo link | inspect README | GitHub URL present | DONE || Space build | Hugging Face runtime API | `stage=RUNNING`, `requested=cpu-basic` | DONE || Browser test on Space | Playwright on public Space | card renders; debug source/fallback hidden until accordion opens | DONE || Hosted model-backed generation | Playwright on public Space, then open `See the cursed paperwork` | `Source: transformers_model`; runtime `Qwen/Qwen2.5-0.5B-Instruct` as `fallback_model` on CPU; fallback note reports primary `RthItalia/nano_compact_3b_qkvfp16` skipped because CUDA is unavailable | DONE |
## Final Ship Plan
| step | owner | output | done criteria | priority ||---|---|---|---|---|| 1 | Codex | Final README and submission docs | Docs committed | P0 || 2 | Codex/User | GitHub push | `rthgit/Trollsona` contains latest commits | P0 || 3 | Codex | Hugging Face Space | Public Space URL opens app | P0 || 4 | Codex | README Space link | Space URL is present in `README.md` | P0 || 5 | User | Demo video | 45-60s video available | P1 || 6 | User | Social post | Published post with links | P1 || 7 | User | Submission form | All required URLs submitted | P0 |123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848from __future__ import annotations
import hashlibimport htmlimport jsonimport osimport refrom functools import lru_cachefrom typing import Any
APP_TITLE = "Trollsona"APP_SUBTITLE = "Summon the little menace living behind your respectable personality."TRACK_NAME = "An Adventure in Thousand Token Wood"DEFAULT_MODEL_ID = "RthItalia/nano_compact_3b_qkvfp16"DEFAULT_FALLBACK_MODEL_ID = "Qwen/Qwen2.5-0.5B-Instruct"MAX_PROFILE_CHARS = 700MAX_NAME_CHARS = 36
def parse_bool_env(name: str, default: bool) -> bool: raw_value = os.getenv(name) if raw_value is None: return default normalized = raw_value.strip().lower() if normalized in {"1", "true", "yes", "on"}: return True if normalized in {"0", "false", "no", "off"}: return False return default
def parse_int_env(name: str, default: int, min_value: int, max_value: int) -> int: raw_value = os.getenv(name) if raw_value is None: return default try: value = int(raw_value) except ValueError: return default return max(min_value, min(max_value, value))
MODEL_ID = os.getenv("TROLLSONA_MODEL_ID", DEFAULT_MODEL_ID)FALLBACK_MODEL_ID = os.getenv("TROLLSONA_FALLBACK_MODEL_ID", DEFAULT_FALLBACK_MODEL_ID)MODEL_ENABLED = parse_bool_env("TROLLSONA_ENABLE_MODEL", default=False)MAX_NEW_TOKENS = parse_int_env("TROLLSONA_MAX_NEW_TOKENS", 200, 32, 512)
PERSONA_STYLES = { "Back-Alley Oracle": { "flavor": "candlelit prophecy from a very suspicious side street", "noun_pool": ["Candle", "Omen", "Alley", "Brass", "Whisper", "Ledger"], }, "Basement Prince": { "flavor": "royal delusion wrapped in dust, snacks, and old cables", "noun_pool": ["Basement", "Velvet", "Outlet", "Throne", "Snack", "Static"], }, "Forest Heckler": { "flavor": "mossy woodland sarcasm with a pocket full of bad advice", "noun_pool": ["Moss", "Root", "Twig", "Bog", "Fern", "Stump"], }, "Union Goblin": { "flavor": "petty workplace grievance with ceremonial clipboard energy", "noun_pool": ["Clause", "Mug", "Breakroom", "Badge", "Staple", "Shift"], }, "Dungeon Intern": { "flavor": "overworked dungeon bureaucracy and unpaid dramatic labor", "noun_pool": ["Ledger", "Torch", "Mop", "Key", "Goblet", "Trapdoor"], }, "Mall Witch": { "flavor": "food-court divination with lip gloss and thunder", "noun_pool": ["Kiosk", "Charm", "Receipt", "Fountain", "Mascara", "Pretzel"], }, "Parking Lot Philosopher": { "flavor": "deep truths delivered beside a dented shopping cart", "noun_pool": ["Asphalt", "Cart", "Neon", "Cone", "Puddle", "Keychain"], }, "Saint of Bad Decisions": { "flavor": "holy nonsense for people who turn errands into lore", "noun_pool": ["Halo", "Candle", "Excuse", "Relic", "Errand", "Confetti"], }, "Meme Caporegime": { "flavor": "old-neighborhood swagger filtered through cursed screenshots", "noun_pool": ["Pixel", "Prophecy", "Caption", "Scroll", "Vibe", "Echo"], },}
SPICE_LABELS = { 1: "tiny pinch", 2: "polite sting", 3: "back-room heckle", 4: "crispy little judgment", 5: "full dossier incident",}
BLOCKED_PATTERNS = [ r"\bkill yourself\b", r"\bkys\b", r"\bself[- ]?harm\b", r"\bsuicide\b", r"\bhate\b", r"\bidiot\b", r"\bstupid\b", r"\bmoron\b", r"\bdumb\b", r"\bloser\b", r"\bugly\b", r"\bworthless\b", r"\bsubhuman\b", r"\bslur\b", r"\bterrorist\b", r"\bsexual\b", r"\bexplicit\b", r"\bprotected class\b",]
PROTECTED_TARGETING_PATTERNS = [ r"\bbecause of your race\b", r"\bbecause of your religion\b", r"\bbecause of your gender\b", r"\bbecause of your sexuality\b", r"\bbecause of your disability\b", r"\bbecause of your nationality\b", r"\bbecause of your ethnicity\b",]
SAFE_REPLY = ( "The dossier hissed, smoked, and refused to punch down. " "Final harmless verdict: your chaos has excellent posture and a suspicious little hat.")SAFE_ADVICE = "Make the next useful move before you decorate the excuse."
PRESET_DOSSIERS = [ { "button": "Mira - coffee-built UI oracle", "values": ( "Mira", "I overbuild side projects, drink too much coffee, and love weird UI.", "Back-Alley Oracle", 3, True, ), }, { "button": "Alex - label-system dungeon clerk", "values": ( "Alex", "I start productivity systems and then reorganize the labels forever.", "Dungeon Intern", 4, True, ), }, { "button": "Sam - tiny-game screenshot boss", "values": ( "Sam", "I make tiny games, forget lunch, and name variables like ancient spells.", "Meme Caporegime", 2, False, ), },]
def stable_int(*parts: str) -> int: payload = "||".join(parts).encode("utf-8", errors="ignore") return int(hashlib.sha256(payload).hexdigest()[:12], 16)
def clean_text(value: Any, max_chars: int) -> str: text = "" if value is None else str(value) text = re.sub(r"\s+", " ", text).strip() return text[:max_chars]
def clamp_spice(value: Any) -> int: try: spice = int(value) except (TypeError, ValueError): spice = 3 return max(1, min(5, spice))
def compute_cringe_score(profile: str, persona: str, spice: int) -> int: base = stable_int(profile.lower(), persona.lower(), str(spice)) % 61 return max(0, min(100, 22 + base + (spice * 3)))
def cringe_label(score: int) -> str: if score < 35: return "barely haunted" if score < 60: return "noticeably cursed" if score < 82: return "dossier-grade cringe" return "full goblin canon event"
def build_prompt( user_name: str, profile: str, persona: str, spice: int, include_advice: bool, score: int,) -> str: style = PERSONA_STYLES.get(persona, PERSONA_STYLES["Forest Heckler"]) advice_rule = "Include one practical useful_advice sentence." if include_advice else ( "Set useful_advice to a short note that advice was disabled." ) return f"""You are Trollsona, a theatrical troll alter-ego generator.Track: {TRACK_NAME}.
Your job is to transform the user's self-description into a funny, slightly grotesque,whimsical troll persona. Make it feel like a stained-paper character dossier that wasdictated by a back-alley fortune teller, stamped by a petty clerk, and lightly heckledby an italo-american cousin who has opinions but not cruelty.
Return only valid minified JSON with these fields:trollsona_name, troll_reply, useful_advice, cringe_score, cringe_score_label.
Objective:- Make the result absurd, memorable, specific, and theatrical.- Make trollsona_name sound like a summoned character, not a username.- Keep it roasty, not hateful.- Keep the humor sharp but warm: playful sting, never humiliation.
Style rules:- Write in vivid, punchy English.- Use occasional light italo-american flavor, but sparingly.- Good flavor examples: "listen, paisan", "madone", "capisce".- Do not overuse slang or turn the voice into a caricature.- Use grotesque but charming imagery: candle wax, receipts, tiny crowns, haunted binders, dented carts, snack dust, side quests, suspicious paperwork.- No generic roast bot voice.- No generic assistant copy, no filler, no disclaimers, no moralizing.- troll_reply must be the strongest comedic line, 1-3 short sentences max.- useful_advice must contain one real insight in 1 sentence max.
Humor boundaries:- Roast only habits, vibe, overthinking, productivity rituals, startup energy, internet behavior, wording, or harmless personal lore.- Never attack protected characteristics or identity.- Never insult appearance, race, ethnicity, religion, disability, nationality, gender, sexuality, trauma, mental health, or protected traits.- Never include threats, self-harm, sexual content, profanity, or slurs.- Never punch down.
User name: {user_name or "Anonymous traveler"}User profile: {profile or "No profile supplied."}Persona: {persona}Persona flavor: {style["flavor"]}Spice level: {spice}/5 ({SPICE_LABELS[spice]})Use this exact deterministic cringe_score: {score}Use this matching cringe_score_label: {cringe_label(score)}{advice_rule}""".strip()
def is_safe_text(text: str) -> bool: normalized = text.lower() for pattern in BLOCKED_PATTERNS + PROTECTED_TARGETING_PATTERNS: if re.search(pattern, normalized): return False return True
def fallback_trollsona( user_name: str, profile: str, persona: str, spice: int, include_advice: bool, reason: str,) -> dict[str, Any]: style = PERSONA_STYLES.get(persona, PERSONA_STYLES["Forest Heckler"]) seed = stable_int(user_name.lower(), profile.lower(), persona.lower(), str(spice)) adjectives = ["Velvet", "Candle", "Ashen", "Brass", "Crooked", "Sainted", "Static"] titles = [ "Overthinker in Residence", "Snack Baron of Almost", "Dossier Clerk", "Chaos Notary", "Sidequest Duke", "Patron Saint of Later", ] noun = style["noun_pool"][seed % len(style["noun_pool"])] adjective = adjectives[(seed // 7) % len(adjectives)] title = titles[(seed // 13) % len(titles)]
safe_name = re.sub(r"[^A-Za-z0-9 ]+", "", user_name).strip()[:MAX_NAME_CHARS] name_prefix = safe_name.title() if safe_name else adjective trollsona_name = f"{name_prefix} {noun}-{title}"
roast_templates = [ "Listen, paisan: your vibe is a candlelit side quest that opened twelve tabs, found a tiny crown, and called it destiny.", "Your aura says main character, but your calendar is dressed like a haunted binder asking for rent.", "You are one dramatic cape away from turning a normal errand into a village ordinance.", "Your brain is a basement tavern where every idea demands a theme song, a snack bowl, and a separate invoice.", "Madone, you carry the confidence of a bridge troll charging tolls in vibes and loose receipts.", "You alphabetize chaos, misplace the alphabet, then file a complaint with the moon.", ] advice_templates = [ "Pick one task, make it smaller, and finish that version before you rename the kingdom.", "Write the next concrete step in one sentence, then do only that step. Capisce?", "Keep the weird idea, but give it a deadline and a visible done state.", "Trade one dramatic plan for one shipped artifact before the candles burn out.", "Use the chaos as seasoning, not as project management.", ]
score = compute_cringe_score(profile, persona, spice) reply = roast_templates[(seed // 17 + spice) % len(roast_templates)] advice = advice_templates[(seed // 23 + spice) % len(advice_templates)] if not include_advice: advice = "Truth withheld. The dossier clerk stamps the page and looks away."
return { "trollsona_name": trollsona_name, "troll_reply": reply, "useful_advice": advice, "cringe_score": score, "cringe_score_label": cringe_label(score), "include_advice": include_advice, "runtime": f"model_id={MODEL_ID}; fallback_model_id={FALLBACK_MODEL_ID}; model_enabled={MODEL_ENABLED}", "source": "deterministic_fallback", "fallback_reason": reason, }
@lru_cache(maxsize=1)def load_model() -> tuple[Any | None, Any | None, str, str]: if not MODEL_ENABLED: return ( None, None, "model disabled by TROLLSONA_ENABLE_MODEL", f"model_id={MODEL_ID}; fallback_model_id={FALLBACK_MODEL_ID}; device=disabled", )
try: import torch from transformers import AutoModelForCausalLM, AutoTokenizer except Exception as exc: return ( None, None, f"model dependencies unavailable: {type(exc).__name__}: {exc}", f"model_id={MODEL_ID}; fallback_model_id={FALLBACK_MODEL_ID}; device=unavailable", )
failures: list[str] = []
def load_tokenizer(candidate_id: str) -> Any: tokenizer = AutoTokenizer.from_pretrained( candidate_id, use_fast=True, trust_remote_code=True, ) if tokenizer.pad_token_id is None and tokenizer.eos_token is not None: tokenizer.pad_token = tokenizer.eos_token return tokenizer
def load_cuda_model(candidate_id: str) -> Any: load_attempts = [ { "trust_remote_code": True, "device_map": "cuda", "dtype": torch.float16, "low_cpu_mem_usage": True, }, { "trust_remote_code": True, "device_map": "cuda", "torch_dtype": torch.float16, "low_cpu_mem_usage": True, }, { "trust_remote_code": True, "torch_dtype": torch.float16, "low_cpu_mem_usage": True, }, ] last_error: Exception | None = None for kwargs in load_attempts: try: model = AutoModelForCausalLM.from_pretrained(candidate_id, **kwargs) if "device_map" not in kwargs: model = model.to("cuda") return model except Exception as exc: last_error = exc if last_error is not None: raise last_error raise RuntimeError("CUDA model load failed without exception")
def load_cpu_model(candidate_id: str) -> Any: try: return AutoModelForCausalLM.from_pretrained( candidate_id, trust_remote_code=True, low_cpu_mem_usage=True, ) except TypeError: return AutoModelForCausalLM.from_pretrained(candidate_id, trust_remote_code=True)
candidates = [ {"role": "primary", "model_id": MODEL_ID, "requires_cuda": True}, {"role": "fallback_model", "model_id": FALLBACK_MODEL_ID, "requires_cuda": False}, ]
seen_model_ids: set[str] = set() for candidate in candidates: candidate_id = str(candidate["model_id"]).strip() if not candidate_id or candidate_id in seen_model_ids: continue seen_model_ids.add(candidate_id) role = str(candidate["role"]) requires_cuda = bool(candidate["requires_cuda"])
if requires_cuda and not torch.cuda.is_available(): failures.append(f"{role} {candidate_id}: CUDA unavailable") continue
try: tokenizer = load_tokenizer(candidate_id) if torch.cuda.is_available(): model = load_cuda_model(candidate_id) device = "cuda" else: model = load_cpu_model(candidate_id) device = "cpu" model.eval() torch.manual_seed(0) if torch.cuda.is_available(): torch.cuda.manual_seed_all(0) fallback_note = "; ".join(failures) status = "model loaded" if not fallback_note else f"model loaded after fallback: {fallback_note}" runtime = ( f"model_id={candidate_id}; role={role}; device={device}; " f"cuda_available={torch.cuda.is_available()}" ) return tokenizer, model, status, runtime except Exception as exc: failures.append(f"{role} {candidate_id}: {type(exc).__name__}: {exc}")
failure_text = " | ".join(failures) if failures else "no model candidates configured" runtime = ( f"model_id={MODEL_ID}; fallback_model_id={FALLBACK_MODEL_ID}; " f"cuda_available={torch.cuda.is_available()}" ) return None, None, f"model load failed: {failure_text}", runtime
def format_generation_prompt(tokenizer: Any, prompt: str) -> str: try: if getattr(tokenizer, "chat_template", None): return tokenizer.apply_chat_template( [{"role": "user", "content": prompt}], tokenize=False, add_generation_prompt=True, ) except Exception: return prompt return prompt
def generation_temperature(spice: int) -> float: return round(0.48 + (clamp_spice(spice) * 0.08), 2)
def model_device(model: Any) -> Any: target_device = getattr(model, "device", None) if target_device is not None and str(target_device) != "meta": return target_device try: return next(model.parameters()).device except Exception: return None
def generate_with_model(prompt: str, spice: int) -> tuple[str | None, str, str]: tokenizer, model, status, runtime = load_model() if tokenizer is None or model is None: return None, status, runtime
try: import torch
model_prompt = format_generation_prompt(tokenizer, prompt) inputs = tokenizer(model_prompt, return_tensors="pt", truncation=True, max_length=1536) target_device = model_device(model) if target_device is not None: inputs = {key: value.to(target_device) for key, value in inputs.items()}
seed = stable_int(prompt, str(spice), runtime) % (2**31) torch.manual_seed(seed) if hasattr(torch, "cuda") and torch.cuda.is_available(): torch.cuda.manual_seed_all(seed)
with torch.no_grad(): output_ids = model.generate( **inputs, max_new_tokens=MAX_NEW_TOKENS, do_sample=True, temperature=generation_temperature(spice), num_beams=1, repetition_penalty=1.1, pad_token_id=tokenizer.eos_token_id, ) prompt_len = inputs["input_ids"].shape[-1] generated_ids = output_ids[0][prompt_len:] return tokenizer.decode(generated_ids, skip_special_tokens=True).strip(), status, runtime except Exception as exc: return None, f"model generation failed: {type(exc).__name__}: {exc}", runtime
def parse_loose_model_fields(raw_text: str) -> dict[str, str]: fields: dict[str, str] = {} for field in ["trollsona_name", "troll_reply", "useful_advice", "cringe_score_label"]: pattern = rf'"{field}"\s*:\s*"((?:\\.|[^"\\])*)' match = re.search(pattern, raw_text or "", flags=re.DOTALL) if not match: continue try: value = json.loads(f'"{match.group(1)}"') except json.JSONDecodeError: value = match.group(1) fields[field] = str(value) return fields
def coerce_model_result( parsed: dict[str, Any], fallback: dict[str, Any], score: int, include_advice: bool, fallback_reason: str, runtime: str,) -> dict[str, Any] | None: result = dict(fallback) field_limits = { "trollsona_name": 80, "troll_reply": 360, "useful_advice": 280, "cringe_score_label": 80, } used_fields: list[str] = [] missing_fields: list[str] = []
for field, limit in field_limits.items(): value = clean_text(parsed.get(field), limit) if value and is_safe_text(value): result[field] = value used_fields.append(field) else: missing_fields.append(field)
if not used_fields: return None
result["cringe_score"] = score result["include_advice"] = include_advice result["source"] = "transformers_model" result["runtime"] = runtime if missing_fields: partial_reason = f"model output partial; fallback filled: {', '.join(missing_fields)}" result["fallback_reason"] = ( f"{fallback_reason}; {partial_reason}" if fallback_reason else partial_reason ) else: result["fallback_reason"] = fallback_reason return result
def parse_model_output( raw_text: str, fallback: dict[str, Any], score: int, include_advice: bool, fallback_reason: str, runtime: str,) -> dict[str, Any] | None: decoder = json.JSONDecoder() parsed = None for match in re.finditer(r"\{", raw_text or ""): try: candidate, _ = decoder.raw_decode(raw_text[match.start() :]) except json.JSONDecodeError: continue if isinstance(candidate, dict): parsed = candidate break
if parsed is None: parsed = parse_loose_model_fields(raw_text)
return coerce_model_result(parsed, fallback, score, include_advice, fallback_reason, runtime)
def repair_model_output( raw_text: str, fallback: dict[str, Any], fallback_reason: str, runtime: str,) -> dict[str, Any] | None: repaired_reply = clean_text(raw_text, 360) repaired_reply = re.sub(r"^```(?:json)?|```$", "", repaired_reply).strip() if not repaired_reply or repaired_reply.startswith("{"): return None if not is_safe_text(repaired_reply): return None
result = dict(fallback) result["troll_reply"] = repaired_reply result["source"] = "transformers_model_repaired" result["runtime"] = runtime repair_reason = "model output was not valid JSON and was repaired" result["fallback_reason"] = f"{fallback_reason}; {repair_reason}" if fallback_reason else repair_reason return result
def safety_guard(result: dict[str, Any], fallback: dict[str, Any]) -> dict[str, Any]: fields = [ result.get("trollsona_name", ""), result.get("troll_reply", ""), result.get("useful_advice", ""), result.get("cringe_score_label", ""), ] if not all(is_safe_text(str(field)) for field in fields): guarded = dict(fallback) guarded["troll_reply"] = SAFE_REPLY guarded["useful_advice"] = SAFE_ADVICE guarded["fallback_reason"] = "safety guard replaced unsafe output" return guarded return result
def render_card(result: dict[str, Any]) -> str: esc = {key: html.escape(str(value)) for key, value in result.items()} score = max(0, min(100, int(result.get("cringe_score", 0)))) useful_advice = clean_text(result.get("useful_advice", ""), 280) show_advice = bool(result.get("include_advice", True)) and bool(useful_advice) advice_tile = ( f""" <div class="trollsona-tile"> <div class="trollsona-label">A USEFUL SLAP</div> <div class="trollsona-value">{html.escape(useful_advice)}</div> </div>""".rstrip() if show_advice else "" ) grid_class = "trollsona-grid" if show_advice else "trollsona-grid trollsona-grid-single" return f"""<div class="trollsona-card"> <div class="dossier-kicker">THE SUMMONED MENACE</div> <h2>{esc["trollsona_name"]}</h2> <div class="trollsona-mainline">{esc["troll_reply"]}</div> <div class="{grid_class}">{advice_tile} <div class="trollsona-tile"> <div class="trollsona-label">GOBLIN METER</div> <div class="meter-shell" aria-label="Goblin meter {score} out of 100"> <div class="meter-fill" style="width: {score}%"></div> </div> <div class="trollsona-value">{score}/100 - {esc["cringe_score_label"]}</div> </div> </div></div>""".strip()
def render_cursed_paperwork(result: dict[str, Any]) -> str: source = clean_text(result.get("source", "unknown"), 80) runtime = clean_text(result.get("runtime", "runtime unavailable"), 260) fallback_reason = clean_text(result.get("fallback_reason", ""), 180) if not fallback_reason: fallback_reason = "No fallback note." return ( f"**Source:** `{source}` \n" f"**Runtime:** `{runtime}` \n" f"**Fallback note:** {fallback_reason}" )
def render_empty_card() -> str: return """<div class="empty-dossier"> <div class="dossier-kicker">The dossier is sealed</div> <h2>No menace has signed the paperwork yet.</h2> <p>Feed the booth a little lore, pick a resident menace, and pull the handle.</p></div>""".strip()
def load_preset(index: int) -> tuple[str, str, str, int, bool]: return PRESET_DOSSIERS[index]["values"]
def generate_trollsona( user_name: str, profile: str, persona: str, spice: int, include_advice: bool,) -> tuple[str, dict[str, Any], str]: user_name = clean_text(user_name, MAX_NAME_CHARS) profile = clean_text(profile, MAX_PROFILE_CHARS) persona = persona if persona in PERSONA_STYLES else "Forest Heckler" spice = clamp_spice(spice) include_advice = bool(include_advice)
fallback = fallback_trollsona( user_name=user_name, profile=profile, persona=persona, spice=spice, include_advice=include_advice, reason="model unavailable or output invalid", )
score = compute_cringe_score(profile, persona, spice) prompt = build_prompt(user_name, profile, persona, spice, include_advice, score) raw_text, model_status, runtime = generate_with_model(prompt, spice) model_fallback_reason = "" if model_status == "model loaded" else model_status
result = None if raw_text: result = parse_model_output( raw_text=raw_text, fallback=fallback, score=score, include_advice=include_advice, fallback_reason=model_fallback_reason, runtime=runtime, ) if result is None: result = repair_model_output(raw_text, fallback, model_fallback_reason, runtime)
if result is None: result = dict(fallback) result["fallback_reason"] = model_status result["runtime"] = runtime
result = safety_guard(result, fallback) return render_card(result), result, render_cursed_paperwork(result)
def build_demo() -> Any: import gradio as gr
css = "" css_path = os.path.join(os.path.dirname(__file__), "assets", "style.css") if os.path.exists(css_path): with open(css_path, "r", encoding="utf-8") as handle: css = handle.read()
with gr.Blocks(title=APP_TITLE, css=css) as demo: gr.HTML( f"""<section class="ritual-hero"> <div class="hero-mark">Trollsona</div> <h1>{APP_TITLE}</h1> <p>{APP_SUBTITLE}</p> <div class="badge-row"> <span>Build Small Hackathon</span> <span>Small model</span> <span>Safe grotesque humor</span> <span>{TRACK_NAME}</span> </div></section>""".strip() )
with gr.Row(elem_classes=["ritual-layout"]): with gr.Column(scale=1, elem_classes=["summoning-panel"]): gr.HTML('<div class="panel-heading">The summoning booth</div>') user_name = gr.Textbox( label="What do they call you?", placeholder="Mira", max_lines=1, ) profile = gr.Textbox( label="Confess your little lore", placeholder="I overbuild side projects, drink too much coffee, and love weird UI.", lines=5, max_lines=7, ) persona = gr.Dropdown( label="Pick your resident menace", choices=list(PERSONA_STYLES.keys()), value="Back-Alley Oracle", ) spice = gr.Slider( label="How hard should it sting?", minimum=1, maximum=5, value=3, step=1, ) include_advice = gr.Checkbox(label="Slip in one useful truth", value=True) generate_button = gr.Button("Summon Trollsona", variant="primary")
with gr.Column(scale=1, elem_classes=["dossier-stage"]): card_output = gr.HTML(value=render_empty_card()) debug_state = gr.State() with gr.Accordion("See the cursed paperwork", open=False): debug_output = gr.Markdown( value=( "**Source:** `not summoned` \n" "**Runtime:** `not summoned` \n" "**Fallback note:** The dossier clerk is still asleep." ) )
generate_button.click( fn=generate_trollsona, inputs=[user_name, profile, persona, spice, include_advice], outputs=[card_output, debug_state, debug_output], )
with gr.Accordion("Stolen dossiers", open=False): gr.HTML('<div class="preset-note">Tap a stolen dossier to pre-fill the booth.</div>') with gr.Row(elem_classes=["preset-row"]): for preset_index, preset in enumerate(PRESET_DOSSIERS): preset_button = gr.Button( preset["button"], variant="secondary", elem_classes=["preset-card"], ) preset_button.click( fn=lambda index=preset_index: load_preset(index), inputs=[], outputs=[user_name, profile, persona, spice, include_advice], )
return demo
demo = None if parse_bool_env("TROLLSONA_SKIP_UI_BUILD", default=False) else build_demo()
if __name__ == "__main__": (demo or build_demo()).launch()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446:root { --ink: #130f0c; --coal: #1d1712; --coal-soft: #2b2118; --parchment: #efe0bf; --paper: #f8edcf; --paper-deep: #d7bd86; --brass: #c68633; --ember: #b44a24; --olive: #55633f; --bone: #fff7df; --muted: #bda985;}
body,.gradio-container { background: var(--ink) !important; color: var(--bone) !important;}
.gradio-container { width: min(100%, 1180px) !important; max-width: 1180px !important; min-height: 100vh; margin: 0 auto !important; padding: 24px !important; --body-background-fill: var(--ink); --body-text-color: var(--bone); --background-fill-primary: var(--coal); --background-fill-secondary: var(--coal-soft); --border-color-primary: rgba(215, 189, 134, 0.34); --block-background-fill: var(--coal-soft); --block-border-color: rgba(215, 189, 134, 0.34); --block-label-background-fill: transparent; --block-label-border-color: transparent; --block-label-text-color: var(--paper); --block-info-text-color: var(--muted); --input-background-fill: #251d15; --input-border-color: rgba(215, 189, 134, 0.48); --input-placeholder-color: rgba(255, 247, 223, 0.52); --body-text-color-subdued: var(--muted); --button-primary-background-fill: var(--ember); --button-primary-background-fill-hover: #c9572b; --button-primary-text-color: var(--bone); --button-secondary-background-fill: var(--coal-soft); --button-secondary-background-fill-hover: #35291e; --button-secondary-text-color: var(--paper);}
.ritual-hero { max-width: 100%; border: 1px solid rgba(198, 134, 51, 0.45); border-radius: 8px; background: linear-gradient(135deg, rgba(29, 23, 18, 0.98), rgba(43, 33, 24, 0.98)), repeating-linear-gradient(90deg, rgba(255, 247, 223, 0.04) 0, rgba(255, 247, 223, 0.04) 1px, transparent 1px, transparent 9px); padding: 28px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);}
.hero-mark,.dossier-kicker,.panel-heading,.trollsona-label { color: var(--brass); font-size: 0.78rem; font-weight: 800; letter-spacing: 0; text-transform: uppercase;}
.ritual-hero h1 { color: var(--bone); font-size: 3rem; line-height: 1; margin: 10px 0 8px;}
.ritual-hero p { color: var(--paper); font-size: 1.12rem; line-height: 1.45; margin: 0; max-width: 620px;}
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px;}
.badge-row span { border: 1px solid rgba(198, 134, 51, 0.48); border-radius: 999px; background: rgba(85, 99, 63, 0.28); color: var(--paper); padding: 6px 10px; font-size: 0.82rem; line-height: 1;}
.ritual-layout { display: grid !important; grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr); align-items: stretch; gap: 20px; margin: 20px auto 0; width: 100%;}
.summoning-panel,.dossier-stage { border: 1px solid rgba(215, 189, 134, 0.36); border-radius: 8px; background: rgba(29, 23, 18, 0.94); min-width: 0; padding: 16px;}
.summoning-panel { box-shadow: inset 0 0 0 1px rgba(255, 247, 223, 0.04);}
.panel-heading { margin: 0 0 14px;}
.summoning-panel > *,.dossier-stage > * { background: transparent !important;}
.summoning-panel .block,.summoning-panel .form,.summoning-panel .gr-form,.summoning-panel .wrap,.summoning-panel .container,.summoning-panel .input-container,.summoning-panel .prose,.dossier-stage .block,.dossier-stage .form,.dossier-stage .wrap,.dossier-stage .container,.dossier-stage .input-container { border-color: rgba(215, 189, 134, 0.36) !important; background: var(--coal-soft) !important; color: var(--bone) !important;}
.summoning-panel label,.summoning-panel .label-wrap,.summoning-panel [data-testid="block-label"],.summoning-panel [data-testid="block-info"],.summoning-panel span,.dossier-stage label,.dossier-stage .label-wrap,.dossier-stage [data-testid="block-label"] { color: var(--paper) !important;}
.summoning-panel label,.summoning-panel [data-testid="block-label"] { font-weight: 700 !important;}
.summoning-panel input,.summoning-panel textarea,.summoning-panel select,.summoning-panel [role="listbox"],.summoning-panel [role="combobox"],.summoning-panel .dropdown,.summoning-panel .wrap input,.summoning-panel .wrap textarea { border-color: rgba(215, 189, 134, 0.45) !important; background: #251d15 !important; color: var(--bone) !important; box-shadow: none !important;}
.summoning-panel input::placeholder,.summoning-panel textarea::placeholder { color: rgba(255, 247, 223, 0.48) !important;}
.summoning-panel input:focus,.summoning-panel textarea:focus,.summoning-panel [role="listbox"]:focus,.summoning-panel [role="combobox"]:focus { border-color: var(--brass) !important; outline: 2px solid rgba(198, 134, 51, 0.28) !important;}
.summoning-panel input[type="range"] { accent-color: var(--ember); background: transparent !important;}
.summoning-panel input[type="number"] { min-width: 62px; text-align: center;}
.summoning-panel input[type="checkbox"] { accent-color: var(--ember); border: 1px solid rgba(215, 189, 134, 0.55) !important; background: #251d15 !important;}
.summoning-panel input[type="checkbox"]:checked { background: var(--ember) !important;}
.summoning-panel button,button.primary,.gradio-container button.primary { border: 1px solid rgba(255, 247, 223, 0.28) !important; border-radius: 8px !important; background: var(--ember) !important; color: var(--bone) !important; font-weight: 800 !important; box-shadow: 0 10px 28px rgba(180, 74, 36, 0.22);}
.summoning-panel button:hover,button.primary:hover,.gradio-container button.primary:hover { background: #c9572b !important;}
.empty-dossier,.trollsona-card { border: 1px solid rgba(92, 65, 35, 0.45); border-radius: 8px; color: var(--coal); min-height: 360px; padding: 24px; box-shadow: 0 22px 60px rgba(0, 0, 0, 0.32);}
.trollsona-card { background: linear-gradient(180deg, rgba(248, 237, 207, 0.98), rgba(239, 224, 191, 0.98)), repeating-linear-gradient(0deg, rgba(92, 65, 35, 0.06) 0, rgba(92, 65, 35, 0.06) 1px, transparent 1px, transparent 10px);}
.empty-dossier { display: flex; flex-direction: column; justify-content: center; background: linear-gradient(180deg, rgba(219, 194, 139, 0.98), rgba(190, 151, 84, 0.96)), repeating-linear-gradient(0deg, rgba(43, 33, 24, 0.08) 0, rgba(43, 33, 24, 0.08) 1px, transparent 1px, transparent 11px); box-shadow: inset 0 0 0 1px rgba(255, 247, 223, 0.2), 0 22px 60px rgba(0, 0, 0, 0.32);}
.empty-dossier h2,.trollsona-card h2 { color: var(--coal); font-size: 2rem; line-height: 1.1; margin: 10px 0 14px; overflow-wrap: anywhere;}
.empty-dossier p { color: #281b12; font-size: 1.03rem; font-weight: 650; line-height: 1.52; margin: 0; max-width: 360px;}
.trollsona-mainline { border-left: 4px solid var(--ember); color: #35271b; font-size: 1.08rem; font-weight: 750; line-height: 1.48; margin: 0 0 18px; padding-left: 14px; overflow-wrap: anywhere;}
.trollsona-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-top: 16px;}
.trollsona-grid-single { grid-template-columns: 1fr;}
.trollsona-tile { border: 1px solid rgba(92, 65, 35, 0.22); border-radius: 8px; background: rgba(255, 247, 223, 0.64); padding: 14px;}
.trollsona-value { color: #3f3020; font-size: 1rem; line-height: 1.42; margin-top: 8px; overflow-wrap: anywhere;}
.meter-shell { border: 1px solid rgba(92, 65, 35, 0.28); border-radius: 999px; background: rgba(29, 23, 18, 0.16); height: 12px; margin-top: 10px; overflow: hidden;}
.meter-fill { background: linear-gradient(90deg, var(--olive), var(--brass), var(--ember)); height: 100%;}
.gradio-container details,.gradio-container .accordion,.gradio-container button[aria-expanded],.gradio-container button.label-wrap,.dossier-stage button,.gradio-container .secondary { border-color: rgba(215, 189, 134, 0.32) !important; background: rgba(29, 23, 18, 0.82) !important; color: var(--paper) !important;}
.gradio-container details summary,.gradio-container button[aria-expanded] span,.gradio-container button[aria-expanded],.gradio-container button.label-wrap,.gradio-container button.label-wrap *,.gradio-container button.label-wrap span { color: var(--paper) !important;}
.gradio-container button.label-wrap svg,.gradio-container button.label-wrap path { color: var(--paper) !important; fill: var(--paper) !important; stroke: var(--paper) !important;}
.preset-note { color: var(--paper); font-size: 0.94rem; line-height: 1.35; margin: 2px 0 12px;}
.preset-row { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;}
.preset-card,.preset-card button,.gradio-container .preset-card { border: 1px solid rgba(215, 189, 134, 0.34) !important; border-radius: 8px !important; background: linear-gradient(180deg, rgba(43, 33, 24, 0.96), rgba(29, 23, 18, 0.96)) !important; color: var(--paper) !important; font-weight: 800 !important; line-height: 1.25 !important; min-height: 78px !important; text-align: left !important; white-space: normal !important; box-shadow: inset 0 0 0 1px rgba(255, 247, 223, 0.04) !important;}
.preset-card:hover,.preset-card button:hover,.gradio-container .preset-card:hover { border-color: rgba(198, 134, 51, 0.72) !important; background: linear-gradient(180deg, rgba(62, 45, 31, 0.98), rgba(37, 29, 21, 0.98)) !important;}
.gradio-container table,.gradio-container th,.gradio-container td { border-color: rgba(215, 189, 134, 0.24) !important; background: var(--coal-soft) !important; color: var(--paper) !important;}
.dossier-stage .prose,.dossier-stage .prose p,.dossier-stage .prose strong,.dossier-stage .prose code { color: var(--paper) !important;}
.dossier-stage .prose code { border: 1px solid rgba(215, 189, 134, 0.26); border-radius: 4px; background: #251d15; padding: 2px 5px;}
.gradio-container footer { display: none !important;}
@media (max-width: 760px) { .gradio-container { padding: 14px !important; }
.ritual-layout { grid-template-columns: 1fr; gap: 14px; }
.preset-row { grid-template-columns: 1fr; }
.ritual-hero { padding: 20px; }
.ritual-hero h1 { font-size: 2.35rem; }
.empty-dossier, .trollsona-card { min-height: 300px; padding: 18px; }}1234gradio>=4.44,<6transformers>=4.44,<5torch>=2.2accelerate>=0.33.env.exampleAdded+4
.gitignoreAdded+12
README.md+201-6
SUBMISSION.mdAdded+92
app.pyAdded+848
assets/style.cssAdded+446
requirements.txtAdded+4