rabiyulfahim commited on
Commit
f5d16b0
·
verified ·
1 Parent(s): 511a6d9

Create static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +41 -0
static/index.html ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>QA GPT2 Interface</title>
6
+ <style>
7
+ body { font-family: Arial, sans-serif; margin: 30px; }
8
+ .container { max-width: 600px; margin: auto; }
9
+ input, button { width: 100%; padding: 10px; margin-top: 10px; }
10
+ pre { background: #f4f4f4; padding: 10px; border-radius: 5px; }
11
+ </style>
12
+ </head>
13
+ <body>
14
+ <div class="container">
15
+ <h2>Ask GPT2</h2>
16
+ <input id="question" placeholder="Type your question..." />
17
+ <input id="tokens" type="number" value="50" min="1" max="200" />
18
+ <button id="askBtn">Ask</button>
19
+
20
+ <h3>Response:</h3>
21
+ <pre id="response">No answer yet.</pre>
22
+ </div>
23
+
24
+ <script>
25
+ document.getElementById("askBtn").addEventListener("click", async () => {
26
+ const q = document.getElementById("question").value;
27
+ const max = document.getElementById("tokens").value;
28
+
29
+ document.getElementById("response").textContent = "Loading...";
30
+
31
+ try {
32
+ const resp = await fetch(`/answers?question=${encodeURIComponent(q)}&max_new_tokens=${max}`);
33
+ const data = await resp.json();
34
+ document.getElementById("response").textContent = JSON.stringify(data, null, 2);
35
+ } catch (err) {
36
+ document.getElementById("response").textContent = "Error: " + err;
37
+ }
38
+ });
39
+ </script>
40
+ </body>
41
+ </html>