Spaces:
Running
Running
File size: 3,873 Bytes
7373476 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
<!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>
|