Spaces:
Sleeping
Sleeping
Commit History
-
feat(hf-space): add ZeroGPU backend for HuggingFace Pro Spacesβ
apingali +1: Claude Opus 4.7 (1M context)User has a HF Pro plan, so the Space can use ZeroGPU: free on-demand A10g/A100/H200 allocation per request, no API round-trip, no inference credits burned. We load an open model directly via transformers and decorate the inference call with @spaces.GPU so the Pro plan picks up the GPU automatically. Default model is Phi-4-mini-instruct (small enough for fast cold start); swappable to Gemma 2 9B, Llama-3.3, or full Phi-4 via ZEROGPU_MODEL_ID. What changed: app.py - try/except imports of `spaces`, `torch`, `transformers` at module load; sets _ZEROGPU_DEPS_AVAILABLE accordingly. _zerogpu_available() wrapper exists so tests can monkeypatch the answer without touching the real imports. - _call_zerogpu(system, user) decorated with `@spaces.GPU(duration=ZEROGPU_DURATION_SECONDS)` when deps are available; replaced with a clear-error stub otherwise. - Lazy model load (_load_zerogpu_model) β kept warm across requests in module-level state; cold β¦971e3f4 -
feat(hf-space): add HuggingFace backend (Gemma/Phi-4) alongside Anthropicβ
apingali +1: Claude Opus 4.7 (1M context)Users without an ANTHROPIC_API_KEY can now run the diagnostic via an open-weight model served through the HuggingFace Inference Providers API. On a deployed HuggingFace Space, the Space's identity provides free monthly inference credits, so no credentials are needed at all β this is the zero-signup path for trying the diagnostic. What changed: app.py - _detect_provider(env) β env-driven dispatcher (MODEL_PROVIDER > ANTHROPIC_API_KEY > HF_TOKEN/HUGGING_FACE_HUB_TOKEN/SPACE_ID > anthropic default). Captured at module load as DEFAULT_PROVIDER. - _call_anthropic(system, user) and _call_huggingface(system, user) β two interchangeable backends behind a thin _call_model dispatcher. HF uses huggingface_hub.InferenceClient.chat_completion with temperature=0.2 to keep JSON output stable on smaller models. - diagnose() takes a new provider parameter, defaulting to DEFAULT_PROVIDER. The Gradio UI now has a Model-provider dropdown so users caβ¦033a83e -
feat(hf-space): Gradio diagnostic with Anthropic SDK + prompt caching (US4)β
apingali +1: Claude Opus 4.7 (1M context)US4 T031-T037 β the HuggingFace Space at gradio-apps/compounding-test/. A single-shot Gradio app that runs an AI-initiative description through the two-axis Berkshire Test and returns a scored writeup. Engine/site boundary preserved (Principle VIII): lives in gradio-apps/ only, no runtime fetch from the site, no build integration with the site. Files (per contracts/hf-space-interface.md): requirements.txt β gradio>=4.0, anthropic>=0.39, python-dotenv>=1.0, pytest>=8.0 .env.example β ANTHROPIC_API_KEY + MODEL_ID + MAX_DESCRIPTION_WORDS template app.py β parse_response (covered by 15 tests), diagnose() (validates 200-5000 word range, calls Anthropic with cache_control:ephemeral on the system block, parses + returns markdown + JSON tabs), build_demo() Gradio β¦60518c1