// DeepSeek page: thin client over /ai/deepseek/* (all limits server side). (function () { "use strict"; var $ = function (id) { return document.getElementById(id); }; var out = $("ds-out"), err = $("ds-error"); var templates = { "chat": { prompt: "Hello!", thinking: "enabled", effort: "high", max_tokens: 256 }, "stream": { prompt: "Count to five.", thinking: "disabled", max_tokens: 128 }, "prefix": { prompt: "Write quick sort", prefix: "```python\n", stop: ["```"], thinking: "disabled" }, "tools": { prompt: "Weather in Hangzhou?", strict: false, thinking: "disabled" }, "fim": { prompt: "def fib(a):", suffix: " return fib(a-1) + fib(a-2)", max_tokens: 128 }, "responses": { input: "Hi, how are you?", instructions: "Be brief.", effort: "low" }, "anthropic": { prompt: "Hi", max_tokens: 256, thinking: "disabled" }, "models": {}, "balance": {}, "files": { action: "list", limit: 20 }, "search": { query: "DeepSeek V4 release", count: 5 }, "fetch": { url: "https://example.com" } }; var sel = $("ds-route"); Object.keys(templates).forEach(function (k) { var o = document.createElement("option"); o.value = k; o.textContent = k; sel.appendChild(o); }); function fill() { $("ds-body").value = JSON.stringify(templates[sel.value], null, 1); } sel.onchange = fill; fill(); function send(confirm) { var body; try { body = JSON.parse($("ds-body").value || "{}"); } catch (e) { err.textContent = "Body is not valid JSON"; return; } if (confirm) body.confirm = true; err.textContent = ""; out.textContent = "..."; fetch("/ai/deepseek/" + sel.value, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }).then(function (res) { return res.text().then(function (t) { var j; try { j = JSON.parse(t); } catch (e) { j = { message: t }; } if (!res.ok) { err.textContent = j.message || ("HTTP " + res.status); out.textContent = ""; } else { out.textContent = JSON.stringify(j, null, 2); } }); }).catch(function (e) { err.textContent = String(e); out.textContent = ""; }); } $("ds-send").onclick = function () { send(false); }; $("ds-confirm").onclick = function () { send(true); }; fetch("/ai/deepseek/status").then(function (r) { return r.json(); }).then(function (s) { $("ds-config").textContent = s.configured ? "DEEPSEEK_API_KEY found. Calls are real; paid ones need confirm." : "No DEEPSEEK_API_KEY: calls answer 503 until one is configured; dry runs still work."; }); })();