Fine-Coder / index.html
DSDUDEd's picture
Update index.html
8a9035d verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>πŸš€ AI Code Assistant</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<div class="container">
<h1>πŸ€– Multi-Model Code Assistant</h1>
<label for="model">Select Model:</label>
<select id="model"></select>
<div id="chatbox"></div>
<form id="chat-form">
<input type="text" id="user-input" placeholder="Ask me to build a website..." required>
<button type="submit">Send</button>
</form>
</div>
<script>
let history = [];
// Fetch models dynamically
const models = ["DeepSeek Coder 1.3B", "StarCoder 1B", "CodeLLaMA 7B"];
const modelSelect = document.getElementById("model");
models.forEach(m => {
let opt = document.createElement("option");
opt.value = m;
opt.textContent = m;
modelSelect.appendChild(opt);
});
document.getElementById("chat-form").addEventListener("submit", async (e) => {
e.preventDefault();
const userInput = document.getElementById("user-input").value;
const modelChoice = document.getElementById("model").value;
history.push(["user", userInput]);
document.getElementById("chatbox").innerHTML += `<div class="user">πŸ§‘: ${userInput}</div>`;
const formData = new FormData();
formData.append("user_input", userInput);
formData.append("model_choice", modelChoice);
formData.append("history", JSON.stringify(history));
const res = await fetch("/chat", { method: "POST", body: formData });
const data = await res.json();
history = data.history;
document.getElementById("chatbox").innerHTML += `<div class="ai">πŸ€–: ${data.response}</div>`;
document.getElementById("user-input").value = "";
});
</script>
</body>
</html>