File size: 1,822 Bytes
6a75340
 
 
 
 
8a9035d
6a75340
 
 
 
 
 
8a9035d
6a75340
 
 
 
 
 
 
 
 
 
 
 
8a9035d
 
 
 
 
 
 
 
 
 
6a75340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!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>