Spaces:
Running
Running
Download index.html from runcrate/inference-playground: direct link, hf CLI and curl.
- Browser
- Download file 8.57 kB
-
https://huggingface.co/spaces/runcrate/inference-playground/resolve/main/index.html
- Command line
-
hf download hf://spaces/runcrate/inference-playground/index.html
-
curl -L -o index.html https://huggingface.co/spaces/runcrate/inference-playground/resolve/main/index.html
8.57 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>Runcrate inference playground</title> | |
| <style> | |
| :root { --bg:#0b0d12; --panel:#12151c; --line:#232836; --text:#e8eaf0; --dim:#8b93a7; --accent:#4c8dff; } | |
| @media (prefers-color-scheme: light) { :root { --bg:#f7f8fa; --panel:#fff; --line:#e3e6ec; --text:#14171f; --dim:#5d6578; --accent:#2563eb; } } | |
| * { box-sizing: border-box; } | |
| body { margin:0; font:15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; background:var(--bg); color:var(--text); } | |
| main { max-width: 920px; margin: 0 auto; padding: 28px 20px 40px; } | |
| h1 { font-size: 22px; margin: 0 0 4px; } | |
| p.sub { color: var(--dim); margin: 0 0 20px; } | |
| a { color: var(--accent); text-decoration: none; } | |
| a:hover { text-decoration: underline; } | |
| .card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; } | |
| .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } | |
| @media (max-width: 640px) { .grid { grid-template-columns: 1fr; } } | |
| label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; } | |
| input, select, textarea { width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; } | |
| textarea { resize: vertical; } | |
| button { padding: 9px 16px; border-radius: 8px; border: 0; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; } | |
| button.ghost { background: transparent; color: var(--dim); border: 1px solid var(--line); } | |
| button:disabled { opacity: .5; cursor: default; } | |
| #log { min-height: 220px; max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; } | |
| .msg { padding: 10px 12px; border-radius: 10px; white-space: pre-wrap; word-wrap: break-word; } | |
| .user { align-self: flex-end; background: var(--accent); color: #fff; max-width: 80%; } | |
| .assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); max-width: 92%; } | |
| .error { color: #f87171; } | |
| .row { display: flex; gap: 8px; margin-top: 12px; } | |
| .row textarea { flex: 1; } | |
| .meta { font-size: 12px; color: var(--dim); margin-top: 6px; } | |
| pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 13px; } | |
| </style> | |
| </head> | |
| <body> | |
| <main> | |
| <h1>Runcrate inference playground</h1> | |
| <p class="sub">Chat with the open models on <a href="https://www.runcrate.ai/?utm_source=huggingface&utm_medium=directory&utm_campaign=gpu_pricing" target="_blank">Runcrate</a> (DeepSeek, Qwen, Llama, Kimi, gpt-oss and more) through one OpenAI-compatible API. Your API key stays in this browser tab and is sent only to api.runcrate.ai. | |
| <a href="https://www.runcrate.ai/inference/pricing?utm_source=huggingface&utm_medium=directory&utm_campaign=gpu_pricing" target="_blank">Models and prices</a> · | |
| <a href="https://www.runcrate.ai/docs/account/api-keys?utm_source=huggingface&utm_medium=directory&utm_campaign=gpu_pricing" target="_blank">Get an API key</a> · | |
| <a href="https://www.runcrate.ai/docs/mcp/setup?utm_source=huggingface&utm_medium=directory&utm_campaign=mcp" target="_blank">Let your agent rent GPUs (MCP)</a></p> | |
| <div class="card grid"> | |
| <div><label for="key">Runcrate API key</label><input id="key" type="password" autocomplete="off" placeholder="Paste your key"></div> | |
| <div><label for="model">Model</label><select id="model"><option>Loading models...</option></select></div> | |
| <div><label for="system">System prompt</label><input id="system" value="You are a helpful assistant."></div> | |
| <div class="grid" style="gap:8px"> | |
| <div><label for="temp">Temperature</label><input id="temp" type="number" min="0" max="2" step="0.1" value="0.7"></div> | |
| <div><label for="max">Max tokens</label><input id="max" type="number" min="16" max="8192" step="16" value="1024"></div> | |
| </div> | |
| </div> | |
| <div class="card"> | |
| <div id="log"></div> | |
| <div class="row"> | |
| <textarea id="input" rows="2" placeholder="Ask something. Enter to send, Shift+Enter for a new line."></textarea> | |
| <div style="display:flex;flex-direction:column;gap:6px"> | |
| <button id="send">Send</button> | |
| <button id="clear" class="ghost">Clear</button> | |
| </div> | |
| </div> | |
| <div class="meta" id="meta"></div> | |
| </div> | |
| <div class="card"> | |
| <label>Same call from your code</label> | |
| <pre id="code"></pre> | |
| </div> | |
| </main> | |
| <script> | |
| const API = "https://api.runcrate.ai/v1"; | |
| const $ = (id) => document.getElementById(id); | |
| const history = []; | |
| let busy = false; | |
| $("key").value = sessionStorage.getItem("rc_key") || ""; | |
| $("key").addEventListener("input", () => sessionStorage.setItem("rc_key", $("key").value.trim())); | |
| function renderCode() { | |
| const m = $("model").value || "deepseek-ai/DeepSeek-V3.2"; | |
| $("code").textContent = | |
| `from openai import OpenAI | |
| client = OpenAI(base_url="${API}", api_key="RUNCRATE_API_KEY") | |
| r = client.chat.completions.create( | |
| model="${m}", | |
| messages=[{"role": "user", "content": "Hello"}], | |
| ) | |
| print(r.choices[0].message.content)`; | |
| } | |
| async function loadModels() { | |
| const sel = $("model"); | |
| try { | |
| const data = (await (await fetch(API + "/models")).json()).data; | |
| const ids = data.filter((m) => (m.output_modalities || []).includes("text") && (m.input_modalities || []).includes("text")).map((m) => m.id).sort(); | |
| sel.innerHTML = ids.map((id) => `<option>${id}</option>`).join(""); | |
| sel.value = ids.includes("deepseek-ai/DeepSeek-V3.2") ? "deepseek-ai/DeepSeek-V3.2" : ids[0]; | |
| $("meta").textContent = `${ids.length} chat models available.`; | |
| } catch (e) { | |
| sel.innerHTML = "<option>deepseek-ai/DeepSeek-V3.2</option>"; | |
| } | |
| renderCode(); | |
| } | |
| $("model").addEventListener("change", renderCode); | |
| function bubble(role, text) { | |
| const d = document.createElement("div"); | |
| d.className = "msg " + role; | |
| d.textContent = text; | |
| $("log").appendChild(d); | |
| $("log").scrollTop = $("log").scrollHeight; | |
| return d; | |
| } | |
| async function send() { | |
| const text = $("input").value.trim(); | |
| const key = $("key").value.trim(); | |
| if (!text || busy) return; | |
| if (!key) { bubble("assistant error", "Paste your Runcrate API key above first."); return; } | |
| busy = true; $("send").disabled = true; $("input").value = ""; | |
| bubble("user", text); | |
| history.push({ role: "user", content: text }); | |
| const out = bubble("assistant", ""); | |
| const messages = ($("system").value ? [{ role: "system", content: $("system").value }] : []).concat(history); | |
| const t0 = performance.now(); | |
| let reply = ""; | |
| try { | |
| const res = await fetch(API + "/chat/completions", { | |
| method: "POST", | |
| headers: { "Content-Type": "application/json", Authorization: "Bearer " + key }, | |
| body: JSON.stringify({ model: $("model").value, messages, stream: true, temperature: Number($("temp").value), max_tokens: Number($("max").value) }), | |
| }); | |
| if (!res.ok) { | |
| let msg = res.status + " " + res.statusText; | |
| try { msg = (await res.json()).error?.message || msg; } catch {} | |
| throw new Error(msg); | |
| } | |
| const reader = res.body.getReader(); | |
| const dec = new TextDecoder(); | |
| let buf = ""; | |
| for (;;) { | |
| const { value, done } = await reader.read(); | |
| if (done) break; | |
| buf += dec.decode(value, { stream: true }); | |
| const lines = buf.split("\n"); | |
| buf = lines.pop(); | |
| for (const line of lines) { | |
| if (!line.startsWith("data:")) continue; | |
| const data = line.slice(5).trim(); | |
| if (data === "[DONE]") continue; | |
| try { | |
| const delta = JSON.parse(data).choices?.[0]?.delta?.content; | |
| if (delta) { reply += delta; out.textContent = reply; $("log").scrollTop = $("log").scrollHeight; } | |
| } catch {} | |
| } | |
| } | |
| history.push({ role: "assistant", content: reply }); | |
| $("meta").textContent = `${$("model").value} · ${((performance.now() - t0) / 1000).toFixed(1)} s`; | |
| } catch (e) { | |
| history.pop(); | |
| out.classList.add("error"); | |
| out.textContent = "Error from the Runcrate API: " + e.message; | |
| } finally { | |
| busy = false; $("send").disabled = false; $("input").focus(); | |
| } | |
| } | |
| $("send").addEventListener("click", send); | |
| $("input").addEventListener("keydown", (e) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); send(); } }); | |
| $("clear").addEventListener("click", () => { history.length = 0; $("log").innerHTML = ""; }); | |
| loadModels(); | |
| </script> | |
| </body> | |
| </html> | |