fix: Думать - the model is reminded in the question itself, the label no longer lands in the arrow, and the thinking with its time is kept to show again later
This commit is contained in:
1 parent
3b7a6271ac
commit
fa62f2c5b6
5 files changed
+78
-15
No files matched your search
@@ -207,7 +207,7 @@
|
||||
if (chatId !== id) return;
|
||||
h.forEach(m => {
|
||||
if (m.role === 'result') showResult(m.content);
|
||||
else { const el = add(m.role, m.content); el.querySelectorAll('.ai-act').forEach(b => { b.disabled = true; }); }
|
||||
else { const el = add(m.role, m.content, m.think_ms); el.querySelectorAll('.ai-act').forEach(b => { b.disabled = true; }); }
|
||||
});
|
||||
if (!h.length) q('.ai-hello').hidden = false;
|
||||
} catch (e) { /* stays empty */ }
|
||||
@@ -365,11 +365,12 @@
|
||||
// Markdown; ``` blocks apart, action blocks with their button. The
|
||||
// thinking block is made once and only its words change, so it stays open
|
||||
// or shut as the user left it while the answer streams.
|
||||
const CHEV = '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="m9 6 6 6-6 6"/></svg>';
|
||||
// The arrow of the + menu's groups: right shut, down open.
|
||||
const CHEV = '<span class="chev">›</span>';
|
||||
function render(el, text, done) {
|
||||
let think = el.querySelector(':scope > .ai-think'), body = el.querySelector(':scope > .ai-body');
|
||||
if (!body) {
|
||||
el.innerHTML = '<div class="ai-think" hidden><button type="button" class="ai-think-h">' + CHEV + '<span></span></button>' +
|
||||
el.innerHTML = '<div class="ai-think" hidden><button type="button" class="ai-think-h">' + CHEV + '<span class="lbl"></span></button>' +
|
||||
'<div class="ai-think-b"><div class="ai-think-in"></div></div></div><div class="ai-body"></div>';
|
||||
think = el.querySelector('.ai-think'); body = el.querySelector('.ai-body');
|
||||
think.querySelector('.ai-think-h').onclick = () => think.classList.toggle('open');
|
||||
@@ -381,8 +382,9 @@
|
||||
if (!going && !el._t1) el._t1 = Date.now();
|
||||
think.hidden = false;
|
||||
think.classList.toggle('going', going);
|
||||
think.querySelector('.ai-think-h span').textContent = going ? 'Думаю…'
|
||||
: 'Думал ' + Math.max(1, Math.round((el._t1 - el._t0) / 1000)) + ' с';
|
||||
// How long: timed here as it streams, or kept with the answer.
|
||||
const ms = el._thinkMs || (el._t1 - el._t0);
|
||||
think.querySelector('.ai-think-h .lbl').textContent = going ? 'Думаю…' : 'Думал ' + Math.max(1, Math.round(ms / 1000)) + ' с';
|
||||
think.querySelector('.ai-think-in').innerHTML = WSUtil.md(th[1].trim());
|
||||
text = text.slice(th[0].length);
|
||||
}
|
||||
@@ -407,11 +409,11 @@
|
||||
body.innerHTML = html;
|
||||
el.dataset.text = text;
|
||||
}
|
||||
function add(role, text) {
|
||||
function add(role, text, thinkMs) {
|
||||
q('.ai-hello').hidden = true;
|
||||
const el = document.createElement('div');
|
||||
el.className = 'ai-msg ' + role;
|
||||
if (role === 'assistant') render(el, text, true); else el.textContent = text;
|
||||
if (role === 'assistant') { el._thinkMs = thinkMs || 0; render(el, text, true); } else el.textContent = text;
|
||||
list.appendChild(el);
|
||||
list.scrollTop = list.scrollHeight;
|
||||
return el;
|
||||
|
||||
Reference in new issue
Block a user