--- title: Mythical Universal AI API emoji: 🧠 colorFrom: indigo colorTo: purple sdk: docker app_port: 7860 pinned: true --- # Mythical Universal System — v7.1 Free forever. Text + Images + Audio + Video + PDFs + Web Search + File Generation. ## Setup 1. New HF Space → Docker → CPU Basic (Free) 2. Secrets: `HF_TOKEN` + `API_KEY` 3. Upload 6 files → wait 15min → done forever ## Quick Test ```bash curl https://YOUR-SPACE.hf.space/ready curl https://YOUR-SPACE.hf.space/v1/chat/completions \ -H "Authorization: Bearer KEY" \ -H "Content-Type: application/json" \ -d '{"model":"mythical","messages":[{"role":"user","content":"Hello!"}]}' ``` ## v7.1 Fixes (production issues from live logs) | # | Bug | Root Cause | Fix | |---|-----|-----------|-----| | A | **Watchdog constant flush loop** | Dockerfile `ENV RAM_WARN_GB=11 RAM_REJECT_GB=13 RAM_FLUSH_GB=14` hardcoded tiny values — on a 124 GB shared HF host, system RAM showed 80 GB > 14 GB → infinite flush | `ENV` defaults set to `0`; watchdog now reads container limit from cgroup v1/v2; ignores env vars < 30% of total (stale config guard) | | B | **max_tokens always halved** | Factor used hardcoded GB thresholds `>12.0 → 0.5`, always true in flush state | Factor now uses `wd.level` (ok/warn/reject/flush) | | C | **Thinking mode 504 timeout** | `REQUEST_TIMEOUT=90s` applied to thinking requests that need 2–5 min | New `THINKING_TIMEOUT=300s` env var; applied dynamically per-request | | D | **llama-server cuts thinking at 90s** | `--timeout 90` in `build_cmd()` kills the HTTP connection | Changed to `--timeout 600` | | E | **Watchdog spams logs every 2s** | `post-flush` logged every watchdog tick while in flush state | 30s cooldown between flush attempts; only logs on state change or actual freed memory | | F | **Health shows wrong RAM%** | `psutil.virtual_memory().percent` = host machine %, not container % | Health/metrics use container cgroup values when available | | G | **Model upgrade starts at minute 10** | `last_check=0` in fresh config → always triggers immediately | `last_check=time.time()` on fresh config; initial sleep 10min → 2h | | H | **Whisper tries "base" twice** | Loop `for WSIZE in "$WHISPER_SIZE" "base" "tiny"` — if SIZE=base, tries base×2 | Deduplicated fallback list with `declare -A` | | I | **Whisper hangs on blocked network** | No curl timeout on whisper download | Added `--connect-timeout 15 --max-time 120` | ## v7.0 Fixes (still active) - Semaphore never double-releases (StreamGuard) - /ready probe — no cold-start 502s - System prompt 100% match (KV cache always hits) - File uploads chunked (never blocks event loop) - Encrypted PDFs handled gracefully - Job queue thread-safe (asyncio.Lock) - Web search returns clear message when empty - Whisper auto-retries with smaller model on failure