Spaces:
Running
Running
Commit
·
3825b50
1
Parent(s):
c79d99a
Update index.html
Browse files- index.html +620 -56
index.html
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
|
2 |
<!DOCTYPE html>
|
3 |
<html lang="en">
|
4 |
|
@@ -13,9 +12,615 @@
|
|
13 |
<link rel="stylesheet"
|
14 |
href="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/github-dark.css">
|
15 |
<script src="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js"></script>
|
16 |
-
<link rel="stylesheet" type="text/css" href="style.css">
|
17 |
</head>
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
<body>
|
20 |
<div class="container">
|
21 |
<div class="sidebar">
|
@@ -55,7 +660,6 @@
|
|
55 |
<div class="btn-array" id="btn-array-personality-section">
|
56 |
<button id="btn-add-personality">Add Personality</button>
|
57 |
<button id="btn-import-personality">Import</button>
|
58 |
-
<button id="btn-save-personalities">Save</button>
|
59 |
</div>
|
60 |
</div>
|
61 |
|
@@ -86,6 +690,7 @@
|
|
86 |
</div>
|
87 |
<div class="message-container"></div>
|
88 |
<div class="message-box">
|
|
|
89 |
<textarea type="text" placeholder="Type your message here" id="messageInput"
|
90 |
class="input-field"></textarea>
|
91 |
<button type="submit" class="btn-textual material-symbols-outlined" id="btn-send">send</button>
|
@@ -169,7 +774,8 @@
|
|
169 |
const API_KEY = document.querySelector("#apiKeyInput");
|
170 |
const maxTokens = document.querySelector("#maxTokens");
|
171 |
API_KEY.value = localStorage.getItem("API_KEY");
|
172 |
-
maxTokens.value = localStorage.getItem("
|
|
|
173 |
|
174 |
|
175 |
//function to hide element smoothly then setting display none after the transition time elapsed
|
@@ -253,8 +859,9 @@
|
|
253 |
const editDefaultPersonalityButton = document.querySelector("#btn-edit-personality-default");
|
254 |
const submitNewPersonalityButton = document.querySelector("#btn-submit-personality");
|
255 |
const updatePersonalityButton = document.querySelector("#updatePersonality");
|
256 |
-
const
|
257 |
|
|
|
258 |
const sendMessageButton = document.querySelector("#btn-send");
|
259 |
|
260 |
|
@@ -428,48 +1035,9 @@
|
|
428 |
closeOverlay();
|
429 |
}
|
430 |
|
431 |
-
//save personalities to local storage
|
432 |
-
async function savePersonalities() {
|
433 |
-
//get array of personality cards
|
434 |
-
const personalityCards = document.querySelectorAll(".card-personality");
|
435 |
-
|
436 |
-
//create an array of personality objects
|
437 |
-
const personalityObjects = [];
|
438 |
-
personalityCards.forEach(card => {
|
439 |
-
const personalityObject = {
|
440 |
-
name: card.querySelector(".personality-title").innerText,
|
441 |
-
description: card.querySelector(".personality-description").innerText,
|
442 |
-
prompt: card.querySelector(".personality-prompt").innerText,
|
443 |
-
image: card.style.backgroundImage.match(/url\((.*?)\)/)[1].replace(/('|")/g, '')
|
444 |
-
}
|
445 |
-
personalityObjects.push(personalityObject);
|
446 |
-
})
|
447 |
-
|
448 |
-
//stringify the array
|
449 |
-
const personalityJSON = JSON.stringify(personalityObjects);
|
450 |
-
|
451 |
-
//save to local storage
|
452 |
-
localStorage.setItem("personalities", personalityJSON);
|
453 |
-
}
|
454 |
-
|
455 |
-
//load personalities from local storage
|
456 |
-
async function loadPersonalities() {
|
457 |
-
//get the json string from local storage
|
458 |
-
const personalityJSON = localStorage.getItem("personalities");
|
459 |
-
|
460 |
-
//parse the json string into an array
|
461 |
-
const personalityObjects = JSON.parse(personalityJSON);
|
462 |
-
|
463 |
-
//insert each personality into the DOM
|
464 |
-
personalityObjects.forEach(personalityObject => {
|
465 |
-
insertPersonality(personalityObject);
|
466 |
-
})
|
467 |
-
}
|
468 |
-
|
469 |
async function run() {
|
470 |
const msg = document.querySelector("#messageInput");
|
471 |
const msgText = msg.value;
|
472 |
-
const messageContainer = document.querySelector(".message-container");
|
473 |
const maxTokens = document.querySelector("#maxTokens");
|
474 |
const API_KEY = document.querySelector("#apiKeyInput");
|
475 |
const selectedPersonalityTitle = document.querySelector("input[name='personality']:checked + div .personality-title").innerText;
|
@@ -478,7 +1046,7 @@
|
|
478 |
|
479 |
|
480 |
//chat history
|
481 |
-
|
482 |
//get chat history from message container
|
483 |
const messageElements = messageContainer.querySelectorAll(".message");
|
484 |
messageElements.forEach(element => {
|
@@ -564,10 +1132,16 @@
|
|
564 |
|
565 |
//save api key to local storage
|
566 |
localStorage.setItem("API_KEY", API_KEY.value);
|
567 |
-
localStorage.setItem("
|
568 |
|
569 |
}
|
570 |
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
|
572 |
const messageInput = document.querySelector("#messageInput");
|
573 |
|
@@ -613,16 +1187,6 @@
|
|
613 |
sendMessageButton.addEventListener("click", run);
|
614 |
|
615 |
|
616 |
-
//load local storage if available
|
617 |
-
if (localStorage.getItem("personalities")) {
|
618 |
-
loadPersonalities();
|
619 |
-
}
|
620 |
-
|
621 |
-
//save personalities to local storage when closing the window
|
622 |
-
window.addEventListener("beforeunload", () => {
|
623 |
-
savePersonalities();
|
624 |
-
})
|
625 |
-
|
626 |
// ...
|
627 |
</script>
|
628 |
|
|
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
|
|
|
12 |
<link rel="stylesheet"
|
13 |
href="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/github-dark.css">
|
14 |
<script src="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js"></script>
|
|
|
15 |
</head>
|
16 |
|
17 |
+
<style>
|
18 |
+
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,200;0,400;0,800;1,200;1,400;1,800&display=swap');
|
19 |
+
|
20 |
+
@import url('https://fonts.googleapis.com/css2?family=Product+Sans&family=Google+Sans+Display:ital@0;1&family=Google+Sans:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&family=Google+Sans+Text:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&family=Material+Symbols+Outlined&family=Space+Mono&display=swap');
|
21 |
+
|
22 |
+
@font-face {
|
23 |
+
font-family: 'Material Symbols Outlined';
|
24 |
+
font-style: normal;
|
25 |
+
font-weight: 400;
|
26 |
+
src: url(https://fonts.gstatic.com/s/materialsymbolsoutlined/v154/kJF1BvYX7BgnkSrUwT8OhrdQw4oELdPIeeII9v6oDMzByHX9rA6RzaxHMPdY43zj-jCxv3fzvRNU22ZXGJpEpjC_1v-p_4MrImHCIJIZrDCvHOej.woff2) format('woff2');
|
27 |
+
}
|
28 |
+
|
29 |
+
.material-symbols-outlined {
|
30 |
+
font-family: 'Material Symbols Outlined';
|
31 |
+
font-weight: normal;
|
32 |
+
font-style: normal;
|
33 |
+
font-size: 1.5rem;
|
34 |
+
line-height: 1;
|
35 |
+
letter-spacing: normal;
|
36 |
+
text-transform: none;
|
37 |
+
display: inline-block;
|
38 |
+
white-space: nowrap;
|
39 |
+
word-wrap: normal;
|
40 |
+
direction: ltr;
|
41 |
+
-webkit-font-feature-settings: 'liga';
|
42 |
+
font-feature-settings: "liga";
|
43 |
+
-webkit-font-smoothing: antialiased;
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
body {
|
48 |
+
font-family: 'Noto Sans', sans-serif;
|
49 |
+
|
50 |
+
margin: 0;
|
51 |
+
}
|
52 |
+
|
53 |
+
p {
|
54 |
+
margin: 0;
|
55 |
+
margin-bottom: 0.5rem;
|
56 |
+
padding: 0;
|
57 |
+
font-size: 1rem;
|
58 |
+
}
|
59 |
+
|
60 |
+
h1,
|
61 |
+
h2,
|
62 |
+
h3,
|
63 |
+
ol,
|
64 |
+
ul {
|
65 |
+
margin: 0;
|
66 |
+
}
|
67 |
+
|
68 |
+
h1 {
|
69 |
+
margin-bottom: 0.5rem;
|
70 |
+
}
|
71 |
+
|
72 |
+
a {
|
73 |
+
color: #3b82f6;
|
74 |
+
}
|
75 |
+
|
76 |
+
input,
|
77 |
+
textarea,
|
78 |
+
select {
|
79 |
+
border: 1px solid;
|
80 |
+
padding: 0.5rem;
|
81 |
+
border-radius: 0.5rem;
|
82 |
+
border: none;
|
83 |
+
font-family: noto sans, sans-serif;
|
84 |
+
font-size: 1rem;
|
85 |
+
}
|
86 |
+
|
87 |
+
button:focus {
|
88 |
+
outline: none;
|
89 |
+
}
|
90 |
+
|
91 |
+
.form {
|
92 |
+
display: none;
|
93 |
+
opacity: 0;
|
94 |
+
flex-direction: column;
|
95 |
+
width: 32rem;
|
96 |
+
gap: 0.5rem;
|
97 |
+
flex-grow: 1;
|
98 |
+
justify-content: center;
|
99 |
+
}
|
100 |
+
|
101 |
+
.overlay {
|
102 |
+
flex-direction: column;
|
103 |
+
display: none;
|
104 |
+
position: fixed;
|
105 |
+
opacity: 0;
|
106 |
+
top: 0;
|
107 |
+
left: 0;
|
108 |
+
width: 100dvw;
|
109 |
+
height: 100dvh;
|
110 |
+
backdrop-filter: blur(2rem);
|
111 |
+
z-index: 2;
|
112 |
+
justify-content: flex-start;
|
113 |
+
align-items: center;
|
114 |
+
}
|
115 |
+
|
116 |
+
.backButton {
|
117 |
+
position: absolute;
|
118 |
+
top: 1rem;
|
119 |
+
left: 1rem;
|
120 |
+
border: none;
|
121 |
+
background-color: transparent;
|
122 |
+
font-size: 1.5rem;
|
123 |
+
font-weight: 600;
|
124 |
+
transition: all 0.2s;
|
125 |
+
|
126 |
+
}
|
127 |
+
|
128 |
+
#btn-hide-sidebar {
|
129 |
+
display: none;
|
130 |
+
}
|
131 |
+
|
132 |
+
.message-container {
|
133 |
+
display: flex;
|
134 |
+
flex-direction: column-reverse;
|
135 |
+
overflow-y: auto;
|
136 |
+
gap: 1rem;
|
137 |
+
padding-bottom: 2rem;
|
138 |
+
flex-grow: 1;
|
139 |
+
}
|
140 |
+
|
141 |
+
.message-box {
|
142 |
+
display: flex;
|
143 |
+
position: relative;
|
144 |
+
}
|
145 |
+
|
146 |
+
.message {
|
147 |
+
|
148 |
+
padding: 1rem;
|
149 |
+
}
|
150 |
+
|
151 |
+
.message-model {
|
152 |
+
border-radius: 1rem;
|
153 |
+
}
|
154 |
+
|
155 |
+
#messageInput {
|
156 |
+
height: 2.5rem;
|
157 |
+
box-sizing: border-box;
|
158 |
+
text-wrap: wrap;
|
159 |
+
resize: none;
|
160 |
+
width: 100%;
|
161 |
+
padding-right: 2rem;
|
162 |
+
}
|
163 |
+
|
164 |
+
#messageInput::-webkit-scrollbar {
|
165 |
+
height: 1rem;
|
166 |
+
width: 0.5rem;
|
167 |
+
}
|
168 |
+
|
169 |
+
#messageInput::-webkit-scrollbar {
|
170 |
+
height: 2.5rem !important;
|
171 |
+
width: 0.5rem !important;
|
172 |
+
}
|
173 |
+
|
174 |
+
.btn-textual {
|
175 |
+
background: transparent !important;
|
176 |
+
margin: 0;
|
177 |
+
padding: 0;
|
178 |
+
border: none;
|
179 |
+
transition: all 0.2s;
|
180 |
+
cursor: pointer;
|
181 |
+
font-size: inherit;
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
|
186 |
+
#btn-send {
|
187 |
+
position: absolute;
|
188 |
+
right: 0.5rem;
|
189 |
+
bottom: 0.5rem;
|
190 |
+
font-size: 1.5rem;
|
191 |
+
}
|
192 |
+
|
193 |
+
.btn-array {
|
194 |
+
display: flex;
|
195 |
+
flex-direction: row;
|
196 |
+
gap: 0.5rem;
|
197 |
+
margin-top: 0.5rem;
|
198 |
+
}
|
199 |
+
|
200 |
+
.btn-array button {
|
201 |
+
flex-grow: 1;
|
202 |
+
}
|
203 |
+
|
204 |
+
.personality-prompt {
|
205 |
+
display: none;
|
206 |
+
}
|
207 |
+
|
208 |
+
.prompt-field {
|
209 |
+
resize: vertical;
|
210 |
+
height: 7rem;
|
211 |
+
}
|
212 |
+
|
213 |
+
.container {
|
214 |
+
box-sizing: border-box;
|
215 |
+
display: flex;
|
216 |
+
gap: 0.5rem;
|
217 |
+
padding: 1rem;
|
218 |
+
|
219 |
+
|
220 |
+
width: 100dvw;
|
221 |
+
height: 100dvh;
|
222 |
+
|
223 |
+
}
|
224 |
+
|
225 |
+
.sidebar {
|
226 |
+
position: sticky;
|
227 |
+
top: 1rem;
|
228 |
+
|
229 |
+
display: flex;
|
230 |
+
flex-direction: column;
|
231 |
+
overflow-y: auto;
|
232 |
+
gap: 0.5rem;
|
233 |
+
padding: 1rem;
|
234 |
+
width: 25rem;
|
235 |
+
border-radius: 1rem;
|
236 |
+
scrollbar-width: thin;
|
237 |
+
height: calc(100dvh - 4rem);
|
238 |
+
z-index: 1;
|
239 |
+
}
|
240 |
+
|
241 |
+
.sidebar-section {
|
242 |
+
margin-bottom: 1rem;
|
243 |
+
display: flex;
|
244 |
+
flex-direction: column;
|
245 |
+
gap: 0.5rem;
|
246 |
+
}
|
247 |
+
|
248 |
+
#btn-show-sidebar {
|
249 |
+
display: none;
|
250 |
+
}
|
251 |
+
|
252 |
+
.header {
|
253 |
+
display: flex;
|
254 |
+
|
255 |
+
box-sizing: border-box;
|
256 |
+
align-items: center;
|
257 |
+
font-size: 2rem;
|
258 |
+
font-weight: 800;
|
259 |
+
gap: 0.5rem;
|
260 |
+
width: 100%;
|
261 |
+
}
|
262 |
+
|
263 |
+
.navbar {
|
264 |
+
position: relative;
|
265 |
+
display: flex;
|
266 |
+
flex-direction: row;
|
267 |
+
border-radius: 0.5rem;
|
268 |
+
justify-content: space-evenly;
|
269 |
+
margin-bottom: 1rem;
|
270 |
+
z-index: 0;
|
271 |
+
}
|
272 |
+
|
273 |
+
.navbar-tab {
|
274 |
+
width: 100%;
|
275 |
+
padding: 0.5rem;
|
276 |
+
text-align: center;
|
277 |
+
|
278 |
+
z-index: 2;
|
279 |
+
-webkit-tap-highlight-color: transparent;
|
280 |
+
cursor: pointer;
|
281 |
+
|
282 |
+
}
|
283 |
+
|
284 |
+
|
285 |
+
|
286 |
+
.navbar-tab-highlight {
|
287 |
+
padding: 0;
|
288 |
+
margin: 0;
|
289 |
+
position: absolute;
|
290 |
+
border-radius: 0.5rem;
|
291 |
+
transition: all 0.2s;
|
292 |
+
height: 100%;
|
293 |
+
z-index: 1;
|
294 |
+
/* glow */
|
295 |
+
box-shadow: 0 0 1rem 0.05rem #29292a3f;
|
296 |
+
}
|
297 |
+
|
298 |
+
#gemini-pro-branding {
|
299 |
+
font-family: Google Sans Display, sans-serif;
|
300 |
+
color: #7c8a9c;
|
301 |
+
font-size: 1rem;
|
302 |
+
font-weight: 400;
|
303 |
+
}
|
304 |
+
|
305 |
+
#gemin-pro-logo {
|
306 |
+
width: 2rem;
|
307 |
+
height: 2rem;
|
308 |
+
}
|
309 |
+
|
310 |
+
.credits {
|
311 |
+
margin-top: auto;
|
312 |
+
display: flex;
|
313 |
+
padding: 0rem 1rem 0 1rem;
|
314 |
+
|
315 |
+
font-size: 0.75rem;
|
316 |
+
color: #7c8a9c;
|
317 |
+
|
318 |
+
justify-content: space-between;
|
319 |
+
align-items: center;
|
320 |
+
}
|
321 |
+
|
322 |
+
button {
|
323 |
+
border: none;
|
324 |
+
background-color: #3b82f6;
|
325 |
+
color: white;
|
326 |
+
padding: 0.5rem;
|
327 |
+
border-radius: 0.5rem;
|
328 |
+
transition: all 0.2s;
|
329 |
+
}
|
330 |
+
|
331 |
+
#mainContent {
|
332 |
+
display: flex;
|
333 |
+
flex-direction: column;
|
334 |
+
padding: 2rem;
|
335 |
+
margin-left: auto;
|
336 |
+
margin-right: auto;
|
337 |
+
width: 32rem;
|
338 |
+
text-align: justify;
|
339 |
+
}
|
340 |
+
|
341 |
+
.card-personality {
|
342 |
+
box-sizing: border-box;
|
343 |
+
-moz-box-sizing: border-box;
|
344 |
+
-webkit-box-sizing: border-box;
|
345 |
+
color: #e4e4e4;
|
346 |
+
background-color: black;
|
347 |
+
background-size: cover;
|
348 |
+
background-position: center;
|
349 |
+
position: relative;
|
350 |
+
|
351 |
+
display: flex;
|
352 |
+
flex-direction: column;
|
353 |
+
justify-content: end;
|
354 |
+
padding: 1rem;
|
355 |
+
border-radius: 1rem;
|
356 |
+
height: 10rem;
|
357 |
+
-webkit-tap-highlight-color: transparent;
|
358 |
+
cursor: pointer;
|
359 |
+
text-shadow: 0 0 10px #000000, 0 0 5px #181818;
|
360 |
+
}
|
361 |
+
|
362 |
+
.edit:hover {
|
363 |
+
text-shadow: 0 0 10px #e4e4e4, 0 0 5px #dfdfdf;
|
364 |
+
}
|
365 |
+
|
366 |
+
|
367 |
+
.card-personality * {
|
368 |
+
/* unselectable */
|
369 |
+
-webkit-user-select: none;
|
370 |
+
/* Safari */
|
371 |
+
-moz-user-select: none;
|
372 |
+
/* Firefox */
|
373 |
+
-ms-user-select: none;
|
374 |
+
/* IE10+/Edge */
|
375 |
+
user-select: none;
|
376 |
+
/* Standard */
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
.card-personality input {
|
381 |
+
display: none;
|
382 |
+
}
|
383 |
+
|
384 |
+
.btn-edit-card {
|
385 |
+
/* top right corner */
|
386 |
+
position: absolute;
|
387 |
+
top: 1rem;
|
388 |
+
right: 1rem;
|
389 |
+
color: #e4e4e4;
|
390 |
+
}
|
391 |
+
|
392 |
+
.btn-share-card {
|
393 |
+
/* bottom right corner */
|
394 |
+
position: absolute;
|
395 |
+
top: 1rem;
|
396 |
+
right: 2.5rem;
|
397 |
+
font-size: 1rem;
|
398 |
+
color: #e4e4e4;
|
399 |
+
}
|
400 |
+
|
401 |
+
#btn-hide-overlay {
|
402 |
+
padding: 2rem;
|
403 |
+
}
|
404 |
+
|
405 |
+
|
406 |
+
|
407 |
+
|
408 |
+
@media (max-width: 768px) {
|
409 |
+
body {
|
410 |
+
margin: 0;
|
411 |
+
padding: 0;
|
412 |
+
}
|
413 |
+
|
414 |
+
|
415 |
+
.container {
|
416 |
+
padding: 0;
|
417 |
+
|
418 |
+
}
|
419 |
+
|
420 |
+
.message-container {
|
421 |
+
padding-left: 1rem;
|
422 |
+
padding-right: 1rem;
|
423 |
+
}
|
424 |
+
|
425 |
+
.sidebar {
|
426 |
+
top: 0;
|
427 |
+
height: calc(100dvh - 2rem);
|
428 |
+
margin: 0;
|
429 |
+
width: calc(100dvw - 2rem);
|
430 |
+
position: fixed;
|
431 |
+
border-radius: 0;
|
432 |
+
display: none;
|
433 |
+
}
|
434 |
+
|
435 |
+
.navbar {
|
436 |
+
position: relative;
|
437 |
+
}
|
438 |
+
|
439 |
+
|
440 |
+
#btn-hide-sidebar {
|
441 |
+
display: block;
|
442 |
+
}
|
443 |
+
|
444 |
+
#mainContent {
|
445 |
+
padding: 0;
|
446 |
+
margin: 0;
|
447 |
+
width: 100%;
|
448 |
+
}
|
449 |
+
|
450 |
+
#mainContent .header {
|
451 |
+
padding: 2rem;
|
452 |
+
}
|
453 |
+
|
454 |
+
#messageInput {
|
455 |
+
border-radius: 0;
|
456 |
+
}
|
457 |
+
|
458 |
+
#btn-show-sidebar {
|
459 |
+
display: block;
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
|
464 |
+
/* Light theme styles */
|
465 |
+
@media (prefers-color-scheme: light) {
|
466 |
+
:focus {
|
467 |
+
outline: 1px solid #8f9eb3;
|
468 |
+
}
|
469 |
+
|
470 |
+
body {
|
471 |
+
background-color: #f0f6ff;
|
472 |
+
color: #0a0a0a;
|
473 |
+
}
|
474 |
+
|
475 |
+
a {
|
476 |
+
color: #444ed6;
|
477 |
+
}
|
478 |
+
|
479 |
+
.sidebar {
|
480 |
+
background-color: #d2e2f7;
|
481 |
+
}
|
482 |
+
|
483 |
+
.navbar {
|
484 |
+
background-color: rgb(176 205 246);
|
485 |
+
}
|
486 |
+
|
487 |
+
.navbar-tab {
|
488 |
+
color: #0a0a0a;
|
489 |
+
}
|
490 |
+
|
491 |
+
.navbar-tab-highlight {
|
492 |
+
background-color: #87b0ed;
|
493 |
+
}
|
494 |
+
|
495 |
+
.btn-textual:hover {
|
496 |
+
text-shadow: 0 0 10px #000000;
|
497 |
+
}
|
498 |
+
|
499 |
+
button {
|
500 |
+
background-color: #83b5f7;
|
501 |
+
|
502 |
+
color: #2b3d59;
|
503 |
+
}
|
504 |
+
|
505 |
+
button:hover {
|
506 |
+
background-color: rgb(63, 191, 255);
|
507 |
+
}
|
508 |
+
|
509 |
+
|
510 |
+
input,
|
511 |
+
textarea,
|
512 |
+
select {
|
513 |
+
background-color: #f0f6ff;
|
514 |
+
outline: 1px solid #8f9eb3;
|
515 |
+
}
|
516 |
+
|
517 |
+
input::placeholder,
|
518 |
+
textarea::placeholder {
|
519 |
+
color: #7c8a9c;
|
520 |
+
}
|
521 |
+
|
522 |
+
.message-model {
|
523 |
+
background-color: #d2e2f7;
|
524 |
+
}
|
525 |
+
}
|
526 |
+
|
527 |
+
/* Dark theme styles */
|
528 |
+
@media (prefers-color-scheme: dark) {
|
529 |
+
:root {
|
530 |
+
color-scheme: dark;
|
531 |
+
}
|
532 |
+
|
533 |
+
:focus {
|
534 |
+
outline: 1px solid #73859e;
|
535 |
+
}
|
536 |
+
|
537 |
+
|
538 |
+
|
539 |
+
body {
|
540 |
+
background-color: #151e24;
|
541 |
+
color: #e4e4e4;
|
542 |
+
}
|
543 |
+
|
544 |
+
a {
|
545 |
+
color: #92d9eb;
|
546 |
+
}
|
547 |
+
|
548 |
+
|
549 |
+
|
550 |
+
.sidebar {
|
551 |
+
background-color: #1a2733;
|
552 |
+
}
|
553 |
+
|
554 |
+
.navbar {
|
555 |
+
background-color: #00000047;
|
556 |
+
}
|
557 |
+
|
558 |
+
.navbar-tab {
|
559 |
+
color: #e4e4e4;
|
560 |
+
}
|
561 |
+
|
562 |
+
.navbar-tab-highlight {
|
563 |
+
background-color: #22486b;
|
564 |
+
|
565 |
+
box-shadow: 0 0 1rem 0.05rem #29292aac;
|
566 |
+
}
|
567 |
+
|
568 |
+
button {
|
569 |
+
background-color: #22486b;
|
570 |
+
color: #c9d3ee;
|
571 |
+
}
|
572 |
+
|
573 |
+
button:hover {
|
574 |
+
background-color: #31689c;
|
575 |
+
}
|
576 |
+
|
577 |
+
.btn-textual {
|
578 |
+
color: #e4e4e4;
|
579 |
+
}
|
580 |
+
|
581 |
+
.btn-textual:hover {
|
582 |
+
text-shadow: 0 0 10px #ffffff, 0 0 5px #dfdfdf;
|
583 |
+
}
|
584 |
+
|
585 |
+
.edit:hover {
|
586 |
+
text-shadow: 0 0 10px #ffffff, 0 0 5px #dfdfdf;
|
587 |
+
/* Change #00ff00 to the color you want */
|
588 |
+
}
|
589 |
+
|
590 |
+
input,
|
591 |
+
textarea,
|
592 |
+
select {
|
593 |
+
background-color: #283542;
|
594 |
+
|
595 |
+
color: #e4e4e4;
|
596 |
+
border: none;
|
597 |
+
}
|
598 |
+
|
599 |
+
input::placeholder,
|
600 |
+
textarea::placeholder {
|
601 |
+
color: #849caf;
|
602 |
+
}
|
603 |
+
|
604 |
+
|
605 |
+
.message-model {
|
606 |
+
background-color: #1a2733;
|
607 |
+
}
|
608 |
+
}
|
609 |
+
|
610 |
+
#btn-reset-chat {
|
611 |
+
background-color: #1a2733;
|
612 |
+
color: #e4e4e4;
|
613 |
+
right: 4rem;
|
614 |
+
margin-right: 5px;
|
615 |
+
transition: all 0.2s;
|
616 |
+
cursor: pointer;
|
617 |
+
}
|
618 |
+
|
619 |
+
#btn-reset-chat:hover {
|
620 |
+
background-color: #313131;
|
621 |
+
}
|
622 |
+
</style>
|
623 |
+
|
624 |
<body>
|
625 |
<div class="container">
|
626 |
<div class="sidebar">
|
|
|
660 |
<div class="btn-array" id="btn-array-personality-section">
|
661 |
<button id="btn-add-personality">Add Personality</button>
|
662 |
<button id="btn-import-personality">Import</button>
|
|
|
663 |
</div>
|
664 |
</div>
|
665 |
|
|
|
690 |
</div>
|
691 |
<div class="message-container"></div>
|
692 |
<div class="message-box">
|
693 |
+
<button class="material-symbols-outlined" id="btn-reset-chat">rotate_left</button>
|
694 |
<textarea type="text" placeholder="Type your message here" id="messageInput"
|
695 |
class="input-field"></textarea>
|
696 |
<button type="submit" class="btn-textual material-symbols-outlined" id="btn-send">send</button>
|
|
|
774 |
const API_KEY = document.querySelector("#apiKeyInput");
|
775 |
const maxTokens = document.querySelector("#maxTokens");
|
776 |
API_KEY.value = localStorage.getItem("API_KEY");
|
777 |
+
maxTokens.value = localStorage.getItem("maxTokens");
|
778 |
+
if (maxTokens.value == "") maxTokens.value = 1000;
|
779 |
|
780 |
|
781 |
//function to hide element smoothly then setting display none after the transition time elapsed
|
|
|
859 |
const editDefaultPersonalityButton = document.querySelector("#btn-edit-personality-default");
|
860 |
const submitNewPersonalityButton = document.querySelector("#btn-submit-personality");
|
861 |
const updatePersonalityButton = document.querySelector("#updatePersonality");
|
862 |
+
const resetChatButton = document.querySelector("#btn-reset-chat");
|
863 |
|
864 |
+
const messageContainer = document.querySelector(".message-container");
|
865 |
const sendMessageButton = document.querySelector("#btn-send");
|
866 |
|
867 |
|
|
|
1035 |
closeOverlay();
|
1036 |
}
|
1037 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1038 |
async function run() {
|
1039 |
const msg = document.querySelector("#messageInput");
|
1040 |
const msgText = msg.value;
|
|
|
1041 |
const maxTokens = document.querySelector("#maxTokens");
|
1042 |
const API_KEY = document.querySelector("#apiKeyInput");
|
1043 |
const selectedPersonalityTitle = document.querySelector("input[name='personality']:checked + div .personality-title").innerText;
|
|
|
1046 |
|
1047 |
|
1048 |
//chat history
|
1049 |
+
let chatHistory = [];
|
1050 |
//get chat history from message container
|
1051 |
const messageElements = messageContainer.querySelectorAll(".message");
|
1052 |
messageElements.forEach(element => {
|
|
|
1132 |
|
1133 |
//save api key to local storage
|
1134 |
localStorage.setItem("API_KEY", API_KEY.value);
|
1135 |
+
localStorage.setItem("maxTokens",maxTokens.value);
|
1136 |
|
1137 |
}
|
1138 |
|
1139 |
+
//reset chat button (async)
|
1140 |
+
resetChatButton.addEventListener("click", () => {
|
1141 |
+
//remove all messages
|
1142 |
+
messageContainer.innerHTML = "";
|
1143 |
+
});
|
1144 |
+
|
1145 |
|
1146 |
const messageInput = document.querySelector("#messageInput");
|
1147 |
|
|
|
1187 |
sendMessageButton.addEventListener("click", run);
|
1188 |
|
1189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1190 |
// ...
|
1191 |
</script>
|
1192 |
|