-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
197 lines (179 loc) · 8.33 KB
/
index.html
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>AI Hub | kthcloud</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="AI tools hosted by kthcloud">
<meta name="keywords" content="ai tools genai kthcloud">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Public+Sans:wght@100;400;700&display=swap" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/[email protected]"
integrity="sha384-rgjA7mptc2ETQqXoYC3/zJvkU7K/aP44Y+z7xQuJiVnB/422P/Ak+F/AqFR7E4Wr"
crossorigin="anonymous"></script>
<script src="/completion.js"></script>
</head>
<body>
<h1 class="text-3xl font-bold tracking-tight md:text-4xl lg:text-5xl text-center mb-1 md:mb-2 lg:mb-3 mt-20">AI Hub
</h1>
<h2 class="text-xl font-semibold tracking-tight md:text-2xl lg:text-2xl text-center md:mb-1 lg:mb-10">
Free and open-source AI tools hosted by kthcloud
</h2>
<main>
<div class="flex flex-col p-4 md:p-6 lg:p-8 gap-6 md:gap-8 lg:gap-10">
<div class="grid md:grid-cols-2 gap-6 md:gap-8 lg:gap-10 w-full">
<div class="border border-zinc-200 p-4 rounded-lg dark:border-zinc-800">
<div class="flex justify-center items-center flex-col h-full">
<h2 class="text-2xl font-bold tracking-tight md:text-3xl lg:text-4xl mb-4 text-center">
Llama 2
</h2>
<h2 class="text-xl font-bold tracking-tight md:text-2xl lg:text-3xl mb-4 text-center">
Large Language Model
</h2>
<p class="m-5">🦙 Llama 2: <span id="llama-text"></span></p>
<div class="h-full flex justify-center items-center">
<button
class="inline-flex items-center justify-center rounded-md font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-black hover:bg-black/70 h-15 px-4 py-2 text-lg text-blue-500 hover:text-blue-700 dark:text-blue-300 dark:hover:text-blue-200">
<a href="https://llama.app.cloud.cbh.kth.se" target=”_blank”>
Try llama!
</a>
</button>
</div>
</div>
</div>
<div class="border border-zinc-200 p-4 rounded-lg dark:border-zinc-800">
<h2 class="text-2xl font-bold tracking-tight md:text-3xl lg:text-4xl mb-4 text-center">
Stable Diffusion
</h2>
<h2 class="text-xl font-bold tracking-tight md:text-2xl lg:text-3xl mb-4 text-center">
Image Generator
</h2>
<div class="grid gap-2 md:gap-4 lg:gap-6">
<label
class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
for="prompt-input">
Enter your prompt:
</label>
<input
class="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
id="prompt" placeholder="Type your prompt here..." type="text" />
<button id="generate"
class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2"
type="submit">
Generate Image
</button>
</div>
<div
class="flex justify-center items-center border border-zinc-200 p-4 rounded-lg dark:border-zinc-800 mt-4">
<div id="image-container">
<img id="generated-image" src="/placeholder.svg" alt="Generated Image" width="500"
height="500" class="object-cover" style="aspect-ratio: 500 / 500; object-fit: cover;"
onload="imageLoaded(this)" />
</div>
</div>
</div>
</div>
</div>
</main>
<script>
document.querySelector('#generate').addEventListener('click', () => {
const imageContainer = document.querySelector('#image-container');
imageContainer.classList.add('loader');
const image = document.querySelector('#generated-image');
image.style.opacity = 0;
const prompt = document.querySelector('#prompt').value;
const encodedPrompt = encodeURIComponent(prompt);
image.src = `https://sd0.vm-app.cloud.cbh.kth.se/generate?prompt=${encodedPrompt}`;
});
function imageLoaded(img) {
const imageContainer = document.querySelector('#image-container');
imageContainer.classList.remove('loader');
const image = document.querySelector('#generated-image');
image.style.opacity = 1;
}
const llamaText = document.querySelector('#llama-text');
async function queryLlama() {
const prompt = `User: Explain something about large language models (LLMs). Answer in three sentences. Llama2: `
const params = {
temperature: Math.random() * (1 - 0.1) + 0.1,
}
for await (const chunk of llama(prompt)) {
llamaText.innerHTML += (chunk.data.content)
}
}
queryLlama();
</script>
<style>
.loader {
border: 16px solid #f3f3f3;
border-top: 16px solid #3498db;
border-radius: 50%;
/* width: 90%; */
animation: spin 0.5s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
body {
display: flex;
flex-direction: column;
align-items: center;
font-family: 'Public Sans', sans-serif;
}
main {
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
gap: 3rem;
margin: 3rem;
}
@media screen and (max-width: 600px) {
main {
flex-direction: column;
}
}
button {
background: #fff;
border: 1px solid #000;
padding: 0.5rem 1rem;
border-radius: 5px;
cursor: pointer;
}
.item {
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;
padding: 3rem;
background: rgba(255, 255, 255, 0.8);
backdrop-filter: blur(500px);
min-height: 500px;
min-width: 300px;
}
form {
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;
}
a {
text-decoration: none;
color: inherit;
}
.border-wrap {
padding: 1rem;
position: relative;
background: linear-gradient(to right, #008fe0, #00cde9);
padding: 1rem;
}
</style>
</body>
</html>