diff --git a/dist/assets/index-DfSXZB8u.js b/dist/assets/index-mliZjutQ.js similarity index 97% rename from dist/assets/index-DfSXZB8u.js rename to dist/assets/index-mliZjutQ.js index 173df9d..da4a8a6 100644 --- a/dist/assets/index-DfSXZB8u.js +++ b/dist/assets/index-mliZjutQ.js @@ -213,25 +213,17 @@ const SUNE = window.SUNE = new Proxy({ get list() { state.messages.push(assistantMsg); THREAD.persist(false); state.stream = { rid: streamId, bubble: suneBubble, meta: suneMeta, text: "", done: false }; - let contentBuf = "", reasoningBuf = "", completed = false, reasoningEl = null; + let buf = "", completed = false; const onDelta = (delta, done) => { - contentBuf += delta.content; - reasoningBuf += delta.reasoning; - state.stream.text = contentBuf; - renderMarkdown(suneBubble, contentBuf, { enhance: false }); - assistantMsg.content[0].text = contentBuf; - if (reasoningBuf && !reasoningEl) { - reasoningEl = document.createElement("div"); - reasoningEl.className = "markdown-body rounded-none px-4 py-3 w-full bg-blue-50 border-l-4 border-blue-300 text-sm text-gray-600"; - suneBubble.parentElement.insertBefore(reasoningEl, suneBubble); - } - if (reasoningEl) renderMarkdown(reasoningEl, reasoningBuf, { enhance: false }); + buf += delta; + state.stream.text = buf; + renderMarkdown(suneBubble, buf, { enhance: false }); + assistantMsg.content[0].text = buf; if (done && !completed) { completed = true; setBtnSend(); state.busy = false; enhanceCodeBlocks(suneBubble, true); - if (reasoningEl) enhanceCodeBlocks(reasoningEl, true); THREAD.persist(true); el.composer.dispatchEvent(new CustomEvent("sune:newSuneResponse", { detail: { message: assistantMsg } })); state.stream = { rid: null, bubble: null, meta: null, text: "", done: false }; @@ -805,25 +797,17 @@ $(el.composer).on("submit", async (e) => { state.messages.push(assistantMsg); THREAD.persist(false); state.stream = { rid: streamId, bubble: suneBubble, meta: suneMeta, text: "", done: false }; - let contentBuf = "", reasoningBuf = "", completed = false, reasoningEl = null; + let buf = "", completed = false; const onDelta = (delta, done) => { - contentBuf += delta.content; - reasoningBuf += delta.reasoning; - state.stream.text = contentBuf; - renderMarkdown(suneBubble, contentBuf, { enhance: false }); - assistantMsg.content[0].text = contentBuf; - if (reasoningBuf && !reasoningEl) { - reasoningEl = document.createElement("div"); - reasoningEl.className = "markdown-body rounded-none px-4 py-3 w-full bg-blue-50 border-l-4 border-blue-300 text-sm text-gray-600"; - suneBubble.parentElement.insertBefore(reasoningEl, suneBubble); - } - if (reasoningEl) renderMarkdown(reasoningEl, reasoningBuf, { enhance: false }); + buf += delta; + state.stream.text = buf; + renderMarkdown(suneBubble, buf, { enhance: false }); + assistantMsg.content[0].text = buf; if (done && !completed) { completed = true; setBtnSend(); state.busy = false; enhanceCodeBlocks(suneBubble, true); - if (reasoningEl) enhanceCodeBlocks(reasoningEl, true); THREAD.persist(true); el.composer.dispatchEvent(new CustomEvent("sune:newSuneResponse", { detail: { message: assistantMsg } })); state.stream = { rid: null, bubble: null, meta: null, text: "", done: false }; @@ -1211,7 +1195,7 @@ const buildBody = () => { async function askOpenRouterStreaming(onDelta, streamId) { const model = SUNE.model, provider = model.startsWith("oai:") ? "openai" : model.startsWith("g:") ? "google" : model.startsWith("cla:") ? "claude" : model.startsWith("cf:") ? "cloudflare" : model.startsWith("or:") ? "openrouter" : USER.provider, apiKey = provider === "openai" ? USER.apiKeyOpenAI : provider === "google" ? USER.apiKeyGoogle : provider === "claude" ? USER.apiKeyClaude : provider === "cloudflare" ? USER.apiKeyCloudflare : USER.apiKeyOpenRouter; if (!apiKey) { - onDelta({ content: localDemoReply(), reasoning: "" }, true); + onDelta(localDemoReply(), true); return { ok: true, rid: streamId || null }; } const r = { rid: streamId || gid(), seq: -1, done: false, signaled: false, ws: null }; @@ -1219,7 +1203,7 @@ async function askOpenRouterStreaming(onDelta, streamId) { const signal = (t) => { if (!r.signaled) { r.signaled = true; - onDelta({ content: t || "", reasoning: "" }, true); + onDelta(t || "", true); } }; const ws = new WebSocket(HTTP_BASE.replace("https", "wss") + "?uid=" + encodeURIComponent(r.rid)); @@ -1234,7 +1218,7 @@ async function askOpenRouterStreaming(onDelta, streamId) { } if (m.type === "delta" && typeof m.seq === "number" && m.seq > r.seq) { r.seq = m.seq; - onDelta({ content: m.content || "", reasoning: m.reasoning || "" }, false); + onDelta(m.text || "", false); } else if (m.type === "done" || m.type === "err") { r.done = true; cacheStore.setItem(r.rid, "done"); diff --git a/dist/index.html b/dist/index.html index 929389b..d2e53f7 100644 --- a/dist/index.html +++ b/dist/index.html @@ -11,7 +11,7 @@ - + diff --git a/dist/sw.js b/dist/sw.js index f92e450..8e57d68 100644 --- a/dist/sw.js +++ b/dist/sw.js @@ -1 +1 @@ -if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let o={};const c=e=>i(e,t),l={module:{uri:t},exports:o,require:c};s[t]=Promise.all(n.map(e=>l[e]||c(e))).then(e=>(r(...e),o))}}define(["./workbox-5ffe50d4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-CZ8Js0gk.css",revision:null},{url:"assets/index-DfSXZB8u.js",revision:null},{url:"index.html",revision:"ca3c2ca1f8a160c237c3b3a4b5671316"},{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))}); +if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,t)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(s[r])return;let c={};const o=e=>i(e,r),l={module:{uri:r},exports:c,require:o};s[r]=Promise.all(n.map(e=>l[e]||o(e))).then(e=>(t(...e),c))}}define(["./workbox-5ffe50d4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-CZ8Js0gk.css",revision:null},{url:"assets/index-mliZjutQ.js",revision:null},{url:"index.html",revision:"449e7e44cc39205c06610cc6f33ffcc8"},{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});