mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Put loading spinner at bottom of chat message in web client
This commit is contained in:
parent
fc33162ec6
commit
fafc467173
1 changed files with 12 additions and 6 deletions
|
@ -683,13 +683,19 @@ To get started, just start typing below. You can also type / to see a list of co
|
|||
}
|
||||
|
||||
function handleStreamResponse(newResponseElement, rawResponse, rawQuery, loadingEllipsis, replace=true) {
|
||||
if (newResponseElement.getElementsByClassName("lds-ellipsis").length > 0 && loadingEllipsis) {
|
||||
if (!newResponseElement) return;
|
||||
// Remove loading ellipsis if it exists
|
||||
if (newResponseElement.getElementsByClassName("lds-ellipsis").length > 0 && loadingEllipsis)
|
||||
newResponseElement.removeChild(loadingEllipsis);
|
||||
}
|
||||
if (replace) {
|
||||
newResponseElement.innerHTML = "";
|
||||
}
|
||||
// Clear the response element if replace is true
|
||||
if (replace) newResponseElement.innerHTML = "";
|
||||
|
||||
// Append response to the response element
|
||||
newResponseElement.appendChild(formatHTMLMessage(rawResponse, false, replace, rawQuery));
|
||||
|
||||
// Append loading ellipsis if it exists
|
||||
if (!replace && loadingEllipsis) newResponseElement.appendChild(loadingEllipsis);
|
||||
// Scroll to bottom of chat view
|
||||
document.getElementById("chat-body").scrollTop = document.getElementById("chat-body").scrollHeight;
|
||||
}
|
||||
|
||||
|
@ -777,7 +783,7 @@ To get started, just start typing below. You can also type / to see a list of co
|
|||
if (chunk.type ==='status') {
|
||||
console.log(`status: ${chunk.data}`);
|
||||
const statusMessage = chunk.data;
|
||||
handleStreamResponse(chatMessageState.newResponseTextEl, statusMessage, chatMessageState.rawQuery, null, false);
|
||||
handleStreamResponse(chatMessageState.newResponseTextEl, statusMessage, chatMessageState.rawQuery, chatMessageState.loadingEllipsis, false);
|
||||
} else if (chunk.type === 'start_llm_response') {
|
||||
console.log("Started streaming", new Date());
|
||||
} else if (chunk.type === 'end_llm_response') {
|
||||
|
|
Loading…
Reference in a new issue