diff --git a/src/interface/desktop/chat.html b/src/interface/desktop/chat.html index 391160fc..ecd8ebf9 100644 --- a/src/interface/desktop/chat.html +++ b/src/interface/desktop/chat.html @@ -386,6 +386,9 @@ let chatInput = document.getElementById("chat-input"); chatInput.value = chatInput.value.trimStart(); + let questionStarterSuggestions = document.getElementById("question-starters"); + questionStarterSuggestions.style.display = "none"; + if (chatInput.value.startsWith("/") && chatInput.value.split(" ").length === 1) { let chatTooltip = document.getElementById("chat-tooltip"); chatTooltip.style.display = "block"; @@ -468,6 +471,31 @@ return; }); + fetch(`${hostURL}/api/chat/starters?client=desktop`, { headers }) + .then(response => response.json()) + .then(data => { + // Render chat options, if any + if (data) { + let questionStarterSuggestions = document.getElementById("question-starters"); + for (let index in data) { + let questionStarter = data[index]; + let questionStarterButton = document.createElement('button'); + questionStarterButton.innerHTML = questionStarter; + questionStarterButton.classList.add("question-starter"); + questionStarterButton.addEventListener('click', function() { + questionStarterSuggestions.style.display = "none"; + document.getElementById("chat-input").value = questionStarter; + chat(); + }); + questionStarterSuggestions.appendChild(questionStarterButton); + } + questionStarterSuggestions.style.display = "grid"; + } + }) + .catch(err => { + return; + }); + fetch(`${hostURL}/api/chat/options`, { headers }) .then(response => response.json()) .then(data => { @@ -507,6 +535,9 @@
+ + +