Döpte om message till query för bättre semantisk överensstämmelse med vad variabeln gör.
This commit is contained in:
@@ -6,15 +6,15 @@ const userInput = document.getElementById('userInput');
|
||||
// Define a function to send the user's message to the AI
|
||||
function sendMessage() {
|
||||
// Get the user's input message and trim any whitespace
|
||||
const message = userInput.value.trim();
|
||||
const query = userInput.value.trim();
|
||||
|
||||
// Check if the message is not empty
|
||||
if (message !== '') {
|
||||
if (query !== '') {
|
||||
// Send a POST request to the /api/chat endpoint with the message
|
||||
fetch('http://localhost:5005/api/chat', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ message }),
|
||||
body: JSON.stringify({ query }),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
@@ -22,7 +22,7 @@ function sendMessage() {
|
||||
const aiResponse = data.response;
|
||||
|
||||
// Render the user's original message in the chatbox
|
||||
renderMessage(message, 'user-message');
|
||||
renderMessage(query, 'user-message');
|
||||
|
||||
// Render the AI's response in the chatbox
|
||||
renderMessage(aiResponse, 'ai-response');
|
||||
|
||||
Reference in New Issue
Block a user