diff --git a/public/js/chat.js b/public/js/chat.js index 8e09e8e..395917a 100644 --- a/public/js/chat.js +++ b/public/js/chat.js @@ -1,207 +1,201 @@ - - + // Handles key down event to send message on Enter + function handleKeyDown(event) { + if (event.key === 'Enter' && !event.shiftKey) { + event.preventDefault(); + sendMessage(); + } +} -
- - - - +// Sends a message to the chat API +async function sendMessage() { + const messageInput = document.getElementById('messageInput'); + let message = messageInput.value.trim(); -Ask any question, and the AI will respond to you!
+ try { + const response = await fetch('https://infer.x64.world/chat', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ message: message }) + }); - -