ParthSadaria commited on
Commit
2b05113
·
verified ·
1 Parent(s): 12f5eb9

Update playground.html

Browse files
Files changed (1) hide show
  1. playground.html +376 -362
playground.html CHANGED
@@ -1,4 +1,4 @@
1
- <!DOCTYPE html>
2
  <html lang="en">
3
 
4
  <head>
@@ -13,339 +13,341 @@
13
  <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
14
 
15
  <style>
16
- @import url('https://fonts.googleapis.com/css2?family=Encode+Sans:[email protected]&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Protest+Revolution&display=swap');
17
- :root {
18
- --bg-dark: #0a0a0f;
19
- --bg-darker: #040409;
20
- --bg-deepest: #020205;
21
- --primary-blue: #4a6cf7;
22
- --secondary-blue: #6678e3;
23
- --accent-color: #7e57c2;
24
- --text-light: #e0e0e8;
25
- --text-muted: #8a8a9b;
26
- --border-color: #1a1a2e;
27
- --hover-color: rgba(78, 108, 247, 0.1);
28
- --delete-red: #ff4d4d;
29
- --header-height: 60px;
30
- --input-height: 80px;
31
- }
32
-
33
- * {
34
- margin: 0;
35
- padding: 0;
36
- box-sizing: border-box;
37
- scrollbar-width: thin;
38
- scrollbar-color: var(--primary-blue) transparent;
39
- }
40
-
41
- *::-webkit-scrollbar {
42
- width: 8px;
43
- }
44
-
45
- *::-webkit-scrollbar-track {
46
- background: transparent;
47
- }
48
-
49
- *::-webkit-scrollbar-thumb {
50
- background-color: var(--primary-blue);
51
- border-radius: 20px;
52
- }
53
-
54
- body {
55
- font-family: 'Inter', sans-serif;
56
- background-color: var(--bg-dark);
57
- color: var(--text-light);
58
- display: flex;
59
- justify-content: center;
60
- align-items: center;
61
- height: 100vh;
62
- overflow: hidden;
63
- perspective: 2000px;
64
- }
65
-
66
- .chat-wrapper {
67
- position: relative;
68
- width: 100%;
69
- max-width: 800px;
70
- height: 90vh;
71
- background-color: var(--bg-darker);
72
- border-radius: 24px;
73
- overflow: hidden;
74
- box-shadow: 0 20px 50px rgba(5, 5, 10, 0.7);
75
- display: flex;
76
- flex-direction: column;
77
- opacity: 1;
78
- transform: scale(1);
79
- transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
80
- border: 1px solid var(--border-color);
81
- }
82
-
83
- .chat-header {
84
- background-color: var(--bg-deepest);
85
- padding: 15px 20px;
86
- display: flex;
87
- justify-content: space-between;
88
- align-items: center;
89
- border-bottom: 1px solid var(--border-color);
90
- flex-shrink: 0;
91
- height: var(--header-height);
92
- }
93
-
94
- .chat-container {
95
- display: none;
96
- flex-direction: column;
97
- height: calc(100% - var(--header-height));
98
- position: relative;
99
- }
100
-
101
- .chat-messages {
102
- flex: 1;
103
- overflow-y: auto;
104
- padding: 20px;
105
- display: flex;
106
- flex-direction: column;
107
- gap: 16px;
108
- background-color: var(--bg-dark);
109
- font-family: 'JetBrains Mono', monospace;
110
- height: calc(100% - var(--input-height));
111
- margin-bottom: var(--input-height);
112
- }
113
-
114
- .chat-input {
115
- position: absolute;
116
- bottom: 0;
117
- left: 0;
118
- right: 0;
119
- background-color: var(--bg-darker);
120
- border-top: 1px solid var(--border-color);
121
- padding: 16px;
122
- height: var(--input-height);
123
- display: flex;
124
- gap: 12px;
125
- z-index: 10;
126
- align-items: center;
127
- }
128
-
129
- .chat-input-container {
130
- position: relative;
131
- flex: 1;
132
- display: flex;
133
- align-items: center;
134
- }
135
-
136
- .chat-input input {
137
- width: 100%;
138
- padding: 12px 16px;
139
- padding-right: 50px; /* Space for send icon */
140
- background-color: rgba(30, 30, 50, 0.8);
141
- border: 1px solid var(--border-color);
142
- border-radius: 12px;
143
- color: var(--text-light);
144
- font-size: 14px;
145
- font-family: 'JetBrains Mono', monospace;
146
- outline: none;
147
- }
148
-
149
- .chat-input input:focus {
150
- border-color: var(--primary-blue);
151
- box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.2);
152
- }
153
-
154
- .message {
155
- max-width: 80%;
156
- width: fit-content;
157
- padding: 12px 18px;
158
- border-radius: 12px;
159
- font-size: 14px;
160
- line-height: 1.5;
161
- position: relative;
162
- animation: fadeIn 0.4s forwards;
163
- margin-bottom: 8px;
164
- }
165
-
166
- .message.user {
167
- align-self: flex-end;
168
- background-color: var(--primary-blue);
169
- color: white;
170
- }
171
-
172
- .message.bot {
173
- align-self: flex-start;
174
- background-color: rgba(40, 40, 70, 0.8);
175
- color: var(--text-light);
176
- border: 1px solid var(--border-color);
177
- }
178
-
179
- .message::before {
180
- content: '';
181
- position: absolute;
182
- top: 0;
183
- left: 0;
184
- right: 0;
185
- bottom: 0;
186
- background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.1));
187
- opacity: 0;
188
- transition: opacity 0.3s ease;
189
- }
190
-
191
- .message:hover::before {
192
- opacity: 1;
193
- }
194
-
195
- .initial-input {
196
- flex: 1;
197
- display: flex;
198
- flex-direction: column;
199
- justify-content: center;
200
- align-items: center;
201
- padding: 24px;
202
- text-align: center;
203
- background: linear-gradient(145deg, var(--bg-dark), var(--bg-darker));
204
- }
205
-
206
- .initial-input h2 {
207
- font-size: 24px;
208
- margin-bottom: 16px;
209
- color: var(--text-light);
210
- font-weight: 600;
211
- font-family: 'JetBrains Mono', monospace;
212
- }
213
-
214
- .input-container {
215
- width: 100%;
216
- max-width: 400px;
217
- position: relative;
218
- }
219
-
220
- .initial-input input {
221
- width: 100%;
222
- padding: 16px 24px;
223
- background-color: rgba(30, 30, 50, 0.8);
224
- border: 1px solid var(--border-color);
225
- border-radius: 12px;
226
- color: var(--text-light);
227
- font-size: 16px;
228
- font-family: 'JetBrains Mono', monospace;
229
- outline: none;
230
- transition: all 0.3s ease;
231
- }
232
-
233
- .send-icon {
234
- position: absolute;
235
- right: 12px;
236
- top: 50%;
237
- transform: translateY(-50%);
238
- background-color: var(--primary-blue);
239
- border-radius: 8px;
240
- width: 40px;
241
- height: 40px;
242
- display: flex;
243
- justify-content: center;
244
- align-items: center;
245
- cursor: pointer;
246
- transition: all 0.3s ease;
247
- }
248
-
249
- .send-icon:hover {
250
- background-color: var(--accent-color);
251
- transform: translateY(-50%) scale(1.05);
252
- border-radius: 15px;
253
- }
254
-
255
- @keyframes fadeIn {
256
- from {
257
- opacity: 0;
258
- transform: translateY(20px);
259
- }
260
- to {
261
- opacity: 1;
262
- transform: translateY(0);
263
- }
264
- }
265
-
266
- /* Header actions */
267
- .header-actions {
268
- display: flex;
269
- align-items: center;
270
- gap: 10px;
271
- }
272
-
273
- .model-select {
274
- background-color: black;
275
- color: var(--text-light);
276
- border: 1px solid var(--border-color);
277
- border-radius: 8px;
278
- padding: 10px 14px;
279
- font-family: 'JetBrains Mono', monospace;
280
- font-size: 14px;
281
- cursor: pointer;
282
- transition: all 0.3s ease;
283
- }
284
-
285
- .clear-chat {
286
- background-color: var(--delete-red);
287
- color: white;
288
- border: none;
289
- border-radius: 8px;
290
- padding: 10px 14px;
291
- font-family: 'JetBrains Mono', monospace;
292
- font-size: 14px;
293
- cursor: pointer;
294
- transition: all 0.3s ease;
295
- display: flex;
296
- align-items: center;
297
- gap: 5px;
298
- }
299
-
300
- .clear-chat:hover {
301
- background-color: #ff6666;
302
- }
303
-
304
- .watermark {
305
- position: absolute;
306
- bottom: 10px;
307
- right: 15px;
308
- color: var(--text-muted);
309
- font-size: 10px;
310
- opacity: 0.5;
311
- transition: opacity 0.3s ease;
312
- z-index: 11;
313
- }
314
-
315
- .watermark:hover {
316
- opacity: 0.8;
317
- }
318
-
319
- /* Select2 customization */
320
- .select2-container--default .select2-selection--single {
321
- background-color: #333;
322
- color: white;
323
- border: 1px solid #555;
324
- font-size: 14px;
325
- }
326
-
327
- .select2-container--default .select2-selection--single .select2-selection__rendered {
328
- background-color: #333;
329
- color: white;
330
- }
331
-
332
- .select2-dropdown {
333
- background-color: #333;
334
- color: white;
335
- max-height: 300px;
336
- overflow-y: auto;
337
- }
338
-
339
- .select2-container--default .select2-results__option {
340
- background-color: #333;
341
- color: white;
342
- }
343
-
344
- .select2-container--default .select2-results__option--highlighted {
345
- background-color: #555;
346
- color: white;
347
- }
348
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  </style>
350
  </head>
351
 
@@ -355,19 +357,19 @@ body {
355
  <h2 style="font-family: 'JetBrains Mono', monospace;">LOKI.AI Playground</h2>
356
  <div class="header-actions">
357
  <select id="modelSelect" class="model-select">
358
- <option value="gpt-4o-mini">GPT-4o Mini</option>
359
- <option value="gpt-4o">GPT-4o</option>
360
- <option value="gpt-3.5-turbo">GPT-3.5 Turbo</option>
361
- <option value="claude-3-haiku">Claude 3 Haiku</option>
362
- <option value="llama-3.1-8b">Llama 3.1 8B</option>
363
- <option value="llama-3.1-70b">Llama 3.1 70B</option>
364
- <option value="llama-3.1-405b">Llama 3.1 405b</option>
365
- <option value="gemini-1.5-flash">Gemini 1.5 Flash</option>
366
- <option value="gemini-pro">Gemini Pro</option>
367
- <option value="mixtral-8x7b">Mixtral 8x7b</option>
368
- <option value="command-r">Command-R</option>
369
- <option value="command">Command</option>
370
- </select>
371
  <button id="clearChatButton" class="clear-chat">
372
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"
373
  stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
@@ -399,7 +401,8 @@ body {
399
  <div class="chat-messages" id="chatMessages"></div>
400
  <div class="chat-input">
401
  <input type="text" id="chatInput" placeholder="Type your message...">
402
- <button id="sendButton" style="padding: 10px 10px; background-color: black;color: #e0e0e8; font-family: 'JetBrains Mono'; border: solid #1a1a2e 2px; border-radius: 15px;">Send</button>
 
403
  </div>
404
  </div>
405
  </div>
@@ -423,7 +426,7 @@ body {
423
  function scrollToBottom() {
424
  const chatMessages = document.getElementById('chatMessages');
425
  chatMessages.scrollTop = chatMessages.scrollHeight;
426
- }
427
  function appendMessage(content, type = 'bot', isStreaming = false) {
428
  if (type === 'bot' && isStreaming) {
429
  if (!currentStreamingMessage) {
@@ -431,7 +434,8 @@ body {
431
  currentStreamingMessage.className = `message ${type}`;
432
  chatMessages.appendChild(currentStreamingMessage);
433
  }
434
- currentStreamingMessage.textContent += content;
 
435
  chatMessages.scrollTop = chatMessages.scrollHeight;
436
  } else {
437
  if (currentStreamingMessage) {
@@ -440,7 +444,8 @@ body {
440
 
441
  const messageBox = document.createElement('div');
442
  messageBox.className = `message ${type}`;
443
- messageBox.textContent = content;
 
444
  chatMessages.appendChild(messageBox);
445
  chatMessages.scrollTop = chatMessages.scrollHeight;
446
 
@@ -451,12 +456,12 @@ body {
451
  });
452
  }
453
  }
454
- $(document).ready(function() {
455
- $('#modelSelect').select2({
456
- placeholder: 'Select a model', // Placeholder text
457
- minimumResultsForSearch: 1 // Show search when there is at least 1 item
 
458
  });
459
- });
460
  function clearChat() {
461
  chatMessages.innerHTML = '';
462
  conversationHistory = [];
@@ -469,7 +474,7 @@ body {
469
  const userMessage = initialChatInput.value.trim();
470
  const selectedModel = modelSelect.value;
471
  if (!userMessage) return;
472
-
473
  initialInput.style.display = 'none';
474
  chatContainer.style.display = 'flex';
475
  chatWrapper.classList.add('active');
@@ -506,7 +511,6 @@ body {
506
  const payload = {
507
  model: model,
508
  messages: [
509
- // Send entire conversation history
510
  ...conversationHistory,
511
  { role: "user", content: userMessage }
512
  ],
@@ -544,11 +548,17 @@ body {
544
  try {
545
  const jsonData = JSON.parse(jsonString);
546
  const delta = jsonData.choices?.[0]?.delta || {};
547
- const content = delta.content || "";
548
 
549
  if (content) {
550
- fullResponse += content;
551
- appendMessage(content, 'bot', true);
 
 
 
 
 
 
552
  }
553
  } catch (err) {
554
  console.warn("Parsing error:", err);
@@ -566,7 +576,6 @@ body {
566
 
567
  return fullResponse.trim();
568
  }
569
-
570
  // Event Listeners
571
  initialSendIcon.addEventListener('click', sendInitialMessage);
572
  initialChatInput.addEventListener('keypress', (event) => {
@@ -582,5 +591,10 @@ body {
582
  clearChatButton.addEventListener('click', clearChat);
583
  </script>
584
  </body>
585
-
 
 
 
 
 
586
  </html>
 
1
+ <!DOCTYPE html>
2
  <html lang="en">
3
 
4
  <head>
 
13
  <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
14
 
15
  <style>
16
+ @import url('https://fonts.googleapis.com/css2?family=Encode+Sans:[email protected]&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Protest+Revolution&display=swap');
17
+
18
+ :root {
19
+ --bg-dark: #0a0a0f;
20
+ --bg-darker: #040409;
21
+ --bg-deepest: #020205;
22
+ --primary-blue: #4a6cf7;
23
+ --secondary-blue: #6678e3;
24
+ --accent-color: #7e57c2;
25
+ --text-light: #e0e0e8;
26
+ --text-muted: #8a8a9b;
27
+ --border-color: #1a1a2e;
28
+ --hover-color: rgba(78, 108, 247, 0.1);
29
+ --delete-red: #ff4d4d;
30
+ --header-height: 60px;
31
+ --input-height: 80px;
32
+ }
33
+
34
+ * {
35
+ margin: 0;
36
+ padding: 0;
37
+ box-sizing: border-box;
38
+ scrollbar-width: thin;
39
+ scrollbar-color: var(--primary-blue) transparent;
40
+ }
41
+
42
+ *::-webkit-scrollbar {
43
+ width: 8px;
44
+ }
45
+
46
+ *::-webkit-scrollbar-track {
47
+ background: transparent;
48
+ }
49
+
50
+ *::-webkit-scrollbar-thumb {
51
+ background-color: var(--primary-blue);
52
+ border-radius: 20px;
53
+ }
54
+
55
+ body {
56
+ font-family: 'Inter', sans-serif;
57
+ background-color: var(--bg-dark);
58
+ color: var(--text-light);
59
+ display: flex;
60
+ justify-content: center;
61
+ align-items: center;
62
+ height: 100vh;
63
+ overflow: hidden;
64
+ perspective: 2000px;
65
+ }
66
+
67
+ .chat-wrapper {
68
+ position: relative;
69
+ width: 100%;
70
+ max-width: 800px;
71
+ height: 90vh;
72
+ background-color: var(--bg-darker);
73
+ border-radius: 24px;
74
+ overflow: hidden;
75
+ box-shadow: 0 20px 50px rgba(5, 5, 10, 0.7);
76
+ display: flex;
77
+ flex-direction: column;
78
+ opacity: 1;
79
+ transform: scale(1);
80
+ transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
81
+ border: 1px solid var(--border-color);
82
+ }
83
+
84
+ .chat-header {
85
+ background-color: var(--bg-deepest);
86
+ padding: 15px 20px;
87
+ display: flex;
88
+ justify-content: space-between;
89
+ align-items: center;
90
+ border-bottom: 1px solid var(--border-color);
91
+ flex-shrink: 0;
92
+ height: var(--header-height);
93
+ }
94
+
95
+ .chat-container {
96
+ display: none;
97
+ flex-direction: column;
98
+ height: calc(100% - var(--header-height));
99
+ position: relative;
100
+ }
101
+
102
+ .chat-messages {
103
+ flex: 1;
104
+ overflow-y: auto;
105
+ padding: 20px;
106
+ display: flex;
107
+ flex-direction: column;
108
+ gap: 16px;
109
+ background-color: var(--bg-dark);
110
+ font-family: 'JetBrains Mono', monospace;
111
+ height: calc(100% - var(--input-height));
112
+ margin-bottom: var(--input-height);
113
+ }
114
+
115
+ .chat-input {
116
+ position: absolute;
117
+ bottom: 0;
118
+ left: 0;
119
+ right: 0;
120
+ background-color: var(--bg-darker);
121
+ border-top: 1px solid var(--border-color);
122
+ padding: 16px;
123
+ height: var(--input-height);
124
+ display: flex;
125
+ gap: 12px;
126
+ z-index: 10;
127
+ align-items: center;
128
+ }
129
+
130
+ .chat-input-container {
131
+ position: relative;
132
+ flex: 1;
133
+ display: flex;
134
+ align-items: center;
135
+ }
136
+
137
+ .chat-input input {
138
+ width: 100%;
139
+ padding: 12px 16px;
140
+ padding-right: 50px;
141
+ /* Space for send icon */
142
+ background-color: rgba(30, 30, 50, 0.8);
143
+ border: 1px solid var(--border-color);
144
+ border-radius: 12px;
145
+ color: var(--text-light);
146
+ font-size: 14px;
147
+ font-family: 'JetBrains Mono', monospace;
148
+ outline: none;
149
+ }
150
+
151
+ .chat-input input:focus {
152
+ border-color: var(--primary-blue);
153
+ box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.2);
154
+ }
155
+
156
+ .message {
157
+ max-width: 80%;
158
+ width: fit-content;
159
+ padding: 12px 18px;
160
+ border-radius: 12px;
161
+ font-size: 14px;
162
+ line-height: 1.5;
163
+ position: relative;
164
+ animation: fadeIn 0.4s forwards;
165
+ margin-bottom: 8px;
166
+ }
167
+
168
+ .message.user {
169
+ align-self: flex-end;
170
+ background-color: var(--primary-blue);
171
+ color: white;
172
+ }
173
+
174
+ .message.bot {
175
+ align-self: flex-start;
176
+ background-color: rgba(40, 40, 70, 0.8);
177
+ color: var(--text-light);
178
+ border: 1px solid var(--border-color);
179
+ }
180
+
181
+ .message::before {
182
+ content: '';
183
+ position: absolute;
184
+ top: 0;
185
+ left: 0;
186
+ right: 0;
187
+ bottom: 0;
188
+ background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.1));
189
+ opacity: 0;
190
+ transition: opacity 0.3s ease;
191
+ }
192
+
193
+ .message:hover::before {
194
+ opacity: 1;
195
+ }
196
+
197
+ .initial-input {
198
+ flex: 1;
199
+ display: flex;
200
+ flex-direction: column;
201
+ justify-content: center;
202
+ align-items: center;
203
+ padding: 24px;
204
+ text-align: center;
205
+ background: linear-gradient(145deg, var(--bg-dark), var(--bg-darker));
206
+ }
207
+
208
+ .initial-input h2 {
209
+ font-size: 24px;
210
+ margin-bottom: 16px;
211
+ color: var(--text-light);
212
+ font-weight: 600;
213
+ font-family: 'JetBrains Mono', monospace;
214
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
+ .input-container {
217
+ width: 100%;
218
+ max-width: 400px;
219
+ position: relative;
220
+ }
221
+
222
+ .initial-input input {
223
+ width: 100%;
224
+ padding: 16px 24px;
225
+ background-color: rgba(30, 30, 50, 0.8);
226
+ border: 1px solid var(--border-color);
227
+ border-radius: 12px;
228
+ color: var(--text-light);
229
+ font-size: 16px;
230
+ font-family: 'JetBrains Mono', monospace;
231
+ outline: none;
232
+ transition: all 0.3s ease;
233
+ }
234
+
235
+ .send-icon {
236
+ position: absolute;
237
+ right: 12px;
238
+ top: 50%;
239
+ transform: translateY(-50%);
240
+ background-color: var(--primary-blue);
241
+ border-radius: 8px;
242
+ width: 40px;
243
+ height: 40px;
244
+ display: flex;
245
+ justify-content: center;
246
+ align-items: center;
247
+ cursor: pointer;
248
+ transition: all 0.3s ease;
249
+ }
250
+
251
+ .send-icon:hover {
252
+ background-color: var(--accent-color);
253
+ transform: translateY(-50%) scale(1.05);
254
+ border-radius: 15px;
255
+ }
256
+
257
+ @keyframes fadeIn {
258
+ from {
259
+ opacity: 0;
260
+ transform: translateY(20px);
261
+ }
262
+
263
+ to {
264
+ opacity: 1;
265
+ transform: translateY(0);
266
+ }
267
+ }
268
+
269
+ /* Header actions */
270
+ .header-actions {
271
+ display: flex;
272
+ align-items: center;
273
+ gap: 10px;
274
+ }
275
+
276
+ .model-select {
277
+ background-color: black;
278
+ color: var(--text-light);
279
+ border: 1px solid var(--border-color);
280
+ border-radius: 8px;
281
+ padding: 10px 14px;
282
+ font-family: 'JetBrains Mono', monospace;
283
+ font-size: 14px;
284
+ cursor: pointer;
285
+ transition: all 0.3s ease;
286
+ }
287
+
288
+ .clear-chat {
289
+ background-color: var(--delete-red);
290
+ color: white;
291
+ border: none;
292
+ border-radius: 8px;
293
+ padding: 10px 14px;
294
+ font-family: 'JetBrains Mono', monospace;
295
+ font-size: 14px;
296
+ cursor: pointer;
297
+ transition: all 0.3s ease;
298
+ display: flex;
299
+ align-items: center;
300
+ gap: 5px;
301
+ }
302
+
303
+ .clear-chat:hover {
304
+ background-color: #ff6666;
305
+ }
306
+
307
+ .watermark {
308
+ position: absolute;
309
+ bottom: 10px;
310
+ right: 15px;
311
+ color: var(--text-muted);
312
+ font-size: 10px;
313
+ opacity: 0.5;
314
+ transition: opacity 0.3s ease;
315
+ z-index: 11;
316
+ }
317
+
318
+ .watermark:hover {
319
+ opacity: 0.8;
320
+ }
321
+
322
+ /* Select2 customization */
323
+ .select2-container--default .select2-selection--single {
324
+ background-color: #333;
325
+ color: white;
326
+ border: 1px solid #555;
327
+ font-size: 14px;
328
+ }
329
+
330
+ .select2-container--default .select2-selection--single .select2-selection__rendered {
331
+ background-color: #333;
332
+ color: white;
333
+ }
334
+
335
+ .select2-dropdown {
336
+ background-color: #333;
337
+ color: white;
338
+ max-height: 300px;
339
+ overflow-y: auto;
340
+ }
341
+
342
+ .select2-container--default .select2-results__option {
343
+ background-color: #333;
344
+ color: white;
345
+ }
346
+
347
+ .select2-container--default .select2-results__option--highlighted {
348
+ background-color: #555;
349
+ color: white;
350
+ }
351
  </style>
352
  </head>
353
 
 
357
  <h2 style="font-family: 'JetBrains Mono', monospace;">LOKI.AI Playground</h2>
358
  <div class="header-actions">
359
  <select id="modelSelect" class="model-select">
360
+ <option value="gpt-4o-mini">GPT-4o Mini</option>
361
+ <option value="gpt-4o">GPT-4o</option>
362
+ <option value="gpt-3.5-turbo">GPT-3.5 Turbo</option>
363
+ <option value="claude-3-haiku">Claude 3 Haiku</option>
364
+ <option value="llama-3.1-8b">Llama 3.1 8B</option>
365
+ <option value="llama-3.1-70b">Llama 3.1 70B</option>
366
+ <option value="llama-3.1-405b">Llama 3.1 405b</option>
367
+ <option value="gemini-1.5-flash">Gemini 1.5 Flash</option>
368
+ <option value="gemini-pro">Gemini Pro</option>
369
+ <option value="mixtral-8x7b">Mixtral 8x7b</option>
370
+ <option value="command-r">Command-R</option>
371
+ <option value="command">Command</option>
372
+ </select>
373
  <button id="clearChatButton" class="clear-chat">
374
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"
375
  stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
 
401
  <div class="chat-messages" id="chatMessages"></div>
402
  <div class="chat-input">
403
  <input type="text" id="chatInput" placeholder="Type your message...">
404
+ <button id="sendButton"
405
+ style="padding: 10px 10px; background-color: black;color: #e0e0e8; font-family: 'JetBrains Mono'; border: solid #1a1a2e 2px; border-radius: 15px;">Send</button>
406
  </div>
407
  </div>
408
  </div>
 
426
  function scrollToBottom() {
427
  const chatMessages = document.getElementById('chatMessages');
428
  chatMessages.scrollTop = chatMessages.scrollHeight;
429
+ }
430
  function appendMessage(content, type = 'bot', isStreaming = false) {
431
  if (type === 'bot' && isStreaming) {
432
  if (!currentStreamingMessage) {
 
434
  currentStreamingMessage.className = `message ${type}`;
435
  chatMessages.appendChild(currentStreamingMessage);
436
  }
437
+ // Use innerHTML for streaming content
438
+ currentStreamingMessage.innerHTML = currentStreamingMessage.innerHTML + content;
439
  chatMessages.scrollTop = chatMessages.scrollHeight;
440
  } else {
441
  if (currentStreamingMessage) {
 
444
 
445
  const messageBox = document.createElement('div');
446
  messageBox.className = `message ${type}`;
447
+ // Use innerHTML for new messages
448
+ messageBox.innerHTML = content;
449
  chatMessages.appendChild(messageBox);
450
  chatMessages.scrollTop = chatMessages.scrollHeight;
451
 
 
456
  });
457
  }
458
  }
459
+ $(document).ready(function () {
460
+ $('#modelSelect').select2({
461
+ placeholder: 'Select a model', // Placeholder text
462
+ minimumResultsForSearch: 1 // Show search when there is at least 1 item
463
+ });
464
  });
 
465
  function clearChat() {
466
  chatMessages.innerHTML = '';
467
  conversationHistory = [];
 
474
  const userMessage = initialChatInput.value.trim();
475
  const selectedModel = modelSelect.value;
476
  if (!userMessage) return;
477
+
478
  initialInput.style.display = 'none';
479
  chatContainer.style.display = 'flex';
480
  chatWrapper.classList.add('active');
 
511
  const payload = {
512
  model: model,
513
  messages: [
 
514
  ...conversationHistory,
515
  { role: "user", content: userMessage }
516
  ],
 
548
  try {
549
  const jsonData = JSON.parse(jsonString);
550
  const delta = jsonData.choices?.[0]?.delta || {};
551
+ let content = delta.content || "";
552
 
553
  if (content) {
554
+ // Convert \n to <br>
555
+ // Properly handle newline characters
556
+ content = content.replace(/\\n/g, '<br>'); // Replace escaped newlines (\n) with <br>
557
+ fullResponse += content; // Append to the full response
558
+
559
+ // Call appendMessage with the processed content
560
+ appendMessage(fullResponse, 'bot', true);
561
+
562
  }
563
  } catch (err) {
564
  console.warn("Parsing error:", err);
 
576
 
577
  return fullResponse.trim();
578
  }
 
579
  // Event Listeners
580
  initialSendIcon.addEventListener('click', sendInitialMessage);
581
  initialChatInput.addEventListener('keypress', (event) => {
 
591
  clearChatButton.addEventListener('click', clearChat);
592
  </script>
593
  </body>
594
+ <!-- random
595
+ comments
596
+ to
597
+ get
598
+ to
599
+ 600 lines -->
600
  </html>