Spaces:
Running on Zero
A newer version of the Gradio SDK is available: 6.19.0
Handoff Prompt β Ship Phantom Grid as a Hugging Face Space
Paste the block below to the agent taking over. It is self-contained.
Task
Ship the Phantom Grid game (this repo) as a Docker Hugging Face Space in the
build-small-hackathon org, for the Build Small Hackathon. The app already works locally on
Windows; your job is to make it run on a Linux Space and submit it. Do not rewrite the
gameplay β only do deployment/packaging.
Hard facts (already verified β do not re-litigate)
- Models are compliant: MiniCPM4.1-8B (text, default) and MiniCPM-o-4.5 (~8B, optional voice). Both under the 32B cap. Keep the text model as the default backend.
- Custom interface is allowed and encouraged. The app uses
gr.Server()with a custom HTML/JS frontend. The field guide says "gr.Server is your friend β go well beyond the stock components" (Off Brand badge). Do NOT convert it to stock Gradio Blocks. - llama.cpp is the blessed inference path. The org's recommended pattern is
llama-server -hf <repo>:Q4_K_Mexposing an OpenAI-compatible API at:8080/v1, with the Gradio app pointing at it. The app already supports this via itsllama_cpp_server/external_llama_cpp_serverprovider (PHANTOM_GRID_LLAMACPP_BASE_URL). - Account: logged-in HF user is
unity4ar, a member ofbuild-small-hackathon. β οΈ The cached token is read-only β obtain a write token andhuggingface-cli loginbefore pushing, or repo creation/push will fail. - HF home on this machine:
D:\AppData\Local\huggingface.
The core problem to solve
The current app cannot run on a Linux Space because it is Windows-only and builds its runtime at first launch:
- Windows APIs:
ctypes.windll,msvcrt,subprocess.CREATE_NO_WINDOW,.exepaths inapp.pyandscripts/provision_local_runtime.py. - First-launch native compile of
llama.cpp-omni+ ~12 GB model download intoruntime/. - PowerShell/cmd launchers (
run_game.ps1,run_game.cmd).
Required deliverables (all mandatory for a valid submission)
- A Docker Space that runs on Linux (Docker is allowed "as long as the interface is a
Gradio Space";
gr.Serverqualifies). - Space README with YAML frontmatter (
sdk: docker,app_port), the track tag (this is the delightful / Thousand Token Wood track β an AI-driven game), prize-category badges, a short description, and links to the demo video and social post. - Demo video of the app working (judges may not be able to run it live).
- One social-media post, linked from the README.
Implementation plan
- Write a
Dockerfileat repo root (Linux base, e.g.python:3.12-slimor annvidia/cudabase if using a GPU Space):- Install
requirements.txt(drop Windows-only bits;audioop-ltsis Py3.13-only and optional). - Obtain
llama-serverfor Linux β eitherpip install llama-cpp-python[server]or fetch a prebuilt llama.cpp Linux binary. Do not compile the vendoredllama.cpp-omnitree. - Download the GGUF at build time via
huggingface_hub.hf_hub_download(text model: a MiniCPM 8B Q4_K_M GGUF) into a known path β no first-run provisioning. - Copy app code. Exclude
.venv/,runtime/,tools/*/Lib, and other multi-GB vendored trees (add a.dockerignore).
- Install
- Add a Linux entrypoint (shell script or a small supervisor) that:
- Starts
llama-serveron:8080pointing at the downloaded GGUF. - Sets env so the app uses the external server:
PHANTOM_GRID_LLM_PROVIDER=llama_cpp_server(orexternal_llama_cpp_server),PHANTOM_GRID_LLAMACPP_BASE_URL=http://127.0.0.1:8080/v1,PHANTOM_GRID_WITNESS_CHAT_TTS=0(text backend has no voice). - Launches
app.pyand binds the Gradio/gr.Serverport to the Space'sapp_port(default 7860; expose it).
- Starts
- Make
app.pyimport on Linux. Guard or remove the Windows-only code paths that run at import/startup (msvcrt,ctypes.windll,CREATE_NO_WINDOW,.exelookups). The in-app "setup/provisioner" screen should be disabled or hidden on Spaces since the model is baked into the image βnew_caserequires a healthy backend, so ensure the baked server reports healthy. - Pick hardware. A GPU Space is realistic for an 8B model; CPU works but is slow. If using ZeroGPU, remember the 10-apps-per-user cap. Document the choice in the README.
- Create & push the Space to
build-small-hackathon/<name>with a write token:huggingface-cli login, then create the Space (SDK: Docker) andgit push(or usehuggingface_hub.HfApi.create_repo(repo_type="space", space_sdk="docker")+ upload). - Verify it boots on the Space, the server reports healthy, and a new case starts.
- Record the demo video, publish the social post, and finalize the README with both links + track tag + badges.
Acceptance criteria
- The Space builds and runs on HF Spaces (Linux), starts a case, and answers a witness question using the under-32B model.
- README has track tag, badges, description, video link, social link.
- Space lives under the
build-small-hackathonorg. - No Windows-only call runs in the container; no multi-GB build-from-source at startup.
Pitfalls
- Read-only token β push fails. Get a write token first.
- Pushing
.venv//runtime/β bloated/broken Space. Use.dockerignore. - Model download at startup instead of build time β Space times out. Bake it into the image.
- Leaving
PHANTOM_GRID_LLM_PROVIDER=minicpm_omniβ needs the heavy omni stack. Use the plain text llama.cpp server provider.
dont upload anything but make a script to do all the requirements to ship everything... i will copy the present folder to another system and will run this script from that system....but test to make sure that it will run....only one step left must be to run this script