mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-01-28 19:34:35 +01:00
UI: Make thinking blocks closed by default
This commit is contained in:
parent
cd5c32dc19
commit
195a45c6e1
|
|
@ -31,13 +31,13 @@ function removeLastClick() {
|
|||
}
|
||||
|
||||
function handleMorphdomUpdate(text) {
|
||||
// Track closed blocks
|
||||
const closedBlocks = new Set();
|
||||
// Track open blocks
|
||||
const openBlocks = new Set();
|
||||
document.querySelectorAll(".thinking-block").forEach(block => {
|
||||
const blockId = block.getAttribute("data-block-id");
|
||||
// If block exists and is not open, add to closed set
|
||||
if (blockId && !block.hasAttribute("open")) {
|
||||
closedBlocks.add(blockId);
|
||||
// If block exists and is open, add to open set
|
||||
if (blockId && block.hasAttribute("open")) {
|
||||
openBlocks.add(blockId);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -72,13 +72,15 @@ function handleMorphdomUpdate(text) {
|
|||
}
|
||||
}
|
||||
|
||||
// For thinking blocks, respect closed state
|
||||
// For thinking blocks, assume closed by default
|
||||
if (fromEl.classList && fromEl.classList.contains("thinking-block") &&
|
||||
toEl.classList && toEl.classList.contains("thinking-block")) {
|
||||
toEl.classList && toEl.classList.contains("thinking-block")) {
|
||||
const blockId = toEl.getAttribute("data-block-id");
|
||||
// If this block was closed by user, keep it closed
|
||||
if (blockId && closedBlocks.has(blockId)) {
|
||||
toEl.removeAttribute("open");
|
||||
// Remove open attribute by default
|
||||
toEl.removeAttribute("open");
|
||||
// If this block was explicitly opened by user, keep it open
|
||||
if (blockId && openBlocks.has(blockId)) {
|
||||
toEl.setAttribute("open", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ def convert_to_markdown(string, message_id=None):
|
|||
title_text = "Thinking..." if is_streaming else "Thought"
|
||||
|
||||
thinking_block = f'''
|
||||
<details class="thinking-block" data-block-id="{block_id}" data-streaming="{str(is_streaming).lower()}" open>
|
||||
<details class="thinking-block" data-block-id="{block_id}" data-streaming="{str(is_streaming).lower()}">
|
||||
<summary class="thinking-header">
|
||||
<svg class="thinking-icon" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M8 1.33334C4.31868 1.33334 1.33334 4.31868 1.33334 8.00001C1.33334 11.6813 4.31868 14.6667 8 14.6667C11.6813 14.6667 14.6667 11.6813 14.6667 8.00001C14.6667 4.31868 11.6813 1.33334 8 1.33334Z" stroke="currentColor" stroke-width="1.33" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue