SPB Git

Repository Public

playground.html 14.1 KB 184 lines html

1<!doctype html>2<html lang="en">3<head>4  <meta charset="utf-8">5  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">6  <title>Playground — MacLustr AI</title>7  <meta name="description" content="Interactive playground for the MacLustr LLM API. Uses the real API with your key.">8  <meta name="theme-color" content="#07090c" media="(prefers-color-scheme: dark)">9  <meta name="theme-color" content="#f6f7f9" media="(prefers-color-scheme: light)">10  <link rel="icon" href="/assets/favicon.svg" type="image/svg+xml">11  <script src="/assets/site/theme.js"></script>12  <link rel="stylesheet" href="/assets/tokens.css">13  <link rel="stylesheet" href="/assets/site.css">14  <link rel="stylesheet" href="/assets/site/playground.css">15  <link rel="modulepreload" href="/assets/site/core.js">16  <link rel="modulepreload" href="/assets/site/playground.js">17  <link rel="modulepreload" href="/assets/site/markdown.js">18</head>19<body>20  <a class="skip-link" href="#main">Skip to content</a>21  <header class="site-header">22    <div class="wrap">23      <a class="brand" href="/" aria-label="MacLustr AI — home">24        <img src="/assets/logo.svg" alt="" width="28" height="28">25        <span>MacLustr <span>AI</span></span>26      </a>27      <nav class="site-nav" id="site-nav" aria-label="Primary">28        <a href="/docs" data-nav="docs">Docs</a>29        <a href="/playground" aria-current="page" data-nav="playground">Playground</a>30        <a href="/status" data-nav="status">Status</a>31        <a href="/changelog" data-nav="changelog">Changelog</a>32      </nav>33      <div class="header-tools">34        <button type="button" class="icon-btn theme-toggle" data-theme-toggle aria-label="Switch theme">35          <svg class="i-moon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5Z"/></svg>36          <svg class="i-sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2.5v2M12 19.5v2M2.5 12h2M19.5 12h2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"/></svg>37        </button>38        <button type="button" class="icon-btn menu-btn" data-menu-btn aria-controls="site-nav" aria-expanded="false" aria-label="Open menu">39          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16"/></svg>40        </button>41      </div>42    </div>43  </header>4445  <main id="main" tabindex="-1" class="pg">46    <section class="pg-chat" data-chat aria-label="Conversation">47      <div class="pg-top">48        <div class="pg-model">49          <label for="pg-model">Model</label>50          <select id="pg-model" data-model aria-describedby="pg-auth-state"></select>51        </div>52        <div class="ctx" data-ctx title="Tokens used by the last response (prompt + completion) against the model context window">53          <div class="ctx-bar" role="meter" aria-label="Context window used" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" data-ctx-meter><span data-ctx-fill></span></div>54          <span class="ctx-text tabular" data-ctx-text>— / —</span>55        </div>56        <button type="button" class="btn btn-sm pg-auth-btn" data-auth-open aria-haspopup="dialog"><span class="dot" aria-hidden="true"></span><span id="pg-auth-state" data-auth-state>Connect</span></button>57        <button type="button" class="icon-btn" data-clear aria-label="Clear conversation" title="Clear conversation"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 7h16M10 11v6M14 11v6M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg></button>58        <button type="button" class="icon-btn pg-panel-btn" data-panel-open aria-controls="pg-panel" aria-expanded="false" aria-label="Request settings"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6h10M18 6h2M4 12h4M12 12h8M4 18h12M20 18h0"/><circle cx="16" cy="6" r="2"/><circle cx="10" cy="12" r="2"/><circle cx="18" cy="18" r="2"/></svg></button>59      </div>6061      <div class="pg-scroll" data-scroll tabindex="0" role="log" aria-label="Messages" aria-live="off">62        <div class="pg-inner">63          <details class="pg-system" data-system-box>64            <summary><span class="role-tag">System</span><span class="pg-system-preview" data-system-preview>No system prompt</span></summary>65            <label class="sr-only" for="pg-system">System prompt</label>66            <textarea id="pg-system" data-system rows="3" placeholder="Optional instructions that frame the whole conversation"></textarea>67          </details>68          <div class="pg-empty" data-empty>69            <img src="/assets/logo.svg" alt="" width="44" height="44">70            <h1>Playground</h1>71            <p>Every message here is a real request to <code>POST /v1/chat/completions</code>. Nothing is simulated, and timings are measured in your browser.</p>72            <p class="pg-empty-auth" data-empty-auth></p>73          </div>74          <ol class="pg-messages" data-messages></ol>75        </div>76      </div>7778      <form class="pg-composer" data-composer>79        <div class="pg-composer-box">80          <label class="sr-only" for="pg-input">Message</label>81          <textarea id="pg-input" data-input rows="1" placeholder="Send a message" enterkeyhint="send"></textarea>82          <button type="submit" class="pg-send" data-send aria-label="Send message"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 19V5M6 11l6-6 6 6"/></svg></button>83          <button type="button" class="pg-send pg-stop" data-stop aria-label="Stop generating" hidden><svg viewBox="0 0 24 24" aria-hidden="true"><rect x="7" y="7" width="10" height="10" rx="2" fill="currentColor"/></svg></button>84        </div>85        <p class="pg-hint" data-hint>Enter to send · Shift + Enter for a new line</p>86      </form>87    </section>8889    <div class="pg-backdrop" data-panel-backdrop hidden></div>90    <aside class="pg-panel" id="pg-panel" data-panel aria-label="Request settings">91      <div class="pg-panel-grip" aria-hidden="true"></div>92      <div class="pg-panel-head">93        <div class="pg-tabs" role="tablist" aria-label="Request settings">94          <button type="button" role="tab" id="pt-params" aria-controls="pp-params" aria-selected="true" data-value="params">Parameters</button>95          <button type="button" role="tab" id="pt-tools" aria-controls="pp-tools" aria-selected="false" tabindex="-1" data-value="tools">Tools</button>96          <button type="button" role="tab" id="pt-json" aria-controls="pp-json" aria-selected="false" tabindex="-1" data-value="json">JSON</button>97          <button type="button" role="tab" id="pt-request" aria-controls="pp-request" aria-selected="false" tabindex="-1" data-value="request">Request</button>98          <span class="tab-ink" aria-hidden="true"></span>99        </div>100        <button type="button" class="icon-btn pg-panel-close" data-panel-close aria-label="Close settings"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg></button>101      </div>102103      <div class="pg-panel-body">104        <div role="tabpanel" id="pp-params" aria-labelledby="pt-params" tabindex="0">105          <p class="pg-note">Empty fields are not sent: the model or engine default applies.</p>106          <div class="field-grid">107            <div class="field"><label for="p-temperature">temperature</label><input id="p-temperature" data-param="temperature" type="number" inputmode="decimal" min="0" max="2" step="0.1" placeholder="default"></div>108            <div class="field"><label for="p-top_p">top_p</label><input id="p-top_p" data-param="top_p" type="number" inputmode="decimal" min="0.01" max="1" step="0.05" placeholder="default"></div>109            <div class="field"><label for="p-max_tokens">max_tokens</label><input id="p-max_tokens" data-param="max_tokens" type="number" inputmode="numeric" min="1" step="1" placeholder="default"></div>110            <div class="field"><label for="p-seed">seed</label><input id="p-seed" data-param="seed" type="number" inputmode="numeric" step="1" placeholder="none"></div>111          </div>112          <div class="field"><label for="p-stop">stop <span>one sequence per line, up to 8</span></label><textarea id="p-stop" data-param="stop" rows="2" placeholder="none" spellcheck="false"></textarea></div>113          <label class="check"><input type="checkbox" data-thinking><span>Request reasoning <code>enable_thinking</code><small data-thinking-note>Returned as reasoning_content when the model supports it.</small></span></label>114          <dl class="pg-facts" data-model-facts></dl>115        </div>116117        <div role="tabpanel" id="pp-tools" aria-labelledby="pt-tools" tabindex="0" hidden>118          <label class="check"><input type="checkbox" data-tools-on><span>Send tools with the request<small>Only <code>tool_choice</code> auto and none are supported. Each call arrives whole in one chunk.</small></span></label>119          <div class="field"><label for="p-tool-choice">tool_choice</label><select id="p-tool-choice" data-tool-choice><option value="auto">auto</option><option value="none">none</option></select></div>120          <div class="field"><label for="p-tools">tools <span>JSON array</span></label><textarea id="p-tools" class="mono" data-tools rows="14" spellcheck="false" autocapitalize="off" autocomplete="off"></textarea>121            <p class="field-msg" data-tools-msg role="status"></p></div>122          <button type="button" class="btn btn-sm" data-tools-reset>Restore example</button>123          <p class="pg-note" data-tools-conflict hidden>Tools are not sent while a JSON mode is active: the API rejects the combination.</p>124        </div>125126        <div role="tabpanel" id="pp-json" aria-labelledby="pt-json" tabindex="0" hidden>127          <fieldset class="radio-set">128            <legend>response_format</legend>129            <label><input type="radio" name="json-mode" value="off" data-json-mode checked><span>text</span></label>130            <label><input type="radio" name="json-mode" value="json_object" data-json-mode><span>json_object</span></label>131            <label><input type="radio" name="json-mode" value="json_schema" data-json-mode><span>json_schema</span></label>132          </fieldset>133          <p class="pg-note">JSON modes are sent <strong>without streaming</strong>, because the server only validates (and repairs once) non-streaming responses. Invalid output returns 422 <code>json_validation_failed</code>.</p>134          <div class="field" data-schema-field hidden><label for="p-schema">json_schema.schema <span>JSON Schema</span></label><textarea id="p-schema" class="mono" data-schema rows="12" spellcheck="false" autocapitalize="off" autocomplete="off"></textarea>135            <p class="field-msg" data-schema-msg role="status"></p></div>136        </div>137138        <div role="tabpanel" id="pp-request" aria-labelledby="pt-request" tabindex="0" hidden>139          <div class="pg-req-controls">140            <div class="seg" role="group" aria-label="Which request">141              <button type="button" class="seg-btn" data-req-source="next" aria-pressed="true">Next request</button>142              <button type="button" class="seg-btn" data-req-source="last" aria-pressed="false">Last sent</button>143            </div>144            <div class="seg" role="group" aria-label="Export format">145              <button type="button" class="seg-btn" data-req-format="curl" aria-pressed="true">cURL</button>146              <button type="button" class="seg-btn" data-req-format="python" aria-pressed="false">Python</button>147              <button type="button" class="seg-btn" data-req-format="json" aria-pressed="false">JSON</button>148            </div>149          </div>150          <div data-req-out></div>151          <p class="pg-note">The export never contains your key: it uses the placeholder <code>YOUR_MACLUSTR_API_KEY</code>.</p>152        </div>153      </div>154    </aside>155  </main>156157  <dialog class="pg-dialog" id="pg-auth" aria-labelledby="pg-auth-title">158    <form method="dialog" class="pg-dialog-close"><button class="icon-btn" aria-label="Close"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg></button></form>159    <h2 id="pg-auth-title">Connect to the API</h2>160    <p>The Playground calls the real API from this page. Choose how requests are authenticated.</p>161    <form class="pg-key-form" data-key-form>162      <label for="pg-key">API key</label>163      <div class="pg-key-row">164        <input id="pg-key" data-key type="password" placeholder="mlx_sk_…" autocomplete="off" autocapitalize="off" spellcheck="false">165        <button type="submit" class="btn btn-primary btn-sm">Use key</button>166      </div>167      <p class="field-msg" data-key-msg role="status"></p>168      <p class="pg-note">Kept in this tab's <code>sessionStorage</code> only. It is never written to <code>localStorage</code>, and it is forgotten when the tab closes.</p>169    </form>170    <div class="pg-admin" data-admin-box hidden>171      <div class="pg-or"><span>or</span></div>172      <button type="button" class="btn" data-use-admin>Use admin session</button>173      <p class="pg-note">You are signed in to the dashboard in this browser. Requests use that session (admin priority) with a CSRF token; no key is needed.</p>174    </div>175    <div class="pg-current" data-current-auth hidden>176      <span data-current-auth-text></span>177      <button type="button" class="btn btn-sm btn-danger" data-forget>Disconnect</button>178    </div>179  </dialog>180  <noscript><div class="wrap"><p class="notice">This page needs JavaScript for live data and interactive examples. The API itself is documented in <a href="/openapi.json">/openapi.json</a>.</p></div></noscript>181  <script type="module" src="/assets/site/playground.js"></script>182</body>183</html>184
Files main
Menu

Theme