Basic_LLM / index.html
Alimubariz124's picture
Upload index.html
aacf656 verified
raw
history blame
2.41 kB
<!DOCTYPE html>
<html>
<head>
<title>Landon Hotel Chatbot</title>
<style>
/* CSS styles for the chatbot interface */
#chat-container {
width: 400px;
height: 500px;
border: 1px solid #ccc;
overflow-y: scroll;
padding: 10px;
}
.message {
margin-bottom: 10px;
}
.user {
font-weight: bold;
color: blue;
}
.bot {
font-weight: bold;
color: green;
}
</style>
</head>
<body>
<h1>Landon Hotel Chatbot</h1>
<div id="chat-container"></div>
<input type="text" id="user-input" placeholder="Type your message..." />
<button id="send-btn">Send</button>
<script>
const chatContainer = document.getElementById('chat-container');
const userInput = document.getElementById('user-input');
const sendBtn = document.getElementById('send-btn');
sendBtn.addEventListener('click', sendMessage);
function sendMessage() {
const userMessage = userInput.value.trim();
if (userMessage) {
displayMessage('user', userMessage);
sendMessageToServer(userMessage);
userInput.value = '';
}
}
function displayMessage(sender, message) {
const messageElement = document.createElement('div');
messageElement.classList.add('message');
messageElement.classList.add(sender);
messageElement.textContent = `${sender}: ${message}`;
chatContainer.appendChild(messageElement);
chatContainer.scrollTop = chatContainer.scrollHeight;
}
function sendMessageToServer(message) {
fetch('/chatbot', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ question: message }),
})
.then((response) => response.json())
.then((data) => {
displayMessage('bot', data.response);
})
.catch((error) => {
console.error('Error:', error);
});
}
</script>
</body>
</html>