feat: enhance thinking indicator with reasoning text support
All checks were successful
BotUI CI/CD / build (push) Successful in 40s
All checks were successful
BotUI CI/CD / build (push) Successful in 40s
This commit is contained in:
parent
c5c042320c
commit
8baae78692
1 changed files with 15 additions and 4 deletions
|
|
@ -816,7 +816,7 @@ function finalizeStreaming() {
|
|||
function processMessage(data) {
|
||||
// Handle thinking indicator from backend
|
||||
if (data.type === "thinking") {
|
||||
showThinkingIndicator();
|
||||
showThinkingIndicator(data.content);
|
||||
return;
|
||||
}
|
||||
if (data.type === "thinking_clear") {
|
||||
|
|
@ -861,8 +861,15 @@ function finalizeStreaming() {
|
|||
|
||||
// Thinking indicator (shown while LLM is in reasoning mode)
|
||||
var thinkingIndicator = null;
|
||||
function showThinkingIndicator() {
|
||||
if (thinkingIndicator) return; // Already showing
|
||||
function showThinkingIndicator(content) {
|
||||
var text = content || "🤔 Pensando...";
|
||||
if (thinkingIndicator) {
|
||||
var textEl = thinkingIndicator.querySelector(".thinking-text");
|
||||
if (textEl && content) {
|
||||
textEl.textContent = text;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var messages = document.getElementById("messages");
|
||||
if (!messages) return;
|
||||
|
|
@ -872,7 +879,7 @@ function finalizeStreaming() {
|
|||
thinkingIndicator.className = "message bot";
|
||||
thinkingIndicator.innerHTML =
|
||||
'<div class="message-content bot-message">' +
|
||||
'<span class="thinking-text">🤔 Pensando...</span>' +
|
||||
'<span class="thinking-text">' + escapeHtml(text) + '</span>' +
|
||||
"</div>";
|
||||
messages.appendChild(thinkingIndicator);
|
||||
scrollToBottom(true);
|
||||
|
|
@ -1142,6 +1149,10 @@ function finalizeStreaming() {
|
|||
applyThemeData(contentObj.data || {});
|
||||
return;
|
||||
}
|
||||
if (contentObj.type === "thinking" || contentObj.type === "thinking_clear") {
|
||||
processMessage(contentObj);
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
// Content is not JSON, continue processing
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue