huanhoahongso3 commited on
Commit
5415489
1 Parent(s): 2b08270

Upload 276 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .vscode/settings.json +3 -0
  2. Dockerfile +17 -0
  3. LICENSE +674 -0
  4. babel.cfg +2 -0
  5. client/.prettierrc +8 -0
  6. client/css/button.css +28 -0
  7. client/css/buttons.css +5 -0
  8. client/css/checkbox.css +56 -0
  9. client/css/conversation.css +182 -0
  10. client/css/dropdown.css +11 -0
  11. client/css/field.css +18 -0
  12. client/css/global.css +79 -0
  13. client/css/hljs.css +73 -0
  14. client/css/label.css +16 -0
  15. client/css/main.css +19 -0
  16. client/css/message-input.css +22 -0
  17. client/css/message.css +64 -0
  18. client/css/options.css +10 -0
  19. client/css/select.css +35 -0
  20. client/css/settings.css +47 -0
  21. client/css/sidebar.css +202 -0
  22. client/css/stop-generating.css +39 -0
  23. client/css/style.css +18 -0
  24. client/css/typing.css +15 -0
  25. client/html/index.html +157 -0
  26. client/img/android-chrome-192x192.png +0 -0
  27. client/img/android-chrome-512x512.png +0 -0
  28. client/img/apple-touch-icon.png +0 -0
  29. client/img/favicon-16x16.png +0 -0
  30. client/img/favicon-32x32.png +0 -0
  31. client/img/favicon.ico +0 -0
  32. client/img/gpt.png +0 -0
  33. client/img/site.webmanifest +23 -0
  34. client/img/user.png +0 -0
  35. client/js/change-language.js +47 -0
  36. client/js/chat.js +557 -0
  37. client/js/fullscreen-toggle.js +56 -0
  38. client/js/highlight.min.js +0 -0
  39. client/js/highlightjs-copy.min.js +1 -0
  40. client/js/icons.js +1 -0
  41. client/js/markdown-it.min.js +0 -0
  42. client/js/sidebar-toggler.js +37 -0
  43. client/js/theme-toggler.js +22 -0
  44. config.json +8 -0
  45. g4f/Provider/AItianhu.py +79 -0
  46. g4f/Provider/AItianhuSpace.py +117 -0
  47. g4f/Provider/AiAsk.py +46 -0
  48. g4f/Provider/AiChatOnline.py +59 -0
  49. g4f/Provider/Aichat.py +66 -0
  50. g4f/Provider/Aura.py +56 -0
.vscode/settings.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "git.autofetch": true
3
+ }
Dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim-buster
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt requirements.txt
6
+
7
+ RUN python -m venv venv
8
+ ENV PATH="/app/venv/bin:$PATH"
9
+
10
+ RUN pip install --upgrade pip && \
11
+ pip install --no-cache-dir -r requirements.txt
12
+
13
+ COPY . .
14
+
15
+ RUN chmod -R 777 translations
16
+
17
+ CMD ["python3", "./run.py"]
LICENSE ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <https://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <https://www.gnu.org/licenses/why-not-lgpl.html>.
babel.cfg ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [python: **/server/.py]
2
+ [jinja2: **/client/html/**.html]
client/.prettierrc ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "printWidth": 120,
3
+ "tabWidth": 4,
4
+ "useTabs": true,
5
+ "semi": true,
6
+ "singleQuote": false,
7
+ "trailingComma": "es5"
8
+ }
client/css/button.css ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .button {
2
+ display: flex;
3
+ padding: 8px 12px;
4
+ align-items: center;
5
+ justify-content: center;
6
+ border: var(--blur-border);
7
+ border-radius: var(--border-radius-1);
8
+ box-shadow: var(--blur-box-shadow);
9
+ width: 100%;
10
+ background: transparent;
11
+ cursor: pointer;
12
+ }
13
+
14
+ .button span {
15
+ color: var(--colour-3);
16
+ font-size: 0.875rem;
17
+ padding: 8px;
18
+ }
19
+
20
+ .button i::before {
21
+ margin-right: 8px;
22
+ }
23
+
24
+ @media screen and (max-width: 990px) {
25
+ .button span {
26
+ font-size: 0.75rem;
27
+ }
28
+ }
client/css/buttons.css ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ .buttons {
2
+ display: flex;
3
+ justify-content: left;
4
+ }
5
+
client/css/checkbox.css ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .checkbox input {
2
+ height: 0;
3
+ width: 0;
4
+ display: none;
5
+ }
6
+
7
+ .checkbox span {
8
+ font-size: 0.875rem;
9
+ color: var(--colour-2);
10
+ margin-left: 4px;
11
+ }
12
+
13
+ .checkbox label:after {
14
+ content: "";
15
+ position: absolute;
16
+ top: 50%;
17
+ transform: translateY(-50%);
18
+ left: 5px;
19
+ width: 20px;
20
+ height: 20px;
21
+ background: var(--blur-border);
22
+ border-radius: 90px;
23
+ transition: 0.33s;
24
+ }
25
+
26
+ .checkbox input + label:after,
27
+ .checkbox input:checked + label {
28
+ background: var(--colour-3);
29
+ }
30
+
31
+ .checkbox input + label,
32
+ .checkbox input:checked + label:after {
33
+ background: var(--blur-border);
34
+ }
35
+
36
+ .checkbox input:checked + label:after {
37
+ left: calc(100% - 5px - 20px);
38
+ }
39
+
40
+ @media screen and (max-width: 990px) {
41
+ .checkbox label {
42
+ width: 25px;
43
+ height: 15px;
44
+ }
45
+
46
+ .checkbox label:after {
47
+ left: 2px;
48
+ width: 10px;
49
+ height: 10px;
50
+ }
51
+
52
+ .checkbox input:checked + label:after {
53
+ left: calc(100% - 2px - 10px);
54
+ }
55
+
56
+ }
client/css/conversation.css ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .conversation {
2
+ width: max(100%);
3
+ height: max(100%);
4
+ display: flex;
5
+ flex-direction: column;
6
+ justify-content: flex-start;
7
+ }
8
+
9
+ .conversation #messages {
10
+ width: max(100%);
11
+ display: flex;
12
+ flex-direction: column;
13
+ overflow: auto;
14
+ overflow-wrap: break-word;
15
+ padding-bottom: 8px;
16
+ }
17
+
18
+ @media screen and (max-width: 990px) {
19
+ .conversation #messages {
20
+ border-bottom-left-radius: unset;
21
+ border-bottom-right-radius: unset;
22
+ border-bottom: none;
23
+ }
24
+ }
25
+
26
+ .conversation .user-input {
27
+ max-height: 180px;
28
+ margin-top: 4px;
29
+ }
30
+
31
+ @media screen and (max-width: 990px) {
32
+ .conversation .user-input {
33
+ margin-top: 0;
34
+ }
35
+ }
36
+
37
+ .conversation .user-input input {
38
+ font-size: 1rem;
39
+ background: none;
40
+ border: none;
41
+ outline: none;
42
+ color: var(--colour-3);
43
+ }
44
+
45
+ .conversation .user-input input::placeholder {
46
+ color: var(--user-input);
47
+ }
48
+
49
+ .conversation-title {
50
+ color: var(--colour-3);
51
+ font-size: 14px;
52
+ }
53
+
54
+ .conversation .user-input textarea {
55
+ font-size: 1rem;
56
+ width: max(98%);
57
+ height: 100%;
58
+ padding: 12px;
59
+ background: none;
60
+ border: none;
61
+ outline: none;
62
+ color: var(--colour-3);
63
+ resize: vertical;
64
+ max-height: 150px;
65
+ min-height: 80px;
66
+ }
67
+
68
+ .box {
69
+ backdrop-filter: blur(20px);
70
+ -webkit-backdrop-filter: blur(20px);
71
+ background-color: var(--blur-bg);
72
+ height: 100%;
73
+ width: 100%;
74
+ border-radius: var(--border-radius-1);
75
+ border: 1px solid var(--blur-border);
76
+ }
77
+
78
+ .box.input-box {
79
+ position: relative;
80
+ align-items: center;
81
+ padding: 10px 10px;
82
+ cursor: pointer;
83
+ display: flex;
84
+ flex-direction: row;
85
+ flex-wrap: nowrap;
86
+ align-items: center;
87
+ }
88
+
89
+ @media screen and (max-width: 990px) {
90
+ .box.input-box {
91
+ border-top-left-radius: unset;
92
+ border-top-right-radius: unset;
93
+ border-top: var(--blur-border);
94
+ }
95
+ }
96
+
97
+ #send-button {
98
+ right: 0;
99
+ padding: 4px;
100
+ }
101
+
102
+ #cursor {
103
+ line-height: 17px;
104
+ margin-left: 3px;
105
+ -webkit-animation: blink 0.8s infinite;
106
+ animation: blink 0.8s infinite;
107
+ width: 7px;
108
+ height: 15px;
109
+ }
110
+
111
+ @keyframes blink {
112
+ 0% {
113
+ background: #ffffff00;
114
+ }
115
+
116
+ 50% {
117
+ background: white;
118
+ }
119
+
120
+ 100% {
121
+ background: #ffffff00;
122
+ }
123
+ }
124
+
125
+ @-webkit-keyframes blink {
126
+ 0% {
127
+ background: #ffffff00;
128
+ }
129
+
130
+ 50% {
131
+ background: white;
132
+ }
133
+
134
+ 100% {
135
+ background: #ffffff00;
136
+ }
137
+ }
138
+
139
+ /* scrollbar */
140
+ .conversation #messages::-webkit-scrollbar {
141
+ width: 4px;
142
+ padding: 8px 0px;
143
+ }
144
+
145
+ .conversation #messages::-webkit-scrollbar-track {
146
+ background-color: #ffffff00;
147
+ }
148
+
149
+ .conversation #messages::-webkit-scrollbar-thumb {
150
+ background-color: #555555;
151
+ border-radius: 10px;
152
+ }
153
+
154
+ @media screen and (max-width: 100%) {
155
+ .conversation {
156
+ width: 100%;
157
+ height: 100%;
158
+ }
159
+ }
160
+
161
+ @media screen and (max-height: 100%) {
162
+ .conversation.box {
163
+ height: 70%;
164
+ }
165
+
166
+ .conversation .user-input textarea {
167
+ font-size: 0.875rem;
168
+ }
169
+ }
170
+
171
+ @media screen and (max-width: 360px) {
172
+ .box {
173
+ border-radius: 0;
174
+ }
175
+ .conversation {
176
+ margin: 0;
177
+ margin-top: 48px;
178
+ }
179
+ .conversation .user-input {
180
+ margin: 2px 0 8px 0;
181
+ }
182
+ }
client/css/dropdown.css ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .dropdown {
2
+ border: var(--blur-border);
3
+ box-shadow: var(--blur-box-shadow);
4
+ }
5
+
6
+ @media screen and (max-width: 990px) {
7
+ .dropdown {
8
+ padding: 8px 8px;
9
+ font-size: 0.75rem;
10
+ }
11
+ }
client/css/field.css ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .field {
2
+ display: flex;
3
+ align-items: center;
4
+ padding: 10px 0;
5
+ }
6
+
7
+ .fullscreen {
8
+ display: none;
9
+ }
10
+
11
+ @media screen and (max-width: 990px) {
12
+ .field {
13
+ flex-wrap: nowrap;
14
+ }
15
+ .fullscreen {
16
+ display: flex !important;
17
+ }
18
+ }
client/css/global.css ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import url("https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap");
2
+ * {
3
+ --font-1: "Inter", sans-serif;
4
+ --section-gap: 24px;
5
+ --border-radius-1: 8px;
6
+ margin: 0;
7
+ padding: 0;
8
+ box-sizing: border-box;
9
+ position: relative;
10
+ font-family: var(--font-1);
11
+ }
12
+
13
+ .theme-light {
14
+ --colour-1: #f5f5f5;
15
+ --colour-2: #000000;
16
+ --colour-3: #474747;
17
+ --colour-4: #949494;
18
+ --colour-5: #ebebeb;
19
+ --colour-6: #dadada;
20
+ --accent: #b97272;
21
+ --blur-bg: #ffffff;
22
+ --blur-border: 1px solid #dbdbdb57;
23
+ --blur-box-shadow: 2px 2px 2px #dbdbdb57;
24
+ --user-input: #282828;
25
+ --conversations: #666666;
26
+ }
27
+
28
+ .theme-dark {
29
+ --colour-1: #181818;
30
+ --colour-2: #ccc;
31
+ --colour-3: #dadada;
32
+ --colour-4: #f0f0f0;
33
+ --colour-5: #181818;
34
+ --colour-6: #242424;
35
+
36
+ --accent: #151718;
37
+ --blur-bg: #242627;
38
+ --blur-border: 1px solid #47474757;
39
+ --blur-box-shadow: 2px 2px 2px #47474757;
40
+ --user-input: #f5f5f5;
41
+ --conversations: #555555;
42
+ }
43
+
44
+ html,
45
+ body {
46
+ background: var(--colour-1);
47
+ color: var(--colour-3);
48
+ height: max(100%);
49
+ }
50
+
51
+ ol,
52
+ ul {
53
+ padding-left: 20px;
54
+ }
55
+
56
+ .shown {
57
+ display: flex !important;
58
+ }
59
+
60
+ a:-webkit-any-link {
61
+ color: var(--accent);
62
+ }
63
+
64
+ pre {
65
+ white-space: pre-wrap;
66
+ }
67
+
68
+ @media screen and (max-height: 720px) {
69
+ :root {
70
+ --section-gap: 16px;
71
+ }
72
+ }
73
+
74
+ @media screen and (max-width: 990px) {
75
+ * {
76
+ --section-gap: 16px;
77
+ }
78
+ }
79
+
client/css/hljs.css ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .hljs {
2
+ color: #4b45be;
3
+ word-wrap: break-word;
4
+ white-space: pre-wrap;
5
+ }
6
+
7
+ .theme-dark .hljs {
8
+ color: #949494;
9
+ }
10
+
11
+ /* style for hljs copy */
12
+ .hljs-copy-wrapper {
13
+ position: relative;
14
+ overflow-x: clip;
15
+ }
16
+
17
+ .hljs-copy-wrapper:hover .hljs-copy-button,
18
+ .hljs-copy-button:focus {
19
+ transform: translateX(0);
20
+ }
21
+
22
+ .hljs-copy-button {
23
+ position: absolute;
24
+ transform: translateX(calc(100% + 1.125em));
25
+ top: 0.2em;
26
+ right: 1em;
27
+ width: 2em;
28
+ height: 2em;
29
+ text-indent: -9999px;
30
+ color: #fff;
31
+ border-radius: 0.25rem;
32
+ border: 1px solid #ffffff22;
33
+ background-color: #2d2b57;
34
+ background-image: url('data:image/svg+xml;utf-8,<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 5C5.73478 5 5.48043 5.10536 5.29289 5.29289C5.10536 5.48043 5 5.73478 5 6V20C5 20.2652 5.10536 20.5196 5.29289 20.7071C5.48043 20.8946 5.73478 21 6 21H18C18.2652 21 18.5196 20.8946 18.7071 20.7071C18.8946 20.5196 19 20.2652 19 20V6C19 5.73478 18.8946 5.48043 18.7071 5.29289C18.5196 5.10536 18.2652 5 18 5H16C15.4477 5 15 4.55228 15 4C15 3.44772 15.4477 3 16 3H18C18.7956 3 19.5587 3.31607 20.1213 3.87868C20.6839 4.44129 21 5.20435 21 6V20C21 20.7957 20.6839 21.5587 20.1213 22.1213C19.5587 22.6839 18.7957 23 18 23H6C5.20435 23 4.44129 22.6839 3.87868 22.1213C3.31607 21.5587 3 20.7957 3 20V6C3 5.20435 3.31607 4.44129 3.87868 3.87868C4.44129 3.31607 5.20435 3 6 3H8C8.55228 3 9 3.44772 9 4C9 4.55228 8.55228 5 8 5H6Z" fill="white"/><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3C7 1.89543 7.89543 1 9 1H15C16.1046 1 17 1.89543 17 3V5C17 6.10457 16.1046 7 15 7H9C7.89543 7 7 6.10457 7 5V3ZM15 3H9V5H15V3Z" fill="white"/></svg>');
35
+ background-repeat: no-repeat;
36
+ background-position: center;
37
+ transition: background-color 200ms ease, transform 200ms ease-out;
38
+ }
39
+
40
+ .theme-dark .hljs-copy-button {
41
+ background-color: #949494;
42
+ }
43
+
44
+ .hljs-copy-button:hover {
45
+ border-color: #ffffff44;
46
+ cursor: pointer;
47
+ }
48
+
49
+ .hljs-copy-button:active {
50
+ border-color: #ffffff66;
51
+ }
52
+
53
+ .hljs-copy-button[data-copied="true"] {
54
+ text-indent: 0;
55
+ width: auto;
56
+ background-image: none;
57
+ }
58
+
59
+ .hljs-copy-alert {
60
+ clip: rect(0 0 0 0);
61
+ clip-path: inset(50%);
62
+ height: 1px;
63
+ overflow: hidden;
64
+ position: absolute;
65
+ white-space: nowrap;
66
+ width: 1px;
67
+ }
68
+
69
+ @media (prefers-reduced-motion) {
70
+ .hljs-copy-button {
71
+ transition: none;
72
+ }
73
+ }
client/css/label.css ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ label {
2
+ cursor: pointer;
3
+ text-indent: -9999px;
4
+ width: 50px;
5
+ height: 30px;
6
+ backdrop-filter: blur(20px);
7
+ -webkit-backdrop-filter: blur(20px);
8
+ background-color: var(--blur-bg);
9
+ border-radius: var(--border-radius-1);
10
+ border: 1px solid var(--blur-border);
11
+ display: block;
12
+ border-radius: 100px;
13
+ position: relative;
14
+ overflow: hidden;
15
+ transition: 0.33s;
16
+ }
client/css/main.css ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .main-container {
2
+ display: flex;
3
+ width: max(100%);
4
+ height: max(100%);
5
+ padding: 20px;
6
+ align-content: space-around;
7
+ justify-content: space-around;
8
+ align-items: center;
9
+ box-sizing: border-box;
10
+ flex-direction: row;
11
+ }
12
+
13
+ @media screen and (max-width: 990px) {
14
+ .main-container {
15
+ padding: 40px 10px 10px 10px;
16
+ }
17
+ }
18
+
19
+
client/css/message-input.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #message-input::-webkit-scrollbar {
2
+ width: 5px;
3
+ }
4
+
5
+ #message-input::-webkit-scrollbar-track {
6
+ background: #f1f1f1;
7
+ }
8
+
9
+ #message-input::-webkit-scrollbar-thumb {
10
+ background: #c7a2ff;
11
+ }
12
+
13
+ #message-input::-webkit-scrollbar-thumb:hover {
14
+ background: #8b3dff;
15
+ }
16
+
17
+ @media screen and (max-width: 360px) {
18
+ #message-input {
19
+ margin: 0;
20
+ }
21
+ }
22
+
client/css/message.css ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .message {
2
+ width: max(100%);
3
+ overflow-wrap: anywhere;
4
+ display: flex;
5
+ gap: var(--section-gap);
6
+ padding: var(--section-gap);
7
+ padding-bottom: 0;
8
+ }
9
+
10
+ .message:last-child {
11
+ animation: 0.6s show_message;
12
+ }
13
+
14
+ @keyframes show_message {
15
+ from {
16
+ transform: translateY(10px);
17
+ opacity: 0;
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 {
29
+ display: flex;
30
+ flex-direction: column;
31
+ gap: 18px;
32
+ }
33
+
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: 100%) {
42
+ .message {
43
+ padding: 12px;
44
+ gap: 0;
45
+ }
46
+
47
+ .message .content {
48
+ margin-left: 8px;
49
+ width: max(80%);
50
+ }
51
+
52
+ .message .avatar-container img {
53
+ max-width: 32px;
54
+ max-height: 32px;
55
+ }
56
+
57
+ .message .content,
58
+ .message .content p,
59
+ .message .content li,
60
+ .message .content code {
61
+ font-size: 0.875rem;
62
+ line-height: 1.3;
63
+ }
64
+ }
client/css/options.css ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ .options-container {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ }
5
+
6
+ @media screen and (max-width: 990px) {
7
+ .options-container {
8
+ justify-content: space-between;
9
+ }
10
+ }
client/css/select.css ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ select {
2
+ -webkit-border-radius: 8px;
3
+ -moz-border-radius: 8px;
4
+ border-radius: 8px;
5
+
6
+ -webkit-backdrop-filter: blur(20px);
7
+ backdrop-filter: blur(20px);
8
+
9
+ cursor: pointer;
10
+ background-color: var(--blur-bg);
11
+ border: 1px solid var(--blur-border);
12
+ color: var(--colour-3);
13
+ display: block;
14
+ position: relative;
15
+ overflow: hidden;
16
+ outline: none;
17
+ padding: 8px 16px;
18
+
19
+ appearance: none;
20
+ }
21
+
22
+ /* scrollbar */
23
+ select.dropdown::-webkit-scrollbar {
24
+ width: 4px;
25
+ padding: 8px 0px;
26
+ }
27
+
28
+ select.dropdown::-webkit-scrollbar-track {
29
+ background-color: #ffffff00;
30
+ }
31
+
32
+ select.dropdown::-webkit-scrollbar-thumb {
33
+ background-color: #555555;
34
+ border-radius: 10px;
35
+ }
client/css/settings.css ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .settings-container {
2
+ color: var(--colour-2);
3
+ margin: 24px 0px 8px 0px;
4
+ display: flex;
5
+ flex-direction: column;
6
+ }
7
+
8
+ .settings-container span {
9
+ font-size: 0.875rem;
10
+ margin: 0;
11
+ }
12
+
13
+ .settings-container label {
14
+ width: 24px;
15
+ height: 16px;
16
+ }
17
+
18
+ .settings-container .field {
19
+ justify-content: space-between;
20
+ }
21
+
22
+ .settings-container .checkbox input + label,
23
+ .settings-container .checkbox input:checked + label:after {
24
+ background: var(--colour-1);
25
+ }
26
+
27
+ .settings-container .checkbox input + label:after,
28
+ .settings-container .checkbox input:checked + label {
29
+ background: var(--colour-3);
30
+ }
31
+
32
+ .settings-container .checkbox label:after {
33
+ left: 2px;
34
+ width: 10px;
35
+ height: 10px;
36
+ }
37
+
38
+ .settings-container .checkbox input:checked + label:after {
39
+ left: calc(100% - 2px - 10px);
40
+ }
41
+
42
+ .settings-container .dropdown {
43
+ padding: 4px 8px;
44
+ margin-left: 6px;
45
+ font-size: 0.75rem;
46
+ width: max(70%);
47
+ }
client/css/sidebar.css ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .sidebar {
2
+ max-width: 260px;
3
+ padding: var(--section-gap);
4
+ flex-shrink: 0;
5
+ display: flex;
6
+ flex-direction: column;
7
+ justify-content: space-between;
8
+ margin-right: 4px;
9
+ }
10
+
11
+ .sidebar .title {
12
+ font-size: 14px;
13
+ font-weight: 500;
14
+ }
15
+
16
+ .sidebar .conversation-sidebar {
17
+ padding: 8px 12px;
18
+ display: flex;
19
+ gap: 18px;
20
+ align-items: center;
21
+ user-select: none;
22
+ justify-content: space-between;
23
+ }
24
+
25
+ .sidebar .conversation-sidebar .left {
26
+ cursor: pointer;
27
+ display: flex;
28
+ align-items: center;
29
+ gap: 10px;
30
+ }
31
+
32
+ .sidebar i {
33
+ color: var(--conversations);
34
+ cursor: pointer;
35
+ }
36
+
37
+ .sidebar .top {
38
+ display: flex;
39
+ flex-direction: column;
40
+ overflow: auto;
41
+ gap: 16px;
42
+ padding-right: 8px;
43
+ height: max(80%);
44
+ margin-top: 20px;
45
+ }
46
+
47
+ .sidebar .top:hover {
48
+ overflow: auto;
49
+ }
50
+
51
+ .sidebar .info {
52
+ padding: 8px 12px 0px 12px;
53
+ display: flex;
54
+ align-items: center;
55
+ justify-content: center;
56
+ user-select: none;
57
+ background: transparent;
58
+ width: 100%;
59
+ border: none;
60
+ text-decoration: none;
61
+ }
62
+
63
+ .sidebar .info span {
64
+ color: var(--conversations);
65
+ line-height: 1.5;
66
+ font-size: 0.75rem;
67
+ }
68
+
69
+ .sidebar .info i::before {
70
+ margin-right: 8px;
71
+ }
72
+
73
+ .sidebar-footer {
74
+ width: 100%;
75
+ margin-top: 16px;
76
+ display: flex;
77
+ flex-direction: column;
78
+ }
79
+
80
+ .sidebar-footer button {
81
+ cursor: pointer;
82
+ user-select: none;
83
+ background: transparent;
84
+ }
85
+
86
+ .sidebar.shown {
87
+ position: fixed;
88
+ top: 6px;
89
+ left: 4px;
90
+ width: min(70%);
91
+ height: max(98%);
92
+ z-index: 1000;
93
+ border: none;
94
+ box-shadow: var(--blur-box-shadow);
95
+ }
96
+
97
+ .sidebar.shown .box {
98
+ background-color: #16171a;
99
+ width: 80%;
100
+ height: 100%;
101
+ overflow-y: auto;
102
+ }
103
+
104
+ .sidebar.shown #sidebar-button {
105
+ margin-top: 24px;
106
+ }
107
+
108
+ @keyframes spinner {
109
+ to {
110
+ transform: rotate(360deg);
111
+ }
112
+ }
113
+
114
+ /* scrollbar */
115
+ .sidebar .top::-webkit-scrollbar {
116
+ width: 4px;
117
+ padding: 8px 0px;
118
+ }
119
+
120
+ .sidebar .top::-webkit-scrollbar-track {
121
+ background-color: #ffffff00;
122
+ }
123
+
124
+ .sidebar .top::-webkit-scrollbar-thumb {
125
+ background-color: #555555;
126
+ border-radius: 10px;
127
+ }
128
+
129
+ .spinner:before {
130
+ content: "";
131
+ box-sizing: border-box;
132
+ position: absolute;
133
+ top: 50%;
134
+ left: 45%;
135
+ width: 20px;
136
+ height: 20px;
137
+ border-radius: 50%;
138
+ border: 1px solid var(--conversations);
139
+ border-top-color: white;
140
+ animation: spinner 0.6s linear infinite;
141
+ }
142
+
143
+ .menu-button {
144
+ display: none !important;
145
+ position: absolute;
146
+ z-index: 100000;
147
+ top: 0;
148
+ left: 0;
149
+ margin: 10px 0;
150
+ font-size: 1rem;
151
+ cursor: pointer;
152
+ width: 30px;
153
+ height: 30px;
154
+ justify-content: center;
155
+ align-items: center;
156
+ transition: 0.33s;
157
+ }
158
+
159
+ .menu-button i {
160
+ transition: 0.33s;
161
+ }
162
+
163
+ .rotated {
164
+ transform: rotate(360deg);
165
+ }
166
+
167
+ .menu-button.rotated {
168
+ position: absolute;
169
+ }
170
+
171
+ @media screen and (max-width: 990px) {
172
+ .sidebar {
173
+ display: none;
174
+ width: 100%;
175
+ max-width: none;
176
+ }
177
+ .menu-button {
178
+ display: flex !important;
179
+ }
180
+ }
181
+
182
+ @media (max-width: 990px) {
183
+ .sidebar .top {
184
+ height: max(80%);
185
+ overflow: auto;
186
+ }
187
+ }
188
+
189
+ @media (min-width: 990px) {
190
+ .sidebar.shown {
191
+ position: static;
192
+ width: auto;
193
+ height: auto;
194
+ background-color: transparent;
195
+ }
196
+ .sidebar.shown .box {
197
+ background-color: #16171a;
198
+ width: auto;
199
+ height: auto;
200
+ overflow-y: auto;
201
+ }
202
+ }
client/css/stop-generating.css ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .stop-generating {
2
+ position: absolute;
3
+ bottom: 128px;
4
+ left: 50%;
5
+ transform: translateX(-50%);
6
+ z-index: 1000000;
7
+
8
+ }
9
+
10
+ .stop-generating button {
11
+ backdrop-filter: blur(20px);
12
+ -webkit-backdrop-filter: blur(20px);
13
+ background-color: var(--blur-bg);
14
+ color: var(--colour-3);
15
+ cursor: pointer;
16
+ animation: show_popup 0.4s;
17
+ }
18
+
19
+ @keyframes show_popup {
20
+ from {
21
+ opacity: 0;
22
+ transform: translateY(10px);
23
+ }
24
+ }
25
+
26
+ @keyframes hide_popup {
27
+ to {
28
+ opacity: 0;
29
+ transform: translateY(10px);
30
+ }
31
+ }
32
+
33
+ .stop-generating-hiding button {
34
+ animation: hide_popup 0.4s;
35
+ }
36
+
37
+ .stop-generating-hidden button {
38
+ display: none;
39
+ }
client/css/style.css ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import "./global.css";
2
+ @import "./hljs.css";
3
+ @import "./main.css";
4
+ @import "./sidebar.css";
5
+ @import "./conversation.css";
6
+ @import "./message.css";
7
+ @import "./stop-generating.css";
8
+ @import "./typing.css";
9
+ @import "./checkbox.css";
10
+ @import "./label.css";
11
+ @import "./button.css";
12
+ @import "./buttons.css";
13
+ @import "./dropdown.css";
14
+ @import "./field.css";
15
+ @import "./select.css";
16
+ @import "./options.css";
17
+ @import "./settings.css";
18
+ @import "./message-input.css";
client/css/typing.css ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .typing {
2
+ position: absolute;
3
+ top: -25px;
4
+ left: 0;
5
+ font-size: 14px;
6
+ animation: show_popup 0.4s;
7
+ }
8
+
9
+ .typing-hiding {
10
+ animation: hide_popup 0.4s;
11
+ }
12
+
13
+ .typing-hidden {
14
+ display: none;
15
+ }
client/html/index.html ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
7
+ <meta name="full-screen" content="yes" />
8
+ <meta name="description" content="A conversational AI system that listens, learns, and challenges" />
9
+ <meta property="og:title" content="ChatGPT" />
10
+ <meta property="og:image" content="https://openai.com/content/images/2022/11/ChatGPT.jpg" />
11
+ <meta
12
+ property="og:description"
13
+ content="A conversational AI system that listens, learns, and challenges" />
14
+ <meta property="og:url" content="https://chat.acy.dev" />
15
+ <link rel="stylesheet" href="{{ url_for('bp.static', filename='css/style.css') }}" />
16
+ <link
17
+ rel="apple-touch-icon"
18
+ sizes="180x180"
19
+ href="{{ url_for('bp.static', filename='img/apple-touch-icon.png') }}" />
20
+ <link
21
+ rel="icon"
22
+ type="image/png"
23
+ sizes="32x32"
24
+ href="{{ url_for('bp.static', filename='img/favicon-32x32.png') }}" />
25
+ <link
26
+ rel="icon"
27
+ type="image/png"
28
+ sizes="16x16"
29
+ href="{{ url_for('bp.static', filename='img/favicon-16x16.png') }}" />
30
+ <link rel="manifest" href="{{ url_for('bp.static', filename='img/site.webmanifest') }}" />
31
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css">
32
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/markdown-it-texmath/texmath.min.js"></script>
33
+ <script src="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.js"></script>
34
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/markdown-it-texmath/css/texmath.min.css">
35
+ <title>FreeGPT</title>
36
+ </head>
37
+
38
+ <body data-urlprefix="{{ url_prefix}}">
39
+ <div class="main-container">
40
+ <div class="box sidebar">
41
+ <button class="button" id="sidebar-button" onclick="new_conversation()">
42
+ <i class="fa-regular fa-plus"></i>
43
+ <span>{{_('New Conversation')}}</span>
44
+ </button>
45
+ <div class="top">
46
+ <div class="spinner"></div>
47
+ </div>
48
+ <div class="sidebar-footer">
49
+ <!-- <button class="button" onclick="delete_conversations()">
50
+ <i class="fa-regular fa-trash"></i>
51
+ <span>{{_('Clear Conversations')}}</span>
52
+ </button> -->
53
+ <div class="settings-container">
54
+ <div class="field">
55
+ <span>{{_('Model')}}</span>
56
+ <select class="dropdown" name="model" id="model">
57
+ <option value="gpt-3.5-turbo" selected="">GPT-3.5-turbo</option>
58
+ <option value="gpt-4">GPT-4</option>
59
+ <option value="llama2-70b">LLaMA2-70b</option>
60
+ <option value="gemini-pro">Gemini-pro</option>
61
+ </select>
62
+ </div>
63
+ <div class="field">
64
+ <span>{{_('Provider')}}</span>
65
+ <select class="dropdown" name="provider" id="provider">
66
+ <option value="g4f.Provider.Auto" selected>Auto</option>
67
+ <option value="g4f.Provider.ChatgptLogin">ChatGPT Login</option>
68
+ <option value="g4f.Provider.Bing">Bing</option>
69
+ <option value="g4f.Provider.Llama2">Llama2</option>
70
+ <option value="g4f.Provider.Liaobots">Liaobots</option>
71
+ <option value="g4f.Provider.Phind">Phind</option>
72
+ <option value="g4f.Provider.You">You</option>
73
+ </select>
74
+ </div>
75
+ <div class="field">
76
+ <span>{{_('Jailbreak')}}</span>
77
+ <select class="dropdown" name="jailbreak" id="jailbreak">
78
+ <option value="default" selected>{{_('Default')}}</option>
79
+ <option value="gpt-dan-11.0">{{_('DAN')}}</option>
80
+ <option value="gpt-evil">{{_('Evil')}}</option>
81
+ </select>
82
+ </div>
83
+ <div class="field">
84
+ <span>{{_('Language')}}</span>
85
+ <select
86
+ class="dropdown"
87
+ id="language"
88
+ onchange="changeLanguage(this.value)"></select>
89
+ </div>
90
+ <div class="field checkbox">
91
+ <span>{{_('Web Access')}}</span>
92
+ <input type="checkbox" id="switch" />
93
+ <label for="switch"></label>
94
+ </div>
95
+ <div class="field checkbox">
96
+ <span>{{_('Dark Mode')}}</span>
97
+ <input type="checkbox" id="theme-toggler" />
98
+ <label for="theme-toggler"></label>
99
+ </div>
100
+ <div class="field checkbox fullscreen">
101
+ <span>{{_('Fullscreen Mode')}}</span>
102
+ <input type="checkbox" id="fullscreen-toggle" />
103
+ <label for="fullscreen-toggle"></label>
104
+ </div>
105
+ <!-- <div class="field checkbox">
106
+ <span>{{_('Highlight')}}</span>
107
+ <input type="checkbox" id="hl-toggle" />
108
+ <label for="hl-toggle"></label>
109
+ </div> -->
110
+ </div>
111
+ <a class="info" href="https://github.com/VadimBoev/freegpt-webui-v2" target="_blank">
112
+ <i class="fa-brands fa-github"></i>
113
+ <span class="conversation-title"> {{_('Version')}}: 0.8 </span>
114
+ </a>
115
+ </div>
116
+ </div>
117
+ <div class="conversation">
118
+ <div class="stop-generating stop-generating-hidden">
119
+ <button class="button" id="cancelButton">
120
+ <span>{{_('Stop Generating')}}</span>
121
+ </button>
122
+ </div>
123
+ <div class="box" id="messages"></div>
124
+ <div class="user-input">
125
+ <div class="box input-box">
126
+ <textarea
127
+ id="message-input"
128
+ placeholder="{{_('Ask a question')}}"
129
+ cols="30"
130
+ rows="10"
131
+ style="white-space: pre-wrap"></textarea>
132
+ <div id="send-button">
133
+ <i class="fa-regular fa-paper-plane-top"></i>
134
+ </div>
135
+ </div>
136
+ </div>
137
+
138
+ </div>
139
+ </div>
140
+ <div class="menu-button">
141
+ <i class="fa-solid fa-bars"></i>
142
+ </div>
143
+
144
+ <!-- scripts -->
145
+
146
+ <script>window.conversation_id = "{{ chat_id }}";</script>
147
+ <script src="{{ url_for('bp.static', filename='js/icons.js') }}"></script>
148
+ <script src="{{ url_for('bp.static', filename='js/chat.js') }}" defer></script>
149
+ <script src="{{ url_for('bp.static', filename='js/markdown-it.min.js') }}"></script>
150
+ <script src="{{ url_for('bp.static', filename='js/highlight.min.js') }}"></script>
151
+ <script src="{{ url_for('bp.static', filename='js/highlightjs-copy.min.js') }}"></script>
152
+ <script src="{{ url_for('bp.static', filename='js/theme-toggler.js') }}"></script>
153
+ <script src="{{ url_for('bp.static', filename='js/sidebar-toggler.js') }}"></script>
154
+ <script src="{{ url_for('bp.static', filename='js/change-language.js') }}"></script>
155
+ <script src="{{ url_for('bp.static', filename='js/fullscreen-toggle.js') }}"></script>
156
+ </body>
157
+ </html>
client/img/android-chrome-192x192.png ADDED
client/img/android-chrome-512x512.png ADDED
client/img/apple-touch-icon.png ADDED
client/img/favicon-16x16.png ADDED
client/img/favicon-32x32.png ADDED
client/img/favicon.ico ADDED
client/img/gpt.png ADDED
client/img/site.webmanifest ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "FreeGPT",
3
+ "short_name": "FreeGPT",
4
+ "icons": [
5
+ {
6
+ "src": "/assets/img/android-chrome-192x192.png",
7
+ "sizes": "192x192",
8
+ "type": "image/png"
9
+ },
10
+ {
11
+ "src": "/assets/img/android-chrome-512x512.png",
12
+ "sizes": "512x512",
13
+ "type": "image/png"
14
+ }
15
+ ],
16
+ "theme_color": "#ffffff",
17
+ "background_color": "#ffffff",
18
+ "display": "standalone"
19
+ "display_override": ["fullscreen", "minimal-ui"],
20
+ "start_url": "/index.html",
21
+ }
22
+
23
+
client/img/user.png ADDED
client/js/change-language.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener('DOMContentLoaded', fetchLanguages);
2
+
3
+ async function fetchLanguages() {
4
+ try {
5
+ const [languagesResponse, currentLanguageResponse] = await Promise.all([
6
+ fetch(`${url_prefix}/get-languages`),
7
+ fetch(`${url_prefix}/get-locale`)
8
+ ]);
9
+
10
+ const languages = await languagesResponse.json();
11
+ const currentLanguage = await currentLanguageResponse.text();
12
+
13
+ const languageSelect = document.getElementById('language');
14
+ languages.forEach(lang => {
15
+ const option = document.createElement('option');
16
+ option.value = lang;
17
+ option.textContent = lang;
18
+ languageSelect.appendChild(option);
19
+ });
20
+
21
+ const savedLanguage = localStorage.getItem("language") || currentLanguage;
22
+ setLanguageOnPageLoad(savedLanguage);
23
+ } catch (error) {
24
+ console.error("Failed to fetch languages or current language");
25
+ }
26
+ }
27
+
28
+ function setLanguageOnPageLoad(language) {
29
+ document.getElementById("language").value = language;
30
+ }
31
+
32
+ function changeLanguage(lang) {
33
+ fetch(`${url_prefix}/change-language`, {
34
+ method: "POST",
35
+ headers: {
36
+ "Content-Type": "application/json",
37
+ },
38
+ body: JSON.stringify({ language: lang }),
39
+ }).then((response) => {
40
+ if (response.ok) {
41
+ localStorage.setItem("language", lang);
42
+ location.reload();
43
+ } else {
44
+ console.error("Failed to change language");
45
+ }
46
+ });
47
+ }
client/js/chat.js ADDED
@@ -0,0 +1,557 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const query = (obj) =>
2
+ Object.keys(obj)
3
+ .map((k) => encodeURIComponent(k) + "=" + encodeURIComponent(obj[k]))
4
+ .join("&");
5
+ const url_prefix = document.querySelector("body").getAttribute("data-urlprefix");
6
+ //const markdown = window.markdownit();
7
+ const markdown = window.markdownit({html:true})
8
+ .use(texmath, { engine: katex,
9
+ delimiters: 'dollars',
10
+ katexOptions: { macros: {"\\RR": "\\mathbb{R}"} } } );
11
+ const message_box = document.getElementById(`messages`);
12
+ const message_input = document.getElementById(`message-input`);
13
+ const box_conversations = document.querySelector(`.top`);
14
+ const spinner = box_conversations.querySelector(".spinner");
15
+ const stop_generating = document.querySelector(`.stop-generating`);
16
+ const send_button = document.querySelector(`#send-button`);
17
+ const user_image = `<img src="${url_prefix}/assets/img/user.png" alt="User Avatar">`;
18
+ const gpt_image = `<img src="${url_prefix}/assets/img/gpt.png" alt="GPT Avatar">`;
19
+ let prompt_lock = false;
20
+
21
+ hljs.addPlugin(new CopyButtonPlugin());
22
+
23
+ message_input.addEventListener("blur", () => {
24
+ window.scrollTo(0, 0);
25
+ });
26
+
27
+ message_input.addEventListener("focus", () => {
28
+ document.documentElement.scrollTop = document.documentElement.scrollHeight;
29
+ });
30
+
31
+ const delete_conversations = async () => {
32
+ localStorage.clear();
33
+ await new_conversation();
34
+ };
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
+ };
47
+
48
+ const remove_cancel_button = async () => {
49
+ stop_generating.classList.add(`stop-generating-hiding`);
50
+
51
+ setTimeout(() => {
52
+ stop_generating.classList.remove(`stop-generating-hiding`);
53
+ stop_generating.classList.add(`stop-generating-hidden`);
54
+ }, 300);
55
+ };
56
+
57
+ const ask_gpt = async (message) => {
58
+ try {
59
+ message_input.value = ``;
60
+ message_input.innerHTML = ``;
61
+ message_input.innerText = ``;
62
+
63
+ add_conversation(window.conversation_id, message.substr(0, 16));
64
+ window.scrollTo(0, 0);
65
+ window.controller = new AbortController();
66
+
67
+ jailbreak = document.getElementById("jailbreak");
68
+ model = document.getElementById("model");
69
+ provider = document.getElementById("provider");
70
+ prompt_lock = true;
71
+ window.text = ``;
72
+ window.token = message_id();
73
+
74
+ stop_generating.classList.remove(`stop-generating-hidden`);
75
+
76
+ add_user_message_box(message);
77
+
78
+ message_box.scrollTop = message_box.scrollHeight;
79
+ window.scrollTo(0, 0);
80
+ await new Promise((r) => setTimeout(r, 500));
81
+ window.scrollTo(0, 0);
82
+
83
+ message_box.innerHTML += `
84
+ <div class="message">
85
+ <div class="avatar-container">
86
+ ${gpt_image}
87
+ </div>
88
+ <div class="content" id="gpt_${window.token}">
89
+ <div id="cursor"></div>
90
+ </div>
91
+ </div>
92
+ `;
93
+
94
+ message_box.scrollTop = message_box.scrollHeight;
95
+ window.scrollTo(0, 0);
96
+ await new Promise((r) => setTimeout(r, 1000));
97
+ window.scrollTo(0, 0);
98
+
99
+ const response = await fetch(`${url_prefix}/backend-api/v2/conversation`, {
100
+ method: `POST`,
101
+ signal: window.controller.signal,
102
+ headers: {
103
+ "content-type": `application/json`,
104
+ accept: `text/event-stream`,
105
+ },
106
+ body: JSON.stringify({
107
+ conversation_id: window.conversation_id,
108
+ action: `_ask`,
109
+ model: model.options[model.selectedIndex].value,
110
+ provider: provider.options[provider.selectedIndex].value,
111
+ jailbreak: jailbreak.options[jailbreak.selectedIndex].value,
112
+ meta: {
113
+ id: window.token,
114
+ content: {
115
+ conversation: await get_conversation(window.conversation_id),
116
+ internet_access: document.getElementById("switch").checked,
117
+ content_type: "text",
118
+ parts: [
119
+ {
120
+ content: message,
121
+ role: "user",
122
+ },
123
+ ],
124
+ },
125
+ },
126
+ }),
127
+ });
128
+
129
+ const reader = response.body.getReader();
130
+
131
+ while (true) {
132
+ const { value, done } = await reader.read();
133
+ if (done) break;
134
+
135
+ chunk = decodeUnicode(new TextDecoder().decode(value));
136
+
137
+ if (chunk.includes(`<form id="challenge-form" action="${url_prefix}/backend-api/v2/conversation?`)) {
138
+ chunk = `cloudflare token expired, please refresh the page.`;
139
+ }
140
+
141
+ text += chunk;
142
+
143
+ document.getElementById(`gpt_${window.token}`).innerHTML = markdown.render(text);
144
+ document.querySelectorAll(`code`).forEach((el) => {
145
+ hljs.highlightElement(el);
146
+ });
147
+
148
+ window.scrollTo(0, 0);
149
+ message_box.scrollTo({ top: message_box.scrollHeight, behavior: "auto" });
150
+ }
151
+
152
+ // if text contains :
153
+ if (text.includes(`instead. Maintaining this website and API costs a lot of money`)) {
154
+ document.getElementById(`gpt_${window.token}`).innerHTML =
155
+ "An error occurred, please reload / refresh cache and try again.";
156
+ }
157
+
158
+ add_message(window.conversation_id, "user", message);
159
+ add_message(window.conversation_id, "assistant", text);
160
+
161
+ message_box.scrollTop = message_box.scrollHeight;
162
+ await remove_cancel_button();
163
+ prompt_lock = false;
164
+
165
+ await load_conversations(20, 0);
166
+ window.scrollTo(0, 0);
167
+ } catch (e) {
168
+ add_message(window.conversation_id, "user", message);
169
+
170
+ message_box.scrollTop = message_box.scrollHeight;
171
+ await remove_cancel_button();
172
+ prompt_lock = false;
173
+
174
+ await load_conversations(20, 0);
175
+
176
+ console.log(e);
177
+
178
+ let cursorDiv = document.getElementById(`cursor`);
179
+ if (cursorDiv) cursorDiv.parentNode.removeChild(cursorDiv);
180
+
181
+ if (e.name != `AbortError`) {
182
+ let error_message = `oops ! something went wrong, please try again / reload. [stacktrace in console]`;
183
+
184
+ document.getElementById(`gpt_${window.token}`).innerHTML = error_message;
185
+ add_message(window.conversation_id, "assistant", error_message);
186
+ } else {
187
+ document.getElementById(`gpt_${window.token}`).innerHTML += ` [aborted]`;
188
+ add_message(window.conversation_id, "assistant", text + ` [aborted]`);
189
+ }
190
+
191
+ window.scrollTo(0, 0);
192
+ }
193
+ };
194
+
195
+ const add_user_message_box = (message) => {
196
+ const messageDiv = createElement("div", { classNames: ["message"] });
197
+ const avatarContainer = createElement("div", {
198
+ classNames: ["avatar-container"],
199
+ innerHTML: user_image,
200
+ });
201
+ const contentDiv = createElement("div", {
202
+ classNames: ["content"],
203
+ id: `user_${token}`,
204
+ textContent: message,
205
+ });
206
+
207
+ messageDiv.append(avatarContainer, contentDiv);
208
+ message_box.appendChild(messageDiv);
209
+ };
210
+
211
+ const decodeUnicode = (str) => {
212
+ return str.replace(/\\u([a-fA-F0-9]{4})/g, function (match, grp) {
213
+ return String.fromCharCode(parseInt(grp, 16));
214
+ });
215
+ };
216
+
217
+ const clear_conversations = async () => {
218
+ const elements = box_conversations.childNodes;
219
+ let index = elements.length;
220
+
221
+ if (index > 0) {
222
+ while (index--) {
223
+ const element = elements[index];
224
+ if (element.nodeType === Node.ELEMENT_NODE && element.tagName.toLowerCase() !== `button`) {
225
+ box_conversations.removeChild(element);
226
+ }
227
+ }
228
+ }
229
+ };
230
+
231
+ const clear_conversation = async () => {
232
+ let messages = message_box.getElementsByTagName(`div`);
233
+
234
+ while (messages.length > 0) {
235
+ message_box.removeChild(messages[0]);
236
+ }
237
+ };
238
+
239
+ const delete_conversation = async (conversation_id) => {
240
+ localStorage.removeItem(`conversation:${conversation_id}`);
241
+
242
+ if (window.conversation_id == conversation_id) {
243
+ await new_conversation();
244
+ }
245
+
246
+ await load_conversations(20, 0, true);
247
+ };
248
+
249
+ const set_conversation = async (conversation_id) => {
250
+ history.pushState({}, null, `${url_prefix}/chat/${conversation_id}`);
251
+ window.conversation_id = conversation_id;
252
+
253
+ await clear_conversation();
254
+ await load_conversation(conversation_id);
255
+ await load_conversations(20, 0, true);
256
+ };
257
+
258
+ const new_conversation = async () => {
259
+ history.pushState({}, null, `${url_prefix}/chat/`);
260
+ window.conversation_id = uuid();
261
+
262
+ await clear_conversation();
263
+ await load_conversations(20, 0, true);
264
+ };
265
+
266
+ const load_conversation = async (conversation_id) => {
267
+ let conversation = await JSON.parse(localStorage.getItem(`conversation:${conversation_id}`));
268
+ console.log(conversation, conversation_id);
269
+
270
+ model = document.getElementById("model");
271
+ provider = document.getElementById("provider");
272
+ jailbreak = document.getElementById("jailbreak");
273
+ let hasModel = Array.from(model.options).some((option) => option.value === conversation.model);
274
+ let hasProvider = Array.from(provider.options).some((option) => option.value === conversation.provider);
275
+ let hasJailbreak = Array.from(jailbreak.options).some((option) => option.value === conversation.jailbreak);
276
+ if (hasModel) model.value = conversation.model;
277
+ if (hasProvider) provider.value = conversation.provider;
278
+ if (hasJailbreak) jailbreak.value = conversation.jailbreak;
279
+
280
+ for (item of conversation.items) {
281
+ if (is_assistant(item.role)) {
282
+ message_box.innerHTML += load_gpt_message_box(item.content);
283
+ } else {
284
+ message_box.innerHTML += load_user_message_box(item.content);
285
+ }
286
+ }
287
+
288
+ document.querySelectorAll(`code`).forEach((el) => {
289
+ hljs.highlightElement(el);
290
+ });
291
+
292
+ message_box.scrollTo({ top: message_box.scrollHeight, behavior: "smooth" });
293
+
294
+ setTimeout(() => {
295
+ message_box.scrollTop = message_box.scrollHeight;
296
+ }, 500);
297
+ };
298
+
299
+ const load_user_message_box = (content) => {
300
+ const messageDiv = createElement("div", { classNames: ["message"] });
301
+ const avatarContainer = createElement("div", {
302
+ classNames: ["avatar-container"],
303
+ innerHTML: user_image,
304
+ });
305
+ const contentDiv = createElement("div", { classNames: ["content"] });
306
+ const preElement = document.createElement("pre");
307
+ preElement.textContent = content;
308
+ contentDiv.appendChild(preElement);
309
+
310
+ messageDiv.append(avatarContainer, contentDiv);
311
+
312
+ return messageDiv.outerHTML;
313
+ };
314
+
315
+ const load_gpt_message_box = (content) => {
316
+ return `
317
+ <div class="message">
318
+ <div class="avatar-container">
319
+ ${gpt_image}
320
+ </div>
321
+ <div class="content">
322
+ ${markdown.render(content)}
323
+ </div>
324
+ </div>
325
+ `;
326
+ };
327
+
328
+ const is_assistant = (role) => {
329
+ return role == "assistant";
330
+ };
331
+
332
+ const get_conversation = async (conversation_id) => {
333
+ let conversation = await JSON.parse(localStorage.getItem(`conversation:${conversation_id}`));
334
+ return conversation.items;
335
+ };
336
+
337
+ const add_conversation = async (conversation_id, title) => {
338
+ if (localStorage.getItem(`conversation:${conversation_id}`) == null) {
339
+ jailbreak = document.getElementById("jailbreak");
340
+ model = document.getElementById("model");
341
+ provider = document.getElementById("provider");
342
+ localStorage.setItem(
343
+ `conversation:${conversation_id}`,
344
+ JSON.stringify({
345
+ id: conversation_id,
346
+ title: title,
347
+ items: [],
348
+ created_at: Date.now(),
349
+ model: model.options[model.selectedIndex].value,
350
+ provider: provider.options[provider.selectedIndex].value,
351
+ jailbreak: jailbreak.options[jailbreak.selectedIndex].value,
352
+ })
353
+ );
354
+ }
355
+ };
356
+
357
+ const add_message = async (conversation_id, role, content) => {
358
+ let before_adding = JSON.parse(localStorage.getItem(`conversation:${conversation_id}`));
359
+
360
+ before_adding.items.push({
361
+ role: role,
362
+ content: content,
363
+ });
364
+
365
+ localStorage.setItem(`conversation:${conversation_id}`, JSON.stringify(before_adding)); // update conversation
366
+ };
367
+
368
+ const load_conversations = async (limit, offset, loader) => {
369
+ //console.log(loader);
370
+ //if (loader === undefined) box_conversations.appendChild(spinner);
371
+
372
+ let conversations = [];
373
+ for (let i = 0; i < localStorage.length; i++) {
374
+ if (localStorage.key(i).startsWith("conversation:")) {
375
+ let conversation = localStorage.getItem(localStorage.key(i));
376
+ conversations.push(JSON.parse(conversation));
377
+ }
378
+ }
379
+
380
+ conversations.sort((a, b) => b.created_at - a.created_at);
381
+
382
+ //if (loader === undefined) spinner.parentNode.removeChild(spinner)
383
+ await clear_conversations();
384
+
385
+ for (conversation of conversations) {
386
+ box_conversations.innerHTML += `
387
+ <div class="conversation-sidebar">
388
+ <div class="left" onclick="set_conversation('${conversation.id}')">
389
+ <i class="fa-regular fa-comments"></i>
390
+ <span class="conversation-title">${conversation.title}</span>
391
+ </div>
392
+ <i onclick="delete_conversation('${conversation.id}')" class="fa-regular fa-trash"></i>
393
+ </div>
394
+ `;
395
+ }
396
+
397
+ document.querySelectorAll(`code`).forEach((el) => {
398
+ hljs.highlightElement(el);
399
+ });
400
+ };
401
+
402
+ document.getElementById(`cancelButton`).addEventListener(`click`, async () => {
403
+ window.controller.abort();
404
+ console.log(`aborted ${window.conversation_id}`);
405
+ });
406
+
407
+ function h2a(str1) {
408
+ var hex = str1.toString();
409
+ var str = "";
410
+
411
+ for (var n = 0; n < hex.length; n += 2) {
412
+ str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
413
+ }
414
+
415
+ return str;
416
+ }
417
+
418
+ const uuid = () => {
419
+ return `xxxxxxxx-xxxx-4xxx-yxxx-${Date.now().toString(16)}`.replace(/[xy]/g, function (c) {
420
+ var r = (Math.random() * 16) | 0,
421
+ v = c == "x" ? r : (r & 0x3) | 0x8;
422
+ return v.toString(16);
423
+ });
424
+ };
425
+
426
+ const message_id = () => {
427
+ random_bytes = (Math.floor(Math.random() * 1338377565) + 2956589730).toString(2);
428
+ unix = Math.floor(Date.now() / 1000).toString(2);
429
+
430
+ return BigInt(`0b${unix}${random_bytes}`).toString();
431
+ };
432
+
433
+ window.onload = async () => {
434
+ load_settings_localstorage();
435
+
436
+ conversations = 0;
437
+ for (let i = 0; i < localStorage.length; i++) {
438
+ if (localStorage.key(i).startsWith("conversation:")) {
439
+ conversations += 1;
440
+ }
441
+ }
442
+
443
+ if (conversations == 0) localStorage.clear();
444
+
445
+ await setTimeout(() => {
446
+ load_conversations(20, 0);
447
+ }, 1);
448
+
449
+ if (!window.location.href.endsWith(`#`)) {
450
+ if (/\/chat\/.+/.test(window.location.href.slice(url_prefix.length))) {
451
+ await load_conversation(window.conversation_id);
452
+ }
453
+ }
454
+
455
+ message_input.addEventListener("keydown", async (evt) => {
456
+ if (prompt_lock) return;
457
+
458
+ if (evt.key === "Enter" && !evt.shiftKey) {
459
+ evt.preventDefault();
460
+ await handle_ask();
461
+ }
462
+ });
463
+
464
+ send_button.addEventListener("click", async (event) => {
465
+ event.preventDefault();
466
+ if (prompt_lock) return;
467
+ message_input.blur();
468
+ await handle_ask();
469
+ });
470
+
471
+ register_settings_localstorage();
472
+ };
473
+
474
+ const register_settings_localstorage = async () => {
475
+ settings_ids = ["switch", "model", "jailbreak"];
476
+ settings_elements = settings_ids.map((id) => document.getElementById(id));
477
+ settings_elements.map((element) =>
478
+ element.addEventListener(`change`, async (event) => {
479
+ switch (event.target.type) {
480
+ case "checkbox":
481
+ localStorage.setItem(event.target.id, event.target.checked);
482
+ break;
483
+ case "select-one":
484
+ localStorage.setItem(event.target.id, event.target.selectedIndex);
485
+ break;
486
+ default:
487
+ console.warn("Unresolved element type");
488
+ }
489
+ })
490
+ );
491
+ };
492
+
493
+ const load_settings_localstorage = async () => {
494
+ settings_ids = ["switch", "model", "jailbreak"];
495
+ settings_elements = settings_ids.map((id) => document.getElementById(id));
496
+ settings_elements.map((element) => {
497
+ if (localStorage.getItem(element.id)) {
498
+ switch (element.type) {
499
+ case "checkbox":
500
+ element.checked = localStorage.getItem(element.id) === "true";
501
+ break;
502
+ case "select-one":
503
+ element.selectedIndex = parseInt(localStorage.getItem(element.id));
504
+ break;
505
+ default:
506
+ console.warn("Unresolved element type");
507
+ }
508
+ }
509
+ });
510
+ };
511
+
512
+ function clearTextarea(textarea) {
513
+ textarea.style.removeProperty("height");
514
+ textarea.style.height = `${textarea.scrollHeight + 4}px`;
515
+ if (textarea.value.trim() === "" && textarea.value.includes("\n")) {
516
+ textarea.value = "";
517
+ }
518
+ }
519
+
520
+ function createElement(tag, { classNames, id, innerHTML, textContent } = {}) {
521
+ const el = document.createElement(tag);
522
+ if (classNames) {
523
+ el.classList.add(...classNames);
524
+ }
525
+ if (id) {
526
+ el.id = id;
527
+ }
528
+ if (innerHTML) {
529
+ el.innerHTML = innerHTML;
530
+ }
531
+ if (textContent) {
532
+ const preElement = document.createElement("pre");
533
+ preElement.textContent = textContent;
534
+ el.appendChild(preElement);
535
+ }
536
+ return el;
537
+ }
538
+
539
+ //(async () => {
540
+ //response = await fetch('/backend-api/v2/providers')
541
+ // providers = await response.json()
542
+
543
+ // let select = document.getElementById('provider');
544
+ // select.textContent = '';
545
+ //
546
+ // let auto = document.createElement('option');
547
+ // auto.value = '';
548
+ // auto.text = 'Provider: Auto';
549
+ // select.appendChild(auto);
550
+ //
551
+ // for (provider of providers) {
552
+ // let option = document.createElement('option');
553
+ // option.value = option.text = provider;
554
+ // select.appendChild(option);
555
+ // }
556
+ //})
557
+ //();
client/js/fullscreen-toggle.js ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let shiftAmount = 70;
2
+ let mainContainer = document.querySelector('.main-container');
3
+
4
+ function shiftContentUp() {
5
+ mainContainer.style.marginTop = "-" + shiftAmount + "%";
6
+ }
7
+
8
+ function resetContent() {
9
+ mainContainer.style.marginTop = "0";
10
+ }
11
+
12
+ function toggleFullScreen() {
13
+ if (!document.fullscreenElement) {
14
+ const elementToFullScreen = document.documentElement;
15
+ if (elementToFullScreen.mozRequestFullScreen) { // Firefox
16
+ elementToFullScreen.mozRequestFullScreen();
17
+ } else if (elementToFullScreen.webkitRequestFullscreen) { // Chrome, Safari und Opera
18
+ elementToFullScreen.webkitRequestFullscreen();
19
+ } else if (elementToFullScreen.msRequestFullscreen) { // Internet Explorer und Edge
20
+ elementToFullScreen.msRequestFullscreen();
21
+ }
22
+ } else {
23
+ if (document.mozCancelFullScreen) { // Firefox
24
+ document.mozCancelFullScreen();
25
+ } else if (document.webkitExitFullscreen) { // Chrome, Safari und Opera
26
+ document.webkitExitFullscreen();
27
+ } else if (document.msExitFullscreen) { // Internet Explorer und Edge
28
+ document.msExitFullscreen();
29
+ }
30
+ }
31
+ };
32
+
33
+ document.getElementById('message-input').addEventListener('focus', function() {
34
+ if (document.fullscreenElement) {
35
+ shiftContentUp();
36
+ }
37
+ });
38
+
39
+ document.getElementById('message-input').addEventListener('blur', function() {
40
+ if (document.fullscreenElement) {
41
+ resetContent();
42
+ }
43
+ });
44
+
45
+ document.addEventListener('fullscreenchange', function() {
46
+ if (document.fullscreenElement) {
47
+ document.getElementById('fullscreen-toggle').checked = true;
48
+ } else {
49
+ document.getElementById('fullscreen-toggle').checked = false;
50
+ }
51
+ });
52
+
53
+ document.getElementById('fullscreen-toggle').addEventListener('change', function() {
54
+ toggleFullScreen(this.checked);
55
+ });
56
+
client/js/highlight.min.js ADDED
The diff for this file is too large to render. See raw diff
 
client/js/highlightjs-copy.min.js ADDED
@@ -0,0 +1 @@
 
 
1
+ class CopyButtonPlugin{constructor(options={}){self.hook=options.hook;self.callback=options.callback}"after:highlightElement"({el,text}){let button=Object.assign(document.createElement("button"),{innerHTML:"Copy",className:"hljs-copy-button"});button.dataset.copied=false;el.parentElement.classList.add("hljs-copy-wrapper");el.parentElement.appendChild(button);el.parentElement.style.setProperty("--hljs-theme-background",window.getComputedStyle(el).backgroundColor);button.onclick=function(){if(!navigator.clipboard)return;let newText=text;if(hook&&typeof hook==="function"){newText=hook(text,el)||text}navigator.clipboard.writeText(newText).then(function(){button.innerHTML="Copied!";button.dataset.copied=true;let alert=Object.assign(document.createElement("div"),{role:"status",className:"hljs-copy-alert",innerHTML:"Copied to clipboard"});el.parentElement.appendChild(alert);setTimeout(()=>{button.innerHTML="Copy";button.dataset.copied=false;el.parentElement.removeChild(alert);alert=null},2e3)}).then(function(){if(typeof callback==="function")return callback(newText,el)})}}}
client/js/icons.js ADDED
@@ -0,0 +1 @@
 
 
1
+ window.FontAwesomeKitConfig={asyncLoading:{enabled:!1},autoA11y:{enabled:!0},baseUrl:"https://ka-f.fontawesome.com",baseUrlKit:"https://kit-pro.fontawesome.com",detectConflictsUntil:null,iconUploads:{},id:96462084,license:"pro",method:"css",minify:{enabled:!0},token:"d0514f1901",v4FontFaceShim:{enabled:!0},v4shim:{enabled:!0},v5FontFaceShim:{enabled:!0},version:"6.1.1"},function(t){"function"==typeof define&&define.amd?define("kit-loader",t):t()}(function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,o)}return n}function o(t){for(var o=1;o<arguments.length;o++){var r=null!=arguments[o]?arguments[o]:{};o%2?n(Object(r),!0).forEach(function(n){e(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],o=!0,r=!1,i=void 0;try{for(var c,a=t[Symbol.iterator]();!(o=(c=a.next()).done)&&(n.push(c.value),!e||n.length!==e);o=!0);}catch(t){r=!0,i=t}finally{try{o||null==a.return||a.return()}finally{if(r)throw i}}return n}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n<e;n++)o[n]=t[n];return o}function c(t,e){var n=e&&e.addOn||"",o=e&&e.baseFilename||t.license+n,r=e&&e.minify?".min":"",i=e&&e.fileSuffix||t.method,c=e&&e.subdir||t.method;return t.baseUrl+"/releases/"+("latest"===t.version?"latest":"v".concat(t.version))+"/"+c+"/"+o+r+"."+i}function a(t,e){var n=e||["fa"],o="."+Array.prototype.join.call(n,",."),r=t.querySelectorAll(o);Array.prototype.forEach.call(r,function(e){var n=e.getAttribute("title");e.setAttribute("aria-hidden","true");var o=!e.nextElementSibling||!e.nextElementSibling.classList.contains("sr-only");if(n&&o){var r=t.createElement("span");r.innerHTML=n,r.classList.add("sr-only"),e.parentNode.insertBefore(r,e.nextSibling)}})}var u,f=function(){},s="undefined"!=typeof global&&void 0!==global.process&&"function"==typeof global.process.emit,d="undefined"==typeof setImmediate?setTimeout:setImmediate,l=[];function h(){for(var t=0;t<l.length;t++)l[t][0](l[t][1]);l=[],u=!1}function m(t,e){l.push([t,e]),u||(u=!0,d(h,0))}function p(t){var e=t.owner,n=e._state,o=e._data,r=t[n],i=t.then;if("function"==typeof r){n="fulfilled";try{o=r(o)}catch(t){g(i,t)}}v(i,o)||("fulfilled"===n&&b(i,o),"rejected"===n&&g(i,o))}function v(e,n){var o;try{if(e===n)throw new TypeError("A promises callback cannot return that same promise.");if(n&&("function"==typeof n||"object"===t(n))){var r=n.then;if("function"==typeof r)return r.call(n,function(t){o||(o=!0,n===t?y(e,t):b(e,t))},function(t){o||(o=!0,g(e,t))}),!0}}catch(t){return o||g(e,t),!0}return!1}function b(t,e){t!==e&&v(t,e)||y(t,e)}function y(t,e){"pending"===t._state&&(t._state="settled",t._data=e,m(A,t))}function g(t,e){"pending"===t._state&&(t._state="settled",t._data=e,m(S,t))}function w(t){t._then=t._then.forEach(p)}function A(t){t._state="fulfilled",w(t)}function S(t){t._state="rejected",w(t),!t._handled&&s&&global.process.emit("unhandledRejection",t._data,t)}function O(t){global.process.emit("rejectionHandled",t)}function j(t){if("function"!=typeof t)throw new TypeError("Promise resolver "+t+" is not a function");if(this instanceof j==0)throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._then=[],function(t,e){function n(t){g(e,t)}try{t(function(t){b(e,t)},n)}catch(t){n(t)}}(t,this)}j.prototype={constructor:j,_state:"pending",_then:null,_data:void 0,_handled:!1,then:function(t,e){var n={owner:this,then:new this.constructor(f),fulfilled:t,rejected:e};return!e&&!t||this._handled||(this._handled=!0,"rejected"===this._state&&s&&m(O,this)),"fulfilled"===this._state||"rejected"===this._state?m(p,n):this._then.push(n),n.then},catch:function(t){return this.then(null,t)}},j.all=function(t){if(!Array.isArray(t))throw new TypeError("You must pass an array to Promise.all().");return new j(function(e,n){var o=[],r=0;function i(t){return r++,function(n){o[t]=n,--r||e(o)}}for(var c,a=0;a<t.length;a++)(c=t[a])&&"function"==typeof c.then?c.then(i(a),n):o[a]=c;r||e(o)})},j.race=function(t){if(!Array.isArray(t))throw new TypeError("You must pass an array to Promise.race().");return new j(function(e,n){for(var o,r=0;r<t.length;r++)(o=t[r])&&"function"==typeof o.then?o.then(e,n):e(o)})},j.resolve=function(e){return e&&"object"===t(e)&&e.constructor===j?e:new j(function(t){t(e)})},j.reject=function(t){return new j(function(e,n){n(t)})};var F="function"==typeof Promise?Promise:j;function E(t,e){var n=e.fetch,o=e.XMLHttpRequest,r=e.token,i=t;return"URLSearchParams"in window?(i=new URL(t)).searchParams.set("token",r):i=i+"?token="+encodeURIComponent(r),i=i.toString(),new F(function(t,e){if("function"==typeof n)n(i,{mode:"cors",cache:"default"}).then(function(t){if(t.ok)return t.text();throw new Error("")}).then(function(e){t(e)}).catch(e);else if("function"==typeof o){var r=new o;r.addEventListener("loadend",function(){this.responseText?t(this.responseText):e(new Error(""))}),["abort","error","timeout"].map(function(t){r.addEventListener(t,function(){e(new Error(""))})}),r.open("GET",i),r.send()}else e(new Error(""))})}function _(t,e,n){var o=t;return[[/(url\("?)\.\.\/\.\.\/\.\./g,function(t,n){return"".concat(n).concat(e)}],[/(url\("?)\.\.\/webfonts/g,function(t,o){return"".concat(o).concat(e,"/releases/v").concat(n,"/webfonts")}],[/(url\("?)https:\/\/kit-free([^.])*\.fontawesome\.com/g,function(t,n){return"".concat(n).concat(e)}]].forEach(function(t){var e=r(t,2),n=e[0],i=e[1];o=o.replace(n,i)}),o}function C(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},r=e.document||r,i=a.bind(a,r,["fa","fab","fas","far","fal","fad","fak"]),u=Object.keys(t.iconUploads||{}).length>0;t.autoA11y.enabled&&n(i);var f=[{id:"fa-main",addOn:void 0}];t.v4shim&&t.v4shim.enabled&&f.push({id:"fa-v4-shims",addOn:"-v4-shims"}),t.v5FontFaceShim&&t.v5FontFaceShim.enabled&&f.push({id:"fa-v5-font-face",addOn:"-v5-font-face"}),t.v4FontFaceShim&&t.v4FontFaceShim.enabled&&f.push({id:"fa-v4-font-face",addOn:"-v4-font-face"}),u&&f.push({id:"fa-kit-upload",customCss:!0});var s=f.map(function(n){return new F(function(r,i){E(n.customCss?function(t){return t.baseUrlKit+"/"+t.token+"/"+t.id+"/kit-upload.css"}(t):c(t,{addOn:n.addOn,minify:t.minify.enabled}),e).then(function(i){r(function(t,e){var n=e.contentFilter||function(t,e){return t},o=document.createElement("style"),r=document.createTextNode(n(t,e));return o.appendChild(r),o.media="all",e.id&&o.setAttribute("id",e.id),e&&e.detectingConflicts&&e.detectionIgnoreAttr&&o.setAttributeNode(document.createAttribute(e.detectionIgnoreAttr)),o}(i,o(o({},e),{},{baseUrl:t.baseUrl,version:t.version,id:n.id,contentFilter:function(t,e){return _(t,e.baseUrl,e.version)}})))}).catch(i)})});return F.all(s)}function P(t,e){var n=document.createElement("SCRIPT"),o=document.createTextNode(t);return n.appendChild(o),n.referrerPolicy="strict-origin",e.id&&n.setAttribute("id",e.id),e&&e.detectingConflicts&&e.detectionIgnoreAttr&&n.setAttributeNode(document.createAttribute(e.detectionIgnoreAttr)),n}function U(t){var e,n=[],o=document,r=(o.documentElement.doScroll?/^loaded|^c/:/^loaded|^i|^c/).test(o.readyState);r||o.addEventListener("DOMContentLoaded",e=function(){for(o.removeEventListener("DOMContentLoaded",e),r=1;e=n.shift();)e()}),r?setTimeout(t,0):n.push(t)}try{if(window.FontAwesomeKitConfig){var k=window.FontAwesomeKitConfig,L={detectingConflicts:k.detectConflictsUntil&&new Date<=new Date(k.detectConflictsUntil),detectionIgnoreAttr:"data-fa-detection-ignore",fetch:window.fetch,token:k.token,XMLHttpRequest:window.XMLHttpRequest,document:document},I=document.currentScript,T=I?I.parentElement:document.head;(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"js"===t.method?function(t,e){e.autoA11y=t.autoA11y.enabled,"pro"===t.license&&(e.autoFetchSvg=!0,e.fetchSvgFrom=t.baseUrl+"/releases/"+("latest"===t.version?"latest":"v".concat(t.version))+"/svgs",e.fetchUploadedSvgFrom=t.uploadsUrl);var n=[];return t.v4shim.enabled&&n.push(new F(function(n,r){E(c(t,{addOn:"-v4-shims",minify:t.minify.enabled}),e).then(function(t){n(P(t,o(o({},e),{},{id:"fa-v4-shims"})))}).catch(r)})),n.push(new F(function(n,r){E(c(t,{minify:t.minify.enabled}),e).then(function(t){var r=P(t,o(o({},e),{},{id:"fa-main"}));n(function(t,e){var n=e&&void 0!==e.autoFetchSvg?e.autoFetchSvg:void 0,o=e&&void 0!==e.autoA11y?e.autoA11y:void 0;return void 0!==o&&t.setAttribute("data-auto-a11y",o?"true":"false"),n&&(t.setAttributeNode(document.createAttribute("data-auto-fetch-svg")),t.setAttribute("data-fetch-svg-from",e.fetchSvgFrom),t.setAttribute("data-fetch-uploaded-svg-from",e.fetchUploadedSvgFrom)),t}(r,e))}).catch(r)})),F.all(n)}(t,e):"css"===t.method?C(t,e,function(t){U(t),function(t){"undefined"!=typeof MutationObserver&&new MutationObserver(t).observe(document,{childList:!0,subtree:!0})}(t)}):void 0})(k,L).then(function(t){t.map(function(t){try{T.insertBefore(t,I?I.nextSibling:null)}catch(e){T.appendChild(t)}}),L.detectingConflicts&&I&&U(function(){I.setAttributeNode(document.createAttribute(L.detectionIgnoreAttr));var t=function(t,e){var n=document.createElement("script");return e&&e.detectionIgnoreAttr&&n.setAttributeNode(document.createAttribute(e.detectionIgnoreAttr)),n.src=c(t,{baseFilename:"conflict-detection",fileSuffix:"js",subdir:"js",minify:t.minify.enabled}),n}(k,L);document.body.appendChild(t)})}).catch(function(t){console.error("".concat("Font Awesome Kit:"," ").concat(t))})}}catch(t){console.error("".concat("Font Awesome Kit:"," ").concat(t))}});
client/js/markdown-it.min.js ADDED
The diff for this file is too large to render. See raw diff
 
client/js/sidebar-toggler.js ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const sidebar = document.querySelector(".sidebar");
2
+ const menuButton = document.querySelector(".menu-button");
3
+
4
+ function toggleSidebar(event) {
5
+ if (sidebar.classList.contains("shown")) {
6
+ hideSidebar(event.target);
7
+ } else {
8
+ showSidebar(event.target);
9
+ }
10
+ window.scrollTo(0, 0);
11
+ }
12
+
13
+ function showSidebar(target) {
14
+ sidebar.classList.add("shown");
15
+ target.classList.add("rotated");
16
+ document.body.style.overflow = "hidden";
17
+ }
18
+
19
+ function hideSidebar(target) {
20
+ sidebar.classList.remove("shown");
21
+ target.classList.remove("rotated");
22
+ document.body.style.overflow = "auto";
23
+ }
24
+
25
+ menuButton.addEventListener("click", toggleSidebar);
26
+
27
+ document.body.addEventListener('click', function(event) {
28
+ if (!event.target.closest('.sidebar') && !event.target.closest('.menu-button') && !event.target.closest('.conversation-sidebar')){
29
+ hideSidebar(event.target);
30
+ }
31
+ if (event.target.matches('.conversation-title')) {
32
+ const menuButtonStyle = window.getComputedStyle(menuButton);
33
+ if (menuButtonStyle.display !== 'none') {
34
+ hideSidebar(menuButton);
35
+ }
36
+ }
37
+ });
client/js/theme-toggler.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var switch_theme_toggler = document.getElementById("theme-toggler");
2
+
3
+ switch_theme_toggler.addEventListener("change", toggleTheme);
4
+
5
+ function setTheme(themeName) {
6
+ localStorage.setItem("theme", themeName);
7
+ document.documentElement.className = themeName;
8
+ }
9
+
10
+ function toggleTheme() {
11
+ var currentTheme = localStorage.getItem("theme");
12
+ var newTheme = currentTheme === "theme-dark" ? "theme-light" : "theme-dark";
13
+
14
+ setTheme(newTheme);
15
+ switch_theme_toggler.checked = newTheme === "theme-dark";
16
+ }
17
+
18
+ (function () {
19
+ var currentTheme = localStorage.getItem("theme") || "theme-dark";
20
+ setTheme(currentTheme);
21
+ switch_theme_toggler.checked = currentTheme === "theme-dark";
22
+ })();
config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "site_config": {
3
+ "host": "0.0.0.0",
4
+ "port": 1338,
5
+ "debug": false
6
+ },
7
+ "url_prefix": ""
8
+ }
g4f/Provider/AItianhu.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+
5
+ from ..typing import AsyncResult, Messages
6
+ from ..requests import StreamSession
7
+ from .base_provider import AsyncGeneratorProvider, format_prompt, get_cookies
8
+
9
+
10
+ class AItianhu(AsyncGeneratorProvider):
11
+ url = "https://www.aitianhu.com"
12
+ working = False
13
+ supports_gpt_35_turbo = True
14
+
15
+ @classmethod
16
+ async def create_async_generator(
17
+ cls,
18
+ model: str,
19
+ messages: Messages,
20
+ proxy: str = None,
21
+ cookies: dict = None,
22
+ timeout: int = 120, **kwargs) -> AsyncResult:
23
+
24
+ if not cookies:
25
+ cookies = get_cookies(domain_name='www.aitianhu.com')
26
+ if not cookies:
27
+ raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies [refresh https://www.aitianhu.com on chrome]")
28
+
29
+ data = {
30
+ "prompt": format_prompt(messages),
31
+ "options": {},
32
+ "systemMessage": "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully.",
33
+ "temperature": 0.8,
34
+ "top_p": 1,
35
+ **kwargs
36
+ }
37
+
38
+ headers = {
39
+ 'authority': 'www.aitianhu.com',
40
+ 'accept': 'application/json, text/plain, */*',
41
+ 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
42
+ 'content-type': 'application/json',
43
+ 'origin': 'https://www.aitianhu.com',
44
+ 'referer': 'https://www.aitianhu.com/',
45
+ 'sec-ch-ua': '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
46
+ 'sec-ch-ua-mobile': '?0',
47
+ 'sec-ch-ua-platform': '"macOS"',
48
+ 'sec-fetch-dest': 'empty',
49
+ 'sec-fetch-mode': 'cors',
50
+ 'sec-fetch-site': 'same-origin',
51
+ 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36',
52
+ }
53
+
54
+ async with StreamSession(headers=headers,
55
+ cookies=cookies,
56
+ timeout=timeout,
57
+ proxies={"https": proxy},
58
+ impersonate="chrome107", verify=False) as session:
59
+
60
+ async with session.post(f"{cls.url}/api/chat-process", json=data) as response:
61
+ response.raise_for_status()
62
+
63
+ async for line in response.iter_lines():
64
+ if line == b"<script>":
65
+ raise RuntimeError("Solve challenge and pass cookies")
66
+
67
+ if b"platform's risk control" in line:
68
+ raise RuntimeError("Platform's Risk Control")
69
+
70
+ line = json.loads(line)
71
+
72
+ if "detail" not in line:
73
+ raise RuntimeError(f"Response: {line}")
74
+
75
+ content = line["detail"]["choices"][0]["delta"].get(
76
+ "content"
77
+ )
78
+ if content:
79
+ yield content
g4f/Provider/AItianhuSpace.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import time
4
+ import random
5
+
6
+ from ..typing import CreateResult, Messages
7
+ from .base_provider import AbstractProvider
8
+ from .helper import format_prompt, get_random_string
9
+ from ..webdriver import WebDriver, WebDriverSession
10
+ from .. import debug
11
+
12
+ class AItianhuSpace(AbstractProvider):
13
+ url = "https://chat3.aiyunos.top/"
14
+ working = True
15
+ supports_stream = True
16
+ supports_gpt_35_turbo = True
17
+ _domains = ["aitianhu.com", "aitianhu1.top"]
18
+
19
+ @classmethod
20
+ def create_completion(
21
+ cls,
22
+ model: str,
23
+ messages: Messages,
24
+ stream: bool,
25
+ domain: str = None,
26
+ proxy: str = None,
27
+ timeout: int = 120,
28
+ webdriver: WebDriver = None,
29
+ headless: bool = True,
30
+ **kwargs
31
+ ) -> CreateResult:
32
+ if not model:
33
+ model = "gpt-3.5-turbo"
34
+ if not domain:
35
+ rand = get_random_string(6)
36
+ domain = random.choice(cls._domains)
37
+ domain = f"{rand}.{domain}"
38
+ if debug.logging:
39
+ print(f"AItianhuSpace | using domain: {domain}")
40
+ url = f"https://{domain}"
41
+ prompt = format_prompt(messages)
42
+
43
+ with WebDriverSession(webdriver, "", headless=headless, proxy=proxy) as driver:
44
+ from selenium.webdriver.common.by import By
45
+ from selenium.webdriver.support.ui import WebDriverWait
46
+ from selenium.webdriver.support import expected_conditions as EC
47
+
48
+ wait = WebDriverWait(driver, timeout)
49
+
50
+ # Bypass devtools detection
51
+ driver.get("https://blank.page/")
52
+ wait.until(EC.visibility_of_element_located((By.ID, "sheet")))
53
+ driver.execute_script(f"""
54
+ document.getElementById('sheet').addEventListener('click', () => {{
55
+ window.open('{url}', '_blank');
56
+ }});
57
+ """)
58
+ driver.find_element(By.ID, "sheet").click()
59
+ time.sleep(10)
60
+
61
+ original_window = driver.current_window_handle
62
+ for window_handle in driver.window_handles:
63
+ if window_handle != original_window:
64
+ driver.close()
65
+ driver.switch_to.window(window_handle)
66
+ break
67
+
68
+ # Wait for page load
69
+ wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "textarea.n-input__textarea-el")))
70
+
71
+ # Register hook in XMLHttpRequest
72
+ script = """
73
+ const _http_request_open = XMLHttpRequest.prototype.open;
74
+ window._last_message = window._message = "";
75
+ window._loadend = false;
76
+ XMLHttpRequest.prototype.open = function(method, url) {
77
+ if (url == "/api/chat-process") {
78
+ this.addEventListener("progress", (event) => {
79
+ const lines = this.responseText.split("\\n");
80
+ try {
81
+ window._message = JSON.parse(lines[lines.length-1])["text"];
82
+ } catch(e) { }
83
+ });
84
+ this.addEventListener("loadend", (event) => {
85
+ window._loadend = true;
86
+ });
87
+ }
88
+ return _http_request_open.call(this, method, url);
89
+ }
90
+ """
91
+ driver.execute_script(script)
92
+
93
+ # Submit prompt
94
+ driver.find_element(By.CSS_SELECTOR, "textarea.n-input__textarea-el").send_keys(prompt)
95
+ driver.find_element(By.CSS_SELECTOR, "button.n-button.n-button--primary-type.n-button--medium-type").click()
96
+
97
+ # Read response
98
+ while True:
99
+ chunk = driver.execute_script("""
100
+ if (window._message && window._message != window._last_message) {
101
+ try {
102
+ return window._message.substring(window._last_message.length);
103
+ } finally {
104
+ window._last_message = window._message;
105
+ }
106
+ }
107
+ if (window._loadend) {
108
+ return null;
109
+ }
110
+ return "";
111
+ """)
112
+ if chunk:
113
+ yield chunk
114
+ elif chunk != "":
115
+ break
116
+ else:
117
+ time.sleep(0.1)
g4f/Provider/AiAsk.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from aiohttp import ClientSession
4
+ from ..typing import AsyncResult, Messages
5
+ from .base_provider import AsyncGeneratorProvider
6
+
7
+ class AiAsk(AsyncGeneratorProvider):
8
+ url = "https://e.aiask.me"
9
+ supports_message_history = True
10
+ supports_gpt_35_turbo = True
11
+ working = False
12
+
13
+ @classmethod
14
+ async def create_async_generator(
15
+ cls,
16
+ model: str,
17
+ messages: Messages,
18
+ proxy: str = None,
19
+ **kwargs
20
+ ) -> AsyncResult:
21
+ headers = {
22
+ "accept": "application/json, text/plain, */*",
23
+ "origin": cls.url,
24
+ "referer": f"{cls.url}/chat",
25
+ }
26
+ async with ClientSession(headers=headers) as session:
27
+ data = {
28
+ "continuous": True,
29
+ "id": "fRMSQtuHl91A4De9cCvKD",
30
+ "list": messages,
31
+ "models": "0",
32
+ "prompt": "",
33
+ "temperature": kwargs.get("temperature", 0.5),
34
+ "title": "",
35
+ }
36
+ buffer = ""
37
+ rate_limit = "您的免费额度不够使用这个模型啦,请点击右上角登录继续使用!"
38
+ async with session.post(f"{cls.url}/v1/chat/gpt/", json=data, proxy=proxy) as response:
39
+ response.raise_for_status()
40
+ async for chunk in response.content.iter_any():
41
+ buffer += chunk.decode()
42
+ if not rate_limit.startswith(buffer):
43
+ yield buffer
44
+ buffer = ""
45
+ elif buffer == rate_limit:
46
+ raise RuntimeError("Rate limit reached")
g4f/Provider/AiChatOnline.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from aiohttp import ClientSession
5
+
6
+ from ..typing import AsyncResult, Messages
7
+ from .base_provider import AsyncGeneratorProvider
8
+ from .helper import get_random_string
9
+
10
+ class AiChatOnline(AsyncGeneratorProvider):
11
+ url = "https://aichatonline.org"
12
+ working = True
13
+ supports_gpt_35_turbo = True
14
+ supports_message_history = False
15
+
16
+ @classmethod
17
+ async def create_async_generator(
18
+ cls,
19
+ model: str,
20
+ messages: Messages,
21
+ proxy: str = None,
22
+ **kwargs
23
+ ) -> AsyncResult:
24
+ headers = {
25
+ "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0",
26
+ "Accept": "text/event-stream",
27
+ "Accept-Language": "de,en-US;q=0.7,en;q=0.3",
28
+ "Accept-Encoding": "gzip, deflate, br",
29
+ "Referer": f"{cls.url}/chatgpt/chat/",
30
+ "Content-Type": "application/json",
31
+ "Origin": cls.url,
32
+ "Alt-Used": "aichatonline.org",
33
+ "Connection": "keep-alive",
34
+ "Sec-Fetch-Dest": "empty",
35
+ "Sec-Fetch-Mode": "cors",
36
+ "Sec-Fetch-Site": "same-origin",
37
+ "TE": "trailers"
38
+ }
39
+ async with ClientSession(headers=headers) as session:
40
+ data = {
41
+ "botId": "default",
42
+ "customId": None,
43
+ "session": get_random_string(16),
44
+ "chatId": get_random_string(),
45
+ "contextId": 7,
46
+ "messages": messages,
47
+ "newMessage": messages[-1]["content"],
48
+ "newImageId": None,
49
+ "stream": True
50
+ }
51
+ async with session.post(f"{cls.url}/chatgpt/wp-json/mwai-ui/v1/chats/submit", json=data, proxy=proxy) as response:
52
+ response.raise_for_status()
53
+ async for chunk in response.content:
54
+ if chunk.startswith(b"data: "):
55
+ data = json.loads(chunk[6:])
56
+ if data["type"] == "live":
57
+ yield data["data"]
58
+ elif data["type"] == "end":
59
+ break
g4f/Provider/Aichat.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from aiohttp import ClientSession
4
+
5
+ from ..typing import Messages
6
+ from .base_provider import AsyncProvider, format_prompt
7
+ from .helper import get_cookies
8
+ from ..requests import StreamSession
9
+
10
+ class Aichat(AsyncProvider):
11
+ url = "https://chat-gpt.org/chat"
12
+ working = False
13
+ supports_gpt_35_turbo = True
14
+
15
+ @staticmethod
16
+ async def create_async(
17
+ model: str,
18
+ messages: Messages,
19
+ proxy: str = None, **kwargs) -> str:
20
+
21
+ cookies = get_cookies('chat-gpt.org') if not kwargs.get('cookies') else kwargs.get('cookies')
22
+ if not cookies:
23
+ raise RuntimeError(
24
+ "g4f.provider.Aichat requires cookies, [refresh https://chat-gpt.org on chrome]"
25
+ )
26
+
27
+ headers = {
28
+ 'authority': 'chat-gpt.org',
29
+ 'accept': '*/*',
30
+ 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
31
+ 'content-type': 'application/json',
32
+ 'origin': 'https://chat-gpt.org',
33
+ 'referer': 'https://chat-gpt.org/chat',
34
+ 'sec-ch-ua': '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
35
+ 'sec-ch-ua-mobile': '?0',
36
+ 'sec-ch-ua-platform': '"macOS"',
37
+ 'sec-fetch-dest': 'empty',
38
+ 'sec-fetch-mode': 'cors',
39
+ 'sec-fetch-site': 'same-origin',
40
+ 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36',
41
+ }
42
+
43
+ async with StreamSession(headers=headers,
44
+ cookies=cookies,
45
+ timeout=6,
46
+ proxies={"https": proxy} if proxy else None,
47
+ impersonate="chrome110", verify=False) as session:
48
+
49
+ json_data = {
50
+ "message": format_prompt(messages),
51
+ "temperature": kwargs.get('temperature', 0.5),
52
+ "presence_penalty": 0,
53
+ "top_p": kwargs.get('top_p', 1),
54
+ "frequency_penalty": 0,
55
+ }
56
+
57
+ async with session.post("https://chat-gpt.org/api/text",
58
+ json=json_data) as response:
59
+
60
+ response.raise_for_status()
61
+ result = await response.json()
62
+
63
+ if not result['response']:
64
+ raise Exception(f"Error Response: {result}")
65
+
66
+ return result["message"]
g4f/Provider/Aura.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+ from aiohttp import ClientSession
3
+ from ..typing import AsyncResult, Messages
4
+ from .base_provider import AsyncGeneratorProvider
5
+
6
+ class Aura(AsyncGeneratorProvider):
7
+ url = "https://openchat.team"
8
+ working = True
9
+ supports_gpt_35_turbo = True
10
+
11
+ @classmethod
12
+ async def create_async_generator(
13
+ cls,
14
+ model: str,
15
+ messages: Messages,
16
+ proxy: str = None,
17
+ **kwargs
18
+ ) -> AsyncResult:
19
+ headers = {
20
+ "Accept": "*/*",
21
+ "Accept-Encoding": "gzip, deflate, br",
22
+ "Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8",
23
+ "Content-Type": "application/json",
24
+ "Origin": f"{cls.url}",
25
+ "Referer": f"{cls.url}/",
26
+ "Sec-Ch-Ua": '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
27
+ "Sec-Ch-Ua-Mobile": "?0",
28
+ "Sec-Ch-Ua-Platform": '"Linux"',
29
+ "Sec-Fetch-Dest": "empty",
30
+ "Sec-Fetch-Mode": "cors",
31
+ "Sec-Fetch-Site": "same-origin",
32
+ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
33
+ }
34
+ async with ClientSession(headers=headers) as session:
35
+ new_messages = []
36
+ system_message = []
37
+ for message in messages:
38
+ if message["role"] == "system":
39
+ system_message.append(message["content"])
40
+ else:
41
+ new_messages.append(message)
42
+ data = {
43
+ "model": {
44
+ "id": "openchat_v3.2_mistral",
45
+ "name": "OpenChat Aura",
46
+ "maxLength": 24576,
47
+ "tokenLimit": 8192
48
+ },
49
+ "messages": new_messages,
50
+ "key": "",
51
+ "prompt": "\n".join(system_message),
52
+ "temperature": 0.5
53
+ }
54
+ async with session.post(f"{cls.url}/api/chat", json=data, proxy=proxy) as response:
55
+ async for chunk in response.content.iter_any():
56
+ yield chunk.decode()