mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 13:25:11 +00:00
Show temp status message in Khoj web chat while Khoj is thinking
- Scroll to bottom after adding temporary status message and references too
This commit is contained in:
@@ -74,6 +74,10 @@
|
|||||||
new_response_text.classList.add("chat-message-text", "khoj");
|
new_response_text.classList.add("chat-message-text", "khoj");
|
||||||
new_response.appendChild(new_response_text);
|
new_response.appendChild(new_response_text);
|
||||||
|
|
||||||
|
// Temporary status message to indicate that Khoj is thinking
|
||||||
|
new_response_text.innerHTML = "🤔";
|
||||||
|
document.getElementById("chat-body").scrollTop = document.getElementById("chat-body").scrollHeight;
|
||||||
|
|
||||||
// Call specified Khoj API which returns a streamed response of type text/plain
|
// Call specified Khoj API which returns a streamed response of type text/plain
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@@ -96,10 +100,17 @@
|
|||||||
|
|
||||||
new_response_text.innerHTML += polishedReference;
|
new_response_text.innerHTML += polishedReference;
|
||||||
} else {
|
} else {
|
||||||
|
// Clear temporary status message
|
||||||
|
if (new_response_text.innerHTML === "🤔") {
|
||||||
|
new_response_text.innerHTML = "";
|
||||||
|
}
|
||||||
|
|
||||||
new_response_text.innerHTML += chunk;
|
new_response_text.innerHTML += chunk;
|
||||||
document.getElementById("chat-body").scrollTop = document.getElementById("chat-body").scrollHeight;
|
|
||||||
readStream();
|
readStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scroll to bottom of chat window as chat response is streamed
|
||||||
|
document.getElementById("chat-body").scrollTop = document.getElementById("chat-body").scrollHeight;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
readStream();
|
readStream();
|
||||||
|
|||||||
Reference in New Issue
Block a user