# Mario-HTML WebUI
A single-file FastAPI chat UI for **granite-4.2-3b-HTML**. It is model-agnostic: point it at any
OpenAI-compatible endpoint (`/v1`) and it renders that model's output.
## Features
- **Split reasoning and answer** — the ` … ` stream is routed into a collapsible
*Chain of Thought* panel, and everything after it is rendered as HTML.
- **HTML card canvas** — the answer body is rendered live inside a canvas, so `ai-view` cards,
callouts, tables and steppers look the way the model designed them.
- **Themes and custom CSS** — built-in presets (`default`, `notion`, `editorial`, `apple`,
`cyber`) plus a free-form `custom_css` field.
- **Sampling panel** — temperature, top-p, top-k, min-p, presence/repetition penalty, max
tokens and a CoT Reasoning on/off switch.
- **Two backend modes** — `api` (talk to a running vLLM / llama.cpp server) or `direct`
(let the UI start a managed `llama-server` on a local GGUF).
## Quick start
### 1. Serve the model
```bash
# transformers checkpoint in this repo
vllm serve . --served-model-name granite-4.2-3b-HTML \
--max-model-len 65536 --gpu-memory-utilization 0.9
```
### 2. Serve the UI
```bash
cd webui
pip install -r requirements.txt
./run_webui.sh # or: python server.py --port 8791
```
Open `http://localhost:8791`.
`config.json` is the single source of truth — `api_url`, `model_alias`, `context_size`,
sampling defaults, theme and CSS all live there. Environment variables
(`API_URL`, `MODEL_PATH`, `MODEL_ALIAS`, `WEBUI_PORT`, `WEBUI_PY`) override it when you need a
one-off run.
## Files
| File | Purpose |
|---|---|
| `server.py` | All backend logic (single file) |
| `static/index.html` | Frontend (single HTML + JS file) |
| `static/theme.css` | Base theme |
| `config.json` | Runtime config (backend URL, sampling, theme) |
| `run_webui.sh` | Self-contained launcher |
| `requirements.txt` | Python dependencies |
## Notes
- `enable_thinking` is forwarded to the backend as `chat_template_kwargs.enable_thinking`, so the
model card's `enable_thinking=false` shortcut (pre-closed empty think block → straight to the
HTML card) works the same way here.
- With `enable_thinking=true` the chat template pre-fills an opening ``, so the opening tag
is not part of the generated stream — the UI handles that shape as well as the "tags inside the
output" shape.