Extraherar nu svaret från ollama och skickar detta till frontend

This commit is contained in:
Joakim Persson
2024-07-18 13:34:17 +02:00
parent f1fe8f0bfc
commit 18dbee6cbb
2 changed files with 23 additions and 37 deletions
-24
View File
@@ -34,31 +34,7 @@ function sendMessage() {
}
}
// function sendMessage() {
// const message = userInput.value.trim();
// if (message !== '') {
// // Create a new XMLHttpRequest object
// const xhr = new XMLHttpRequest();
// // Configure the request
// xhr.open('POST', 'http://localhost:5000/api/chat'); // Set method to POST and URL
// xhr.setRequestHeader('Content-Type', 'application/json'); // Essential for sending JSON
// // Handle response data
// xhr.onload = function() {
// if (xhr.status >= 200 && xhr.status < 300) { // Successful response
// const data = JSON.parse(xhr.responseText);
// renderMessage(data.response, 'ai-response');
// } else {
// console.error('Request failed. Status:', xhr.status);
// }
// };
// // Send the request
// xhr.send(JSON.stringify({ message }));
// }
// }
// Define a function to render a message in the chatbox with a specific class name