Skip to content

Commit

Permalink
Insert user queries into UI; label llm & user queries in UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcjustin committed Oct 29, 2024
1 parent 98b78ab commit 4b1aa55
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions static/ips/assets/js/llmChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ async function sendMessage() {
content: [{ type: "text", text: userMessage }]
});

insertMessageIntoUi('user', "Your query: " + userMessage);

chatInput.value = '';

try {
Expand All @@ -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);
Expand Down

0 comments on commit 4b1aa55

Please sign in to comment.