Spaces:
Runtime error
Runtime error
Synced repo using 'sync_with_huggingface' Github Action
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- Dockerfile +16 -0
- LICENSE +674 -0
- client/css/api-key.css +26 -0
- client/css/button.css +26 -0
- client/css/buttons.css +4 -0
- client/css/checkbox.css +59 -0
- client/css/conversation.css +138 -0
- client/css/dropdown.css +10 -0
- client/css/field.css +11 -0
- client/css/global.css +81 -0
- client/css/hljs.css +92 -0
- client/css/label.css +16 -0
- client/css/main.css +7 -0
- client/css/message.css +55 -0
- client/css/options.css +10 -0
- client/css/select.css +20 -0
- client/css/sidebar.css +197 -0
- client/css/stop-generating.css +38 -0
- client/css/style.css +18 -0
- client/css/theme-toggler.css +33 -0
- client/css/typing.css +15 -0
- client/html/index.html +159 -0
- client/img/android-chrome-192x192.png +0 -0
- client/img/android-chrome-512x512.png +0 -0
- client/img/apple-touch-icon.png +0 -0
- client/img/favicon-16x16.png +0 -0
- client/img/favicon-32x32.png +0 -0
- client/img/favicon.ico +0 -0
- client/img/gpt.png +0 -0
- client/img/site.webmanifest +19 -0
- client/img/user.png +0 -0
- client/js/api-key.js +33 -0
- client/js/chat.js +516 -0
- client/js/highlight.min.js +0 -0
- client/js/highlightjs-copy.min.js +1 -0
- client/js/icons.js +1 -0
- client/js/theme-toggler.js +22 -0
- config.json +8 -0
- docker-compose.yml +11 -0
- g4f/Provider/Provider.py +16 -0
- g4f/Provider/Providers/Chimera.py +64 -0
- g4f/Provider/__init__.py +4 -0
- g4f/__init__.py +39 -0
- g4f/models.py +93 -0
- g4f/typing.py +3 -0
- g4f/utils.py +49 -0
- requirements.txt +23 -0
- run.py +39 -0
- server/backend.py +179 -0
- server/bp.py +6 -0
Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 apt-get update && \
|
11 |
+
apt-get install -y --no-install-recommends build-essential libffi-dev cmake libcurl4-openssl-dev && \
|
12 |
+
pip3 install --no-cache-dir -r requirements.txt
|
13 |
+
|
14 |
+
COPY . .
|
15 |
+
|
16 |
+
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>.
|
client/css/api-key.css
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.api-key-container {
|
2 |
+
margin: 24px 12px 0;
|
3 |
+
display: flex;
|
4 |
+
justify-content: center;
|
5 |
+
}
|
6 |
+
|
7 |
+
.api-key-container .button {
|
8 |
+
color: var(--colour-3);
|
9 |
+
}
|
10 |
+
|
11 |
+
.api-key-container #show-api-key-button {
|
12 |
+
width: 90%;
|
13 |
+
}
|
14 |
+
|
15 |
+
.api-key-container #api-key-ok-button {
|
16 |
+
width: 30%;
|
17 |
+
}
|
18 |
+
|
19 |
+
.api-key-container input {
|
20 |
+
color: var(--colour-3);
|
21 |
+
margin: 0px 4px;
|
22 |
+
border: 1px solid var(--conversations);
|
23 |
+
border-radius: var(--border-radius-1);
|
24 |
+
background: transparent;
|
25 |
+
width: 70%;
|
26 |
+
}
|
client/css/button.css
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.button {
|
2 |
+
display: flex;
|
3 |
+
padding: 8px 12px;
|
4 |
+
align-items: center;
|
5 |
+
justify-content: center;
|
6 |
+
border: 1px solid var(--conversations);
|
7 |
+
border-radius: var(--border-radius-1);
|
8 |
+
width: 100%;
|
9 |
+
background: transparent;
|
10 |
+
cursor: pointer;
|
11 |
+
}
|
12 |
+
|
13 |
+
.button span {
|
14 |
+
color: var(--colour-3);
|
15 |
+
font-size: 0.875rem;
|
16 |
+
}
|
17 |
+
|
18 |
+
.button i::before {
|
19 |
+
margin-right: 8px;
|
20 |
+
}
|
21 |
+
|
22 |
+
@media screen and (max-width: 990px) {
|
23 |
+
.button span {
|
24 |
+
font-size: 0.75rem;
|
25 |
+
}
|
26 |
+
}
|
client/css/buttons.css
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.buttons {
|
2 |
+
display: flex;
|
3 |
+
justify-content: left;
|
4 |
+
}
|
client/css/checkbox.css
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-3);
|
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 span {
|
42 |
+
font-size: 0.75rem;
|
43 |
+
}
|
44 |
+
|
45 |
+
.checkbox label {
|
46 |
+
width: 25px;
|
47 |
+
height: 15px;
|
48 |
+
}
|
49 |
+
|
50 |
+
.checkbox label:after {
|
51 |
+
left: 2px;
|
52 |
+
width: 10px;
|
53 |
+
height: 10px;
|
54 |
+
}
|
55 |
+
|
56 |
+
.checkbox input:checked + label:after {
|
57 |
+
left: calc(100% - 2px - 10px);
|
58 |
+
}
|
59 |
+
}
|
client/css/conversation.css
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.conversation {
|
2 |
+
width: 60%;
|
3 |
+
margin: 0px 16px;
|
4 |
+
display: flex;
|
5 |
+
flex-direction: column;
|
6 |
+
}
|
7 |
+
|
8 |
+
.conversation #messages {
|
9 |
+
width: 100%;
|
10 |
+
display: flex;
|
11 |
+
flex-direction: column;
|
12 |
+
overflow: auto;
|
13 |
+
overflow-wrap: break-word;
|
14 |
+
padding-bottom: 8px;
|
15 |
+
}
|
16 |
+
|
17 |
+
.conversation .user-input {
|
18 |
+
max-height: 180px;
|
19 |
+
margin: 16px 0px;
|
20 |
+
}
|
21 |
+
|
22 |
+
.conversation .user-input input {
|
23 |
+
font-size: 1rem;
|
24 |
+
background: none;
|
25 |
+
border: none;
|
26 |
+
outline: none;
|
27 |
+
color: var(--colour-3);
|
28 |
+
}
|
29 |
+
|
30 |
+
.conversation .user-input input::placeholder {
|
31 |
+
color: var(--user-input);
|
32 |
+
}
|
33 |
+
|
34 |
+
.conversation-title {
|
35 |
+
color: var(--colour-3);
|
36 |
+
font-size: 14px;
|
37 |
+
}
|
38 |
+
|
39 |
+
.conversation .user-input textarea {
|
40 |
+
font-size: 1rem;
|
41 |
+
width: 100%;
|
42 |
+
height: 100%;
|
43 |
+
padding: 12px;
|
44 |
+
background: none;
|
45 |
+
border: none;
|
46 |
+
outline: none;
|
47 |
+
color: var(--colour-3);
|
48 |
+
resize: vertical;
|
49 |
+
max-height: 150px;
|
50 |
+
min-height: 80px;
|
51 |
+
}
|
52 |
+
|
53 |
+
.box {
|
54 |
+
backdrop-filter: blur(20px);
|
55 |
+
-webkit-backdrop-filter: blur(20px);
|
56 |
+
background-color: var(--blur-bg);
|
57 |
+
height: 100%;
|
58 |
+
width: 100%;
|
59 |
+
border-radius: var(--border-radius-1);
|
60 |
+
border: 1px solid var(--blur-border);
|
61 |
+
}
|
62 |
+
|
63 |
+
.box.input-box {
|
64 |
+
position: relative;
|
65 |
+
align-items: center;
|
66 |
+
padding: 8px;
|
67 |
+
cursor: pointer;
|
68 |
+
}
|
69 |
+
|
70 |
+
#send-button {
|
71 |
+
position: absolute;
|
72 |
+
bottom: 25%;
|
73 |
+
right: 10px;
|
74 |
+
z-index: 1;
|
75 |
+
padding: 16px;
|
76 |
+
}
|
77 |
+
|
78 |
+
#cursor {
|
79 |
+
line-height: 17px;
|
80 |
+
margin-left: 3px;
|
81 |
+
-webkit-animation: blink 0.8s infinite;
|
82 |
+
animation: blink 0.8s infinite;
|
83 |
+
width: 7px;
|
84 |
+
height: 15px;
|
85 |
+
}
|
86 |
+
|
87 |
+
@keyframes blink {
|
88 |
+
0% {
|
89 |
+
background: #ffffff00;
|
90 |
+
}
|
91 |
+
|
92 |
+
50% {
|
93 |
+
background: white;
|
94 |
+
}
|
95 |
+
|
96 |
+
100% {
|
97 |
+
background: #ffffff00;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
@-webkit-keyframes blink {
|
102 |
+
0% {
|
103 |
+
background: #ffffff00;
|
104 |
+
}
|
105 |
+
|
106 |
+
50% {
|
107 |
+
background: white;
|
108 |
+
}
|
109 |
+
|
110 |
+
100% {
|
111 |
+
background: #ffffff00;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
/* scrollbar */
|
116 |
+
.conversation #messages::-webkit-scrollbar {
|
117 |
+
width: 4px;
|
118 |
+
padding: 8px 0px;
|
119 |
+
}
|
120 |
+
|
121 |
+
.conversation #messages::-webkit-scrollbar-track {
|
122 |
+
background-color: #ffffff00;
|
123 |
+
}
|
124 |
+
|
125 |
+
.conversation #messages::-webkit-scrollbar-thumb {
|
126 |
+
background-color: #555555;
|
127 |
+
border-radius: 10px;
|
128 |
+
}
|
129 |
+
|
130 |
+
@media screen and (max-height: 720px) {
|
131 |
+
.conversation.box {
|
132 |
+
height: 70%;
|
133 |
+
}
|
134 |
+
|
135 |
+
.conversation .user-input textarea {
|
136 |
+
font-size: 0.875rem;
|
137 |
+
}
|
138 |
+
}
|
client/css/dropdown.css
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.dropdown {
|
2 |
+
border: 1px solid var(--conversations);
|
3 |
+
}
|
4 |
+
|
5 |
+
@media screen and (max-width: 990px) {
|
6 |
+
.dropdown {
|
7 |
+
padding: 4px 8px;
|
8 |
+
font-size: 0.75rem;
|
9 |
+
}
|
10 |
+
}
|
client/css/field.css
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.field {
|
2 |
+
display: flex;
|
3 |
+
align-items: center;
|
4 |
+
padding: 4px;
|
5 |
+
}
|
6 |
+
|
7 |
+
@media screen and (max-width: 990px) {
|
8 |
+
.field {
|
9 |
+
flex-wrap: nowrap;
|
10 |
+
}
|
11 |
+
}
|
client/css/global.css
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
21 |
+
--accent: #3a3a3a;
|
22 |
+
--blur-bg: #ffffff;
|
23 |
+
--blur-border: #dbdbdb;
|
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: #242627;
|
39 |
+
--user-input: #f5f5f5;
|
40 |
+
--conversations: #555555;
|
41 |
+
}
|
42 |
+
|
43 |
+
html,
|
44 |
+
body {
|
45 |
+
background: var(--colour-1);
|
46 |
+
color: var(--colour-3);
|
47 |
+
}
|
48 |
+
|
49 |
+
ol,
|
50 |
+
ul {
|
51 |
+
padding-left: 20px;
|
52 |
+
}
|
53 |
+
|
54 |
+
.shown {
|
55 |
+
display: flex !important;
|
56 |
+
}
|
57 |
+
|
58 |
+
a:-webkit-any-link {
|
59 |
+
color: var(--accent);
|
60 |
+
}
|
61 |
+
|
62 |
+
.hidden {
|
63 |
+
display: none !important;
|
64 |
+
}
|
65 |
+
|
66 |
+
.fade-in {
|
67 |
+
opacity: 0;
|
68 |
+
animation: fadeIn 1s forwards;
|
69 |
+
}
|
70 |
+
|
71 |
+
@keyframes fadeIn {
|
72 |
+
to {
|
73 |
+
opacity: 1;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
@media screen and (max-height: 720px) {
|
78 |
+
:root {
|
79 |
+
--section-gap: 16px;
|
80 |
+
}
|
81 |
+
}
|
client/css/hljs.css
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.hljs {
|
2 |
+
color: #e9e9f4;
|
3 |
+
background: #28293629;
|
4 |
+
border-radius: var(--border-radius-1);
|
5 |
+
border: 1px solid var(--blur-border);
|
6 |
+
font-size: 15px;
|
7 |
+
word-wrap: break-word;
|
8 |
+
white-space: pre-wrap;
|
9 |
+
}
|
10 |
+
|
11 |
+
#message-input {
|
12 |
+
margin-right: 30px;
|
13 |
+
height: 64px;
|
14 |
+
}
|
15 |
+
|
16 |
+
#message-input::-webkit-scrollbar {
|
17 |
+
width: 5px;
|
18 |
+
}
|
19 |
+
|
20 |
+
/* Track */
|
21 |
+
#message-input::-webkit-scrollbar-track {
|
22 |
+
background: #f1f1f1;
|
23 |
+
}
|
24 |
+
|
25 |
+
/* Handle */
|
26 |
+
#message-input::-webkit-scrollbar-thumb {
|
27 |
+
background: #c7a2ff;
|
28 |
+
}
|
29 |
+
|
30 |
+
/* Handle on hover */
|
31 |
+
#message-input::-webkit-scrollbar-thumb:hover {
|
32 |
+
background: #8b3dff;
|
33 |
+
}
|
34 |
+
|
35 |
+
/* style for hljs copy */
|
36 |
+
.hljs-copy-wrapper {
|
37 |
+
position: relative;
|
38 |
+
overflow: hidden;
|
39 |
+
}
|
40 |
+
|
41 |
+
.hljs-copy-wrapper:hover .hljs-copy-button,
|
42 |
+
.hljs-copy-button:focus {
|
43 |
+
transform: translateX(0);
|
44 |
+
}
|
45 |
+
|
46 |
+
.hljs-copy-button {
|
47 |
+
position: absolute;
|
48 |
+
transform: translateX(calc(100% + 1.125em));
|
49 |
+
top: 1em;
|
50 |
+
right: 1em;
|
51 |
+
width: 2rem;
|
52 |
+
height: 2rem;
|
53 |
+
text-indent: -9999px;
|
54 |
+
color: #fff;
|
55 |
+
border-radius: 0.25rem;
|
56 |
+
border: 1px solid #ffffff22;
|
57 |
+
background-color: #2d2b57;
|
58 |
+
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>');
|
59 |
+
background-repeat: no-repeat;
|
60 |
+
background-position: center;
|
61 |
+
transition: background-color 200ms ease, transform 200ms ease-out;
|
62 |
+
}
|
63 |
+
|
64 |
+
.hljs-copy-button:hover {
|
65 |
+
border-color: #ffffff44;
|
66 |
+
}
|
67 |
+
|
68 |
+
.hljs-copy-button:active {
|
69 |
+
border-color: #ffffff66;
|
70 |
+
}
|
71 |
+
|
72 |
+
.hljs-copy-button[data-copied="true"] {
|
73 |
+
text-indent: 0;
|
74 |
+
width: auto;
|
75 |
+
background-image: none;
|
76 |
+
}
|
77 |
+
|
78 |
+
.hljs-copy-alert {
|
79 |
+
clip: rect(0 0 0 0);
|
80 |
+
clip-path: inset(50%);
|
81 |
+
height: 1px;
|
82 |
+
overflow: hidden;
|
83 |
+
position: absolute;
|
84 |
+
white-space: nowrap;
|
85 |
+
width: 1px;
|
86 |
+
}
|
87 |
+
|
88 |
+
@media (prefers-reduced-motion) {
|
89 |
+
.hljs-copy-button {
|
90 |
+
transition: none;
|
91 |
+
}
|
92 |
+
}
|
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,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.main-container {
|
2 |
+
display: flex;
|
3 |
+
padding: var(--section-gap);
|
4 |
+
height: 100vh;
|
5 |
+
justify-content: center;
|
6 |
+
box-sizing: border-box;
|
7 |
+
}
|
client/css/message.css
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.message {
|
2 |
+
width: 100%;
|
3 |
+
overflow-wrap: break-word;
|
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 |
+
width: 90%;
|
32 |
+
gap: 18px;
|
33 |
+
}
|
34 |
+
|
35 |
+
.message .content p,
|
36 |
+
.message .content li,
|
37 |
+
.message .content code {
|
38 |
+
font-size: 1rem;
|
39 |
+
line-height: 1.3;
|
40 |
+
}
|
41 |
+
|
42 |
+
@media screen and (max-height: 720px) {
|
43 |
+
.message .avatar-container img {
|
44 |
+
max-width: 32px;
|
45 |
+
max-height: 32px;
|
46 |
+
}
|
47 |
+
|
48 |
+
.message .content,
|
49 |
+
.message .content p,
|
50 |
+
.message .content li,
|
51 |
+
.message .content code {
|
52 |
+
font-size: 0.875rem;
|
53 |
+
line-height: 1.3;
|
54 |
+
}
|
55 |
+
}
|
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,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
}
|
client/css/sidebar.css
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
}
|
9 |
+
|
10 |
+
.sidebar .title {
|
11 |
+
font-size: 14px;
|
12 |
+
font-weight: 500;
|
13 |
+
}
|
14 |
+
|
15 |
+
.sidebar .conversation-sidebar {
|
16 |
+
padding: 8px 12px;
|
17 |
+
display: flex;
|
18 |
+
gap: 18px;
|
19 |
+
align-items: center;
|
20 |
+
user-select: none;
|
21 |
+
justify-content: space-between;
|
22 |
+
}
|
23 |
+
|
24 |
+
.sidebar .conversation-sidebar .left {
|
25 |
+
cursor: pointer;
|
26 |
+
display: flex;
|
27 |
+
align-items: center;
|
28 |
+
gap: 10px;
|
29 |
+
}
|
30 |
+
|
31 |
+
.sidebar i {
|
32 |
+
color: var(--conversations);
|
33 |
+
cursor: pointer;
|
34 |
+
}
|
35 |
+
|
36 |
+
.sidebar .top {
|
37 |
+
display: flex;
|
38 |
+
flex-direction: column;
|
39 |
+
overflow: hidden;
|
40 |
+
gap: 16px;
|
41 |
+
padding-right: 8px;
|
42 |
+
}
|
43 |
+
|
44 |
+
.sidebar .top:hover {
|
45 |
+
overflow: auto;
|
46 |
+
}
|
47 |
+
|
48 |
+
.sidebar .info {
|
49 |
+
padding: 8px 12px 0px 12px;
|
50 |
+
display: flex;
|
51 |
+
align-items: center;
|
52 |
+
justify-content: center;
|
53 |
+
user-select: none;
|
54 |
+
background: transparent;
|
55 |
+
width: 100%;
|
56 |
+
border: none;
|
57 |
+
text-decoration: none;
|
58 |
+
}
|
59 |
+
|
60 |
+
.sidebar .info span {
|
61 |
+
color: var(--conversations);
|
62 |
+
line-height: 1.5;
|
63 |
+
font-size: 0.75rem;
|
64 |
+
}
|
65 |
+
|
66 |
+
.sidebar .info i::before {
|
67 |
+
margin-right: 8px;
|
68 |
+
}
|
69 |
+
|
70 |
+
.sidebar-footer {
|
71 |
+
width: 100%;
|
72 |
+
margin-top: 16px;
|
73 |
+
display: flex;
|
74 |
+
flex-direction: column;
|
75 |
+
}
|
76 |
+
|
77 |
+
.sidebar-footer button {
|
78 |
+
cursor: pointer;
|
79 |
+
user-select: none;
|
80 |
+
background: transparent;
|
81 |
+
}
|
82 |
+
|
83 |
+
.sidebar.shown {
|
84 |
+
position: fixed;
|
85 |
+
top: 0;
|
86 |
+
left: 0;
|
87 |
+
width: 100%;
|
88 |
+
height: 100%;
|
89 |
+
z-index: 1000;
|
90 |
+
}
|
91 |
+
|
92 |
+
.sidebar.shown .box {
|
93 |
+
background-color: #16171a;
|
94 |
+
width: 80%;
|
95 |
+
height: 100%;
|
96 |
+
overflow-y: auto;
|
97 |
+
}
|
98 |
+
|
99 |
+
@keyframes spinner {
|
100 |
+
to {
|
101 |
+
transform: rotate(360deg);
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
/* scrollbar */
|
106 |
+
.sidebar .top::-webkit-scrollbar {
|
107 |
+
width: 4px;
|
108 |
+
padding: 8px 0px;
|
109 |
+
}
|
110 |
+
|
111 |
+
.sidebar .top::-webkit-scrollbar-track {
|
112 |
+
background-color: #ffffff00;
|
113 |
+
}
|
114 |
+
|
115 |
+
.sidebar .top::-webkit-scrollbar-thumb {
|
116 |
+
background-color: #555555;
|
117 |
+
border-radius: 10px;
|
118 |
+
}
|
119 |
+
|
120 |
+
.spinner:before {
|
121 |
+
content: "";
|
122 |
+
box-sizing: border-box;
|
123 |
+
position: absolute;
|
124 |
+
top: 50%;
|
125 |
+
left: 45%;
|
126 |
+
width: 20px;
|
127 |
+
height: 20px;
|
128 |
+
border-radius: 50%;
|
129 |
+
border: 1px solid var(--conversations);
|
130 |
+
border-top-color: white;
|
131 |
+
animation: spinner 0.6s linear infinite;
|
132 |
+
}
|
133 |
+
|
134 |
+
.mobile-sidebar {
|
135 |
+
display: none !important;
|
136 |
+
position: absolute;
|
137 |
+
z-index: 100000;
|
138 |
+
top: 0;
|
139 |
+
left: 0;
|
140 |
+
margin: 10px;
|
141 |
+
font-size: 1rem;
|
142 |
+
cursor: pointer;
|
143 |
+
width: 30px;
|
144 |
+
height: 30px;
|
145 |
+
justify-content: center;
|
146 |
+
align-items: center;
|
147 |
+
transition: 0.33s;
|
148 |
+
}
|
149 |
+
|
150 |
+
.mobile-sidebar i {
|
151 |
+
transition: 0.33s;
|
152 |
+
}
|
153 |
+
|
154 |
+
.rotated {
|
155 |
+
transform: rotate(360deg);
|
156 |
+
}
|
157 |
+
|
158 |
+
.mobile-sidebar.rotated {
|
159 |
+
position: fixed;
|
160 |
+
top: 10px;
|
161 |
+
left: 10px;
|
162 |
+
z-index: 1001;
|
163 |
+
}
|
164 |
+
|
165 |
+
@media screen and (max-width: 990px) {
|
166 |
+
.sidebar {
|
167 |
+
display: none;
|
168 |
+
width: 100%;
|
169 |
+
max-width: none;
|
170 |
+
}
|
171 |
+
|
172 |
+
.mobile-sidebar {
|
173 |
+
display: flex !important;
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
@media (max-width: 990px) {
|
178 |
+
.sidebar .top {
|
179 |
+
padding-top: 48px;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
@media (min-width: 768px) {
|
184 |
+
.sidebar.shown {
|
185 |
+
position: static;
|
186 |
+
width: auto;
|
187 |
+
height: auto;
|
188 |
+
background-color: transparent;
|
189 |
+
}
|
190 |
+
|
191 |
+
.sidebar.shown .box {
|
192 |
+
background-color: #16171a;
|
193 |
+
width: auto;
|
194 |
+
height: auto;
|
195 |
+
overflow-y: auto;
|
196 |
+
}
|
197 |
+
}
|
client/css/stop-generating.css
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.stop-generating {
|
2 |
+
position: absolute;
|
3 |
+
bottom: 128px;
|
4 |
+
left: 50%;
|
5 |
+
transform: translateX(-50%);
|
6 |
+
z-index: 1000000;
|
7 |
+
}
|
8 |
+
|
9 |
+
.stop-generating button {
|
10 |
+
backdrop-filter: blur(20px);
|
11 |
+
-webkit-backdrop-filter: blur(20px);
|
12 |
+
background-color: var(--blur-bg);
|
13 |
+
color: var(--colour-3);
|
14 |
+
cursor: pointer;
|
15 |
+
animation: show_popup 0.4s;
|
16 |
+
}
|
17 |
+
|
18 |
+
@keyframes show_popup {
|
19 |
+
from {
|
20 |
+
opacity: 0;
|
21 |
+
transform: translateY(10px);
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
@keyframes hide_popup {
|
26 |
+
to {
|
27 |
+
opacity: 0;
|
28 |
+
transform: translateY(10px);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
.stop-generating-hiding button {
|
33 |
+
animation: hide_popup 0.4s;
|
34 |
+
}
|
35 |
+
|
36 |
+
.stop-generating-hidden button {
|
37 |
+
display: none;
|
38 |
+
}
|
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 "./theme-toggler.css";
|
18 |
+
@import "./api-key.css";
|
client/css/theme-toggler.css
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.theme-toggler-container {
|
2 |
+
margin: 12px 0px 8px 0px;
|
3 |
+
justify-content: center;
|
4 |
+
}
|
5 |
+
|
6 |
+
.theme-toggler-container.checkbox input + label,
|
7 |
+
.theme-toggler-container.checkbox input:checked + label:after {
|
8 |
+
background: var(--colour-1);
|
9 |
+
}
|
10 |
+
|
11 |
+
.theme-toggler-container.checkbox input + label:after,
|
12 |
+
.theme-toggler-container.checkbox input:checked + label {
|
13 |
+
background: var(--colour-3);
|
14 |
+
}
|
15 |
+
|
16 |
+
.theme-toggler-container.checkbox span {
|
17 |
+
font-size: 0.75rem;
|
18 |
+
}
|
19 |
+
|
20 |
+
.theme-toggler-container.checkbox label {
|
21 |
+
width: 24px;
|
22 |
+
height: 16px;
|
23 |
+
}
|
24 |
+
|
25 |
+
.theme-toggler-container.checkbox label:after {
|
26 |
+
left: 2px;
|
27 |
+
width: 10px;
|
28 |
+
height: 10px;
|
29 |
+
}
|
30 |
+
|
31 |
+
.theme-toggler-container.checkbox input:checked + label:after {
|
32 |
+
left: calc(100% - 2px - 10px);
|
33 |
+
}
|
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,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.0 maximum-scale=1.0" />
|
7 |
+
<meta name="description" content="A conversational AI system that listens, learns, and challenges" />
|
8 |
+
<meta property="og:title" content="ChatGPT" />
|
9 |
+
<meta property="og:image" content="https://openai.com/content/images/2022/11/ChatGPT.jpg" />
|
10 |
+
<meta
|
11 |
+
property="og:description"
|
12 |
+
content="A conversational AI system that listens, learns, and challenges" />
|
13 |
+
<meta property="og:url" content="https://chat.acy.dev" />
|
14 |
+
<link rel="stylesheet" href="{{ url_for('bp.static', filename='css/style.css') }}" />
|
15 |
+
<link
|
16 |
+
rel="apple-touch-icon"
|
17 |
+
sizes="180x180"
|
18 |
+
href="{{ url_for('bp.static', filename='img/apple-touch-icon.png') }}" />
|
19 |
+
<link
|
20 |
+
rel="icon"
|
21 |
+
type="image/png"
|
22 |
+
sizes="32x32"
|
23 |
+
href="{{ url_for('bp.static', filename='img/favicon-32x32.png') }}" />
|
24 |
+
<link
|
25 |
+
rel="icon"
|
26 |
+
type="image/png"
|
27 |
+
sizes="16x16"
|
28 |
+
href="{{ url_for('bp.static', filename='img/favicon-16x16.png') }}" />
|
29 |
+
<link rel="manifest" href="{{ url_for('bp.static', filename='img/site.webmanifest') }}" />
|
30 |
+
<link
|
31 |
+
rel="stylesheet"
|
32 |
+
href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/styles/base16/dracula.min.css" />
|
33 |
+
<title>FreeGPT</title>
|
34 |
+
</head>
|
35 |
+
|
36 |
+
<body data-urlprefix="{{ url_prefix}}">
|
37 |
+
<div class="main-container">
|
38 |
+
<div class="box sidebar">
|
39 |
+
<div class="top">
|
40 |
+
<button class="button" onclick="new_conversation()">
|
41 |
+
<i class="fa-regular fa-plus"></i>
|
42 |
+
<span>New Conversation</span>
|
43 |
+
</button>
|
44 |
+
<div class="spinner"></div>
|
45 |
+
</div>
|
46 |
+
<div class="sidebar-footer">
|
47 |
+
<button class="button" onclick="delete_conversations()">
|
48 |
+
<i class="fa-regular fa-trash"></i>
|
49 |
+
<span>Clear Conversations</span>
|
50 |
+
</button>
|
51 |
+
<div class="api-key-container" id="api-key-container">
|
52 |
+
<button id="show-api-key-button" class="button">
|
53 |
+
<i class="fa-regular fa-key"></i>
|
54 |
+
<span>API Key</span>
|
55 |
+
</button>
|
56 |
+
<input type="password" id="API-key" class="hidden fade-in" />
|
57 |
+
<button id="api-key-ok-button" class="button hidden fade-in">Ok</button>
|
58 |
+
</div>
|
59 |
+
<div class="field checkbox theme-toggler-container">
|
60 |
+
<input type="checkbox" id="theme-toggler" />
|
61 |
+
<label for="theme-toggler"></label>
|
62 |
+
<span>Dark Mode</span>
|
63 |
+
</div>
|
64 |
+
<a
|
65 |
+
class="info"
|
66 |
+
href="https://github.com/ramonvc/freegpt-webui/tree/chimeragpt-version"
|
67 |
+
target="_blank">
|
68 |
+
<i class="fa-brands fa-github"></i>
|
69 |
+
<span class="conversation-title">freegpt-webui-chimera</span>
|
70 |
+
</a>
|
71 |
+
<a class="info" href="https://discord.gg/chimeragpt" target="_blank">
|
72 |
+
<i class="fa-brands fa-discord"></i>
|
73 |
+
<span class="conversation-title">ChimeraGPT</span>
|
74 |
+
</a>
|
75 |
+
</div>
|
76 |
+
</div>
|
77 |
+
<div class="conversation">
|
78 |
+
<div class="stop-generating stop-generating-hidden">
|
79 |
+
<button class="button" id="cancelButton">
|
80 |
+
<span>Stop Generating</span>
|
81 |
+
</button>
|
82 |
+
</div>
|
83 |
+
<div class="box" id="messages"></div>
|
84 |
+
<div class="user-input">
|
85 |
+
<div class="box input-box">
|
86 |
+
<textarea
|
87 |
+
id="message-input"
|
88 |
+
placeholder="Ask a question"
|
89 |
+
cols="30"
|
90 |
+
rows="10"
|
91 |
+
style="white-space: pre-wrap"></textarea>
|
92 |
+
<div id="send-button">
|
93 |
+
<i class="fa-regular fa-paper-plane-top"></i>
|
94 |
+
</div>
|
95 |
+
</div>
|
96 |
+
</div>
|
97 |
+
<div>
|
98 |
+
<div class="options-container">
|
99 |
+
<div class="buttons">
|
100 |
+
<div class="field">
|
101 |
+
<select class="dropdown" name="model" id="model">
|
102 |
+
<optgroup label="GPT">
|
103 |
+
<option value="gpt-3.5-turbo">GPT-3.5-turbo</option>
|
104 |
+
<option value="gpt-3.5-turbo-poe">GPT-3.5-turbo-poe</option>
|
105 |
+
<option value="gpt-3.5-turbo-16k">GPT-3.5-turbo-16k</option>
|
106 |
+
<option value="gpt-3.5-turbo-16k-poe">GPT-3.5-turbo-16k-poe</option>
|
107 |
+
<option value="gpt-4">GPT-4</option>
|
108 |
+
<option value="gpt-4-0613">GPT-4-0613</option>
|
109 |
+
<option value="gpt-4-poe">GPT-4-poe</option>
|
110 |
+
<option value="gpt-4-32k">GPT-4-32k</option>
|
111 |
+
<option value="gpt-4-32k-poe">GPT-4-32k-poe</option>
|
112 |
+
</optgroup>
|
113 |
+
<optgroup label="SAGE">
|
114 |
+
<option value="sage">Sage</option>
|
115 |
+
</optgroup>
|
116 |
+
<optgroup label="CLAUDE">
|
117 |
+
<option value="claude-instant">Claude-Instant</option>
|
118 |
+
<option value="claude-2-100k">Claude-2-100k</option>
|
119 |
+
<option value="claude-instant-100k">Claude-Instant-100k</option>
|
120 |
+
</optgroup>
|
121 |
+
<optgroup label="IMAGE">
|
122 |
+
<option value="" disabled>Kandinsky (soon)</option>
|
123 |
+
</optgroup>
|
124 |
+
</select>
|
125 |
+
</div>
|
126 |
+
<div class="field">
|
127 |
+
<select class="dropdown" name="jailbreak" id="jailbreak">
|
128 |
+
<option value="default" selected>Default</option>
|
129 |
+
<option value="gpt-dan-11.0">DAN</option>
|
130 |
+
<option value="gpt-evil">Evil</option>
|
131 |
+
</select>
|
132 |
+
</div>
|
133 |
+
</div>
|
134 |
+
<div class="field checkbox">
|
135 |
+
<input type="checkbox" id="switch" />
|
136 |
+
<label for="switch"></label>
|
137 |
+
<span>Web Access</span>
|
138 |
+
</div>
|
139 |
+
</div>
|
140 |
+
</div>
|
141 |
+
</div>
|
142 |
+
</div>
|
143 |
+
<div class="mobile-sidebar">
|
144 |
+
<i class="fa-solid fa-bars"></i>
|
145 |
+
</div>
|
146 |
+
|
147 |
+
<!-- scripts -->
|
148 |
+
<script>
|
149 |
+
window.conversation_id = "{{ chat_id }}";
|
150 |
+
</script>
|
151 |
+
<script src="{{ url_for('bp.static', filename='js/api-key.js') }}"></script>
|
152 |
+
<script src="{{ url_for('bp.static', filename='js/icons.js') }}"></script>
|
153 |
+
<script src="{{ url_for('bp.static', filename='js/chat.js') }}" defer></script>
|
154 |
+
<script src="https://cdn.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js"></script>
|
155 |
+
<script src="{{ url_for('bp.static', filename='js/highlight.min.js') }}"></script>
|
156 |
+
<script src="{{ url_for('bp.static', filename='js/highlightjs-copy.min.js') }}"></script>
|
157 |
+
<script src="{{ url_for('bp.static', filename='js/theme-toggler.js') }}"></script>
|
158 |
+
</body>
|
159 |
+
</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,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "",
|
3 |
+
"short_name": "",
|
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 |
+
}
|
client/img/user.png
ADDED
client/js/api-key.js
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const showApiKeyButton = document.getElementById("show-api-key-button");
|
2 |
+
const apiKeyInput = document.getElementById("API-key");
|
3 |
+
const apiKeyOkButton = document.getElementById("api-key-ok-button");
|
4 |
+
|
5 |
+
showApiKeyButton.addEventListener("click", () => {
|
6 |
+
showApiKeyButton.classList.add("hidden");
|
7 |
+
|
8 |
+
apiKeyInput.classList.remove("hidden");
|
9 |
+
apiKeyOkButton.classList.remove("hidden");
|
10 |
+
});
|
11 |
+
|
12 |
+
apiKeyOkButton.addEventListener("click", () => {
|
13 |
+
localStorage.setItem("API-key", apiKeyInput.value);
|
14 |
+
|
15 |
+
apiKeyInput.classList.add("hidden");
|
16 |
+
apiKeyOkButton.classList.add("hidden");
|
17 |
+
|
18 |
+
showApiKeyButton.classList.remove("hidden");
|
19 |
+
});
|
20 |
+
|
21 |
+
window.addEventListener("DOMContentLoaded", () => {
|
22 |
+
const apiKey = localStorage.getItem("API-key");
|
23 |
+
if (apiKey) {
|
24 |
+
apiKeyInput.value = apiKey;
|
25 |
+
}
|
26 |
+
});
|
27 |
+
|
28 |
+
(function () {
|
29 |
+
function get_api_key_from_input() {
|
30 |
+
return apiKeyInput.value;
|
31 |
+
}
|
32 |
+
window.get_api_key_from_input = get_api_key_from_input;
|
33 |
+
})();
|
client/js/chat.js
ADDED
@@ -0,0 +1,516 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 message_box = document.getElementById(`messages`);
|
8 |
+
const message_input = document.getElementById(`message-input`);
|
9 |
+
const box_conversations = document.querySelector(`.top`);
|
10 |
+
const spinner = box_conversations.querySelector(".spinner");
|
11 |
+
const stop_generating = document.querySelector(`.stop-generating`);
|
12 |
+
const send_button = document.querySelector(`#send-button`);
|
13 |
+
const user_image = `<img src="${url_prefix}/assets/img/user.png" alt="User Avatar">`;
|
14 |
+
const gpt_image = `<img src="${url_prefix}/assets/img/gpt.png" alt="GPT Avatar">`;
|
15 |
+
let prompt_lock = false;
|
16 |
+
|
17 |
+
hljs.addPlugin(new CopyButtonPlugin());
|
18 |
+
|
19 |
+
message_input.addEventListener("blur", () => {
|
20 |
+
window.scrollTo(0, 0);
|
21 |
+
});
|
22 |
+
|
23 |
+
message_input.addEventListener("focus", () => {
|
24 |
+
document.documentElement.scrollTop = document.documentElement.scrollHeight;
|
25 |
+
});
|
26 |
+
|
27 |
+
const delete_conversations = async () => {
|
28 |
+
localStorage.clear();
|
29 |
+
await new_conversation();
|
30 |
+
};
|
31 |
+
|
32 |
+
const handle_ask = async () => {
|
33 |
+
message_input.style.height = `80px`;
|
34 |
+
window.scrollTo(0, 0);
|
35 |
+
let message = message_input.value;
|
36 |
+
|
37 |
+
if (message.length > 0) {
|
38 |
+
message_input.value = ``;
|
39 |
+
message_input.dispatchEvent(new Event("input"));
|
40 |
+
await ask_gpt(message);
|
41 |
+
}
|
42 |
+
};
|
43 |
+
|
44 |
+
const remove_cancel_button = async () => {
|
45 |
+
stop_generating.classList.add(`stop-generating-hiding`);
|
46 |
+
|
47 |
+
setTimeout(() => {
|
48 |
+
stop_generating.classList.remove(`stop-generating-hiding`);
|
49 |
+
stop_generating.classList.add(`stop-generating-hidden`);
|
50 |
+
}, 300);
|
51 |
+
};
|
52 |
+
|
53 |
+
const ask_gpt = async (message) => {
|
54 |
+
try {
|
55 |
+
message_input.value = ``;
|
56 |
+
message_input.innerHTML = ``;
|
57 |
+
message_input.innerText = ``;
|
58 |
+
|
59 |
+
add_conversation(window.conversation_id, message.substr(0, 16));
|
60 |
+
window.scrollTo(0, 0);
|
61 |
+
window.controller = new AbortController();
|
62 |
+
|
63 |
+
jailbreak = document.getElementById("jailbreak");
|
64 |
+
model = document.getElementById("model");
|
65 |
+
prompt_lock = true;
|
66 |
+
window.text = ``;
|
67 |
+
window.token = message_id();
|
68 |
+
|
69 |
+
stop_generating.classList.remove(`stop-generating-hidden`);
|
70 |
+
|
71 |
+
add_user_message_box(message);
|
72 |
+
|
73 |
+
message_box.scrollTop = message_box.scrollHeight;
|
74 |
+
window.scrollTo(0, 0);
|
75 |
+
await new Promise((r) => setTimeout(r, 500));
|
76 |
+
window.scrollTo(0, 0);
|
77 |
+
|
78 |
+
message_box.innerHTML += `
|
79 |
+
<div class="message">
|
80 |
+
<div class="avatar-container">
|
81 |
+
${gpt_image}
|
82 |
+
</div>
|
83 |
+
<div class="content" id="gpt_${window.token}">
|
84 |
+
<div id="cursor"></div>
|
85 |
+
</div>
|
86 |
+
</div>
|
87 |
+
`;
|
88 |
+
|
89 |
+
message_box.scrollTop = message_box.scrollHeight;
|
90 |
+
window.scrollTo(0, 0);
|
91 |
+
await new Promise((r) => setTimeout(r, 1000));
|
92 |
+
window.scrollTo(0, 0);
|
93 |
+
|
94 |
+
const response = await fetch(`${url_prefix}/backend-api/v2/conversation`, {
|
95 |
+
method: `POST`,
|
96 |
+
signal: window.controller.signal,
|
97 |
+
headers: {
|
98 |
+
"content-type": `application/json`,
|
99 |
+
accept: `text/event-stream`,
|
100 |
+
},
|
101 |
+
body: JSON.stringify({
|
102 |
+
api_key: get_api_key_from_input(),
|
103 |
+
conversation_id: window.conversation_id,
|
104 |
+
action: `_ask`,
|
105 |
+
model: model.options[model.selectedIndex].value,
|
106 |
+
jailbreak: jailbreak.options[jailbreak.selectedIndex].value,
|
107 |
+
meta: {
|
108 |
+
id: window.token,
|
109 |
+
content: {
|
110 |
+
conversation: await get_conversation(window.conversation_id),
|
111 |
+
internet_access: document.getElementById("switch").checked,
|
112 |
+
content_type: "text",
|
113 |
+
parts: [
|
114 |
+
{
|
115 |
+
content: message,
|
116 |
+
role: "user",
|
117 |
+
},
|
118 |
+
],
|
119 |
+
},
|
120 |
+
},
|
121 |
+
}),
|
122 |
+
});
|
123 |
+
|
124 |
+
const reader = response.body.getReader();
|
125 |
+
|
126 |
+
while (true) {
|
127 |
+
const { value, done } = await reader.read();
|
128 |
+
if (done) break;
|
129 |
+
|
130 |
+
chunk = decodeUnicode(new TextDecoder().decode(value));
|
131 |
+
|
132 |
+
if (chunk.includes(`<form id="challenge-form" action="${url_prefix}/backend-api/v2/conversation?`)) {
|
133 |
+
chunk = `cloudflare token expired, please refresh the page.`;
|
134 |
+
}
|
135 |
+
|
136 |
+
text += chunk;
|
137 |
+
|
138 |
+
document.getElementById(`gpt_${window.token}`).innerHTML = markdown.render(text);
|
139 |
+
document.querySelectorAll(`code`).forEach((el) => {
|
140 |
+
hljs.highlightElement(el);
|
141 |
+
});
|
142 |
+
|
143 |
+
window.scrollTo(0, 0);
|
144 |
+
message_box.scrollTo({ top: message_box.scrollHeight, behavior: "auto" });
|
145 |
+
}
|
146 |
+
|
147 |
+
// if text contains :
|
148 |
+
if (text.includes(`instead. Maintaining this website and API costs a lot of money`)) {
|
149 |
+
document.getElementById(`gpt_${window.token}`).innerHTML =
|
150 |
+
"An error occurred, please reload / refresh cache and try again.";
|
151 |
+
}
|
152 |
+
|
153 |
+
add_message(window.conversation_id, "user", message);
|
154 |
+
add_message(window.conversation_id, "assistant", text);
|
155 |
+
|
156 |
+
message_box.scrollTop = message_box.scrollHeight;
|
157 |
+
await remove_cancel_button();
|
158 |
+
prompt_lock = false;
|
159 |
+
|
160 |
+
await load_conversations(20, 0);
|
161 |
+
window.scrollTo(0, 0);
|
162 |
+
} catch (e) {
|
163 |
+
add_message(window.conversation_id, "user", message);
|
164 |
+
|
165 |
+
message_box.scrollTop = message_box.scrollHeight;
|
166 |
+
await remove_cancel_button();
|
167 |
+
prompt_lock = false;
|
168 |
+
|
169 |
+
await load_conversations(20, 0);
|
170 |
+
|
171 |
+
console.log(e);
|
172 |
+
|
173 |
+
let cursorDiv = document.getElementById(`cursor`);
|
174 |
+
if (cursorDiv) cursorDiv.parentNode.removeChild(cursorDiv);
|
175 |
+
|
176 |
+
if (e.name != `AbortError`) {
|
177 |
+
let error_message = `oops ! something went wrong, please try again / reload. [stacktrace in console]`;
|
178 |
+
|
179 |
+
document.getElementById(`gpt_${window.token}`).innerHTML = error_message;
|
180 |
+
add_message(window.conversation_id, "assistant", error_message);
|
181 |
+
} else {
|
182 |
+
document.getElementById(`gpt_${window.token}`).innerHTML += ` [aborted]`;
|
183 |
+
add_message(window.conversation_id, "assistant", text + ` [aborted]`);
|
184 |
+
}
|
185 |
+
|
186 |
+
window.scrollTo(0, 0);
|
187 |
+
}
|
188 |
+
};
|
189 |
+
|
190 |
+
const add_user_message_box = (message) => {
|
191 |
+
const messageDiv = document.createElement("div");
|
192 |
+
messageDiv.classList.add("message");
|
193 |
+
|
194 |
+
const avatarContainer = document.createElement("div");
|
195 |
+
avatarContainer.classList.add("avatar-container");
|
196 |
+
avatarContainer.innerHTML = user_image;
|
197 |
+
|
198 |
+
const contentDiv = document.createElement("div");
|
199 |
+
contentDiv.classList.add("content");
|
200 |
+
contentDiv.id = `user_${token}`;
|
201 |
+
contentDiv.innerText = message;
|
202 |
+
|
203 |
+
messageDiv.appendChild(avatarContainer);
|
204 |
+
messageDiv.appendChild(contentDiv);
|
205 |
+
|
206 |
+
message_box.appendChild(messageDiv);
|
207 |
+
};
|
208 |
+
|
209 |
+
const decodeUnicode = (str) => {
|
210 |
+
return str.replace(/\\u([a-fA-F0-9]{4})/g, function (match, grp) {
|
211 |
+
return String.fromCharCode(parseInt(grp, 16));
|
212 |
+
});
|
213 |
+
};
|
214 |
+
|
215 |
+
const clear_conversations = async () => {
|
216 |
+
const elements = box_conversations.childNodes;
|
217 |
+
let index = elements.length;
|
218 |
+
|
219 |
+
if (index > 0) {
|
220 |
+
while (index--) {
|
221 |
+
const element = elements[index];
|
222 |
+
if (element.nodeType === Node.ELEMENT_NODE && element.tagName.toLowerCase() !== `button`) {
|
223 |
+
box_conversations.removeChild(element);
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
};
|
228 |
+
|
229 |
+
const clear_conversation = async () => {
|
230 |
+
let messages = message_box.getElementsByTagName(`div`);
|
231 |
+
|
232 |
+
while (messages.length > 0) {
|
233 |
+
message_box.removeChild(messages[0]);
|
234 |
+
}
|
235 |
+
};
|
236 |
+
|
237 |
+
const delete_conversation = async (conversation_id) => {
|
238 |
+
localStorage.removeItem(`conversation:${conversation_id}`);
|
239 |
+
|
240 |
+
if (window.conversation_id == conversation_id) {
|
241 |
+
await new_conversation();
|
242 |
+
}
|
243 |
+
|
244 |
+
await load_conversations(20, 0, true);
|
245 |
+
};
|
246 |
+
|
247 |
+
const set_conversation = async (conversation_id) => {
|
248 |
+
history.pushState({}, null, `${url_prefix}/chat/${conversation_id}`);
|
249 |
+
window.conversation_id = conversation_id;
|
250 |
+
|
251 |
+
await clear_conversation();
|
252 |
+
await load_conversation(conversation_id);
|
253 |
+
await load_conversations(20, 0, true);
|
254 |
+
};
|
255 |
+
|
256 |
+
const new_conversation = async () => {
|
257 |
+
history.pushState({}, null, `${url_prefix}/chat/`);
|
258 |
+
window.conversation_id = uuid();
|
259 |
+
|
260 |
+
await clear_conversation();
|
261 |
+
await load_conversations(20, 0, true);
|
262 |
+
};
|
263 |
+
|
264 |
+
const load_conversation = async (conversation_id) => {
|
265 |
+
let conversation = await JSON.parse(localStorage.getItem(`conversation:${conversation_id}`));
|
266 |
+
console.log(conversation, conversation_id);
|
267 |
+
|
268 |
+
for (item of conversation.items) {
|
269 |
+
if (is_assistant(item.role)) {
|
270 |
+
message_box.innerHTML += load_gpt_message_box(item.content);
|
271 |
+
} else {
|
272 |
+
message_box.innerHTML += load_user_message_box(item.content);
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
document.querySelectorAll(`code`).forEach((el) => {
|
277 |
+
hljs.highlightElement(el);
|
278 |
+
});
|
279 |
+
|
280 |
+
message_box.scrollTo({ top: message_box.scrollHeight, behavior: "smooth" });
|
281 |
+
|
282 |
+
setTimeout(() => {
|
283 |
+
message_box.scrollTop = message_box.scrollHeight;
|
284 |
+
}, 500);
|
285 |
+
};
|
286 |
+
|
287 |
+
const load_user_message_box = (content) => {
|
288 |
+
const messageDiv = document.createElement("div");
|
289 |
+
messageDiv.classList.add("message");
|
290 |
+
|
291 |
+
const avatarContainer = document.createElement("div");
|
292 |
+
avatarContainer.classList.add("avatar-container");
|
293 |
+
avatarContainer.innerHTML = user_image;
|
294 |
+
|
295 |
+
const contentDiv = document.createElement("div");
|
296 |
+
contentDiv.classList.add("content");
|
297 |
+
contentDiv.innerText = content;
|
298 |
+
|
299 |
+
messageDiv.appendChild(avatarContainer);
|
300 |
+
messageDiv.appendChild(contentDiv);
|
301 |
+
|
302 |
+
return messageDiv.outerHTML;
|
303 |
+
};
|
304 |
+
|
305 |
+
const load_gpt_message_box = (content) => {
|
306 |
+
return `
|
307 |
+
<div class="message">
|
308 |
+
<div class="avatar-container">
|
309 |
+
${gpt_image}
|
310 |
+
</div>
|
311 |
+
<div class="content">
|
312 |
+
${markdown.render(content)}
|
313 |
+
</div>
|
314 |
+
</div>
|
315 |
+
`;
|
316 |
+
};
|
317 |
+
|
318 |
+
const is_assistant = (role) => {
|
319 |
+
return role == "assistant";
|
320 |
+
};
|
321 |
+
|
322 |
+
const get_conversation = async (conversation_id) => {
|
323 |
+
let conversation = await JSON.parse(localStorage.getItem(`conversation:${conversation_id}`));
|
324 |
+
return conversation.items;
|
325 |
+
};
|
326 |
+
|
327 |
+
const add_conversation = async (conversation_id, title) => {
|
328 |
+
if (localStorage.getItem(`conversation:${conversation_id}`) == null) {
|
329 |
+
localStorage.setItem(
|
330 |
+
`conversation:${conversation_id}`,
|
331 |
+
JSON.stringify({
|
332 |
+
id: conversation_id,
|
333 |
+
title: title,
|
334 |
+
items: [],
|
335 |
+
})
|
336 |
+
);
|
337 |
+
}
|
338 |
+
};
|
339 |
+
|
340 |
+
const add_message = async (conversation_id, role, content) => {
|
341 |
+
before_adding = JSON.parse(localStorage.getItem(`conversation:${conversation_id}`));
|
342 |
+
|
343 |
+
before_adding.items.push({
|
344 |
+
role: role,
|
345 |
+
content: content,
|
346 |
+
});
|
347 |
+
|
348 |
+
localStorage.setItem(`conversation:${conversation_id}`, JSON.stringify(before_adding)); // update conversation
|
349 |
+
};
|
350 |
+
|
351 |
+
const load_conversations = async (limit, offset, loader) => {
|
352 |
+
//console.log(loader);
|
353 |
+
//if (loader === undefined) box_conversations.appendChild(spinner);
|
354 |
+
|
355 |
+
let conversations = [];
|
356 |
+
for (let i = 0; i < localStorage.length; i++) {
|
357 |
+
if (localStorage.key(i).startsWith("conversation:")) {
|
358 |
+
let conversation = localStorage.getItem(localStorage.key(i));
|
359 |
+
conversations.push(JSON.parse(conversation));
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
//if (loader === undefined) spinner.parentNode.removeChild(spinner)
|
364 |
+
await clear_conversations();
|
365 |
+
|
366 |
+
for (conversation of conversations) {
|
367 |
+
box_conversations.innerHTML += `
|
368 |
+
<div class="conversation-sidebar">
|
369 |
+
<div class="left" onclick="set_conversation('${conversation.id}')">
|
370 |
+
<i class="fa-regular fa-comments"></i>
|
371 |
+
<span class="conversation-title">${conversation.title}</span>
|
372 |
+
</div>
|
373 |
+
<i onclick="delete_conversation('${conversation.id}')" class="fa-regular fa-trash"></i>
|
374 |
+
</div>
|
375 |
+
`;
|
376 |
+
}
|
377 |
+
|
378 |
+
document.querySelectorAll(`code`).forEach((el) => {
|
379 |
+
hljs.highlightElement(el);
|
380 |
+
});
|
381 |
+
};
|
382 |
+
|
383 |
+
document.getElementById(`cancelButton`).addEventListener(`click`, async () => {
|
384 |
+
window.controller.abort();
|
385 |
+
console.log(`aborted ${window.conversation_id}`);
|
386 |
+
});
|
387 |
+
|
388 |
+
function h2a(str1) {
|
389 |
+
var hex = str1.toString();
|
390 |
+
var str = "";
|
391 |
+
|
392 |
+
for (var n = 0; n < hex.length; n += 2) {
|
393 |
+
str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
|
394 |
+
}
|
395 |
+
|
396 |
+
return str;
|
397 |
+
}
|
398 |
+
|
399 |
+
const uuid = () => {
|
400 |
+
return `xxxxxxxx-xxxx-4xxx-yxxx-${Date.now().toString(16)}`.replace(/[xy]/g, function (c) {
|
401 |
+
var r = (Math.random() * 16) | 0,
|
402 |
+
v = c == "x" ? r : (r & 0x3) | 0x8;
|
403 |
+
return v.toString(16);
|
404 |
+
});
|
405 |
+
};
|
406 |
+
|
407 |
+
const message_id = () => {
|
408 |
+
random_bytes = (Math.floor(Math.random() * 1338377565) + 2956589730).toString(2);
|
409 |
+
unix = Math.floor(Date.now() / 1000).toString(2);
|
410 |
+
|
411 |
+
return BigInt(`0b${unix}${random_bytes}`).toString();
|
412 |
+
};
|
413 |
+
|
414 |
+
window.onload = async () => {
|
415 |
+
load_settings_localstorage();
|
416 |
+
|
417 |
+
conversations = 0;
|
418 |
+
for (let i = 0; i < localStorage.length; i++) {
|
419 |
+
if (localStorage.key(i).startsWith("conversation:")) {
|
420 |
+
conversations += 1;
|
421 |
+
}
|
422 |
+
}
|
423 |
+
|
424 |
+
if (conversations == 0) localStorage.clear();
|
425 |
+
|
426 |
+
await setTimeout(() => {
|
427 |
+
load_conversations(20, 0);
|
428 |
+
}, 1);
|
429 |
+
|
430 |
+
if (!window.location.href.endsWith(`#`)) {
|
431 |
+
if (/\/chat\/.+/.test(window.location.href.slice(url_prefix.length))) {
|
432 |
+
await load_conversation(window.conversation_id);
|
433 |
+
}
|
434 |
+
}
|
435 |
+
|
436 |
+
message_input.addEventListener("keydown", async (evt) => {
|
437 |
+
if (prompt_lock) return;
|
438 |
+
|
439 |
+
if (evt.key === "Enter" && !evt.shiftKey) {
|
440 |
+
evt.preventDefault();
|
441 |
+
await handle_ask();
|
442 |
+
}
|
443 |
+
});
|
444 |
+
|
445 |
+
send_button.addEventListener("click", async (event) => {
|
446 |
+
event.preventDefault();
|
447 |
+
if (prompt_lock) return;
|
448 |
+
message_input.blur();
|
449 |
+
await handle_ask();
|
450 |
+
});
|
451 |
+
|
452 |
+
register_settings_localstorage();
|
453 |
+
};
|
454 |
+
|
455 |
+
document.querySelector(".mobile-sidebar").addEventListener("click", (event) => {
|
456 |
+
const sidebar = document.querySelector(".sidebar");
|
457 |
+
|
458 |
+
if (sidebar.classList.contains("shown")) {
|
459 |
+
sidebar.classList.remove("shown");
|
460 |
+
event.target.classList.remove("rotated");
|
461 |
+
document.body.style.overflow = "auto";
|
462 |
+
} else {
|
463 |
+
sidebar.classList.add("shown");
|
464 |
+
event.target.classList.add("rotated");
|
465 |
+
document.body.style.overflow = "hidden";
|
466 |
+
}
|
467 |
+
|
468 |
+
window.scrollTo(0, 0);
|
469 |
+
});
|
470 |
+
|
471 |
+
const register_settings_localstorage = async () => {
|
472 |
+
settings_ids = ["switch", "model", "jailbreak"];
|
473 |
+
settings_elements = settings_ids.map((id) => document.getElementById(id));
|
474 |
+
settings_elements.map((element) =>
|
475 |
+
element.addEventListener(`change`, async (event) => {
|
476 |
+
switch (event.target.type) {
|
477 |
+
case "checkbox":
|
478 |
+
localStorage.setItem(event.target.id, event.target.checked);
|
479 |
+
break;
|
480 |
+
case "select-one":
|
481 |
+
localStorage.setItem(event.target.id, event.target.selectedIndex);
|
482 |
+
break;
|
483 |
+
default:
|
484 |
+
console.warn("Unresolved element type");
|
485 |
+
}
|
486 |
+
})
|
487 |
+
);
|
488 |
+
};
|
489 |
+
|
490 |
+
const load_settings_localstorage = async () => {
|
491 |
+
settings_ids = ["switch", "model", "jailbreak"];
|
492 |
+
settings_elements = settings_ids.map((id) => document.getElementById(id));
|
493 |
+
settings_elements.map((element) => {
|
494 |
+
if (localStorage.getItem(element.id)) {
|
495 |
+
switch (element.type) {
|
496 |
+
case "checkbox":
|
497 |
+
element.checked = localStorage.getItem(element.id) === "true";
|
498 |
+
break;
|
499 |
+
case "select-one":
|
500 |
+
element.selectedIndex = parseInt(localStorage.getItem(element.id));
|
501 |
+
break;
|
502 |
+
default:
|
503 |
+
console.warn("Unresolved element type");
|
504 |
+
}
|
505 |
+
}
|
506 |
+
});
|
507 |
+
};
|
508 |
+
|
509 |
+
function clearTextarea(textarea) {
|
510 |
+
textarea.style.removeProperty("height");
|
511 |
+
textarea.style.height = `${textarea.scrollHeight + 4}px`;
|
512 |
+
|
513 |
+
if (textarea.value.trim() === "" && textarea.value.includes("\n")) {
|
514 |
+
textarea.value = "";
|
515 |
+
}
|
516 |
+
}
|
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/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 |
+
}
|
docker-compose.yml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3.5'
|
2 |
+
|
3 |
+
services:
|
4 |
+
freegpt-webui:
|
5 |
+
image: freegpt-webui
|
6 |
+
container_name: freegpt-webui
|
7 |
+
build:
|
8 |
+
context: .
|
9 |
+
dockerfile: Dockerfile
|
10 |
+
ports:
|
11 |
+
- "1338:1338"
|
g4f/Provider/Provider.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from ..typing import sha256, Dict, get_type_hints
|
3 |
+
|
4 |
+
url = None
|
5 |
+
model = None
|
6 |
+
supports_stream = False
|
7 |
+
needs_auth = False
|
8 |
+
|
9 |
+
|
10 |
+
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
11 |
+
return
|
12 |
+
|
13 |
+
|
14 |
+
params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
|
15 |
+
'(%s)' % ', '.join(
|
16 |
+
[f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
|
g4f/Provider/Providers/Chimera.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
import os
|
3 |
+
import openai
|
4 |
+
import openai.error
|
5 |
+
from dotenv import load_dotenv
|
6 |
+
from ...typing import sha256, Dict, get_type_hints
|
7 |
+
|
8 |
+
load_dotenv()
|
9 |
+
api_key_env = os.environ.get("CHIMERA_API_KEY")
|
10 |
+
openai.api_base = "https://chimeragpt.adventblocks.cc/v1"
|
11 |
+
|
12 |
+
url = 'https://chimeragpt.adventblocks.cc/'
|
13 |
+
model = [
|
14 |
+
'gpt-3.5-turbo',
|
15 |
+
'gpt-3.5-turbo-poe',
|
16 |
+
'gpt-3.5-turbo-openai',
|
17 |
+
'gpt-3.5-turbo-16k',
|
18 |
+
'gpt-3.5-turbo-16k-openai',
|
19 |
+
'gpt-3.5-turbo-16k-poe',
|
20 |
+
'gpt-4',
|
21 |
+
'gpt-4-0613',
|
22 |
+
'gpt-4-poe',
|
23 |
+
'gpt-4-32k',
|
24 |
+
'gpt-4-32k-poe',
|
25 |
+
'claude_instant',
|
26 |
+
'claude-instant-100k',
|
27 |
+
'claude-2-100k',
|
28 |
+
'sage'
|
29 |
+
]
|
30 |
+
|
31 |
+
supports_stream = True
|
32 |
+
needs_auth = False
|
33 |
+
|
34 |
+
|
35 |
+
def _create_completion(api_key: str, model: str, messages: list, stream: bool, **kwargs):
|
36 |
+
|
37 |
+
openai.api_key = api_key if api_key else api_key_env
|
38 |
+
|
39 |
+
try:
|
40 |
+
response = openai.ChatCompletion.create(
|
41 |
+
model=model,
|
42 |
+
messages=messages,
|
43 |
+
stream=stream
|
44 |
+
)
|
45 |
+
|
46 |
+
for chunk in response:
|
47 |
+
yield chunk.choices[0].delta.get("content", "")
|
48 |
+
|
49 |
+
except openai.error.APIError as e:
|
50 |
+
detail_pattern = re.compile(r'{"detail":"(.*?)"}')
|
51 |
+
match = detail_pattern.search(e.user_message)
|
52 |
+
if match:
|
53 |
+
error_message = match.group(1)
|
54 |
+
print(error_message)
|
55 |
+
yield error_message
|
56 |
+
else:
|
57 |
+
print(e.user_message)
|
58 |
+
yield e.user_message
|
59 |
+
|
60 |
+
|
61 |
+
|
62 |
+
params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
|
63 |
+
'(%s)' % ', '.join(
|
64 |
+
[f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
|
g4f/Provider/__init__.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from . import Provider
|
2 |
+
from .Providers import (
|
3 |
+
Chimera,
|
4 |
+
)
|
g4f/__init__.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from . import Provider
|
3 |
+
from g4f.models import Model, ModelUtils
|
4 |
+
|
5 |
+
|
6 |
+
class ChatCompletion:
|
7 |
+
@staticmethod
|
8 |
+
def create(api_key: str, model: Model.model or str, messages: list, provider: Provider.Provider = None, stream: bool = False, auth: str = False, **kwargs):
|
9 |
+
kwargs['auth'] = auth
|
10 |
+
|
11 |
+
if provider and provider.needs_auth and not auth:
|
12 |
+
print(
|
13 |
+
f'ValueError: {provider.__name__} requires authentication (use auth="cookie or token or jwt ..." param)', file=sys.stderr)
|
14 |
+
sys.exit(1)
|
15 |
+
|
16 |
+
try:
|
17 |
+
if isinstance(model, str):
|
18 |
+
try:
|
19 |
+
model = ModelUtils.convert[model]
|
20 |
+
except KeyError:
|
21 |
+
raise Exception(f'The model: {model} does not exist')
|
22 |
+
|
23 |
+
engine = model.best_provider if not provider else provider
|
24 |
+
|
25 |
+
if not engine.supports_stream and stream == True:
|
26 |
+
print(
|
27 |
+
f"ValueError: {engine.__name__} does not support 'stream' argument", file=sys.stderr)
|
28 |
+
sys.exit(1)
|
29 |
+
|
30 |
+
print(f'Using {engine.__name__} provider')
|
31 |
+
|
32 |
+
return (engine._create_completion(api_key=api_key, model=model.name, messages=messages, stream=stream, **kwargs)
|
33 |
+
if stream else ''.join(engine._create_completion(api_key=api_key, model=model.name, messages=messages, stream=stream, **kwargs)))
|
34 |
+
except TypeError as e:
|
35 |
+
print(e)
|
36 |
+
arg: str = str(e).split("'")[1]
|
37 |
+
print(
|
38 |
+
f"ValueError: {engine.__name__} does not support '{arg}' argument", file=sys.stderr)
|
39 |
+
sys.exit(1)
|
g4f/models.py
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from g4f import Provider
|
2 |
+
|
3 |
+
|
4 |
+
class Model:
|
5 |
+
class model:
|
6 |
+
name: str
|
7 |
+
base_provider: str
|
8 |
+
best_provider: str
|
9 |
+
|
10 |
+
class gpt_35_turbo:
|
11 |
+
name: str = 'gpt-3.5-turbo'
|
12 |
+
base_provider: str = 'openai'
|
13 |
+
best_provider: Provider.Provider = Provider.Chimera
|
14 |
+
|
15 |
+
class gpt_35_turbo_poe:
|
16 |
+
name: str = 'gpt-3.5-turbo-poe'
|
17 |
+
base_provider: str = 'poe'
|
18 |
+
best_provider: Provider.Provider = Provider.Chimera
|
19 |
+
|
20 |
+
class gpt_35_turbo_16k:
|
21 |
+
name: str = 'gpt-3.5-turbo-16k'
|
22 |
+
base_provider: str = 'reversed'
|
23 |
+
best_provider: Provider.Provider = Provider.Chimera
|
24 |
+
|
25 |
+
class gpt_35_turbo_16k_poe:
|
26 |
+
name: str = 'gpt-3.5-turbo-16k-poe'
|
27 |
+
base_provider: str = 'poe'
|
28 |
+
best_provider: Provider.Provider = Provider.Chimera
|
29 |
+
|
30 |
+
class gpt_4:
|
31 |
+
name: str = 'gpt-4'
|
32 |
+
base_provider: str = 'reversed'
|
33 |
+
best_provider: Provider.Provider = Provider.Chimera
|
34 |
+
|
35 |
+
class gpt_4_0613:
|
36 |
+
name: str = 'gpt-4-0613'
|
37 |
+
base_provider: str = 'reversed'
|
38 |
+
best_provider: Provider.Provider = Provider.Chimera
|
39 |
+
|
40 |
+
class gpt_4_poe:
|
41 |
+
name: str = 'gpt-4-poe'
|
42 |
+
base_provider: str = 'poe'
|
43 |
+
best_provider: Provider.Provider = Provider.Chimera
|
44 |
+
|
45 |
+
class gpt_4_32k:
|
46 |
+
name: str = 'gpt-4-32k'
|
47 |
+
base_provider: str = 'reversed'
|
48 |
+
best_provider: Provider.Provider = Provider.Chimera
|
49 |
+
|
50 |
+
class gpt_4_32k_poe:
|
51 |
+
name: str = 'gpt-4-32k-poe'
|
52 |
+
base_provider: str = 'poe'
|
53 |
+
best_provider: Provider.Provider = Provider.Chimera
|
54 |
+
|
55 |
+
class claude_instant_100k:
|
56 |
+
name: str = 'claude-instant-100k'
|
57 |
+
base_provider: str = 'anthropic'
|
58 |
+
best_provider: Provider.Provider = Provider.Chimera
|
59 |
+
|
60 |
+
class claude_instant:
|
61 |
+
name: str = 'claude-instant'
|
62 |
+
base_provider: str = 'anthropic'
|
63 |
+
best_provider: Provider.Provider = Provider.Chimera
|
64 |
+
|
65 |
+
class claude_2_100k:
|
66 |
+
name: str = 'claude-2-100k'
|
67 |
+
base_provider: str = 'anthropic'
|
68 |
+
best_provider: Provider.Provider = Provider.Chimera
|
69 |
+
|
70 |
+
class sage:
|
71 |
+
name: str = 'sage'
|
72 |
+
base_provider: str = 'poe'
|
73 |
+
best_provider: Provider.Provider = Provider.Chimera
|
74 |
+
|
75 |
+
|
76 |
+
class ModelUtils:
|
77 |
+
convert: dict = {
|
78 |
+
'gpt-3.5-turbo': Model.gpt_35_turbo,
|
79 |
+
'gpt-3.5-turbo-poe': Model.gpt_35_turbo_poe,
|
80 |
+
'gpt-3.5-turbo-16k': Model.gpt_35_turbo_16k,
|
81 |
+
'gpt-3.5-turbo-16k-poe': Model.gpt_35_turbo_16k_poe,
|
82 |
+
'gpt-4': Model.gpt_4,
|
83 |
+
'gpt-4-0613': Model.gpt_4_0613,
|
84 |
+
'gpt-4-poe': Model.gpt_4_poe,
|
85 |
+
'gpt-4-32k': Model.gpt_4_32k,
|
86 |
+
'gpt-4-32k-poe': Model.gpt_4_32k_poe,
|
87 |
+
|
88 |
+
'claude-instant-100k': Model.claude_instant_100k,
|
89 |
+
'claude-instant': Model.claude_instant,
|
90 |
+
'claude-2-100k': Model.claude_2_100k,
|
91 |
+
|
92 |
+
'sage': Model.sage,
|
93 |
+
}
|
g4f/typing.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Dict, NewType, Union, Optional, List, get_type_hints
|
2 |
+
|
3 |
+
sha256 = NewType('sha_256_hash', str)
|
g4f/utils.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import browser_cookie3
|
2 |
+
|
3 |
+
|
4 |
+
class Utils:
|
5 |
+
browsers = [
|
6 |
+
browser_cookie3.chrome, # 62.74% market share
|
7 |
+
browser_cookie3.safari, # 24.12% market share
|
8 |
+
browser_cookie3.firefox, # 4.56% market share
|
9 |
+
browser_cookie3.edge, # 2.85% market share
|
10 |
+
browser_cookie3.opera, # 1.69% market share
|
11 |
+
browser_cookie3.brave, # 0.96% market share
|
12 |
+
browser_cookie3.opera_gx, # 0.64% market share
|
13 |
+
browser_cookie3.vivaldi, # 0.32% market share
|
14 |
+
]
|
15 |
+
|
16 |
+
def get_cookies(domain: str, setName: str = None, setBrowser: str = False) -> dict:
|
17 |
+
cookies = {}
|
18 |
+
|
19 |
+
if setBrowser != False:
|
20 |
+
for browser in Utils.browsers:
|
21 |
+
if browser.__name__ == setBrowser:
|
22 |
+
try:
|
23 |
+
for c in browser(domain_name=domain):
|
24 |
+
if c.name not in cookies:
|
25 |
+
cookies = cookies | {c.name: c.value}
|
26 |
+
|
27 |
+
except Exception as e:
|
28 |
+
pass
|
29 |
+
|
30 |
+
else:
|
31 |
+
for browser in Utils.browsers:
|
32 |
+
try:
|
33 |
+
for c in browser(domain_name=domain):
|
34 |
+
if c.name not in cookies:
|
35 |
+
cookies = cookies | {c.name: c.value}
|
36 |
+
|
37 |
+
except Exception as e:
|
38 |
+
pass
|
39 |
+
|
40 |
+
if setName:
|
41 |
+
try:
|
42 |
+
return {setName: cookies[setName]}
|
43 |
+
|
44 |
+
except ValueError:
|
45 |
+
print(f'Error: could not find {setName} cookie in any browser.')
|
46 |
+
exit(1)
|
47 |
+
|
48 |
+
else:
|
49 |
+
return cookies
|
requirements.txt
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
websocket-client
|
2 |
+
python-dotenv
|
3 |
+
requests
|
4 |
+
tls-client
|
5 |
+
pypasser
|
6 |
+
names
|
7 |
+
colorama
|
8 |
+
curl_cffi
|
9 |
+
aiohttp
|
10 |
+
flask
|
11 |
+
flask_cors
|
12 |
+
streamlit
|
13 |
+
selenium
|
14 |
+
fake-useragent
|
15 |
+
twocaptcha
|
16 |
+
pydantic
|
17 |
+
pymailtm
|
18 |
+
Levenshtein
|
19 |
+
retrying
|
20 |
+
numpy>=1.22.2 # pinned to avoid a vulnerability
|
21 |
+
tornado>=6.3.2 # pinned to avoid a vulnerability
|
22 |
+
PyExecJS
|
23 |
+
openai
|
run.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from server.bp import bp
|
2 |
+
from server.website import Website
|
3 |
+
from server.backend import Backend_Api
|
4 |
+
from json import load
|
5 |
+
from flask import Flask
|
6 |
+
|
7 |
+
if __name__ == '__main__':
|
8 |
+
|
9 |
+
# Load configuration from config.json
|
10 |
+
config = load(open('config.json', 'r'))
|
11 |
+
site_config = config['site_config']
|
12 |
+
url_prefix = config.pop('url_prefix')
|
13 |
+
|
14 |
+
# Set up the website routes
|
15 |
+
site = Website(bp, url_prefix)
|
16 |
+
for route in site.routes:
|
17 |
+
bp.add_url_rule(
|
18 |
+
route,
|
19 |
+
view_func=site.routes[route]['function'],
|
20 |
+
methods=site.routes[route]['methods'],
|
21 |
+
)
|
22 |
+
|
23 |
+
# Set up the backend API routes
|
24 |
+
backend_api = Backend_Api(bp, config)
|
25 |
+
for route in backend_api.routes:
|
26 |
+
bp.add_url_rule(
|
27 |
+
route,
|
28 |
+
view_func=backend_api.routes[route]['function'],
|
29 |
+
methods=backend_api.routes[route]['methods'],
|
30 |
+
)
|
31 |
+
|
32 |
+
# Create the app and register the blueprint
|
33 |
+
app = Flask(__name__)
|
34 |
+
app.register_blueprint(bp, url_prefix=url_prefix)
|
35 |
+
|
36 |
+
# Run the Flask server
|
37 |
+
print(f"Running on {site_config['port']}{url_prefix}")
|
38 |
+
app.run(**site_config)
|
39 |
+
print(f"Closing port {site_config['port']}")
|
server/backend.py
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
from datetime import datetime
|
3 |
+
from g4f import ChatCompletion
|
4 |
+
from flask import request, Response, stream_with_context
|
5 |
+
from requests import get
|
6 |
+
from server.config import special_instructions
|
7 |
+
|
8 |
+
|
9 |
+
class Backend_Api:
|
10 |
+
def __init__(self, bp, config: dict) -> None:
|
11 |
+
"""
|
12 |
+
Initialize the Backend_Api class.
|
13 |
+
:param app: Flask application instance
|
14 |
+
:param config: Configuration dictionary
|
15 |
+
"""
|
16 |
+
self.bp = bp
|
17 |
+
self.routes = {
|
18 |
+
'/backend-api/v2/conversation': {
|
19 |
+
'function': self._conversation,
|
20 |
+
'methods': ['POST']
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
def _conversation(self):
|
25 |
+
"""
|
26 |
+
Handles the conversation route.
|
27 |
+
|
28 |
+
:return: Response object containing the generated conversation stream
|
29 |
+
"""
|
30 |
+
conversation_id = request.json['conversation_id']
|
31 |
+
|
32 |
+
try:
|
33 |
+
api_key = request.json['api_key']
|
34 |
+
jailbreak = request.json['jailbreak']
|
35 |
+
model = request.json['model']
|
36 |
+
messages = build_messages(jailbreak)
|
37 |
+
|
38 |
+
# Generate response
|
39 |
+
response = ChatCompletion.create(
|
40 |
+
api_key=api_key,
|
41 |
+
model=model,
|
42 |
+
stream=True,
|
43 |
+
chatId=conversation_id,
|
44 |
+
messages=messages
|
45 |
+
)
|
46 |
+
|
47 |
+
return Response(stream_with_context(generate_stream(response, jailbreak)), mimetype='text/event-stream')
|
48 |
+
|
49 |
+
except Exception as e:
|
50 |
+
print(e)
|
51 |
+
print(e.__traceback__.tb_next)
|
52 |
+
|
53 |
+
return {
|
54 |
+
'_action': '_ask',
|
55 |
+
'success': False,
|
56 |
+
"error": f"an error occurred {str(e)}"
|
57 |
+
}, 400
|
58 |
+
|
59 |
+
|
60 |
+
def build_messages(jailbreak):
|
61 |
+
"""
|
62 |
+
Build the messages for the conversation.
|
63 |
+
|
64 |
+
:param jailbreak: Jailbreak instruction string
|
65 |
+
:return: List of messages for the conversation
|
66 |
+
"""
|
67 |
+
_conversation = request.json['meta']['content']['conversation']
|
68 |
+
internet_access = request.json['meta']['content']['internet_access']
|
69 |
+
prompt = request.json['meta']['content']['parts'][0]
|
70 |
+
|
71 |
+
# Add the existing conversation
|
72 |
+
conversation = _conversation
|
73 |
+
|
74 |
+
# Add web results if enabled
|
75 |
+
if internet_access:
|
76 |
+
current_date = datetime.now().strftime("%Y-%m-%d")
|
77 |
+
query = f'Current date: {current_date}. ' + prompt["content"]
|
78 |
+
search_results = fetch_search_results(query)
|
79 |
+
conversation.extend(search_results)
|
80 |
+
|
81 |
+
# Add jailbreak instructions if enabled
|
82 |
+
if jailbreak_instructions := getJailbreak(jailbreak):
|
83 |
+
conversation.extend(jailbreak_instructions)
|
84 |
+
|
85 |
+
# Add the prompt
|
86 |
+
conversation.append(prompt)
|
87 |
+
|
88 |
+
# Reduce conversation size to avoid API Token quantity error
|
89 |
+
if len(conversation) > 3:
|
90 |
+
conversation = conversation[-4:]
|
91 |
+
|
92 |
+
return conversation
|
93 |
+
|
94 |
+
|
95 |
+
def fetch_search_results(query):
|
96 |
+
"""
|
97 |
+
Fetch search results for a given query.
|
98 |
+
|
99 |
+
:param query: Search query string
|
100 |
+
:return: List of search results
|
101 |
+
"""
|
102 |
+
search = get('https://ddg-api.herokuapp.com/search',
|
103 |
+
params={
|
104 |
+
'query': query,
|
105 |
+
'limit': 3,
|
106 |
+
})
|
107 |
+
|
108 |
+
snippets = ""
|
109 |
+
for index, result in enumerate(search.json()):
|
110 |
+
snippet = f'[{index + 1}] "{result["snippet"]}" URL:{result["link"]}.'
|
111 |
+
snippets += snippet
|
112 |
+
|
113 |
+
response = "Here are some updated web searches. Use this to improve user response:"
|
114 |
+
response += snippets
|
115 |
+
|
116 |
+
return [{'role': 'system', 'content': response}]
|
117 |
+
|
118 |
+
|
119 |
+
def generate_stream(response, jailbreak):
|
120 |
+
"""
|
121 |
+
Generate the conversation stream.
|
122 |
+
|
123 |
+
:param response: Response object from ChatCompletion.create
|
124 |
+
:param jailbreak: Jailbreak instruction string
|
125 |
+
:return: Generator object yielding messages in the conversation
|
126 |
+
"""
|
127 |
+
if getJailbreak(jailbreak):
|
128 |
+
response_jailbreak = ''
|
129 |
+
jailbroken_checked = False
|
130 |
+
for message in response:
|
131 |
+
response_jailbreak += message
|
132 |
+
if jailbroken_checked:
|
133 |
+
yield message
|
134 |
+
else:
|
135 |
+
if response_jailbroken_success(response_jailbreak):
|
136 |
+
jailbroken_checked = True
|
137 |
+
if response_jailbroken_failed(response_jailbreak):
|
138 |
+
yield response_jailbreak
|
139 |
+
jailbroken_checked = True
|
140 |
+
else:
|
141 |
+
yield from response
|
142 |
+
|
143 |
+
|
144 |
+
def response_jailbroken_success(response: str) -> bool:
|
145 |
+
"""Check if the response has been jailbroken.
|
146 |
+
|
147 |
+
:param response: Response string
|
148 |
+
:return: Boolean indicating if the response has been jailbroken
|
149 |
+
"""
|
150 |
+
act_match = re.search(r'ACT:', response, flags=re.DOTALL)
|
151 |
+
return bool(act_match)
|
152 |
+
|
153 |
+
|
154 |
+
def response_jailbroken_failed(response):
|
155 |
+
"""
|
156 |
+
Check if the response has not been jailbroken.
|
157 |
+
|
158 |
+
:param response: Response string
|
159 |
+
:return: Boolean indicating if the response has not been jailbroken
|
160 |
+
"""
|
161 |
+
return False if len(response) < 4 else not (response.startswith("GPT:") or response.startswith("ACT:"))
|
162 |
+
|
163 |
+
|
164 |
+
def getJailbreak(jailbreak):
|
165 |
+
"""
|
166 |
+
Check if jailbreak instructions are provided.
|
167 |
+
|
168 |
+
:param jailbreak: Jailbreak instruction string
|
169 |
+
:return: Jailbreak instructions if provided, otherwise None
|
170 |
+
"""
|
171 |
+
if jailbreak != "default":
|
172 |
+
special_instructions[jailbreak][0]['content'] += special_instructions['two_responses_instruction']
|
173 |
+
if jailbreak in special_instructions:
|
174 |
+
special_instructions[jailbreak]
|
175 |
+
return special_instructions[jailbreak]
|
176 |
+
else:
|
177 |
+
return None
|
178 |
+
else:
|
179 |
+
return None
|
server/bp.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Blueprint
|
2 |
+
|
3 |
+
bp = Blueprint('bp', __name__,
|
4 |
+
template_folder='./../client/html',
|
5 |
+
static_folder='./../client',
|
6 |
+
static_url_path='assets')
|