-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
88 lines (77 loc) · 1.92 KB
/
index.html
File metadata and controls
88 lines (77 loc) · 1.92 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>FastAPI Local AI</title>
<style>
* {
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 1rem;
max-width: 100vw; /* Don't exceed viewport width */
overflow-x: hidden; /* Prevent horizontal scroll */
word-wrap: break-word;
}
.container {
width: 100%;
}
h1 {
font-size: 1.5rem;
margin-bottom: 1rem;
}
textarea {
width: 100%;
min-height: 100px;
padding: 0.5rem;
resize: vertical;
font-size: 1rem;
}
button {
margin-top: 0.5rem;
padding: 0.6rem 1.2rem;
font-size: 1rem;
}
#response {
margin-top: 1rem;
background-color: #f5f5f5;
padding: 1rem;
white-space: pre-wrap; /* Keeps line breaks and wraps long text */
}
</style>
</head>
<body>
<div class="container">
<h1>Ask the AI</h1>
<form id="prompt-form">
<textarea id="prompt" placeholder="Type your question..."></textarea>
<br>
<button type="submit">Send</button>
</form>
<div id="response"></div>
</div>
<script>
const form = document.getElementById('prompt-form');
const promptInput = document.getElementById('prompt');
const responseDiv = document.getElementById('response');
form.addEventListener('submit', async (e) => {
e.preventDefault();
const prompt = promptInput.value.trim();
if (!prompt) return;
responseDiv.textContent = "Loading...";
const res = await fetch('/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ prompt })
});
const data = await res.text();
responseDiv.textContent = data;
});
</script>
</body>
</html>