update AI page

This commit is contained in:
Raven Scott 2024-10-02 03:45:08 -04:00
parent 8006c44f81
commit 356ca2001a

View File

@ -406,24 +406,31 @@
}
}
// Resets the chat messages
async function resetChat() {
// Helper function to reset the conversation on the server
async function sendResetRequest() {
const response = await fetch('https://infer.x64.world/reset-conversation', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
});
return response;
}
// Resets the chat messages and optionally displays a success message
async function resetChat(displaySuccessMessage = true) {
try {
// Send a POST request to reset the conversation on the server
const response = await fetch('https://infer.x64.world/reset-conversation', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
});
const response = await sendResetRequest();
if (response.ok) {
// Clear the messages in the UI
const messagesContainer = document.getElementById('messages');
messagesContainer.innerHTML = ''; // Clear all messages
// Display success message
displayAlert('success', 'Messages Cleared!');
// Optionally display a success message
if (displaySuccessMessage) {
displayAlert('success', 'Messages Cleared!');
}
} else {
// Handle error response from the server
displayAlert('error', 'Failed to reset conversation. Please try again.');
@ -433,6 +440,11 @@
displayAlert('error', 'An error occurred while resetting the conversation.');
}
}
// Resets the chat on page load without displaying the success message
document.addEventListener('DOMContentLoaded', function () {
resetChat(false); // Call without displaying success message
});
</script>
</body>