RealTimeAnswer / chat.html
GabrielSalem's picture
Upload 2 files
7373476 verified
raw
history blame
3.87 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Chat with Model</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f7fa;
color: #333;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
width: 100%;
max-width: 600px;
background: white;
border-radius: 10px;
box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.3);
overflow: hidden;
}
header {
background-color: #4a90e2;
color: white;
text-align: center;
padding: 20px;
}
header h1 {
margin: 0;
font-size: 24px;
}
header p {
margin: 5px 0 0;
font-size: 14px;
color: #d9e8f5;
}
.chat-window {
max-height: 400px;
overflow-y: auto;
padding: 15px;
}
.chat-controls {
display: flex;
padding: 10px;
border-top: 1px solid #e1e1e1;
background-color: #f9f9f9;
}
.chat-input {
flex: 1;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
margin-right: 10px;
}
.send-button {
padding: 10px 15px;
font-size: 16px;
color: white;
background-color: #4a90e2;
border: none;
border-radius: 5px;
cursor: pointer;
}
.send-button:hover {
background-color: #357ab8;
}
.message {
padding: 10px;
margin: 8px 0;
border-radius: 10px;
font-size: 16px;
width: fit-content;
max-width: 75%;
}
.message.user {
background-color: #e1f5fe;
align-self: flex-end;
text-align: right;
}
.message.model {
background-color: #f0f0f0;
align-self: flex-start;
text-align: left;
}
</style>
<script>
async function sendPrompt(modelName) {
const prompt = document.getElementById("prompt").value;
if (!prompt.trim()) {
alert("Please enter a message.");
return;
}
const response = await fetch(`/generate/${modelName}`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ prompt })
});
const data = await response.json();
const chatWindow = document.getElementById("chat-window");
chatWindow.innerHTML += `<p><b>You:</b> ${prompt}</p>`;
chatWindow.innerHTML += `<p><b>${modelName}:</b> ${data.response}</p>`;
chatWindow.scrollTop = chatWindow.scrollHeight;
document.getElementById("prompt").value = "";
}
</script>
</head>
<body>
<div class="container">
<header>
<h1>Interactive NLP Model Chat</h1>
<p>Ask questions, get insights, and explore the capabilities of your custom model.</p>
</header>
<main id="chat-window" class="chat-window">
<!-- Messages will appear here -->
</main>
<footer class="chat-controls">
<input id="prompt" class="chat-input" type="text" placeholder="Type your question..." autocomplete="off">
<button onclick="sendPrompt('{{ model_name }}')">Send</button>
</footer>
</div>
</body>
</html>