Sorry, unable to get response from Khoj backend ❤️🩹. Contact developer for help at team@khoj.dev or in Discord
"; + responseElement.innerHTML = errorMsg } } @@ -379,8 +403,9 @@ export class KhojChatModal extends Modal { } else { // If conversation history is cleared successfully, clear chat logs from modal chatBody.innerHTML = ""; - await this.getChatHistory(chatBody); - this.flashStatusInChatInput(result.message); + let getChatHistoryStatus = await this.getChatHistory(chatBody); + let statusMsg = getChatHistoryStatus ? result.message : "Failed to clear conversation history"; + this.flashStatusInChatInput(statusMsg); } } catch (err) { this.flashStatusInChatInput("Failed to clear conversation history"); diff --git a/src/khoj/interface/web/chat.html b/src/khoj/interface/web/chat.html index 2c64d96c..7e6b157f 100644 --- a/src/khoj/interface/web/chat.html +++ b/src/khoj/interface/web/chat.html @@ -124,10 +124,10 @@ To get started, just start typing below. You can also type / to see a list of co return referenceButton; } - function renderMessage(message, by, dt=null, annotations=null) { + function renderMessage(message, by, dt=null, annotations=null, raw=false) { let message_time = formatDate(dt ?? new Date()); let by_name = by == "khoj" ? "🏮 Khoj" : "🤔 You"; - let formattedMessage = formatHTMLMessage(message); + let formattedMessage = formatHTMLMessage(message, raw); let chatBody = document.getElementById("chat-body"); // Create a new div for the chat message @@ -257,7 +257,7 @@ To get started, just start typing below. You can also type / to see a list of co renderMessage(message, by, dt, references); } - function formatHTMLMessage(htmlMessage) { + function formatHTMLMessage(htmlMessage, raw=false) { var md = window.markdownit(); let newHTML = htmlMessage; @@ -276,7 +276,7 @@ To get started, just start typing below. You can also type / to see a list of co }; // Render markdown - newHTML = md.render(newHTML); + newHTML = raw ? newHTML : md.render(newHTML); // Get any elements with a class that starts with "language" let element = document.createElement('div'); element.innerHTML = newHTML; @@ -539,7 +539,8 @@ To get started, just start typing below. You can also type / to see a list of co .then(data => { if (data.detail) { // If the server returns a 500 error with detail, render a setup hint. - renderMessage("Hi 👋🏾, to start chatting add available chat models options via the Django Admin panel on the Server", "khoj"); + let setupMsg = "Hi 👋🏾, to start chatting add available chat models options via the Django Admin panel on the Server"; + renderMessage(setupMsg, "khoj", null, null, true); // Disable chat input field and update placeholder text document.getElementById("chat-input").setAttribute("disabled", "disabled");