Root cause of 'my MINDI generates HTML when I ask for Next.js':
The previous SYSTEM_MSG told the model WHAT to produce ('complete code,
no placeholders') but not HOW to shape the output when the user named
a specific framework. Qwen2.5-Coder-7B has a strong bias toward
single-file HTML for 'landing page' prompts because that's the shortest
artifact that 'looks complete' in one forward pass. Worse, the model
sometimes emits fs.mkdirSync() / execSync('npx create-next-app') style
scaffolding scripts \u2014 technically code, but useless.
Fix: explicit OUTPUT RULES + FRAMEWORK AWARENESS sections in SYSTEM_MSG.
Key behaviours now enforced by the prompt:
- Correct fenced-block language tag for every framework (tsx for Next.js
+ React-TS, jsx for React-JS, html for HTML, vue for Vue SFCs, py/js
/css/json/sql/bash for everything else). Without this the frontend's
detectProjectKind() + StackBlitz template routing were mis-firing.
- NEVER emit fs.mkdirSync / execSync scaffolding scripts.…
frontend/app.js:
- Real Gradio image upload via /gradio_api/upload (gr.Image cannot decode
raw data URLs). dataUrlToBlob() + uploadImageToGradio() helpers send a
multipart POST with Authorization, then hand the resulting /tmp/gradio
path to chat_fn as a {path, meta:{_type:gradio.FileData}} reference.
- Vision toggle state (visionEnabled) plumbed through Settings modal,
persisted in localStorage, defaults OFF because the current vision
fusion is weak. send() drops images from the API payload when the
toggle is off so we don't waste GPU seconds on a known-bad path.
- Cloud sandbox launchers for real Next.js / React / Node / HTML
execution — both StackBlitz (form POST to /run, WebContainer-backed)
and CodeSandbox (Define API JSON POST returning sandbox_id).
buildStackBlitzProject() detects Next.js / React / Node / HTML from
imports and dependency hints, generates a working package.json and
template files. buildCodeSandboxFiles() reuses the same project shape.
- BUG F…
Fixes the embarrassing 'I am GPT-4' hallucination and the no-memory issue
shown in the chat screenshot. Verified end-to-end against the live Space:
Turn 1 'My name is Faaz and I am 24 years old.' -> 'HI'
Turn 2 'What is my name?' -> 'Your name is Faaz.'
Turn 3 'Who are you?' -> 'I am MINDI 1.5
Vision-Coder, built
by MINDIGENOUS.AI.'
hf_space/app.py:
- New strong SYSTEM_MSG anchoring identity (NOT GPT/Claude/Gemini/Qwen)
and behavior (complete code, no placeholders, image-aware, memory-aware).
- _build_prompt(prompt, history) renders system + last 20 turns (capped at
12K chars) + new user message into the Qwen <|im_start|> template, with
oldest turns trimmed first if the budget is exceeded.
- generate(...) and chat_fn(...) take an optional history list.
- _coerce_history accepts list-of-dict OR JSON-encoded string so…
Add HF Space backend and frontend with HF token auth
Faaz
6e8fa2a
Frontend (frontend/):
- index.html: three-panel layout (sidebar, chat, code preview) with
settings modal
- app.js: chat logic, Gradio 5.x SSE v3 protocol (POST + GET event_id),
HF token Authorization header, agent integration, demo fallback,
cold-start hint
- agent.js, sandbox.js: Plan->Generate->Execute->Verify->Fix agent loop
with iframe sandbox for code preview
- styles.css: dark theme with purple/blue gradients
- test_api.py: CLI test that reads HF_TOKEN from env, supports custom
prompt + max_tokens, parses SSE events, falls back to /config when
/gradio_api/config returns 404
Backend (hf_space/):
- app.py: ZeroGPU Space loading full bf16 MINDI-1.5 (Qwen2.5-Coder-7B
+ LoRA + CLIP + fusion). Model load is inside @spaces.GPU function
per ZeroGPU requirements. chat_fn returns clean JSON with quota error
handling.
- requirements.txt: gradio>=5.0, transformers, peft, torch, spaces
- README.md: SDK metadata for HF Space
Fixes Session 4 ZeroGPU quota issue: anonymous re…