Lee commited on
Commit
e8354a7
1 Parent(s): 971eee0

Synced repo using 'sync_with_huggingface' Github Action

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. Dockerfile +16 -0
  2. LICENSE +674 -0
  3. client/css/button.css +26 -0
  4. client/css/buttons.css +4 -0
  5. client/css/checkbox.css +59 -0
  6. client/css/conversation.css +137 -0
  7. client/css/dropdown.css +10 -0
  8. client/css/field.css +11 -0
  9. client/css/global.css +66 -0
  10. client/css/hljs.css +92 -0
  11. client/css/label.css +16 -0
  12. client/css/main.css +7 -0
  13. client/css/message.css +54 -0
  14. client/css/options.css +10 -0
  15. client/css/select.css +20 -0
  16. client/css/sidebar.css +197 -0
  17. client/css/stop-generating.css +38 -0
  18. client/css/style.css +17 -0
  19. client/css/theme-toggler.css +33 -0
  20. client/css/typing.css +15 -0
  21. client/html/index.html +119 -0
  22. client/img/android-chrome-192x192.png +0 -0
  23. client/img/android-chrome-512x512.png +0 -0
  24. client/img/apple-touch-icon.png +0 -0
  25. client/img/favicon-16x16.png +0 -0
  26. client/img/favicon-32x32.png +0 -0
  27. client/img/favicon.ico +0 -0
  28. client/img/gpt.png +0 -0
  29. client/img/site.webmanifest +19 -0
  30. client/img/user.png +0 -0
  31. client/js/chat.js +515 -0
  32. client/js/highlight.min.js +0 -0
  33. client/js/highlightjs-copy.min.js +1 -0
  34. client/js/icons.js +1 -0
  35. client/js/theme-toggler.js +22 -0
  36. config.json +8 -0
  37. docker-compose.yml +11 -0
  38. g4f/Provider/Provider.py +16 -0
  39. g4f/Provider/Providers/Aichat.py +35 -0
  40. g4f/Provider/Providers/Bard.py +74 -0
  41. g4f/Provider/Providers/Better.py +56 -0
  42. g4f/Provider/Providers/Bing.py +349 -0
  43. g4f/Provider/Providers/ChatgptAi.py +51 -0
  44. g4f/Provider/Providers/ChatgptLogin.py +96 -0
  45. g4f/Provider/Providers/DeepAi.py +46 -0
  46. g4f/Provider/Providers/Dfehub.py +49 -0
  47. g4f/Provider/Providers/Easychat.py +27 -0
  48. g4f/Provider/Providers/Ezcht.py +35 -0
  49. g4f/Provider/Providers/Fakeopen.py +54 -0
  50. g4f/Provider/Providers/Forefront.py +30 -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/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,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ .input-box {
64
+ display: flex;
65
+ align-items: center;
66
+ padding: 8px;
67
+ cursor: pointer;
68
+ }
69
+
70
+ #cursor {
71
+ line-height: 17px;
72
+ margin-left: 3px;
73
+ -webkit-animation: blink 0.8s infinite;
74
+ animation: blink 0.8s infinite;
75
+ width: 7px;
76
+ height: 15px;
77
+ }
78
+
79
+ @keyframes blink {
80
+ 0% {
81
+ background: #ffffff00;
82
+ }
83
+
84
+ 50% {
85
+ background: white;
86
+ }
87
+
88
+ 100% {
89
+ background: #ffffff00;
90
+ }
91
+ }
92
+
93
+ @-webkit-keyframes blink {
94
+ 0% {
95
+ background: #ffffff00;
96
+ }
97
+
98
+ 50% {
99
+ background: white;
100
+ }
101
+
102
+ 100% {
103
+ background: #ffffff00;
104
+ }
105
+ }
106
+
107
+ /* scrollbar */
108
+ .conversation #messages::-webkit-scrollbar {
109
+ width: 4px;
110
+ padding: 8px 0px;
111
+ }
112
+
113
+ .conversation #messages::-webkit-scrollbar-track {
114
+ background-color: #ffffff00;
115
+ }
116
+
117
+ .conversation #messages::-webkit-scrollbar-thumb {
118
+ background-color: #555555;
119
+ border-radius: 10px;
120
+ }
121
+
122
+ @media screen and (max-width: 990px) {
123
+ .conversation {
124
+ width: 100%;
125
+ height: 90%;
126
+ }
127
+ }
128
+
129
+ @media screen and (max-height: 720px) {
130
+ .conversation.box {
131
+ height: 70%;
132
+ }
133
+
134
+ .conversation .user-input textarea {
135
+ font-size: 0.875rem;
136
+ }
137
+ }
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,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ @media screen and (max-height: 720px) {
63
+ :root {
64
+ --section-gap: 16px;
65
+ }
66
+ }
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,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ gap: 18px;
32
+ }
33
+
34
+ .message .content p,
35
+ .message .content li,
36
+ .message .content code {
37
+ font-size: 1rem;
38
+ line-height: 1.3;
39
+ }
40
+
41
+ @media screen and (max-height: 720px) {
42
+ .message .avatar-container img {
43
+ max-width: 32px;
44
+ max-height: 32px;
45
+ }
46
+
47
+ .message .content,
48
+ .message .content p,
49
+ .message .content li,
50
+ .message .content code {
51
+ font-size: 0.875rem;
52
+ line-height: 1.3;
53
+ }
54
+ }
client/css/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,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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";
client/css/theme-toggler.css ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .theme-toggler-container {
2
+ margin: 24px 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,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 rel="apple-touch-icon" sizes="180x180" href="{{ url_for('bp.static', filename='img/apple-touch-icon.png') }}" />
16
+ <link rel="icon" type="image/png" sizes="32x32" href="{{ url_for('bp.static', filename='img/favicon-32x32.png') }}" />
17
+ <link rel="icon" type="image/png" sizes="16x16" href="{{ url_for('bp.static', filename='img/favicon-16x16.png') }}" />
18
+ <link rel="manifest" href="{{ url_for('bp.static', filename='img/site.webmanifest') }}" />
19
+ <link
20
+ rel="stylesheet"
21
+ href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/styles/base16/dracula.min.css" />
22
+ <title>FreeGPT</title>
23
+ </head>
24
+
25
+ <body data-urlprefix="{{ url_prefix}}">
26
+ <div class="main-container">
27
+ <div class="box sidebar">
28
+ <div class="top">
29
+ <button class="button" onclick="new_conversation()">
30
+ <i class="fa-regular fa-plus"></i>
31
+ <span>New Conversation</span>
32
+ </button>
33
+ <div class="spinner"></div>
34
+ </div>
35
+ <div class="sidebar-footer">
36
+ <button class="button" onclick="delete_conversations()">
37
+ <i class="fa-regular fa-trash"></i>
38
+ <span>Clear Conversations</span>
39
+ </button>
40
+ <div class="field checkbox theme-toggler-container">
41
+ <input type="checkbox" id="theme-toggler" />
42
+ <label for="theme-toggler"></label>
43
+ <span>Dark Mode</span>
44
+ </div>
45
+ <a class="info" href="https://github.com/ramonvc/gptfree-jailbreak-webui" target="_blank">
46
+ <i class="fa-brands fa-github"></i>
47
+ <span class="conversation-title">
48
+ Version: 0.0.10-Alpha
49
+ </span>
50
+ </a>
51
+ </div>
52
+ </div>
53
+ <div class="conversation">
54
+ <div class="stop-generating stop-generating-hidden">
55
+ <button class="button" id="cancelButton">
56
+ <span>Stop Generating</span>
57
+ </button>
58
+ </div>
59
+ <div class="box" id="messages"></div>
60
+ <div class="user-input">
61
+ <div class="box input-box">
62
+ <textarea
63
+ id="message-input"
64
+ placeholder="Ask a question"
65
+ cols="30"
66
+ rows="10"
67
+ style="white-space: pre-wrap"></textarea>
68
+ <div id="send-button">
69
+ <i class="fa-regular fa-paper-plane-top"></i>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ <div>
74
+ <div class="options-container">
75
+ <div class="buttons">
76
+ <div class="field">
77
+ <select class="dropdown" name="model" id="model">
78
+ <option value="gpt-3.5-turbo">GPT-3.5</option>
79
+ <option value="gpt-3.5-turbo-0613">GPT-3.5-0613</option>
80
+ <option value="gpt-3.5-turbo-16k">GPT-3.5-turbo-16k</option>
81
+ <option value="gpt-3.5-turbo-16k-0613" selected>
82
+ GPT-3.5-turbo-16k-0613
83
+ </option>
84
+ <option value="gpt-4">GPT-4</option>
85
+ </select>
86
+ </div>
87
+ <div class="field">
88
+ <select class="dropdown" name="jailbreak" id="jailbreak">
89
+ <option value="default" selected>Default</option>
90
+ <option value="gpt-dan-11.0">DAN</option>
91
+ <option value="gpt-evil">Evil</option>
92
+ </select>
93
+ </div>
94
+ </div>
95
+ <div class="field checkbox">
96
+ <input type="checkbox" id="switch" />
97
+ <label for="switch"></label>
98
+ <span>Web Access</span>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </div>
103
+ </div>
104
+ <div class="mobile-sidebar">
105
+ <i class="fa-solid fa-bars"></i>
106
+ </div>
107
+
108
+ <!-- scripts -->
109
+ <script>
110
+ window.conversation_id = "{{ chat_id }}";
111
+ </script>
112
+ <script src="{{ url_for('bp.static', filename='js/icons.js') }}"></script>
113
+ <script src="{{ url_for('bp.static', filename='js/chat.js') }}" defer></script>
114
+ <script src="https://cdn.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js"></script>
115
+ <script src="{{ url_for('bp.static', filename='js/highlight.min.js') }}"></script>
116
+ <script src="{{ url_for('bp.static', filename='js/highlightjs-copy.min.js') }}"></script>
117
+ <script src="{{ url_for('bp.static', filename='js/theme-toggler.js') }}"></script>
118
+ </body>
119
+ </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/chat.js ADDED
@@ -0,0 +1,515 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, 20));
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
+ conversation_id: window.conversation_id,
103
+ action: `_ask`,
104
+ model: model.options[model.selectedIndex].value,
105
+ jailbreak: jailbreak.options[jailbreak.selectedIndex].value,
106
+ meta: {
107
+ id: window.token,
108
+ content: {
109
+ conversation: await get_conversation(window.conversation_id),
110
+ internet_access: document.getElementById("switch").checked,
111
+ content_type: "text",
112
+ parts: [
113
+ {
114
+ content: message,
115
+ role: "user",
116
+ },
117
+ ],
118
+ },
119
+ },
120
+ }),
121
+ });
122
+
123
+ const reader = response.body.getReader();
124
+
125
+ while (true) {
126
+ const { value, done } = await reader.read();
127
+ if (done) break;
128
+
129
+ chunk = decodeUnicode(new TextDecoder().decode(value));
130
+
131
+ if (chunk.includes(`<form id="challenge-form" action="${url_prefix}/backend-api/v2/conversation?`)) {
132
+ chunk = `cloudflare token expired, please refresh the page.`;
133
+ }
134
+
135
+ text += chunk;
136
+
137
+ document.getElementById(`gpt_${window.token}`).innerHTML = markdown.render(text);
138
+ document.querySelectorAll(`code`).forEach((el) => {
139
+ hljs.highlightElement(el);
140
+ });
141
+
142
+ window.scrollTo(0, 0);
143
+ message_box.scrollTo({ top: message_box.scrollHeight, behavior: "auto" });
144
+ }
145
+
146
+ // if text contains :
147
+ if (text.includes(`instead. Maintaining this website and API costs a lot of money`)) {
148
+ document.getElementById(`gpt_${window.token}`).innerHTML =
149
+ "An error occurred, please reload / refresh cache and try again.";
150
+ }
151
+
152
+ add_message(window.conversation_id, "user", message);
153
+ add_message(window.conversation_id, "assistant", text);
154
+
155
+ message_box.scrollTop = message_box.scrollHeight;
156
+ await remove_cancel_button();
157
+ prompt_lock = false;
158
+
159
+ await load_conversations(20, 0);
160
+ window.scrollTo(0, 0);
161
+ } catch (e) {
162
+ add_message(window.conversation_id, "user", message);
163
+
164
+ message_box.scrollTop = message_box.scrollHeight;
165
+ await remove_cancel_button();
166
+ prompt_lock = false;
167
+
168
+ await load_conversations(20, 0);
169
+
170
+ console.log(e);
171
+
172
+ let cursorDiv = document.getElementById(`cursor`);
173
+ if (cursorDiv) cursorDiv.parentNode.removeChild(cursorDiv);
174
+
175
+ if (e.name != `AbortError`) {
176
+ let error_message = `oops ! something went wrong, please try again / reload. [stacktrace in console]`;
177
+
178
+ document.getElementById(`gpt_${window.token}`).innerHTML = error_message;
179
+ add_message(window.conversation_id, "assistant", error_message);
180
+ } else {
181
+ document.getElementById(`gpt_${window.token}`).innerHTML += ` [aborted]`;
182
+ add_message(window.conversation_id, "assistant", text + ` [aborted]`);
183
+ }
184
+
185
+ window.scrollTo(0, 0);
186
+ }
187
+ };
188
+
189
+ const add_user_message_box = (message) => {
190
+ const messageDiv = document.createElement("div");
191
+ messageDiv.classList.add("message");
192
+
193
+ const avatarContainer = document.createElement("div");
194
+ avatarContainer.classList.add("avatar-container");
195
+ avatarContainer.innerHTML = user_image;
196
+
197
+ const contentDiv = document.createElement("div");
198
+ contentDiv.classList.add("content");
199
+ contentDiv.id = `user_${token}`;
200
+ contentDiv.innerText = message;
201
+
202
+ messageDiv.appendChild(avatarContainer);
203
+ messageDiv.appendChild(contentDiv);
204
+
205
+ message_box.appendChild(messageDiv);
206
+ };
207
+
208
+ const decodeUnicode = (str) => {
209
+ return str.replace(/\\u([a-fA-F0-9]{4})/g, function (match, grp) {
210
+ return String.fromCharCode(parseInt(grp, 16));
211
+ });
212
+ };
213
+
214
+ const clear_conversations = async () => {
215
+ const elements = box_conversations.childNodes;
216
+ let index = elements.length;
217
+
218
+ if (index > 0) {
219
+ while (index--) {
220
+ const element = elements[index];
221
+ if (element.nodeType === Node.ELEMENT_NODE && element.tagName.toLowerCase() !== `button`) {
222
+ box_conversations.removeChild(element);
223
+ }
224
+ }
225
+ }
226
+ };
227
+
228
+ const clear_conversation = async () => {
229
+ let messages = message_box.getElementsByTagName(`div`);
230
+
231
+ while (messages.length > 0) {
232
+ message_box.removeChild(messages[0]);
233
+ }
234
+ };
235
+
236
+ const delete_conversation = async (conversation_id) => {
237
+ localStorage.removeItem(`conversation:${conversation_id}`);
238
+
239
+ if (window.conversation_id == conversation_id) {
240
+ await new_conversation();
241
+ }
242
+
243
+ await load_conversations(20, 0, true);
244
+ };
245
+
246
+ const set_conversation = async (conversation_id) => {
247
+ history.pushState({}, null, `${url_prefix}/chat/${conversation_id}`);
248
+ window.conversation_id = conversation_id;
249
+
250
+ await clear_conversation();
251
+ await load_conversation(conversation_id);
252
+ await load_conversations(20, 0, true);
253
+ };
254
+
255
+ const new_conversation = async () => {
256
+ history.pushState({}, null, `${url_prefix}/chat/`);
257
+ window.conversation_id = uuid();
258
+
259
+ await clear_conversation();
260
+ await load_conversations(20, 0, true);
261
+ };
262
+
263
+ const load_conversation = async (conversation_id) => {
264
+ let conversation = await JSON.parse(localStorage.getItem(`conversation:${conversation_id}`));
265
+ console.log(conversation, conversation_id);
266
+
267
+ for (item of conversation.items) {
268
+ if (is_assistant(item.role)) {
269
+ message_box.innerHTML += load_gpt_message_box(item.content);
270
+ } else {
271
+ message_box.innerHTML += load_user_message_box(item.content);
272
+ }
273
+ }
274
+
275
+ document.querySelectorAll(`code`).forEach((el) => {
276
+ hljs.highlightElement(el);
277
+ });
278
+
279
+ message_box.scrollTo({ top: message_box.scrollHeight, behavior: "smooth" });
280
+
281
+ setTimeout(() => {
282
+ message_box.scrollTop = message_box.scrollHeight;
283
+ }, 500);
284
+ };
285
+
286
+ const load_user_message_box = (content) => {
287
+ const messageDiv = document.createElement("div");
288
+ messageDiv.classList.add("message");
289
+
290
+ const avatarContainer = document.createElement("div");
291
+ avatarContainer.classList.add("avatar-container");
292
+ avatarContainer.innerHTML = user_image;
293
+
294
+ const contentDiv = document.createElement("div");
295
+ contentDiv.classList.add("content");
296
+ contentDiv.innerText = content;
297
+
298
+ messageDiv.appendChild(avatarContainer);
299
+ messageDiv.appendChild(contentDiv);
300
+
301
+ return messageDiv.outerHTML;
302
+ };
303
+
304
+ const load_gpt_message_box = (content) => {
305
+ return `
306
+ <div class="message">
307
+ <div class="avatar-container">
308
+ ${gpt_image}
309
+ </div>
310
+ <div class="content">
311
+ ${markdown.render(content)}
312
+ </div>
313
+ </div>
314
+ `;
315
+ };
316
+
317
+ const is_assistant = (role) => {
318
+ return role == "assistant";
319
+ };
320
+
321
+ const get_conversation = async (conversation_id) => {
322
+ let conversation = await JSON.parse(localStorage.getItem(`conversation:${conversation_id}`));
323
+ return conversation.items;
324
+ };
325
+
326
+ const add_conversation = async (conversation_id, title) => {
327
+ if (localStorage.getItem(`conversation:${conversation_id}`) == null) {
328
+ localStorage.setItem(
329
+ `conversation:${conversation_id}`,
330
+ JSON.stringify({
331
+ id: conversation_id,
332
+ title: title,
333
+ items: [],
334
+ })
335
+ );
336
+ }
337
+ };
338
+
339
+ const add_message = async (conversation_id, role, content) => {
340
+ before_adding = JSON.parse(localStorage.getItem(`conversation:${conversation_id}`));
341
+
342
+ before_adding.items.push({
343
+ role: role,
344
+ content: content,
345
+ });
346
+
347
+ localStorage.setItem(`conversation:${conversation_id}`, JSON.stringify(before_adding)); // update conversation
348
+ };
349
+
350
+ const load_conversations = async (limit, offset, loader) => {
351
+ //console.log(loader);
352
+ //if (loader === undefined) box_conversations.appendChild(spinner);
353
+
354
+ let conversations = [];
355
+ for (let i = 0; i < localStorage.length; i++) {
356
+ if (localStorage.key(i).startsWith("conversation:")) {
357
+ let conversation = localStorage.getItem(localStorage.key(i));
358
+ conversations.push(JSON.parse(conversation));
359
+ }
360
+ }
361
+
362
+ //if (loader === undefined) spinner.parentNode.removeChild(spinner)
363
+ await clear_conversations();
364
+
365
+ for (conversation of conversations) {
366
+ box_conversations.innerHTML += `
367
+ <div class="conversation-sidebar">
368
+ <div class="left" onclick="set_conversation('${conversation.id}')">
369
+ <i class="fa-regular fa-comments"></i>
370
+ <span class="conversation-title">${conversation.title}</span>
371
+ </div>
372
+ <i onclick="delete_conversation('${conversation.id}')" class="fa-regular fa-trash"></i>
373
+ </div>
374
+ `;
375
+ }
376
+
377
+ document.querySelectorAll(`code`).forEach((el) => {
378
+ hljs.highlightElement(el);
379
+ });
380
+ };
381
+
382
+ document.getElementById(`cancelButton`).addEventListener(`click`, async () => {
383
+ window.controller.abort();
384
+ console.log(`aborted ${window.conversation_id}`);
385
+ });
386
+
387
+ function h2a(str1) {
388
+ var hex = str1.toString();
389
+ var str = "";
390
+
391
+ for (var n = 0; n < hex.length; n += 2) {
392
+ str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
393
+ }
394
+
395
+ return str;
396
+ }
397
+
398
+ const uuid = () => {
399
+ return `xxxxxxxx-xxxx-4xxx-yxxx-${Date.now().toString(16)}`.replace(/[xy]/g, function (c) {
400
+ var r = (Math.random() * 16) | 0,
401
+ v = c == "x" ? r : (r & 0x3) | 0x8;
402
+ return v.toString(16);
403
+ });
404
+ };
405
+
406
+ const message_id = () => {
407
+ random_bytes = (Math.floor(Math.random() * 1338377565) + 2956589730).toString(2);
408
+ unix = Math.floor(Date.now() / 1000).toString(2);
409
+
410
+ return BigInt(`0b${unix}${random_bytes}`).toString();
411
+ };
412
+
413
+ window.onload = async () => {
414
+ load_settings_localstorage();
415
+
416
+ conversations = 0;
417
+ for (let i = 0; i < localStorage.length; i++) {
418
+ if (localStorage.key(i).startsWith("conversation:")) {
419
+ conversations += 1;
420
+ }
421
+ }
422
+
423
+ if (conversations == 0) localStorage.clear();
424
+
425
+ await setTimeout(() => {
426
+ load_conversations(20, 0);
427
+ }, 1);
428
+
429
+ if (!window.location.href.endsWith(`#`)) {
430
+ if (/\/chat\/.+/.test(window.location.href.slice(url_prefix.length))) {
431
+ await load_conversation(window.conversation_id);
432
+ }
433
+ }
434
+
435
+ message_input.addEventListener("keydown", async (evt) => {
436
+ if (prompt_lock) return;
437
+
438
+ if (evt.key === "Enter" && !evt.shiftKey) {
439
+ evt.preventDefault();
440
+ await handle_ask();
441
+ }
442
+ });
443
+
444
+ send_button.addEventListener("click", async (event) => {
445
+ event.preventDefault();
446
+ if (prompt_lock) return;
447
+ message_input.blur();
448
+ await handle_ask();
449
+ });
450
+
451
+ register_settings_localstorage();
452
+ };
453
+
454
+ document.querySelector(".mobile-sidebar").addEventListener("click", (event) => {
455
+ const sidebar = document.querySelector(".sidebar");
456
+
457
+ if (sidebar.classList.contains("shown")) {
458
+ sidebar.classList.remove("shown");
459
+ event.target.classList.remove("rotated");
460
+ document.body.style.overflow = "auto";
461
+ } else {
462
+ sidebar.classList.add("shown");
463
+ event.target.classList.add("rotated");
464
+ document.body.style.overflow = "hidden";
465
+ }
466
+
467
+ window.scrollTo(0, 0);
468
+ });
469
+
470
+ const register_settings_localstorage = async () => {
471
+ settings_ids = ["switch", "model", "jailbreak"];
472
+ settings_elements = settings_ids.map((id) => document.getElementById(id));
473
+ settings_elements.map((element) =>
474
+ element.addEventListener(`change`, async (event) => {
475
+ switch (event.target.type) {
476
+ case "checkbox":
477
+ localStorage.setItem(event.target.id, event.target.checked);
478
+ break;
479
+ case "select-one":
480
+ localStorage.setItem(event.target.id, event.target.selectedIndex);
481
+ break;
482
+ default:
483
+ console.warn("Unresolved element type");
484
+ }
485
+ })
486
+ );
487
+ };
488
+
489
+ const load_settings_localstorage = async () => {
490
+ settings_ids = ["switch", "model", "jailbreak"];
491
+ settings_elements = settings_ids.map((id) => document.getElementById(id));
492
+ settings_elements.map((element) => {
493
+ if (localStorage.getItem(element.id)) {
494
+ switch (element.type) {
495
+ case "checkbox":
496
+ element.checked = localStorage.getItem(element.id) === "true";
497
+ break;
498
+ case "select-one":
499
+ element.selectedIndex = parseInt(localStorage.getItem(element.id));
500
+ break;
501
+ default:
502
+ console.warn("Unresolved element type");
503
+ }
504
+ }
505
+ });
506
+ };
507
+
508
+ function clearTextarea(textarea) {
509
+ textarea.style.removeProperty("height");
510
+ textarea.style.height = `${textarea.scrollHeight + 4}px`;
511
+
512
+ if (textarea.value.trim() === "" && textarea.value.includes("\n")) {
513
+ textarea.value = "";
514
+ }
515
+ }
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": 7860,
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/Aichat.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import os
3
+ import json
4
+ from ...typing import sha256, Dict, get_type_hints
5
+
6
+ url = 'https://hteyun.com'
7
+ model = ['gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-3.5-turbo-16k-0613', 'gpt-3.5-turbo-0613']
8
+ supports_stream = True
9
+ needs_auth = False
10
+
11
+ def _create_completion(model: str, messages: list, stream: bool, temperature: float = 0.7, **kwargs):
12
+ headers = {
13
+ 'Content-Type': 'application/json',
14
+ }
15
+ data = {
16
+ 'model': model,
17
+ 'temperature': 0.7,
18
+ 'presence_penalty': 0,
19
+ 'messages': messages,
20
+ }
21
+ response = requests.post(url + '/api/chat-stream',
22
+ json=data, stream=True)
23
+
24
+ if stream:
25
+ for chunk in response.iter_content(chunk_size=None):
26
+ chunk = chunk.decode('utf-8')
27
+ if chunk.strip():
28
+ message = json.loads(chunk)['choices'][0]['message']['content']
29
+ yield message
30
+ else:
31
+ message = response.json()['choices'][0]['message']['content']
32
+ yield message
33
+
34
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
35
+ '(%s)' % ', '.join([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/Bard.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, requests, json, browser_cookie3, re, random
2
+ from ...typing import sha256, Dict, get_type_hints
3
+
4
+ url = 'https://bard.google.com'
5
+ model = ['Palm2']
6
+ supports_stream = False
7
+ needs_auth = True
8
+
9
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
10
+ psid = {cookie.name: cookie.value for cookie in browser_cookie3.chrome(
11
+ domain_name='.google.com')}['__Secure-1PSID']
12
+
13
+ formatted = '\n'.join([
14
+ '%s: %s' % (message['role'], message['content']) for message in messages
15
+ ])
16
+ prompt = f'{formatted}\nAssistant:'
17
+
18
+ proxy = kwargs.get('proxy', False)
19
+ if proxy == False:
20
+ print('warning!, you did not give a proxy, a lot of countries are banned from Google Bard, so it may not work')
21
+
22
+ snlm0e = None
23
+ conversation_id = None
24
+ response_id = None
25
+ choice_id = None
26
+
27
+ client = requests.Session()
28
+ client.proxies = {
29
+ 'http': f'http://{proxy}',
30
+ 'https': f'http://{proxy}'} if proxy else None
31
+
32
+ client.headers = {
33
+ 'authority': 'bard.google.com',
34
+ 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8',
35
+ 'origin': 'https://bard.google.com',
36
+ 'referer': 'https://bard.google.com/',
37
+ 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
38
+ 'x-same-domain': '1',
39
+ 'cookie': f'__Secure-1PSID={psid}'
40
+ }
41
+
42
+ snlm0e = re.search(r'SNlM0e\":\"(.*?)\"',
43
+ client.get('https://bard.google.com/').text).group(1) if not snlm0e else snlm0e
44
+
45
+ params = {
46
+ 'bl': 'boq_assistant-bard-web-server_20230326.21_p0',
47
+ '_reqid': random.randint(1111, 9999),
48
+ 'rt': 'c'
49
+ }
50
+
51
+ data = {
52
+ 'at': snlm0e,
53
+ 'f.req': json.dumps([None, json.dumps([[prompt], None, [conversation_id, response_id, choice_id]])])}
54
+
55
+ intents = '.'.join([
56
+ 'assistant',
57
+ 'lamda',
58
+ 'BardFrontendService'
59
+ ])
60
+
61
+ response = client.post(f'https://bard.google.com/_/BardChatUi/data/{intents}/StreamGenerate',
62
+ data=data, params=params)
63
+
64
+ chat_data = json.loads(response.content.splitlines()[3])[0][2]
65
+ if chat_data:
66
+ json_chat_data = json.loads(chat_data)
67
+
68
+ yield json_chat_data[0][0]
69
+
70
+ else:
71
+ yield 'error'
72
+
73
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
74
+ '(%s)' % ', '.join([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/Better.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import requests
4
+ from typing import Dict, get_type_hints
5
+
6
+ url = 'https://openai-proxy-api.vercel.app/v1/'
7
+ model = {
8
+ 'gpt-3.5-turbo',
9
+ 'gpt-3.5-turbo-0613'
10
+ 'gpt-3.5-turbo-16k',
11
+ 'gpt-3.5-turbo-16k-0613',
12
+ 'gpt-4',
13
+ }
14
+
15
+ supports_stream = True
16
+ needs_auth = False
17
+
18
+
19
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
20
+ headers = {
21
+ 'Content-Type': 'application/json',
22
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.58',
23
+ 'Referer': 'https://chat.ylokh.xyz/',
24
+ 'Origin': 'https://chat.ylokh.xyz',
25
+ 'Connection': 'keep-alive',
26
+ }
27
+
28
+ json_data = {
29
+ 'messages': messages,
30
+ 'temperature': 1.0,
31
+ 'model': model,
32
+ 'stream': stream,
33
+ }
34
+
35
+ response = requests.post(
36
+ 'https://openai-proxy-api.vercel.app/v1/chat/completions', headers=headers, json=json_data, stream=True
37
+ )
38
+
39
+ for token in response.iter_lines():
40
+ decoded = token.decode('utf-8')
41
+ if decoded.startswith('data: '):
42
+ data_str = decoded.replace('data: ', '')
43
+ data = json.loads(data_str)
44
+ if 'choices' in data and 'delta' in data['choices'][0]:
45
+ delta = data['choices'][0]['delta']
46
+ content = delta.get('content', '')
47
+ finish_reason = delta.get('finish_reason', '')
48
+
49
+ if finish_reason == 'stop':
50
+ break
51
+ if content:
52
+ yield content
53
+
54
+
55
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + '(%s)' % ', '.join(
56
+ [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/Bing.py ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import random
4
+ import json
5
+ import os
6
+ import uuid
7
+ import ssl
8
+ import certifi
9
+ import aiohttp
10
+ import asyncio
11
+
12
+ import requests
13
+ from ...typing import sha256, Dict, get_type_hints
14
+
15
+ url = 'https://bing.com/chat'
16
+ model = ['gpt-4']
17
+ supports_stream = True
18
+ needs_auth = False
19
+
20
+ ssl_context = ssl.create_default_context()
21
+ ssl_context.load_verify_locations(certifi.where())
22
+
23
+
24
+ class optionsSets:
25
+ optionSet: dict = {
26
+ 'tone': str,
27
+ 'optionsSets': list
28
+ }
29
+
30
+ jailbreak: dict = {
31
+ "optionsSets": [
32
+ 'saharasugg',
33
+ 'enablenewsfc',
34
+ 'clgalileo',
35
+ 'gencontentv3',
36
+ "nlu_direct_response_filter",
37
+ "deepleo",
38
+ "disable_emoji_spoken_text",
39
+ "responsible_ai_policy_235",
40
+ "enablemm",
41
+ "h3precise"
42
+ # "harmonyv3",
43
+ "dtappid",
44
+ "cricinfo",
45
+ "cricinfov2",
46
+ "dv3sugg",
47
+ "nojbfedge"
48
+ ]
49
+ }
50
+
51
+
52
+ class Defaults:
53
+ delimiter = '\x1e'
54
+ ip_address = f'13.{random.randint(104, 107)}.{random.randint(0, 255)}.{random.randint(0, 255)}'
55
+
56
+ allowedMessageTypes = [
57
+ 'Chat',
58
+ 'Disengaged',
59
+ 'AdsQuery',
60
+ 'SemanticSerp',
61
+ 'GenerateContentQuery',
62
+ 'SearchQuery',
63
+ 'ActionRequest',
64
+ 'Context',
65
+ 'Progress',
66
+ 'AdsQuery',
67
+ 'SemanticSerp'
68
+ ]
69
+
70
+ sliceIds = [
71
+
72
+ # "222dtappid",
73
+ # "225cricinfo",
74
+ # "224locals0"
75
+
76
+ 'winmuid3tf',
77
+ 'osbsdusgreccf',
78
+ 'ttstmout',
79
+ 'crchatrev',
80
+ 'winlongmsgtf',
81
+ 'ctrlworkpay',
82
+ 'norespwtf',
83
+ 'tempcacheread',
84
+ 'temptacache',
85
+ '505scss0',
86
+ '508jbcars0',
87
+ '515enbotdets0',
88
+ '5082tsports',
89
+ '515vaoprvs',
90
+ '424dagslnv1s0',
91
+ 'kcimgattcf',
92
+ '427startpms0'
93
+ ]
94
+
95
+ location = {
96
+ 'locale': 'en-US',
97
+ 'market': 'en-US',
98
+ 'region': 'US',
99
+ 'locationHints': [
100
+ {
101
+ 'country': 'United States',
102
+ 'state': 'California',
103
+ 'city': 'Los Angeles',
104
+ 'timezoneoffset': 8,
105
+ 'countryConfidence': 8,
106
+ 'Center': {
107
+ 'Latitude': 34.0536909,
108
+ 'Longitude': -118.242766
109
+ },
110
+ 'RegionType': 2,
111
+ 'SourceType': 1
112
+ }
113
+ ],
114
+ }
115
+
116
+
117
+ def _format(msg: dict) -> str:
118
+ return json.dumps(msg, ensure_ascii=False) + Defaults.delimiter
119
+
120
+
121
+ async def create_conversation():
122
+ for _ in range(5):
123
+ create = requests.get('https://www.bing.com/turing/conversation/create',
124
+ headers={
125
+ 'authority': 'edgeservices.bing.com',
126
+ 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
127
+ 'accept-language': 'en-US,en;q=0.9',
128
+ 'cache-control': 'max-age=0',
129
+ 'sec-ch-ua': '"Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"',
130
+ 'sec-ch-ua-arch': '"x86"',
131
+ 'sec-ch-ua-bitness': '"64"',
132
+ 'sec-ch-ua-full-version': '"110.0.1587.69"',
133
+ 'sec-ch-ua-full-version-list': '"Chromium";v="110.0.5481.192", "Not A(Brand";v="24.0.0.0", "Microsoft Edge";v="110.0.1587.69"',
134
+ 'sec-ch-ua-mobile': '?0',
135
+ 'sec-ch-ua-model': '""',
136
+ 'sec-ch-ua-platform': '"Windows"',
137
+ 'sec-ch-ua-platform-version': '"15.0.0"',
138
+ 'sec-fetch-dest': 'document',
139
+ 'sec-fetch-mode': 'navigate',
140
+ 'sec-fetch-site': 'none',
141
+ 'sec-fetch-user': '?1',
142
+ 'upgrade-insecure-requests': '1',
143
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.69',
144
+ 'x-edge-shopping-flag': '1',
145
+ 'x-forwarded-for': Defaults.ip_address
146
+ })
147
+
148
+ conversationId = create.json().get('conversationId')
149
+ clientId = create.json().get('clientId')
150
+ conversationSignature = create.json().get('conversationSignature')
151
+
152
+ if not conversationId or not clientId or not conversationSignature and _ == 4:
153
+ raise Exception('Failed to create conversation.')
154
+
155
+ return conversationId, clientId, conversationSignature
156
+
157
+
158
+ async def stream_generate(prompt: str, mode: optionsSets.optionSet = optionsSets.jailbreak, context: bool or str = False):
159
+ timeout = aiohttp.ClientTimeout(total=900)
160
+ session = aiohttp.ClientSession(timeout=timeout)
161
+
162
+ conversationId, clientId, conversationSignature = await create_conversation()
163
+
164
+ wss = await session.ws_connect('wss://sydney.bing.com/sydney/ChatHub', ssl=ssl_context, autoping=False,
165
+ headers={
166
+ 'accept': 'application/json',
167
+ 'accept-language': 'en-US,en;q=0.9',
168
+ 'content-type': 'application/json',
169
+ 'sec-ch-ua': '"Not_A Brand";v="99", "Microsoft Edge";v="110", "Chromium";v="110"',
170
+ 'sec-ch-ua-arch': '"x86"',
171
+ 'sec-ch-ua-bitness': '"64"',
172
+ 'sec-ch-ua-full-version': '"109.0.1518.78"',
173
+ 'sec-ch-ua-full-version-list': '"Chromium";v="110.0.5481.192", "Not A(Brand";v="24.0.0.0", "Microsoft Edge";v="110.0.1587.69"',
174
+ 'sec-ch-ua-mobile': '?0',
175
+ 'sec-ch-ua-model': '',
176
+ 'sec-ch-ua-platform': '"Windows"',
177
+ 'sec-ch-ua-platform-version': '"15.0.0"',
178
+ 'sec-fetch-dest': 'empty',
179
+ 'sec-fetch-mode': 'cors',
180
+ 'sec-fetch-site': 'same-origin',
181
+ 'x-ms-client-request-id': str(uuid.uuid4()),
182
+ 'x-ms-useragent': 'azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.10.0 OS/Win32',
183
+ 'Referer': 'https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx',
184
+ 'Referrer-Policy': 'origin-when-cross-origin',
185
+ 'x-forwarded-for': Defaults.ip_address
186
+ })
187
+
188
+ await wss.send_str(_format({'protocol': 'json', 'version': 1}))
189
+ await wss.receive(timeout=900)
190
+
191
+ struct = {
192
+ 'arguments': [
193
+ {
194
+ **mode,
195
+ 'source': 'cib',
196
+ 'allowedMessageTypes': Defaults.allowedMessageTypes,
197
+ 'sliceIds': Defaults.sliceIds,
198
+ 'traceId': os.urandom(16).hex(),
199
+ 'isStartOfSession': True,
200
+ 'message': Defaults.location | {
201
+ 'author': 'user',
202
+ 'inputMethod': 'Keyboard',
203
+ 'text': prompt,
204
+ 'messageType': 'Chat'
205
+ },
206
+ 'conversationSignature': conversationSignature,
207
+ 'participant': {
208
+ 'id': clientId
209
+ },
210
+ 'conversationId': conversationId
211
+ }
212
+ ],
213
+ 'invocationId': '0',
214
+ 'target': 'chat',
215
+ 'type': 4
216
+ }
217
+
218
+ if context:
219
+ struct['arguments'][0]['previousMessages'] = [
220
+ {
221
+ "author": "user",
222
+ "description": context,
223
+ "contextType": "WebPage",
224
+ "messageType": "Context",
225
+ "messageId": "discover-web--page-ping-mriduna-----"
226
+ }
227
+ ]
228
+
229
+ await wss.send_str(_format(struct))
230
+
231
+ final = False
232
+ draw = False
233
+ resp_txt = ''
234
+ result_text = ''
235
+ resp_txt_no_link = ''
236
+ cache_text = ''
237
+
238
+ while not final:
239
+ msg = await wss.receive(timeout=900)
240
+ objects = msg.data.split(Defaults.delimiter)
241
+
242
+ for obj in objects:
243
+ if obj is None or not obj:
244
+ continue
245
+
246
+ response = json.loads(obj)
247
+ if response.get('type') == 1 and response['arguments'][0].get('messages',):
248
+ if not draw:
249
+ if (response['arguments'][0]['messages'][0]['contentOrigin'] != 'Apology') and not draw:
250
+ resp_txt = result_text + \
251
+ response['arguments'][0]['messages'][0]['adaptiveCards'][0]['body'][0].get(
252
+ 'text', '')
253
+ resp_txt_no_link = result_text + \
254
+ response['arguments'][0]['messages'][0].get(
255
+ 'text', '')
256
+
257
+ if response['arguments'][0]['messages'][0].get('messageType',):
258
+ resp_txt = (
259
+ resp_txt
260
+ + response['arguments'][0]['messages'][0]['adaptiveCards'][0]['body'][0]['inlines'][0].get('text')
261
+ + '\n'
262
+ )
263
+ result_text = (
264
+ result_text
265
+ + response['arguments'][0]['messages'][0]['adaptiveCards'][0]['body'][0]['inlines'][0].get('text')
266
+ + '\n'
267
+ )
268
+
269
+ if cache_text.endswith(' '):
270
+ final = True
271
+ if wss and not wss.closed:
272
+ await wss.close()
273
+ if session and not session.closed:
274
+ await session.close()
275
+
276
+ yield (resp_txt.replace(cache_text, ''))
277
+ cache_text = resp_txt
278
+
279
+ elif response.get('type') == 2:
280
+ if response['item']['result'].get('error'):
281
+ if wss and not wss.closed:
282
+ await wss.close()
283
+ if session and not session.closed:
284
+ await session.close()
285
+
286
+ raise Exception(
287
+ f"{response['item']['result']['value']}: {response['item']['result']['message']}")
288
+
289
+ if draw:
290
+ cache = response['item']['messages'][1]['adaptiveCards'][0]['body'][0]['text']
291
+ response['item']['messages'][1]['adaptiveCards'][0]['body'][0]['text'] = (
292
+ cache + resp_txt)
293
+
294
+ if (response['item']['messages'][-1]['contentOrigin'] == 'Apology' and resp_txt):
295
+ response['item']['messages'][-1]['text'] = resp_txt_no_link
296
+ response['item']['messages'][-1]['adaptiveCards'][0]['body'][0]['text'] = resp_txt
297
+
298
+ # print('Preserved the message from being deleted', file=sys.stderr)
299
+
300
+ final = True
301
+ if wss and not wss.closed:
302
+ await wss.close()
303
+ if session and not session.closed:
304
+ await session.close()
305
+
306
+
307
+ def run(generator):
308
+ loop = asyncio.new_event_loop()
309
+ asyncio.set_event_loop(loop)
310
+ gen = generator.__aiter__()
311
+
312
+ while True:
313
+ try:
314
+ next_val = loop.run_until_complete(gen.__anext__())
315
+ yield next_val
316
+
317
+ except StopAsyncIteration:
318
+ break
319
+ #print('Done')
320
+
321
+ def convert(messages):
322
+ context = ""
323
+
324
+ for message in messages:
325
+ context += "[%s](#message)\n%s\n\n" % (message['role'],
326
+ message['content'])
327
+
328
+ return context
329
+
330
+
331
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
332
+ if len(messages) < 2:
333
+ prompt = messages[0]['content']
334
+ context = False
335
+
336
+ else:
337
+ prompt = messages[-1]['content']
338
+ context = convert(messages[:-1])
339
+
340
+ response = run(stream_generate(prompt, optionsSets.jailbreak, context))
341
+ for token in response:
342
+ yield (token)
343
+
344
+ #print('Done')
345
+
346
+
347
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
348
+ '(%s)' % ', '.join(
349
+ [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/ChatgptAi.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests, re
3
+ from ...typing import sha256, Dict, get_type_hints
4
+
5
+ url = 'https://chatgpt.ai/gpt-4/'
6
+ model = ['gpt-4']
7
+ supports_stream = True
8
+ needs_auth = False
9
+
10
+
11
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
12
+ chat = ''
13
+ for message in messages:
14
+ chat += '%s: %s\n' % (message['role'], message['content'])
15
+ chat += 'assistant: '
16
+
17
+ response = requests.get('https://chatgpt.ai/')
18
+ nonce, post_id, _, bot_id = re.findall(r'data-nonce="(.*)"\n data-post-id="(.*)"\n data-url="(.*)"\n data-bot-id="(.*)"\n data-width', response.text)[0]
19
+
20
+ headers = {
21
+ 'authority': 'chatgpt.ai',
22
+ 'accept': '*/*',
23
+ 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
24
+ 'cache-control': 'no-cache',
25
+ 'origin': 'https://chatgpt.ai',
26
+ 'pragma': 'no-cache',
27
+ 'referer': 'https://chatgpt.ai/gpt-4/',
28
+ 'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
29
+ 'sec-ch-ua-mobile': '?0',
30
+ 'sec-ch-ua-platform': '"Windows"',
31
+ 'sec-fetch-dest': 'empty',
32
+ 'sec-fetch-mode': 'cors',
33
+ 'sec-fetch-site': 'same-origin',
34
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
35
+ }
36
+ data = {
37
+ '_wpnonce': nonce,
38
+ 'post_id': post_id,
39
+ 'url': 'https://chatgpt.ai/gpt-4',
40
+ 'action': 'wpaicg_chat_shortcode_message',
41
+ 'message': chat,
42
+ 'bot_id': bot_id
43
+ }
44
+
45
+ response = requests.post('https://chatgpt.ai/wp-admin/admin-ajax.php',
46
+ headers=headers, data=data)
47
+
48
+ yield (response.json()['data'])
49
+
50
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
51
+ '(%s)' % ', '.join([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/ChatgptLogin.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from ...typing import sha256, Dict, get_type_hints
3
+ import requests
4
+ import re
5
+ import base64
6
+
7
+ url = 'https://chatgptlogin.ac'
8
+ model = ['gpt-3.5-turbo']
9
+ supports_stream = False
10
+ needs_auth = False
11
+
12
+
13
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
14
+ def get_nonce():
15
+ res = requests.get('https://chatgptlogin.ac/use-chatgpt-free/', headers={
16
+ "Referer": "https://chatgptlogin.ac/use-chatgpt-free/",
17
+ "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36'
18
+ })
19
+
20
+ src = re.search(r'class="mwai-chat mwai-chatgpt">.*<span>Send</span></button></div></div></div> <script defer src="(.*?)">', res.text).group(1)
21
+ decoded_string = base64.b64decode(src.split(",")[-1]).decode('utf-8')
22
+ return re.search(r"let restNonce = '(.*?)';", decoded_string).group(1)
23
+
24
+ def transform(messages: list) -> list:
25
+ def html_encode(string: str) -> str:
26
+ table = {
27
+ '"': '&quot;',
28
+ "'": '&#39;',
29
+ '&': '&amp;',
30
+ '>': '&gt;',
31
+ '<': '&lt;',
32
+ '\n': '<br>',
33
+ '\t': '&nbsp;&nbsp;&nbsp;&nbsp;',
34
+ ' ': '&nbsp;'
35
+ }
36
+
37
+ for key in table:
38
+ string = string.replace(key, table[key])
39
+
40
+ return string
41
+
42
+ return [{
43
+ 'id': os.urandom(6).hex(),
44
+ 'role': message['role'],
45
+ 'content': message['content'],
46
+ 'who': 'AI: ' if message['role'] == 'assistant' else 'User: ',
47
+ 'html': html_encode(message['content'])} for message in messages]
48
+
49
+ headers = {
50
+ 'authority': 'chatgptlogin.ac',
51
+ 'accept': '*/*',
52
+ 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
53
+ 'content-type': 'application/json',
54
+ 'origin': 'https://chatgptlogin.ac',
55
+ 'referer': 'https://chatgptlogin.ac/use-chatgpt-free/',
56
+ 'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
57
+ 'sec-ch-ua-mobile': '?0',
58
+ 'sec-ch-ua-platform': '"Windows"',
59
+ 'sec-fetch-dest': 'empty',
60
+ 'sec-fetch-mode': 'cors',
61
+ 'sec-fetch-site': 'same-origin',
62
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
63
+ 'x-wp-nonce': get_nonce()
64
+ }
65
+
66
+ conversation = transform(messages)
67
+
68
+ json_data = {
69
+ 'env': 'chatbot',
70
+ 'session': 'N/A',
71
+ 'prompt': 'Converse as if you were an AI assistant. Be friendly, creative.',
72
+ 'context': 'Converse as if you were an AI assistant. Be friendly, creative.',
73
+ 'messages': conversation,
74
+ 'newMessage': messages[-1]['content'],
75
+ 'userName': '<div class="mwai-name-text">User:</div>',
76
+ 'aiName': '<div class="mwai-name-text">AI:</div>',
77
+ 'model': 'gpt-3.5-turbo',
78
+ 'temperature': 0.8,
79
+ 'maxTokens': 1024,
80
+ 'maxResults': 1,
81
+ 'apiKey': '',
82
+ 'service': 'openai',
83
+ 'embeddingsIndex': '',
84
+ 'stop': '',
85
+ 'clientId': os.urandom(6).hex()
86
+ }
87
+
88
+ response = requests.post('https://chatgptlogin.ac/wp-json/ai-chatbot/v1/chat',
89
+ headers=headers, json=json_data)
90
+
91
+ return response.json()['reply']
92
+
93
+
94
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
95
+ '(%s)' % ', '.join(
96
+ [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/DeepAi.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import random
4
+ import hashlib
5
+ import requests
6
+
7
+ from ...typing import sha256, Dict, get_type_hints
8
+
9
+ url = 'https://deepai.org'
10
+ model = ['gpt-3.5-turbo']
11
+ supports_stream = True
12
+ needs_auth = False
13
+
14
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
15
+ def md5(text: str) -> str:
16
+ return hashlib.md5(text.encode()).hexdigest()[::-1]
17
+
18
+
19
+ def get_api_key(user_agent: str) -> str:
20
+ part1 = str(random.randint(0, 10**11))
21
+ part2 = md5(user_agent + md5(user_agent + md5(user_agent + part1 + "x")))
22
+
23
+ return f"tryit-{part1}-{part2}"
24
+
25
+ user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36'
26
+
27
+ headers = {
28
+ "api-key": get_api_key(user_agent),
29
+ "user-agent": user_agent
30
+ }
31
+
32
+ files = {
33
+ "chat_style": (None, "chat"),
34
+ "chatHistory": (None, json.dumps(messages))
35
+ }
36
+
37
+ r = requests.post("https://api.deepai.org/chat_response", headers=headers, files=files, stream=True)
38
+
39
+ for chunk in r.iter_content(chunk_size=None):
40
+ r.raise_for_status()
41
+ yield chunk.decode()
42
+
43
+
44
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
45
+ '(%s)' % ', '.join(
46
+ [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/Dfehub.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+ from ...typing import sha256, Dict, get_type_hints
4
+
5
+ url = "https://chat.dfehub.com"
6
+ model = ['gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-4']
7
+ supports_stream = True
8
+ needs_auth = False
9
+
10
+
11
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
12
+ headers = {
13
+ 'Authority': 'chat.dfehub.com',
14
+ 'Content-Type': 'application/json',
15
+ 'Method': 'POST',
16
+ 'Path': '/api/openai/v1/chat/completions',
17
+ 'Scheme': 'https',
18
+ 'Accept': 'text/event-stream',
19
+ 'Accept-Language': 'pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7,zh-CN;q=0.6,zh;q=0.5',
20
+ 'Content-Type': 'application/json',
21
+ 'Origin': 'https://chat.dfehub.com',
22
+ 'Referer': 'https://chat.dfehub.com/',
23
+ 'Sec-Ch-Ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
24
+ 'Sec-Ch-Ua-Mobile': '?0',
25
+ 'Sec-Ch-Ua-Platform': '"Windows"',
26
+ 'Sec-Fetch-Dest': 'empty',
27
+ 'Sec-Fetch-Mode': 'cors',
28
+ 'Sec-Fetch-Site': 'same-origin',
29
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
30
+ 'X-Requested-With': 'XMLHttpRequest',
31
+ }
32
+
33
+ data = {
34
+ 'model': model,
35
+ 'temperature': 0.7,
36
+ 'max_tokens': '8000',
37
+ 'presence_penalty': 0,
38
+ 'messages': messages,
39
+ }
40
+
41
+ response = requests.post(url + '/api/openai/v1/chat/completions',
42
+ headers=headers, json=data, stream=stream)
43
+
44
+ yield response.json()['choices'][0]['message']['content']
45
+
46
+
47
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
48
+ '(%s)' % ', '.join(
49
+ [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/Easychat.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import os
3
+ import json
4
+ from ...typing import sha256, Dict, get_type_hints
5
+
6
+ url = 'https://free.easychat.work'
7
+ model = ['gpt-3.5-turbo-16k', 'gpt-3.5-turbo-16k-0613', 'gpt-3.5-turbo-0613']
8
+ supports_stream = True
9
+ needs_auth = False
10
+
11
+ def _create_completion(model: str, messages: list, stream: bool, temperature: float = 0.7, **kwargs):
12
+ headers = {
13
+ 'Content-Type': 'application/json',
14
+ }
15
+ data = {
16
+ 'model':model,
17
+ 'temperature': 0.7,
18
+ 'presence_penalty': 0,
19
+ 'messages': messages,
20
+ }
21
+ response = requests.post(url + '/api/openai/v1/chat/completions',
22
+ json=data, stream=stream)
23
+
24
+ yield response.json()['choices'][0]['message']['content']
25
+
26
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
27
+ '(%s)' % ', '.join([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/Ezcht.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import os
3
+ import json
4
+ from ...typing import sha256, Dict, get_type_hints
5
+
6
+ url = 'https://gpt4.ezchat.top'
7
+ model = ['gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-3.5-turbo-16k-0613', 'gpt-3.5-turbo-0613']
8
+ supports_stream = True
9
+ needs_auth = False
10
+
11
+ def _create_completion(model: str, messages: list, stream: bool, temperature: float = 0.7, **kwargs):
12
+ headers = {
13
+ 'Content-Type': 'application/json',
14
+ }
15
+ data = {
16
+ 'model': model,
17
+ 'temperature': 0.7,
18
+ 'presence_penalty': 0,
19
+ 'messages': messages,
20
+ }
21
+ response = requests.post(url + '/api/openai/v1/chat/completions',
22
+ json=data, stream=True)
23
+
24
+ if stream:
25
+ for chunk in response.iter_content(chunk_size=None):
26
+ chunk = chunk.decode('utf-8')
27
+ if chunk.strip():
28
+ message = json.loads(chunk)['choices'][0]['message']['content']
29
+ yield message
30
+ else:
31
+ message = response.json()['choices'][0]['message']['content']
32
+ yield message
33
+
34
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
35
+ '(%s)' % ', '.join([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/Fakeopen.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import requests
4
+ from typing import Dict, get_type_hints
5
+
6
+ url = 'https://ai.fakeopen.com/v1/'
7
+ model = [
8
+ 'gpt-3.5-turbo',
9
+ 'gpt-3.5-turbo-0613'
10
+ 'gpt-3.5-turbo-16k',
11
+ 'gpt-3.5-turbo-16k-0613',
12
+ ]
13
+
14
+ supports_stream = True
15
+ needs_auth = False
16
+
17
+
18
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
19
+
20
+ headers = {
21
+ 'Content-Type': 'application/json',
22
+ 'accept': 'text/event-stream',
23
+ 'Cache-Control': 'no-cache',
24
+ 'Proxy-Connection': 'keep-alive',
25
+ 'Authorization': f"Bearer {os.environ.get('FAKE_OPEN_KEY', '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')}",
26
+ }
27
+
28
+ json_data = {
29
+ 'messages': messages,
30
+ 'temperature': 1.0,
31
+ 'model': model,
32
+ 'stream': stream,
33
+ }
34
+
35
+ response = requests.post(
36
+ 'https://ai.fakeopen.com/v1/chat/completions', headers=headers, json=json_data, stream=True
37
+ )
38
+
39
+ for token in response.iter_lines():
40
+ decoded = token.decode('utf-8')
41
+ if decoded == '[DONE]':
42
+ break
43
+ if decoded.startswith('data: '):
44
+ data_str = decoded.replace('data: ', '')
45
+ if data_str != '[DONE]':
46
+ data = json.loads(data_str)
47
+ if 'choices' in data and 'delta' in data['choices'][0] and 'content' in data['choices'][0]['delta']:
48
+ yield data['choices'][0]['delta']['content']
49
+
50
+
51
+
52
+
53
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + '(%s)' % ', '.join(
54
+ [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/Forefront.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import requests
4
+ from ...typing import sha256, Dict, get_type_hints
5
+
6
+ url = 'https://forefront.com'
7
+ model = ['gpt-3.5-turbo']
8
+ supports_stream = True
9
+ needs_auth = False
10
+
11
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
12
+ json_data = {
13
+ 'text': messages[-1]['content'],
14
+ 'action': 'noauth',
15
+ 'id': '',
16
+ 'parentId': '',
17
+ 'workspaceId': '',
18
+ 'messagePersona': '607e41fe-95be-497e-8e97-010a59b2e2c0',
19
+ 'model': 'gpt-4',
20
+ 'messages': messages[:-1] if len(messages) > 1 else [],
21
+ 'internetMode': 'auto'
22
+ }
23
+ response = requests.post( 'https://streaming.tenant-forefront-default.knative.chi.coreweave.com/free-chat',
24
+ json=json_data, stream=True)
25
+ for token in response.iter_lines():
26
+ if b'delta' in token:
27
+ token = json.loads(token.decode().split('data: ')[1])['delta']
28
+ yield (token)
29
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
30
+ '(%s)' % ', '.join([f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])