update AI page
This commit is contained in:
parent
8006c44f81
commit
356ca2001a
@ -406,24 +406,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Resets the chat messages
|
||||
async function resetChat() {
|
||||
try {
|
||||
// Send a POST request to reset the conversation on the server
|
||||
// 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 {
|
||||
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
|
||||
// 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>
|
||||
|
Loading…
Reference in New Issue
Block a user