Spaces:
Running
Running
NakliTechie commited on
Commit ·
3111f03
1
Parent(s): 5c595a3
Sync from GitHub 2026-04-19T08:23:17Z
Browse files- index.html +37 -6
index.html
CHANGED
|
@@ -434,6 +434,12 @@
|
|
| 434 |
border-color: var(--gray-400);
|
| 435 |
}
|
| 436 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 437 |
.msg.assistant .msg-bubble ol,
|
| 438 |
.msg.assistant .msg-bubble ul {
|
| 439 |
padding-left: 20px;
|
|
@@ -8688,11 +8694,18 @@ self.addEventListener('message', async (e) => {
|
|
| 8688 |
|
| 8689 |
// Execute ALL tool calls the model emitted this turn (Qwen3-family
|
| 8690 |
// models including Ternary Bonsai often batch multiple calls into
|
| 8691 |
-
// one response). Blocks are appended to
|
| 8692 |
-
// the bubble —
|
| 8693 |
-
//
|
|
|
|
| 8694 |
toolsUsedInLoop = true;
|
| 8695 |
const msgContainer = currentAssistantEl ? currentAssistantEl.bubble.parentElement : null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8696 |
const toolResults = [];
|
| 8697 |
for (let tcIdx = 0; tcIdx < turn.toolCalls.length; tcIdx++) {
|
| 8698 |
const tc = turn.toolCalls[tcIdx];
|
|
@@ -8712,13 +8725,13 @@ self.addEventListener('message', async (e) => {
|
|
| 8712 |
allSources.push(...toolResult.results);
|
| 8713 |
}
|
| 8714 |
|
| 8715 |
-
if (
|
| 8716 |
const stepLabel = document.createElement('div');
|
| 8717 |
stepLabel.style.cssText = 'font-size:0.68rem;color:var(--gray-400);margin:6px 0 2px;font-weight:500';
|
| 8718 |
const stepSuffix = turn.toolCalls.length > 1 ? ` \u00B7 Call ${tcIdx + 1}/${turn.toolCalls.length}` : '';
|
| 8719 |
stepLabel.textContent = `Step ${iter + 1}/${MAX_TOOL_ITERATIONS}${stepSuffix}`;
|
| 8720 |
-
|
| 8721 |
-
renderToolCallBlock(
|
| 8722 |
}
|
| 8723 |
|
| 8724 |
if (tc.name === 'segment_image' && toolResult._rawMasks) {
|
|
@@ -8814,6 +8827,24 @@ self.addEventListener('message', async (e) => {
|
|
| 8814 |
});
|
| 8815 |
bubble.appendChild(saveBtn);
|
| 8816 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8817 |
}
|
| 8818 |
currentAssistantEl = null;
|
| 8819 |
currentAssistantText = '';
|
|
|
|
| 434 |
border-color: var(--gray-400);
|
| 435 |
}
|
| 436 |
|
| 437 |
+
/* Collapsible tool-trace block (step labels + tool-call blocks) that
|
| 438 |
+
sits above the bubble when expanded. Default collapsed; toggle
|
| 439 |
+
button sits next to Save as MD. */
|
| 440 |
+
.tool-trace-container { margin: 0 0 8px 0; }
|
| 441 |
+
.tool-trace-container.collapsed { display: none; }
|
| 442 |
+
|
| 443 |
.msg.assistant .msg-bubble ol,
|
| 444 |
.msg.assistant .msg-bubble ul {
|
| 445 |
padding-left: 20px;
|
|
|
|
| 8694 |
|
| 8695 |
// Execute ALL tool calls the model emitted this turn (Qwen3-family
|
| 8696 |
// models including Ternary Bonsai often batch multiple calls into
|
| 8697 |
+
// one response). Blocks are appended to a tool-trace container
|
| 8698 |
+
// inserted BEFORE the bubble — collapsed by default, expanded via
|
| 8699 |
+
// a toggle added in finishGeneration. Container is a sibling of
|
| 8700 |
+
// the bubble so streaming updates to bubble.innerHTML don't wipe it.
|
| 8701 |
toolsUsedInLoop = true;
|
| 8702 |
const msgContainer = currentAssistantEl ? currentAssistantEl.bubble.parentElement : null;
|
| 8703 |
+
let traceContainer = msgContainer && msgContainer.querySelector('.tool-trace-container');
|
| 8704 |
+
if (msgContainer && !traceContainer) {
|
| 8705 |
+
traceContainer = document.createElement('div');
|
| 8706 |
+
traceContainer.className = 'tool-trace-container collapsed';
|
| 8707 |
+
msgContainer.insertBefore(traceContainer, currentAssistantEl.bubble);
|
| 8708 |
+
}
|
| 8709 |
const toolResults = [];
|
| 8710 |
for (let tcIdx = 0; tcIdx < turn.toolCalls.length; tcIdx++) {
|
| 8711 |
const tc = turn.toolCalls[tcIdx];
|
|
|
|
| 8725 |
allSources.push(...toolResult.results);
|
| 8726 |
}
|
| 8727 |
|
| 8728 |
+
if (traceContainer) {
|
| 8729 |
const stepLabel = document.createElement('div');
|
| 8730 |
stepLabel.style.cssText = 'font-size:0.68rem;color:var(--gray-400);margin:6px 0 2px;font-weight:500';
|
| 8731 |
const stepSuffix = turn.toolCalls.length > 1 ? ` \u00B7 Call ${tcIdx + 1}/${turn.toolCalls.length}` : '';
|
| 8732 |
stepLabel.textContent = `Step ${iter + 1}/${MAX_TOOL_ITERATIONS}${stepSuffix}`;
|
| 8733 |
+
traceContainer.appendChild(stepLabel);
|
| 8734 |
+
renderToolCallBlock(traceContainer, tc.name, tc.arguments, toolResult);
|
| 8735 |
}
|
| 8736 |
|
| 8737 |
if (tc.name === 'segment_image' && toolResult._rawMasks) {
|
|
|
|
| 8827 |
});
|
| 8828 |
bubble.appendChild(saveBtn);
|
| 8829 |
}
|
| 8830 |
+
// Tool-trace toggle: if this msg has a collapsed trace container
|
| 8831 |
+
// above the bubble, expose a discreet button that expands it.
|
| 8832 |
+
const msgEl = bubble.parentElement;
|
| 8833 |
+
const traceContainer = msgEl && msgEl.querySelector('.tool-trace-container');
|
| 8834 |
+
const callCount = traceContainer ? traceContainer.querySelectorAll('.tool-call-block').length : 0;
|
| 8835 |
+
if (callCount > 0) {
|
| 8836 |
+
const traceBtn = document.createElement('button');
|
| 8837 |
+
traceBtn.className = 'save-md-btn';
|
| 8838 |
+
traceBtn.style.marginLeft = '6px';
|
| 8839 |
+
const label = () => (traceContainer.classList.contains('collapsed') ? '\u25B6' : '\u25BC') +
|
| 8840 |
+
' ' + callCount + ' tool call' + (callCount > 1 ? 's' : '');
|
| 8841 |
+
traceBtn.innerHTML = label();
|
| 8842 |
+
traceBtn.addEventListener('click', () => {
|
| 8843 |
+
traceContainer.classList.toggle('collapsed');
|
| 8844 |
+
traceBtn.innerHTML = label();
|
| 8845 |
+
});
|
| 8846 |
+
bubble.appendChild(traceBtn);
|
| 8847 |
+
}
|
| 8848 |
}
|
| 8849 |
currentAssistantEl = null;
|
| 8850 |
currentAssistantText = '';
|