monra commited on
Commit
f67971f
1 Parent(s): 898685f

Improve the user interface

Browse files
.gitignore CHANGED
@@ -147,6 +147,7 @@ cython_debug/
147
  # others
148
  .config/
149
  .upm/
 
150
 
151
  # PyCharm
152
  # JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
 
147
  # others
148
  .config/
149
  .upm/
150
+ .vscode/
151
 
152
  # PyCharm
153
  # JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
client/css/background.css DELETED
@@ -1,22 +0,0 @@
1
- .background-gradient:nth-child(1) {
2
- --top: 0;
3
- --right: 0;
4
- --size: 70vw;
5
- --blur: calc(0.5 * var(--size));
6
- --opacity: 0.3;
7
- animation: zoom_gradient 6s infinite;
8
- }
9
-
10
- .background-gradient {
11
- position: absolute;
12
- z-index: -1;
13
- border-radius: calc(0.5 * var(--size));
14
- background-color: var(--accent);
15
- background: radial-gradient(circle at center, var(--accent), var(--accent));
16
- width: 70vw;
17
- height: 70vw;
18
- top: 50%;
19
- right: 0;
20
- transform: translateY(-50%);
21
- filter: blur(calc(0.5 * 70vw)) opacity(var(--opacity));
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
client/css/button.css ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .button {
2
+ display: flex;
3
+ padding: 8px 12px;
4
+ align-items: center;
5
+ justify-content: center;
6
+ border: 1px solid var(--conversations);
7
+ border-radius: var(--border-radius-1);
8
+ width: 100%;
9
+ background: transparent;
10
+ cursor: pointer;
11
+ }
12
+
13
+ .button span {
14
+ color: var(--colour-3);
15
+ font-size: 0.875rem;
16
+ }
17
+
18
+ .button i::before {
19
+ margin-right: 8px;
20
+ }
21
+
22
+ @media screen and (max-width: 990px) {
23
+ .button span {
24
+ font-size: 0.75rem;
25
+ }
26
+ }
client/css/conversation.css CHANGED
@@ -1,29 +1,26 @@
1
  .conversation {
2
- width: 100%;
 
3
  display: flex;
4
  flex-direction: column;
5
- gap: 15px;
6
  }
7
 
8
  .conversation #messages {
9
  width: 100%;
10
- height: 100%;
11
  display: flex;
12
  flex-direction: column;
13
  overflow: auto;
14
  overflow-wrap: break-word;
15
- padding-bottom: 50px;
16
  }
17
 
18
  .conversation .user-input {
19
- max-height: 200px;
 
20
  }
21
 
22
  .conversation .user-input input {
23
- font-size: 15px;
24
- width: 100%;
25
- height: 100%;
26
- padding: 12px 15px;
27
  background: none;
28
  border: none;
29
  outline: none;
@@ -40,41 +37,19 @@
40
  }
41
 
42
  .conversation .user-input textarea {
43
- font-size: 15px;
44
  width: 100%;
45
  height: 100%;
46
- padding: 12px 15px;
47
  background: none;
48
  border: none;
49
  outline: none;
50
  color: var(--colour-3);
51
-
52
  resize: vertical;
53
  max-height: 150px;
54
  min-height: 80px;
55
  }
56
 
57
- .new-conversation {
58
- padding: 8px 12px;
59
- display: flex;
60
- gap: 18px;
61
- align-items: center;
62
- cursor: pointer;
63
- user-select: none;
64
- background: transparent;
65
- border: 1px dashed var(--conversations);
66
- border-radius: var(--border-radius-1);
67
- }
68
-
69
- .new-conversation span {
70
- color: var(--colour-3);
71
- font-size: 14px;
72
- }
73
-
74
- .new-conversation:hover {
75
- border-style: solid;
76
- }
77
-
78
  .box {
79
  backdrop-filter: blur(20px);
80
  -webkit-backdrop-filter: blur(20px);
@@ -88,7 +63,7 @@
88
  .input-box {
89
  display: flex;
90
  align-items: center;
91
- padding-right: 15px;
92
  cursor: pointer;
93
  }
94
 
@@ -128,3 +103,20 @@
128
  background: #ffffff00;
129
  }
130
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  .conversation {
2
+ width: 60%;
3
+ margin: 0px 16px;
4
  display: flex;
5
  flex-direction: column;
 
6
  }
7
 
8
  .conversation #messages {
9
  width: 100%;
 
10
  display: flex;
11
  flex-direction: column;
12
  overflow: auto;
13
  overflow-wrap: break-word;
14
+ padding-bottom: 8px;
15
  }
16
 
17
  .conversation .user-input {
18
+ max-height: 180px;
19
+ margin: 16px 0px;
20
  }
21
 
22
  .conversation .user-input input {
23
+ font-size: 1rem;
 
 
 
24
  background: none;
25
  border: none;
26
  outline: none;
 
37
  }
38
 
39
  .conversation .user-input textarea {
40
+ font-size: 1rem;
41
  width: 100%;
42
  height: 100%;
43
+ padding: 12px;
44
  background: none;
45
  border: none;
46
  outline: none;
47
  color: var(--colour-3);
 
48
  resize: vertical;
49
  max-height: 150px;
50
  min-height: 80px;
51
  }
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  .box {
54
  backdrop-filter: blur(20px);
55
  -webkit-backdrop-filter: blur(20px);
 
63
  .input-box {
64
  display: flex;
65
  align-items: center;
66
+ padding: 8px;
67
  cursor: pointer;
68
  }
69
 
 
103
  background: #ffffff00;
104
  }
105
  }
106
+
107
+ @media screen and (max-width: 990px) {
108
+ .conversation {
109
+ width: 100%;
110
+ height: 90%;
111
+ }
112
+ }
113
+
114
+ @media screen and (max-height: 720px) {
115
+ .box {
116
+ height: 70%;
117
+ }
118
+
119
+ .conversation .user-input textarea {
120
+ font-size: 0.875rem;
121
+ }
122
+ }
client/css/dropdown.css ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ .dropdown {
2
+ border: 1px solid var(--conversations);
3
+ }
client/css/global.css CHANGED
@@ -1,24 +1,22 @@
1
  @import url("https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap");
2
 
3
  :root {
4
- --colour-1: #000000;
 
 
 
 
5
  --colour-2: #ccc;
6
- --colour-3: #e4d4ff;
7
  --colour-4: #f0f0f0;
8
  --colour-5: #181818;
9
  --colour-6: #242424;
10
 
11
- --accent: #8b3dff;
12
- --blur-bg: #16101b66;
13
- --blur-border: #84719040;
14
- --user-input: #ac87bb;
15
- --conversations: #c7a2ff;
16
- }
17
-
18
- :root {
19
- --font-1: "Inter", sans-serif;
20
- --section-gap: 25px;
21
- --border-radius-1: 8px;
22
  }
23
 
24
  * {
@@ -31,15 +29,8 @@
31
 
32
  html,
33
  body {
34
- scroll-behavior: smooth;
35
- overflow: hidden;
36
- }
37
-
38
- body {
39
- padding: var(--section-gap);
40
  background: var(--colour-1);
41
  color: var(--colour-3);
42
- height: 100vh;
43
  }
44
 
45
  ol,
@@ -48,15 +39,15 @@ ul {
48
  }
49
 
50
  .shown {
51
- display: flex;
52
  }
53
 
54
  a:-webkit-any-link {
55
  color: var(--accent);
56
  }
57
 
58
- @media screen and (max-height: 640px) {
59
- body {
60
- height: 87vh;
61
  }
62
  }
 
1
  @import url("https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap");
2
 
3
  :root {
4
+ --font-1: "Inter", sans-serif;
5
+ --section-gap: 24px;
6
+ --border-radius-1: 8px;
7
+
8
+ --colour-1: #181818;
9
  --colour-2: #ccc;
10
+ --colour-3: #dadada;
11
  --colour-4: #f0f0f0;
12
  --colour-5: #181818;
13
  --colour-6: #242424;
14
 
15
+ --accent: #151718;
16
+ --blur-bg: #242627;
17
+ --blur-border: #242627;
18
+ --user-input: #f5f5f5;
19
+ --conversations: #555555;
 
 
 
 
 
 
20
  }
21
 
22
  * {
 
29
 
30
  html,
31
  body {
 
 
 
 
 
 
32
  background: var(--colour-1);
33
  color: var(--colour-3);
 
34
  }
35
 
36
  ol,
 
39
  }
40
 
41
  .shown {
42
+ display: flex !important;
43
  }
44
 
45
  a:-webkit-any-link {
46
  color: var(--accent);
47
  }
48
 
49
+ @media screen and (max-height: 720px) {
50
+ :root {
51
+ --section-gap: 16px;
52
  }
53
  }
client/css/hljs.css CHANGED
@@ -4,11 +4,13 @@
4
  border-radius: var(--border-radius-1);
5
  border: 1px solid var(--blur-border);
6
  font-size: 15px;
 
 
7
  }
8
 
9
  #message-input {
10
  margin-right: 30px;
11
- height: 80px;
12
  }
13
 
14
  #message-input::-webkit-scrollbar {
 
4
  border-radius: var(--border-radius-1);
5
  border: 1px solid var(--blur-border);
6
  font-size: 15px;
7
+ word-wrap: break-word;
8
+ white-space: pre-wrap;
9
  }
10
 
11
  #message-input {
12
  margin-right: 30px;
13
+ height: 64px;
14
  }
15
 
16
  #message-input::-webkit-scrollbar {
client/css/main.css CHANGED
@@ -1,5 +1,7 @@
1
  .main-container {
2
  display: flex;
3
- gap: var(--section-gap);
4
- height: 100%;
 
 
5
  }
 
1
  .main-container {
2
  display: flex;
3
+ padding: var(--section-gap);
4
+ height: 100vh;
5
+ justify-content: center;
6
+ box-sizing: border-box;
7
  }
client/css/message.css CHANGED
@@ -18,18 +18,11 @@
18
  }
19
  }
20
 
21
- .message .user {
22
  max-width: 48px;
23
  max-height: 48px;
24
- flex-shrink: 0;
25
- }
26
-
27
- .message .user img {
28
- width: 100%;
29
- height: 100%;
30
- object-fit: cover;
31
- border-radius: 8px;
32
- outline: 1px solid var(--blur-border);
33
  }
34
 
35
  .message .content {
@@ -41,13 +34,21 @@
41
  .message .content p,
42
  .message .content li,
43
  .message .content code {
44
- font-size: 15px;
45
  line-height: 1.3;
46
  }
47
 
48
- .message .user i {
49
- position: absolute;
50
- bottom: -6px;
51
- right: -6px;
52
- z-index: 1000;
 
 
 
 
 
 
 
 
53
  }
 
18
  }
19
  }
20
 
21
+ .message .avatar-container img {
22
  max-width: 48px;
23
  max-height: 48px;
24
+ box-shadow: 0.4px 0.5px 0.7px -2px rgba(0, 0, 0, 0.08), 1.1px 1.3px 2px -2px rgba(0, 0, 0, 0.041),
25
+ 2.7px 3px 4.8px -2px rgba(0, 0, 0, 0.029), 9px 10px 16px -2px rgba(0, 0, 0, 0.022);
 
 
 
 
 
 
 
26
  }
27
 
28
  .message .content {
 
34
  .message .content p,
35
  .message .content li,
36
  .message .content code {
37
+ font-size: 1rem;
38
  line-height: 1.3;
39
  }
40
 
41
+ @media screen and (max-height: 720px) {
42
+ .message .avatar-container img {
43
+ max-width: 32px;
44
+ max-height: 32px;
45
+ }
46
+
47
+ .message .content,
48
+ .message .content p,
49
+ .message .content li,
50
+ .message .content code {
51
+ font-size: 0.875rem;
52
+ line-height: 1.3;
53
+ }
54
  }
client/css/sidebar.css CHANGED
@@ -6,7 +6,6 @@
6
  display: flex;
7
  flex-direction: column;
8
  justify-content: space-between;
9
- gap: 16px;
10
  }
11
 
12
  .sidebar .title {
@@ -43,17 +42,25 @@
43
  }
44
 
45
  .sidebar .info {
46
- padding: 8px 12px;
47
  display: flex;
48
- gap: 18px;
49
  align-items: center;
 
50
  user-select: none;
51
  background: transparent;
52
- border-radius: var(--border-radius-1);
53
  width: 100%;
54
- border: 1px dashed var(--conversations);
55
  text-decoration: none;
56
- color: inherit;
 
 
 
 
 
 
 
 
 
57
  }
58
 
59
  .sidebar-footer {
@@ -64,21 +71,26 @@
64
  }
65
 
66
  .sidebar-footer button {
67
- padding: 8px 12px;
68
- display: flex;
69
- gap: 18px;
70
- align-items: center;
71
  cursor: pointer;
72
  user-select: none;
73
  background: transparent;
74
- border: 1px solid #c7a2ff;
75
- border-radius: var(--border-radius-1);
 
 
 
 
76
  width: 100%;
 
 
 
77
  }
78
 
79
- .sidebar-footer button span {
80
- color: var(--colour-3);
81
- font-size: 14px;
 
 
82
  }
83
 
84
  @keyframes spinner {
@@ -130,6 +142,13 @@
130
  transform: rotate(360deg);
131
  }
132
 
 
 
 
 
 
 
 
133
  @media screen and (max-width: 990px) {
134
  .sidebar {
135
  display: none;
@@ -141,3 +160,20 @@
141
  display: flex !important;
142
  }
143
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  display: flex;
7
  flex-direction: column;
8
  justify-content: space-between;
 
9
  }
10
 
11
  .sidebar .title {
 
42
  }
43
 
44
  .sidebar .info {
45
+ padding: 8px 12px 0px 12px;
46
  display: flex;
 
47
  align-items: center;
48
+ justify-content: center;
49
  user-select: none;
50
  background: transparent;
 
51
  width: 100%;
52
+ border: none;
53
  text-decoration: none;
54
+ }
55
+
56
+ .sidebar .info span {
57
+ color: var(--conversations);
58
+ line-height: 1.5;
59
+ font-size: 0.75rem;
60
+ }
61
+
62
+ .sidebar .info i::before {
63
+ margin-right: 8px;
64
  }
65
 
66
  .sidebar-footer {
 
71
  }
72
 
73
  .sidebar-footer button {
 
 
 
 
74
  cursor: pointer;
75
  user-select: none;
76
  background: transparent;
77
+ }
78
+
79
+ .sidebar.shown {
80
+ position: fixed;
81
+ top: 0;
82
+ left: 0;
83
  width: 100%;
84
+ height: 100%;
85
+ background-color: rgba(0, 0, 0, 0.5);
86
+ z-index: 1000;
87
  }
88
 
89
+ .sidebar.shown .box {
90
+ background-color: #16171a;
91
+ width: 80%;
92
+ height: 100%;
93
+ overflow-y: auto;
94
  }
95
 
96
  @keyframes spinner {
 
142
  transform: rotate(360deg);
143
  }
144
 
145
+ .mobile-sidebar.rotated {
146
+ position: fixed;
147
+ top: 10px;
148
+ left: 10px;
149
+ z-index: 1001;
150
+ }
151
+
152
  @media screen and (max-width: 990px) {
153
  .sidebar {
154
  display: none;
 
160
  display: flex !important;
161
  }
162
  }
163
+
164
+ @media (min-width: 768px) {
165
+ .sidebar.shown {
166
+ position: static;
167
+ width: auto;
168
+ height: auto;
169
+ background-color: transparent;
170
+ padding-top: 64px;
171
+ }
172
+
173
+ .sidebar.shown .box {
174
+ background-color: #16171a;
175
+ width: auto;
176
+ height: auto;
177
+ overflow-y: auto;
178
+ }
179
+ }
client/css/stop-generating.css CHANGED
@@ -1,6 +1,6 @@
1
  .stop-generating {
2
  position: absolute;
3
- bottom: 118px;
4
  left: 50%;
5
  transform: translateX(-50%);
6
  z-index: 1000000;
@@ -10,14 +10,7 @@
10
  backdrop-filter: blur(20px);
11
  -webkit-backdrop-filter: blur(20px);
12
  background-color: var(--blur-bg);
13
- border-radius: var(--border-radius-1);
14
- border: 1px solid var(--blur-border);
15
- padding: 10px 15px;
16
  color: var(--colour-3);
17
- display: flex;
18
- justify-content: center;
19
- align-items: center;
20
- gap: 12px;
21
  cursor: pointer;
22
  animation: show_popup 0.4s;
23
  }
 
1
  .stop-generating {
2
  position: absolute;
3
+ bottom: 128px;
4
  left: 50%;
5
  transform: translateX(-50%);
6
  z-index: 1000000;
 
10
  backdrop-filter: blur(20px);
11
  -webkit-backdrop-filter: blur(20px);
12
  background-color: var(--blur-bg);
 
 
 
13
  color: var(--colour-3);
 
 
 
 
14
  cursor: pointer;
15
  animation: show_popup 0.4s;
16
  }
client/css/style.css CHANGED
@@ -9,6 +9,8 @@
9
  @import "./typing.css";
10
  @import "./checkbox.css";
11
  @import "./label.css";
 
12
  @import "./buttons.css";
 
13
  @import "./field.css";
14
  @import "./select.css";
 
9
  @import "./typing.css";
10
  @import "./checkbox.css";
11
  @import "./label.css";
12
+ @import "./button.css";
13
  @import "./buttons.css";
14
+ @import "./dropdown.css";
15
  @import "./field.css";
16
  @import "./select.css";
client/html/index.html CHANGED
@@ -16,54 +16,40 @@
16
  <link rel="icon" type="image/png" sizes="32x32" href="/assets/img/favicon-32x32.png" />
17
  <link rel="icon" type="image/png" sizes="16x16" href="/assets/img/favicon-16x16.png" />
18
  <link rel="manifest" href="/assets/img/site.webmanifest" />
19
- <script src="/assets/js/icons.js"></script>
20
- <script src="/assets/js/chat.js" defer></script>
21
- <script src="https://cdn.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js"></script>
22
  <link
23
  rel="stylesheet"
24
  href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/styles/base16/dracula.min.css" />
25
- <script>
26
- const user_image = `<img src="/assets/img/user.png" alt="User Avatar">`;
27
- const gpt_image = `<img src="/assets/img/gpt.png" alt="GPT Avatar">`;
28
- </script>
29
- <script src="/assets/js/highlight.min.js"></script>
30
- <script src="/assets/js/highlightjs-copy.min.js"></script>
31
- <script>
32
- window.conversation_id = `{{chat_id}}`;
33
- </script>
34
- <title>ChatGPT</title>
35
  </head>
36
 
37
  <body>
38
- <div class="background-gradient"></div>
39
  <div class="main-container">
40
  <div class="box sidebar">
41
  <div class="top">
42
- <button class="new-conversation" onclick="new_conversation()">
43
  <i class="fa-regular fa-plus"></i>
44
  <span>New Conversation</span>
45
  </button>
46
  <div class="spinner"></div>
47
  </div>
48
  <div class="sidebar-footer">
49
- <button onclick="delete_conversations()">
50
  <i class="fa-regular fa-trash"></i>
51
  <span>Clear Conversations</span>
52
  </button>
53
  <a class="info" href="https://github.com/ramonvc/gptfree-jailbreak-webui" target="_blank">
54
  <i class="fa-brands fa-github"></i>
55
  <span class="conversation-title">
56
- @ramonvc<br />
57
- Version: 0.0.4-Alpha<br />
58
  </span>
59
  </a>
60
  </div>
61
  </div>
62
  <div class="conversation">
63
  <div class="stop-generating stop-generating-hidden">
64
- <button id="cancelButton">
65
  <span>Stop Generating</span>
66
- <i class="fa-regular fa-stop"></i>
67
  </button>
68
  </div>
69
  <div class="box" id="messages"></div>
@@ -81,19 +67,19 @@
81
  </div>
82
  </div>
83
  <div class="buttons">
84
- <div class="field">
85
- <input type="checkbox" id="switch" />
86
  <label for="switch"></label>
87
  <span class="about">Web Access</span>
88
  </div>
89
  <div class="field">
90
- <select name="model" id="model">
91
  <option value="gpt-3.5-turbo">GPT-3.5</option>
92
  <option value="gpt-4" selected>GPT-4</option>
93
  </select>
94
  </div>
95
  <div class="field">
96
- <select name="jailbreak" id="jailbreak">
97
  <option value="default" selected>Default</option>
98
  <option value="gpt-dan-11.0">DAN</option>
99
  <option value="gpt-evil">Evil</option>
@@ -105,5 +91,12 @@
105
  <div class="mobile-sidebar">
106
  <i class="fa-solid fa-bars"></i>
107
  </div>
 
 
 
 
 
 
 
108
  </body>
109
  </html>
 
16
  <link rel="icon" type="image/png" sizes="32x32" href="/assets/img/favicon-32x32.png" />
17
  <link rel="icon" type="image/png" sizes="16x16" href="/assets/img/favicon-16x16.png" />
18
  <link rel="manifest" href="/assets/img/site.webmanifest" />
 
 
 
19
  <link
20
  rel="stylesheet"
21
  href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/styles/base16/dracula.min.css" />
22
+ <title>FreeGPT</title>
 
 
 
 
 
 
 
 
 
23
  </head>
24
 
25
  <body>
 
26
  <div class="main-container">
27
  <div class="box sidebar">
28
  <div class="top">
29
+ <button class="button" onclick="new_conversation()">
30
  <i class="fa-regular fa-plus"></i>
31
  <span>New Conversation</span>
32
  </button>
33
  <div class="spinner"></div>
34
  </div>
35
  <div class="sidebar-footer">
36
+ <button class="button" onclick="delete_conversations()">
37
  <i class="fa-regular fa-trash"></i>
38
  <span>Clear Conversations</span>
39
  </button>
40
  <a class="info" href="https://github.com/ramonvc/gptfree-jailbreak-webui" target="_blank">
41
  <i class="fa-brands fa-github"></i>
42
  <span class="conversation-title">
43
+ Author: @ramonvc<br />
44
+ Version: 0.0.5-Alpha<br />
45
  </span>
46
  </a>
47
  </div>
48
  </div>
49
  <div class="conversation">
50
  <div class="stop-generating stop-generating-hidden">
51
+ <button class="button" id="cancelButton">
52
  <span>Stop Generating</span>
 
53
  </button>
54
  </div>
55
  <div class="box" id="messages"></div>
 
67
  </div>
68
  </div>
69
  <div class="buttons">
70
+ <div class="field" style="display: none">
71
+ <input type="checkbox" disabled id="switch" />
72
  <label for="switch"></label>
73
  <span class="about">Web Access</span>
74
  </div>
75
  <div class="field">
76
+ <select class="dropdown" name="model" id="model">
77
  <option value="gpt-3.5-turbo">GPT-3.5</option>
78
  <option value="gpt-4" selected>GPT-4</option>
79
  </select>
80
  </div>
81
  <div class="field">
82
+ <select class="dropdown" name="jailbreak" id="jailbreak">
83
  <option value="default" selected>Default</option>
84
  <option value="gpt-dan-11.0">DAN</option>
85
  <option value="gpt-evil">Evil</option>
 
91
  <div class="mobile-sidebar">
92
  <i class="fa-solid fa-bars"></i>
93
  </div>
94
+
95
+ <!-- scripts -->
96
+ <script src="/assets/js/icons.js"></script>
97
+ <script src="/assets/js/chat.js" defer></script>
98
+ <script src="https://cdn.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js"></script>
99
+ <script src="/assets/js/highlight.min.js"></script>
100
+ <script src="/assets/js/highlightjs-copy.min.js"></script>
101
  </body>
102
  </html>
client/img/gpt.png CHANGED
client/img/user.png CHANGED
client/js/chat.js CHANGED
@@ -9,7 +9,10 @@ const box_conversations = document.querySelector(`.top`);
9
  const spinner = box_conversations.querySelector(".spinner");
10
  const stop_generating = document.querySelector(`.stop-generating`);
11
  const send_button = document.querySelector(`#send-button`);
 
 
12
  let prompt_lock = false;
 
13
 
14
  hljs.addPlugin(new CopyButtonPlugin());
15
 
@@ -32,13 +35,12 @@ const delete_conversations = async () => {
32
 
33
  const handle_ask = async () => {
34
  message_input.style.height = `80px`;
35
- message_input.focus();
36
-
37
  window.scrollTo(0, 0);
38
  let message = message_input.value;
39
 
40
  if (message.length > 0) {
41
  message_input.value = ``;
 
42
  await ask_gpt(message);
43
  }
44
  };
@@ -72,7 +74,7 @@ const ask_gpt = async (message) => {
72
 
73
  message_box.innerHTML += `
74
  <div class="message">
75
- <div class="user">
76
  ${user_image}
77
  </div>
78
  <div class="content" id="user_${token}">
@@ -88,7 +90,7 @@ const ask_gpt = async (message) => {
88
 
89
  message_box.innerHTML += `
90
  <div class="message">
91
- <div class="user">
92
  ${gpt_image}
93
  </div>
94
  <div class="content" id="gpt_${window.token}">
@@ -259,7 +261,7 @@ const load_conversation = async (conversation_id) => {
259
  for (item of conversation.items) {
260
  message_box.innerHTML += `
261
  <div class="message">
262
- <div class="user">
263
  ${item.role == "assistant" ? gpt_image : user_image}
264
  </div>
265
  <div class="content">
@@ -394,20 +396,21 @@ window.onload = async () => {
394
  }
395
  }
396
 
397
- message_input.addEventListener(`keydown`, async (evt) => {
398
  if (prompt_lock) return;
399
- if (evt.keyCode === 13 && !evt.shiftKey) {
400
- console.log("pressed enter");
 
401
  await handle_ask();
402
  } else {
403
- message_input.style.removeProperty("height");
404
- message_input.style.height = message_input.scrollHeight + 4 + "px";
405
  }
406
  });
407
 
408
- send_button.addEventListener(`click`, async () => {
409
- console.log("clicked send");
410
  if (prompt_lock) return;
 
411
  await handle_ask();
412
  });
413
 
@@ -420,9 +423,11 @@ document.querySelector(".mobile-sidebar").addEventListener("click", (event) => {
420
  if (sidebar.classList.contains("shown")) {
421
  sidebar.classList.remove("shown");
422
  event.target.classList.remove("rotated");
 
423
  } else {
424
  sidebar.classList.add("shown");
425
  event.target.classList.add("rotated");
 
426
  }
427
 
428
  window.scrollTo(0, 0);
@@ -465,3 +470,12 @@ const load_settings_localstorage = async () => {
465
  }
466
  });
467
  };
 
 
 
 
 
 
 
 
 
 
9
  const spinner = box_conversations.querySelector(".spinner");
10
  const stop_generating = document.querySelector(`.stop-generating`);
11
  const send_button = document.querySelector(`#send-button`);
12
+ const user_image = `<img src="/assets/img/user.png" alt="User Avatar">`;
13
+ const gpt_image = `<img src="/assets/img/gpt.png" alt="GPT Avatar">`;
14
  let prompt_lock = false;
15
+ window.conversation_id = `{{chat_id}}`;
16
 
17
  hljs.addPlugin(new CopyButtonPlugin());
18
 
 
35
 
36
  const handle_ask = async () => {
37
  message_input.style.height = `80px`;
 
 
38
  window.scrollTo(0, 0);
39
  let message = message_input.value;
40
 
41
  if (message.length > 0) {
42
  message_input.value = ``;
43
+ message_input.dispatchEvent(new Event("input"));
44
  await ask_gpt(message);
45
  }
46
  };
 
74
 
75
  message_box.innerHTML += `
76
  <div class="message">
77
+ <div class="avatar-container">
78
  ${user_image}
79
  </div>
80
  <div class="content" id="user_${token}">
 
90
 
91
  message_box.innerHTML += `
92
  <div class="message">
93
+ <div class="avatar-container">
94
  ${gpt_image}
95
  </div>
96
  <div class="content" id="gpt_${window.token}">
 
261
  for (item of conversation.items) {
262
  message_box.innerHTML += `
263
  <div class="message">
264
+ <div class="avatar-container">
265
  ${item.role == "assistant" ? gpt_image : user_image}
266
  </div>
267
  <div class="content">
 
396
  }
397
  }
398
 
399
+ message_input.addEventListener("keydown", async (evt) => {
400
  if (prompt_lock) return;
401
+
402
+ if (evt.key === "Enter" && !evt.shiftKey) {
403
+ evt.preventDefault();
404
  await handle_ask();
405
  } else {
406
+ updateTextarea(evt.target);
 
407
  }
408
  });
409
 
410
+ send_button.addEventListener("click", async (event) => {
411
+ event.preventDefault();
412
  if (prompt_lock) return;
413
+ message_input.blur();
414
  await handle_ask();
415
  });
416
 
 
423
  if (sidebar.classList.contains("shown")) {
424
  sidebar.classList.remove("shown");
425
  event.target.classList.remove("rotated");
426
+ document.body.style.overflow = "auto";
427
  } else {
428
  sidebar.classList.add("shown");
429
  event.target.classList.add("rotated");
430
+ document.body.style.overflow = "hidden";
431
  }
432
 
433
  window.scrollTo(0, 0);
 
470
  }
471
  });
472
  };
473
+
474
+ function clearTextarea(textarea) {
475
+ textarea.style.removeProperty("height");
476
+ textarea.style.height = `${textarea.scrollHeight + 4}px`;
477
+
478
+ if (textarea.value.trim() === "" && textarea.value.includes("\n")) {
479
+ textarea.value = "";
480
+ }
481
+ }