Spaces:
Sleeping
Sleeping
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>BitNet 1-Bit LLM Query Interface</title> | |
<style> | |
body { | |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
margin: 0; | |
padding: 0; | |
background-color: #f4f4f9; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
height: 100vh; | |
} | |
.container { | |
display: flex; | |
max-width: 1200px; | |
width: 100%; | |
background-color: #fff; | |
border-radius: 8px; | |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | |
overflow: hidden; | |
} | |
.left-section { | |
flex: 1; | |
padding: 20px; | |
background-color: white; | |
color: black; | |
display: flex; | |
flex-direction: column; | |
justify-content: space-between; | |
box-sizing: border-box; | |
} | |
.left-section h2 { | |
margin-bottom: 20px; | |
font-size: 1.5rem; | |
} | |
.input-group { | |
margin-bottom: 15px; | |
} | |
.input-group label { | |
display: block; | |
font-size: 0.9rem; | |
margin-bottom: 8px; | |
} | |
.input-group input, | |
.input-group textarea { | |
width: 100%; | |
padding: 10px; | |
border-radius: 4px; | |
font-size: 0.95rem; | |
box-sizing: border-box; | |
} | |
input[type="number"], | |
textarea { | |
width: 100%; | |
border: 1px solid #ccc; | |
border-radius: 4px; | |
box-sizing: border-box; | |
} | |
input[type="number"]:focus, | |
textarea:focus { | |
border-color: #238a95; | |
outline: none; | |
box-shadow: 0 0 5px rgba(35, 138, 149, 0.5); | |
} | |
input[type="number"]::placeholder, | |
textarea::placeholder { | |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
} | |
.input-group textarea { | |
resize: none; | |
} | |
.button-group { | |
margin-top: 20px; | |
margin: auto; | |
} | |
.button-group button { | |
padding: 10px 20px; | |
background-color: #238a95; | |
border: none; | |
color: white; | |
cursor: pointer; | |
border-radius: 4px; | |
font-size: 1rem; | |
transition: background-color 0.3s, transform 0.2s; | |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
} | |
.button-group button:hover { | |
background-color: #1e7a84; | |
transform: scale(1.05); | |
} | |
.right-section { | |
flex: 2; | |
padding: 20px; | |
background-color: #ffffff; | |
border-left: 2px solid #dbdbdb; | |
box-sizing: border-box; | |
} | |
.right-section h2 { | |
margin-bottom: 20px; | |
} | |
#response { | |
height: 430px; | |
border: 1px solid #dbdbdb; | |
border-radius: 4px; | |
padding: 10px; | |
overflow-y: auto; | |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
background-color: #f5f4f459; | |
font-size: 0.95rem; | |
} | |
/* Responsive design */ | |
@media screen and (max-width: 768px) { | |
.container { | |
flex-direction: column; | |
} | |
.right-section { | |
border-left: none; | |
border-top: 2px solid #dbdbdb; | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="left-section"> | |
<h2>Command Options</h2> | |
<div class="input-group"> | |
<label for="tokens">Number of tokens to predict</label> | |
<input type="number" id="tokens" min="0" placeholder="Enter number of tokens"> | |
</div> | |
<div class="input-group"> | |
<label for="threads">Number of threads to use</label> | |
<input type="number" id="threads" min="0" placeholder="Enter number of threads"> | |
</div> | |
<div class="input-group"> | |
<label for="context-size">Size of the prompt context</label> | |
<input type="number" id="context-size" min="0" placeholder="Enter context size"> | |
</div> | |
<div class="input-group"> | |
<label for="temperature">Temperature, a hyperparameter that controls the randomness of the generated text</label> | |
<input type="number" min="0" id="temperature" placeholder="Enter temperature value"> | |
</div> | |
<div class="input-group"> | |
<label for="prompt">Prompt</label> | |
<textarea id="prompt" rows="4" min="0" placeholder="Enter your prompt"></textarea> | |
</div> | |
<div class="button-group"> | |
<button onclick="sendQuery()">Send Query</button> | |
</div> | |
</div> | |
<div class="right-section"> | |
<h2>Response</h2> | |
<div id="response"></div> | |
</div> | |
</div> | |
<script type="module"> | |
import { io } from "https://cdn.socket.io/4.8.0/socket.io.esm.min.js"; | |
const socket = io(); | |
window.sendQuery = function() { | |
const tokens = document.getElementById('tokens').value; | |
const threads = document.getElementById('threads').value; | |
const contextSize = document.getElementById('context-size').value; | |
const temperature = document.getElementById('temperature').value; | |
const prompt = document.getElementById('prompt').value; | |
if (!prompt) { | |
return alert('There is no prompt to send!'); | |
} | |
let args = ''; | |
if (tokens && !isNaN(tokens) && tokens > -1) { | |
args += ` -n ${tokens}`; | |
} | |
if (threads && !isNaN(threads) && threads > -1) { | |
args += ` -t ${threads}`; | |
} | |
if (contextSize && !isNaN(contextSize) && contextSize > -1) { | |
args += ` -c ${contextSize}`; | |
} | |
if (temperature && !isNaN(temperature) && temperature > -1) { | |
args += ` -temp ${temperature}`; | |
} | |
// Clear previous response | |
document.getElementById('response').innerText = ''; | |
// Emit query with all parameters | |
socket.emit('query', { query: prompt, args }); | |
} | |
socket.on('response', function (word) { | |
const responseDiv = document.getElementById('response'); | |
responseDiv.innerText += word.word + ' '; | |
// Scroll to the bottom of the response div | |
responseDiv.scrollTop = responseDiv.scrollHeight; | |
}); | |
</script> | |
</body> | |
</html> |