From 4b1aa5526d44af0b5b30ca0a7ef61bb490db64b3 Mon Sep 17 00:00:00 2001 From: Justin McReynolds Date: Tue, 29 Oct 2024 15:00:56 -0700 Subject: [PATCH] Insert user queries into UI; label llm & user queries in UI. --- static/ips/assets/js/llmChat.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/static/ips/assets/js/llmChat.js b/static/ips/assets/js/llmChat.js index be8483b..af91e21 100644 --- a/static/ips/assets/js/llmChat.js +++ b/static/ips/assets/js/llmChat.js @@ -31,6 +31,8 @@ async function sendMessage() { content: [{ type: "text", text: userMessage }] }); + insertMessageIntoUi('user', "Your query: " + userMessage); + chatInput.value = ''; try { @@ -54,14 +56,14 @@ async function sendMessage() { content: [{ type: "text", text: data.content}] }); - appendMessage('assistant', data.content); + insertMessageIntoUi('assistant', "LLM: " + data.content); } catch (error) { console.error('Error sending message to LLM:', error); - appendMessage('error', 'Failed to get a response. Please try again.'); + insertMessageIntoUi('error', 'Failed to get a response. Please try again.'); } } -function appendMessage(role, content) { +function insertMessageIntoUi(role, content) { const chatMessages = document.getElementById('chat-messages'); const messageElement = document.createElement('div'); messageElement.classList.add('message', role);