xiao commited on
Commit
dda4c89
·
1 Parent(s): 0604644

初始化

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .dockerignore +9 -0
  2. .gitignore +32 -0
  3. Dockerfile +29 -0
  4. LICENSE +674 -0
  5. Singularity/gpt4free.sif +15 -0
  6. docker-compose.yaml +15 -0
  7. gpt4free/README.md +115 -0
  8. gpt4free/__init__.py +72 -0
  9. gpt4free/cocalc/__init__.py +67 -0
  10. gpt4free/cocalc/readme.md +19 -0
  11. gpt4free/forefront/README.md +16 -0
  12. gpt4free/forefront/__init__.py +222 -0
  13. gpt4free/forefront/typing.py +26 -0
  14. gpt4free/italygpt/README.md +18 -0
  15. gpt4free/italygpt/__init__.py +28 -0
  16. gpt4free/quora/README.md +77 -0
  17. gpt4free/quora/__init__.py +478 -0
  18. gpt4free/quora/api.py +551 -0
  19. gpt4free/quora/backup-mail.py +45 -0
  20. gpt4free/quora/cookies.txt +30 -0
  21. gpt4free/quora/graphql/AddHumanMessageMutation.graphql +52 -0
  22. gpt4free/quora/graphql/AddMessageBreakMutation.graphql +17 -0
  23. gpt4free/quora/graphql/AutoSubscriptionMutation.graphql +7 -0
  24. gpt4free/quora/graphql/BioFragment.graphql +8 -0
  25. gpt4free/quora/graphql/ChatAddedSubscription.graphql +5 -0
  26. gpt4free/quora/graphql/ChatFragment.graphql +6 -0
  27. gpt4free/quora/graphql/ChatListPaginationQuery.graphql +378 -0
  28. gpt4free/quora/graphql/ChatPaginationQuery.graphql +26 -0
  29. gpt4free/quora/graphql/ChatViewQuery.graphql +8 -0
  30. gpt4free/quora/graphql/DeleteHumanMessagesMutation.graphql +7 -0
  31. gpt4free/quora/graphql/DeleteMessageMutation.graphql +7 -0
  32. gpt4free/quora/graphql/HandleFragment.graphql +8 -0
  33. gpt4free/quora/graphql/LoginWithVerificationCodeMutation.graphql +13 -0
  34. gpt4free/quora/graphql/MessageAddedSubscription.graphql +100 -0
  35. gpt4free/quora/graphql/MessageDeletedSubscription.graphql +6 -0
  36. gpt4free/quora/graphql/MessageFragment.graphql +13 -0
  37. gpt4free/quora/graphql/MessageRemoveVoteMutation.graphql +7 -0
  38. gpt4free/quora/graphql/MessageSetVoteMutation.graphql +7 -0
  39. gpt4free/quora/graphql/PoeBotCreateMutation.graphql +73 -0
  40. gpt4free/quora/graphql/PoeBotEditMutation.graphql +24 -0
  41. gpt4free/quora/graphql/SendMessageMutation.graphql +40 -0
  42. gpt4free/quora/graphql/SendVerificationCodeForLoginMutation.graphql +12 -0
  43. gpt4free/quora/graphql/SettingsDeleteAccountButton_deleteAccountMutation_Mutation.graphql +1 -0
  44. gpt4free/quora/graphql/ShareMessagesMutation.graphql +9 -0
  45. gpt4free/quora/graphql/SignupWithVerificationCodeMutation.graphql +13 -0
  46. gpt4free/quora/graphql/StaleChatUpdateMutation.graphql +7 -0
  47. gpt4free/quora/graphql/SubscriptionsMutation.graphql +9 -0
  48. gpt4free/quora/graphql/SummarizePlainPostQuery.graphql +3 -0
  49. gpt4free/quora/graphql/SummarizeQuotePostQuery.graphql +3 -0
  50. gpt4free/quora/graphql/SummarizeSharePostQuery.graphql +3 -0
.dockerignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Development
2
+ .dockerignore
3
+ .git
4
+ .gitignore
5
+ .github
6
+ .idea
7
+
8
+ # Application
9
+ venv/
.gitignore ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
9
+
10
+ # Ignore local python virtual environment
11
+ venv/
12
+
13
+ # Ignore streamlit_chat_app.py conversations pickle
14
+ conversations.pkl
15
+ *.pkl
16
+
17
+ # Ignore accounts created by api's
18
+ accounts.txt
19
+
20
+ .idea/
21
+
22
+ **/__pycache__/
23
+
24
+ __pycache__/
25
+
26
+ *.log
27
+
28
+ cookie.json
29
+
30
+ *.pyc
31
+
32
+ dist/
Dockerfile ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11 as builder
2
+
3
+ WORKDIR /usr/app
4
+ ENV PATH="/usr/app/venv/bin:$PATH"
5
+
6
+ RUN apt-get update && apt-get install -y git
7
+ RUN mkdir -p /usr/app
8
+ RUN python -m venv ./venv
9
+
10
+ COPY requirements.txt .
11
+
12
+ RUN pip install -r requirements.txt
13
+
14
+ # RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
15
+ # RUN pip config set global.trusted-host mirrors.aliyun.com
16
+
17
+ FROM python:3.11-alpine
18
+
19
+ WORKDIR /usr/app
20
+ ENV PATH="/usr/app/venv/bin:$PATH"
21
+
22
+ COPY --from=builder /usr/app/venv ./venv
23
+ COPY . .
24
+
25
+ RUN cp ./gui/streamlit_app.py .
26
+
27
+ CMD ["streamlit", "run", "streamlit_app.py"]
28
+
29
+ EXPOSE 8501
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>.
Singularity/gpt4free.sif ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Bootstrap: docker
2
+ From: python:3.10-slim
3
+
4
+ %post
5
+ apt-get update && apt-get install -y git
6
+ git clone https://github.com/xtekky/gpt4free.git
7
+ cd gpt4free
8
+ pip install --no-cache-dir -r requirements.txt
9
+ cp gui/streamlit_app.py .
10
+
11
+ %expose
12
+ 8501
13
+
14
+ %startscript
15
+ exec streamlit run streamlit_app.py
docker-compose.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: "3.9"
2
+
3
+ services:
4
+ gpt4free:
5
+ build:
6
+ context: ./
7
+ dockerfile: Dockerfile
8
+ container_name: dc_gpt4free
9
+ # environment:
10
+ # - http_proxy=http://127.0.0.1:1080 # modify this for your proxy
11
+ # - https_proxy=http://127.0.0.1:1080 # modify this for your proxy
12
+ image: img_gpt4free
13
+ ports:
14
+ - 8501:8501
15
+ restart: always
gpt4free/README.md ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # gpt4free package
2
+
3
+ ### What is it?
4
+
5
+ gpt4free is a python package that provides some language model api's
6
+
7
+ ### Main Features
8
+
9
+ - It's free to use
10
+ - Easy access
11
+
12
+ ### Installation:
13
+
14
+ ```bash
15
+ pip install gpt4free
16
+ ```
17
+
18
+ #### Usage:
19
+
20
+ ```python
21
+ import gpt4free
22
+ from gpt4free import Provider, quora, forefront
23
+
24
+ # usage You
25
+ response = gpt4free.Completion.create(Provider.You, prompt='Write a poem on Lionel Messi')
26
+ print(response)
27
+
28
+ # usage Poe
29
+ token = quora.Account.create(logging=False)
30
+ response = gpt4free.Completion.create(Provider.Poe, prompt='Write a poem on Lionel Messi', token=token, model='ChatGPT')
31
+ print(response)
32
+
33
+ # usage forefront
34
+ token = forefront.Account.create(logging=False)
35
+ response = gpt4free.Completion.create(
36
+ Provider.ForeFront, prompt='Write a poem on Lionel Messi', model='gpt-4', token=token
37
+ )
38
+ print(response)
39
+ print(f'END')
40
+
41
+ # usage theb
42
+ response = gpt4free.Completion.create(Provider.Theb, prompt='Write a poem on Lionel Messi')
43
+ print(response)
44
+
45
+ # usage cocalc
46
+ response = gpt4free.Completion.create(Provider.CoCalc, prompt='Write a poem on Lionel Messi', cookie_input='')
47
+ print(response)
48
+
49
+ ```
50
+
51
+ ### Invocation Arguments
52
+
53
+ `gpt4free.Completion.create()` method has two required arguments
54
+
55
+ 1. Provider: This is an enum representing different provider
56
+ 2. prompt: This is the user input
57
+
58
+ #### Keyword Arguments
59
+
60
+ Some of the keyword arguments are optional, while others are required.
61
+
62
+ - You:
63
+ - `safe_search`: boolean - default value is `False`
64
+ - `include_links`: boolean - default value is `False`
65
+ - `detailed`: boolean - default value is `False`
66
+ - Quora:
67
+ - `token`: str - this needs to be provided by the user
68
+ - `model`: str - default value is `gpt-4`.
69
+
70
+ (Available models: `['Sage', 'GPT-4', 'Claude+', 'Claude-instant', 'ChatGPT', 'Dragonfly', 'NeevaAI']`)
71
+ - ForeFront:
72
+ - `token`: str - this need to be provided by the user
73
+
74
+ - Theb:
75
+ (no keyword arguments required)
76
+ - CoCalc:
77
+ - `cookie_input`: str - this needs to be provided by user
78
+
79
+ #### Token generation of quora
80
+ ```python
81
+ from gpt4free import quora
82
+
83
+ token = quora.Account.create(logging=False)
84
+ ```
85
+
86
+ ### Token generation of ForeFront
87
+ ```python
88
+ from gpt4free import forefront
89
+
90
+ token = forefront.Account.create(logging=False)
91
+ ```
92
+
93
+ ## Copyright:
94
+
95
+ This program is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.txt)
96
+
97
+ ### Copyright Notice: <a name="copyright"></a>
98
+
99
+ ```
100
+ xtekky/gpt4free: multiple reverse engineered language-model api's to decentralise the ai industry.
101
+ Copyright (C) 2023 xtekky
102
+
103
+ This program is free software: you can redistribute it and/or modify
104
+ it under the terms of the GNU General Public License as published by
105
+ the Free Software Foundation, either version 3 of the License, or
106
+ (at your option) any later version.
107
+
108
+ This program is distributed in the hope that it will be useful,
109
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
110
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
111
+ GNU General Public License for more details.
112
+
113
+ You should have received a copy of the GNU General Public License
114
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
115
+ ```
gpt4free/__init__.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from enum import Enum
2
+
3
+ from gpt4free import cocalc
4
+ from gpt4free import forefront
5
+ from gpt4free import quora
6
+ from gpt4free import theb
7
+ from gpt4free import usesless
8
+ from gpt4free import you
9
+
10
+
11
+ class Provider(Enum):
12
+ """An enum representing different providers."""
13
+
14
+ You = 'you'
15
+ Poe = 'poe'
16
+ ForeFront = 'fore_front'
17
+ Theb = 'theb'
18
+ CoCalc = 'cocalc'
19
+ UseLess = 'useless'
20
+
21
+
22
+ class Completion:
23
+ """This class will be used for invoking the given provider"""
24
+
25
+ @staticmethod
26
+ def create(provider: Provider, prompt: str, **kwargs) -> str:
27
+ """
28
+ Invokes the given provider with given prompt and addition arguments and returns the string response
29
+
30
+ :param provider: an enum representing the provider to use while invoking
31
+ :param prompt: input provided by the user
32
+ :param kwargs: Additional keyword arguments to pass to the provider while invoking
33
+ :return: A string representing the response from the provider
34
+ """
35
+ if provider == Provider.Poe:
36
+ return Completion.__poe_service(prompt, **kwargs)
37
+ elif provider == Provider.You:
38
+ return Completion.__you_service(prompt, **kwargs)
39
+ elif provider == Provider.ForeFront:
40
+ return Completion.__fore_front_service(prompt, **kwargs)
41
+ elif provider == Provider.Theb:
42
+ return Completion.__theb_service(prompt, **kwargs)
43
+ elif provider == Provider.CoCalc:
44
+ return Completion.__cocalc_service(prompt, **kwargs)
45
+ elif provider == Provider.UseLess:
46
+ return Completion.__useless_service(prompt, **kwargs)
47
+ else:
48
+ raise Exception('Provider not exist, Please try again')
49
+
50
+ @staticmethod
51
+ def __useless_service(prompt: str, **kwargs) -> str:
52
+ return usesless.Completion.create(prompt=prompt, **kwargs)
53
+
54
+ @staticmethod
55
+ def __you_service(prompt: str, **kwargs) -> str:
56
+ return you.Completion.create(prompt, **kwargs).text
57
+
58
+ @staticmethod
59
+ def __poe_service(prompt: str, **kwargs) -> str:
60
+ return quora.Completion.create(prompt=prompt, **kwargs).text
61
+
62
+ @staticmethod
63
+ def __fore_front_service(prompt: str, **kwargs) -> str:
64
+ return forefront.Completion.create(prompt=prompt, **kwargs).text
65
+
66
+ @staticmethod
67
+ def __theb_service(prompt: str, **kwargs):
68
+ return ''.join(theb.Completion.create(prompt=prompt))
69
+
70
+ @staticmethod
71
+ def __cocalc_service(prompt: str, **kwargs):
72
+ return cocalc.Completion.create(prompt, cookie_input=kwargs.get('cookie_input', '')).text
gpt4free/cocalc/__init__.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from fake_useragent import UserAgent
3
+ from pydantic import BaseModel
4
+
5
+
6
+ class CoCalcResponse(BaseModel):
7
+ text: str
8
+ status: bool
9
+
10
+
11
+ class Completion:
12
+ """A class for generating text completions using CoCalc's GPT-based chatbot."""
13
+
14
+ API_ENDPOINT = "https://cocalc.com/api/v2/openai/chatgpt"
15
+ DEFAULT_SYSTEM_PROMPT = "ASSUME I HAVE FULL ACCESS TO COCALC. "
16
+
17
+ @staticmethod
18
+ def create(prompt: str, cookie_input: str) -> CoCalcResponse:
19
+ """
20
+ Generate a text completion for the given prompt using CoCalc's GPT-based chatbot.
21
+
22
+ Args:
23
+ prompt: The text prompt to complete.
24
+ cookie_input: The cookie required to authenticate the chatbot API request.
25
+
26
+ Returns:
27
+ A CoCalcResponse object containing the text completion and a boolean indicating
28
+ whether the request was successful.
29
+ """
30
+
31
+ # Initialize a session with custom headers
32
+ session = Completion._initialize_session(cookie_input)
33
+
34
+ # Set the data that will be submitted
35
+ payload = Completion._create_payload(prompt, Completion.DEFAULT_SYSTEM_PROMPT)
36
+
37
+ try:
38
+ # Submit the request and return the results
39
+ response = session.post(Completion.API_ENDPOINT, json=payload).json()
40
+ return CoCalcResponse(text=response['output'], status=response['success'])
41
+ except requests.exceptions.RequestException as e:
42
+ # Handle exceptions that may occur during the request
43
+ print(f"Error: {e}")
44
+ return CoCalcResponse(text="", status=False)
45
+
46
+ @classmethod
47
+ def _initialize_session(cls, conversation_cookie: str) -> requests.Session:
48
+ """Initialize a session with custom headers for the request."""
49
+
50
+ session = requests.Session()
51
+ headers = {
52
+ "Accept": "*/*",
53
+ "Accept-Language": "en-US,en;q=0.5",
54
+ "Origin": "https://cocalc.com",
55
+ "Referer": "https://cocalc.com/api/v2/openai/chatgpt",
56
+ "Cookie": conversation_cookie,
57
+ "User-Agent": UserAgent().random,
58
+ }
59
+ session.headers.update(headers)
60
+
61
+ return session
62
+
63
+ @staticmethod
64
+ def _create_payload(prompt: str, system_prompt: str) -> dict:
65
+ """Create the payload for the API request."""
66
+
67
+ return {"input": prompt, "system": system_prompt, "tag": "next:index"}
gpt4free/cocalc/readme.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Example: `cocalc` <a name="example-cocalc"></a>
2
+
3
+ ```python
4
+ # import library
5
+ from gpt4free import cocalc
6
+
7
+ cocalc.Completion.create(prompt="How are you!", cookie_input="cookieinput") ## Tutorial
8
+ ```
9
+
10
+ ### How to grab cookie input
11
+ ```js
12
+ // input this into ur developer tools console and the exact response u get from this u put into ur cookieInput!
13
+ var cookies = document.cookie.split("; ");
14
+ var cookieString = "";
15
+ for (var i = 0; i < cookies.length; i++) {
16
+ cookieString += cookies[i] + "; ";
17
+ }
18
+ console.log(cookieString);
19
+ ```
gpt4free/forefront/README.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Example: `forefront` (use like openai pypi package) <a name="example-forefront"></a>
2
+
3
+ ```python
4
+ from gpt4free import forefront
5
+ # create an account
6
+ token = forefront.Account.create(logging=False)
7
+ print(token)
8
+ # get a response
9
+ for response in forefront.StreamingCompletion.create(
10
+ token=token,
11
+ prompt='hello world',
12
+ model='gpt-4'
13
+ ):
14
+ print(response.choices[0].text, end='')
15
+ print("")
16
+ ```
gpt4free/forefront/__init__.py ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pickle
3
+ from json import loads
4
+ from re import findall
5
+ from time import time, sleep
6
+ from typing import Generator, Optional
7
+ from uuid import uuid4
8
+
9
+ from fake_useragent import UserAgent
10
+ from pymailtm import MailTm, Message
11
+ from requests import post
12
+ from tls_client import Session
13
+
14
+ from .typing import ForeFrontResponse
15
+
16
+
17
+ class Account:
18
+ COOKIES_FILE_NAME = 'cookies.pickle'
19
+
20
+ @staticmethod
21
+ def login(proxy: Optional[str] = None, logging: bool = False) -> str:
22
+ if not os.path.isfile(Account.COOKIES_FILE_NAME):
23
+ return Account.create(proxy, logging)
24
+
25
+ with open(Account.COOKIES_FILE_NAME, 'rb') as f:
26
+ cookies = pickle.load(f)
27
+ proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False
28
+
29
+ client = Session(client_identifier='chrome110')
30
+ client.proxies = proxies
31
+ client.cookies.update(cookies)
32
+
33
+ if Account.is_cookie_enabled(client):
34
+ response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4')
35
+ return response.json()['response']['sessions'][0]['last_active_token']['jwt']
36
+ else:
37
+ return Account.create(proxy, logging)
38
+
39
+ @staticmethod
40
+ def create(proxy: Optional[str] = None, logging: bool = False, save_cookies: bool = False) -> str:
41
+ proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False
42
+
43
+ start = time()
44
+
45
+ mail_client = MailTm().get_account()
46
+ mail_address = mail_client.address
47
+
48
+ client = Session(client_identifier='chrome110')
49
+ client.proxies = proxies
50
+ client.headers = {
51
+ 'origin': 'https://accounts.forefront.ai',
52
+ 'user-agent': UserAgent().random,
53
+ }
54
+
55
+ response = client.post(
56
+ 'https://clerk.forefront.ai/v1/client/sign_ups?_clerk_js_version=4.38.4',
57
+ data={'email_address': mail_address},
58
+ )
59
+
60
+ try:
61
+ trace_token = response.json()['response']['id']
62
+ if logging:
63
+ print(trace_token)
64
+ except KeyError:
65
+ return 'Failed to create account!'
66
+
67
+ response = client.post(
68
+ f'https://clerk.forefront.ai/v1/client/sign_ups/{trace_token}/prepare_verification?_clerk_js_version=4.38.4',
69
+ data={'strategy': 'email_link', 'redirect_url': 'https://accounts.forefront.ai/sign-up/verify'},
70
+ )
71
+
72
+ if logging:
73
+ print(response.text)
74
+
75
+ if 'sign_up_attempt' not in response.text:
76
+ return 'Failed to create account!'
77
+
78
+ while True:
79
+ sleep(1)
80
+ new_message: Message = mail_client.wait_for_message()
81
+ if logging:
82
+ print(new_message.data['id'])
83
+
84
+ verification_url = findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', new_message.text)[0]
85
+
86
+ if verification_url:
87
+ break
88
+
89
+ if logging:
90
+ print(verification_url)
91
+
92
+ response = client.get(verification_url)
93
+
94
+ response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4')
95
+
96
+ token = response.json()['response']['sessions'][0]['last_active_token']['jwt']
97
+
98
+ if save_cookies:
99
+ with open(Account.COOKIES_FILE_NAME, 'wb') as f:
100
+ pickle.dump(client.cookies, f)
101
+
102
+ with open('accounts.txt', 'a') as f:
103
+ f.write(f'{mail_address}:{token}\n')
104
+
105
+ if logging:
106
+ print(time() - start)
107
+
108
+ return token
109
+
110
+ @staticmethod
111
+ def is_cookie_enabled(client: Session) -> bool:
112
+ response = client.get('https://chat.forefront.ai/')
113
+ return 'window.startClerk' in response.text
114
+
115
+
116
+ class StreamingCompletion:
117
+ @staticmethod
118
+ def create(
119
+ token=None,
120
+ chat_id=None,
121
+ prompt='',
122
+ action_type='new',
123
+ default_persona='607e41fe-95be-497e-8e97-010a59b2e2c0', # default
124
+ model='gpt-4',
125
+ proxy=None,
126
+ ) -> Generator[ForeFrontResponse, None, None]:
127
+ if not token:
128
+ raise Exception('Token is required!')
129
+ if not chat_id:
130
+ chat_id = str(uuid4())
131
+
132
+ proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None
133
+
134
+ headers = {
135
+ 'authority': 'chat-server.tenant-forefront-default.knative.chi.coreweave.com',
136
+ 'accept': '*/*',
137
+ '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',
138
+ 'authorization': 'Bearer ' + token,
139
+ 'cache-control': 'no-cache',
140
+ 'content-type': 'application/json',
141
+ 'origin': 'https://chat.forefront.ai',
142
+ 'pragma': 'no-cache',
143
+ 'referer': 'https://chat.forefront.ai/',
144
+ 'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
145
+ 'sec-ch-ua-mobile': '?0',
146
+ 'sec-ch-ua-platform': '"macOS"',
147
+ 'sec-fetch-dest': 'empty',
148
+ 'sec-fetch-mode': 'cors',
149
+ 'sec-fetch-site': 'cross-site',
150
+ 'user-agent': UserAgent().random,
151
+ }
152
+
153
+ json_data = {
154
+ 'text': prompt,
155
+ 'action': action_type,
156
+ 'parentId': chat_id,
157
+ 'workspaceId': chat_id,
158
+ 'messagePersona': default_persona,
159
+ 'model': model,
160
+ }
161
+
162
+ for chunk in post(
163
+ 'https://chat-server.tenant-forefront-default.knative.chi.coreweave.com/chat',
164
+ headers=headers,
165
+ proxies=proxies,
166
+ json=json_data,
167
+ stream=True,
168
+ ).iter_lines():
169
+ if b'finish_reason":null' in chunk:
170
+ data = loads(chunk.decode('utf-8').split('data: ')[1])
171
+ token = data['choices'][0]['delta'].get('content')
172
+
173
+ if token is not None:
174
+ yield ForeFrontResponse(
175
+ **{
176
+ 'id': chat_id,
177
+ 'object': 'text_completion',
178
+ 'created': int(time()),
179
+ 'text': token,
180
+ 'model': model,
181
+ 'choices': [{'text': token, 'index': 0, 'logprobs': None, 'finish_reason': 'stop'}],
182
+ 'usage': {
183
+ 'prompt_tokens': len(prompt),
184
+ 'completion_tokens': len(token),
185
+ 'total_tokens': len(prompt) + len(token),
186
+ },
187
+ }
188
+ )
189
+
190
+
191
+ class Completion:
192
+ @staticmethod
193
+ def create(
194
+ token=None,
195
+ chat_id=None,
196
+ prompt='',
197
+ action_type='new',
198
+ default_persona='607e41fe-95be-497e-8e97-010a59b2e2c0', # default
199
+ model='gpt-4',
200
+ proxy=None,
201
+ ) -> ForeFrontResponse:
202
+ text = ''
203
+ final_response = None
204
+ for response in StreamingCompletion.create(
205
+ token=token,
206
+ chat_id=chat_id,
207
+ prompt=prompt,
208
+ action_type=action_type,
209
+ default_persona=default_persona,
210
+ model=model,
211
+ proxy=proxy,
212
+ ):
213
+ if response:
214
+ final_response = response
215
+ text += response.text
216
+
217
+ if final_response:
218
+ final_response.text = text
219
+ else:
220
+ raise Exception('Unable to get the response, Please try again')
221
+
222
+ return final_response
gpt4free/forefront/typing.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any, List
2
+
3
+ from pydantic import BaseModel
4
+
5
+
6
+ class Choice(BaseModel):
7
+ text: str
8
+ index: int
9
+ logprobs: Any
10
+ finish_reason: str
11
+
12
+
13
+ class Usage(BaseModel):
14
+ prompt_tokens: int
15
+ completion_tokens: int
16
+ total_tokens: int
17
+
18
+
19
+ class ForeFrontResponse(BaseModel):
20
+ id: str
21
+ object: str
22
+ created: int
23
+ model: str
24
+ choices: List[Choice]
25
+ usage: Usage
26
+ text: str
gpt4free/italygpt/README.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Example: `italygpt`
2
+
3
+ ```python
4
+ # create an instance
5
+ from gpt4free import italygpt
6
+ italygpt = italygpt.Completion()
7
+
8
+ # initialize api
9
+ italygpt.init()
10
+
11
+ # get an answer
12
+ italygpt.create(prompt="What is the meaning of life?")
13
+ print(italygpt.answer) # html formatted
14
+
15
+ # keep the old conversation
16
+ italygpt.create(prompt="Are you a human?", messages=italygpt.messages)
17
+ print(italygpt.answer)
18
+ ```
gpt4free/italygpt/__init__.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests, time, ast, json
2
+ from bs4 import BeautifulSoup
3
+ from hashlib import sha256
4
+
5
+ class Completion:
6
+ # answer is returned with html formatting
7
+ next_id = None
8
+ messages = []
9
+ answer = None
10
+
11
+ def init(self):
12
+ r = requests.get("https://italygpt.it")
13
+ soup = BeautifulSoup(r.text, "html.parser")
14
+ self.next_id = soup.find("input", {"name": "next_id"})["value"]
15
+
16
+ def create(self, prompt: str, messages: list = []):
17
+ try:
18
+ r = requests.get("https://italygpt.it/question", params={"hash": sha256(self.next_id.encode()).hexdigest(), "prompt": prompt, "raw_messages": json.dumps(messages)}).json()
19
+ except:
20
+ r = requests.get("https://italygpt.it/question", params={"hash": sha256(self.next_id.encode()).hexdigest(), "prompt": prompt, "raw_messages": json.dumps(messages)}).text
21
+ if "too many requests" in r.lower():
22
+ # rate limit is 17 requests per 1 minute
23
+ time.sleep(20)
24
+ return self.create(prompt, messages)
25
+ self.next_id = r["next_id"]
26
+ self.messages = ast.literal_eval(r["raw_messages"])
27
+ self.answer = r["response"]
28
+ return self
gpt4free/quora/README.md ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ > ⚠ Warning !!!
3
+ poe.com added security and can detect if you are making automated requests. You may get your account banned if you are using this api.
4
+ The normal non-driver api is also currently not very stable
5
+
6
+
7
+ ### Example: `quora (poe)` (use like openai pypi package) - GPT-4 <a name="example-poe"></a>
8
+
9
+ ```python
10
+ # quora model names: (use left key as argument)
11
+ models = {
12
+ 'sage' : 'capybara',
13
+ 'gpt-4' : 'beaver',
14
+ 'claude-v1.2' : 'a2_2',
15
+ 'claude-instant-v1.0' : 'a2',
16
+ 'gpt-3.5-turbo' : 'chinchilla'
17
+ }
18
+ ```
19
+
20
+ ### New: bot creation
21
+
22
+ ```python
23
+ # import quora (poe) package
24
+ from gpt4free import quora
25
+
26
+ # create account
27
+ # make sure to set enable_bot_creation to True
28
+ token = quora.Account.create(logging=True, enable_bot_creation=True)
29
+
30
+ model = quora.Model.create(
31
+ token=token,
32
+ model='gpt-3.5-turbo', # or claude-instant-v1.0
33
+ system_prompt='you are ChatGPT a large language model ...'
34
+ )
35
+
36
+ print(model.name) # gptx....
37
+
38
+ # streaming response
39
+ for response in quora.StreamingCompletion.create(
40
+ custom_model=model.name,
41
+ prompt='hello world',
42
+ token=token):
43
+ print(response.completion.choices[0].text)
44
+ ```
45
+
46
+ ### Normal Response:
47
+ ```python
48
+
49
+ response = quora.Completion.create(model = 'gpt-4',
50
+ prompt = 'hello world',
51
+ token = token)
52
+
53
+ print(response.completion.choices[0].text)
54
+ ```
55
+
56
+ ### Update Use This For Poe
57
+ ```python
58
+ from gpt4free.quora import Poe
59
+
60
+ # available models: ['Sage', 'GPT-4', 'Claude+', 'Claude-instant', 'ChatGPT', 'Dragonfly', 'NeevaAI']
61
+
62
+ poe = Poe(model='ChatGPT', driver='firefox', cookie_path='cookie.json', driver_path='path_of_driver')
63
+ poe.chat('who won the football world cup most?')
64
+
65
+ # new bot creation
66
+ poe.create_bot('new_bot_name', prompt='You are new test bot', base_model='gpt-3.5-turbo')
67
+
68
+ # delete account
69
+ poe.delete_account()
70
+ ```
71
+
72
+ ### Deleting the Poe Account
73
+ ```python
74
+ from gpt4free import quora
75
+
76
+ quora.Account.delete(token='')
77
+ ```
gpt4free/quora/__init__.py ADDED
@@ -0,0 +1,478 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from datetime import datetime
3
+ from hashlib import md5
4
+ from json import dumps
5
+ from pathlib import Path
6
+ from random import choice, choices, randint
7
+ from re import search, findall
8
+ from string import ascii_letters, digits
9
+ from typing import Optional, Union, List, Any, Generator
10
+ from urllib.parse import unquote
11
+
12
+ import selenium.webdriver.support.expected_conditions as EC
13
+ from fake_useragent import UserAgent
14
+ from pydantic import BaseModel
15
+ from pypasser import reCaptchaV3
16
+ from requests import Session
17
+ from selenium.webdriver import Firefox, Chrome, FirefoxOptions, ChromeOptions
18
+ from selenium.webdriver.common.by import By
19
+ from selenium.webdriver.support.wait import WebDriverWait
20
+ from tls_client import Session as TLS
21
+
22
+ from .api import Client as PoeClient
23
+ from .mail import Emailnator
24
+
25
+ SELENIUM_WEB_DRIVER_ERROR_MSG = b'''The error message you are receiving is due to the `geckodriver` executable not
26
+ being found in your system\'s PATH. To resolve this issue, you need to download the geckodriver and add its location
27
+ to your system\'s PATH.\n\nHere are the steps to resolve the issue:\n\n1. Download the geckodriver for your platform
28
+ (Windows, macOS, or Linux) from the following link: https://github.com/mozilla/geckodriver/releases\n\n2. Extract the
29
+ downloaded archive and locate the geckodriver executable.\n\n3. Add the geckodriver executable to your system\'s
30
+ PATH.\n\nFor macOS and Linux:\n\n- Open a terminal window.\n- Move the geckodriver executable to a directory that is
31
+ already in your PATH, or create a new directory and add it to your PATH:\n\n```bash\n# Example: Move geckodriver to
32
+ /usr/local/bin\nmv /path/to/your/geckodriver /usr/local/bin\n```\n\n- If you created a new directory, add it to your
33
+ PATH:\n\n```bash\n# Example: Add a new directory to PATH\nexport PATH=$PATH:/path/to/your/directory\n```\n\nFor
34
+ Windows:\n\n- Right-click on "My Computer" or "This PC" and select "Properties".\n- Click on "Advanced system
35
+ settings".\n- Click on the "Environment Variables" button.\n- In the "System variables" section, find the "Path"
36
+ variable, select it, and click "Edit".\n- Click "New" and add the path to the directory containing the geckodriver
37
+ executable.\n\nAfter adding the geckodriver to your PATH, restart your terminal or command prompt and try running
38
+ your script again. The error should be resolved.'''
39
+
40
+ # from twocaptcha import TwoCaptcha
41
+ # solver = TwoCaptcha('72747bf24a9d89b4dcc1b24875efd358')
42
+
43
+ MODELS = {
44
+ 'Sage': 'capybara',
45
+ 'GPT-4': 'beaver',
46
+ 'Claude+': 'a2_2',
47
+ 'Claude-instant': 'a2',
48
+ 'ChatGPT': 'chinchilla',
49
+ 'Dragonfly': 'nutria',
50
+ 'NeevaAI': 'hutia',
51
+ }
52
+
53
+
54
+ def extract_formkey(html):
55
+ script_regex = r'<script>if\(.+\)throw new Error;(.+)</script>'
56
+ script_text = search(script_regex, html).group(1)
57
+ key_regex = r'var .="([0-9a-f]+)",'
58
+ key_text = search(key_regex, script_text).group(1)
59
+ cipher_regex = r'.\[(\d+)\]=.\[(\d+)\]'
60
+ cipher_pairs = findall(cipher_regex, script_text)
61
+
62
+ formkey_list = [''] * len(cipher_pairs)
63
+ for pair in cipher_pairs:
64
+ formkey_index, key_index = map(int, pair)
65
+ formkey_list[formkey_index] = key_text[key_index]
66
+ formkey = ''.join(formkey_list)
67
+
68
+ return formkey
69
+
70
+
71
+ class Choice(BaseModel):
72
+ text: str
73
+ index: int
74
+ logprobs: Any
75
+ finish_reason: str
76
+
77
+
78
+ class Usage(BaseModel):
79
+ prompt_tokens: int
80
+ completion_tokens: int
81
+ total_tokens: int
82
+
83
+
84
+ class PoeResponse(BaseModel):
85
+ id: int
86
+ object: str
87
+ created: int
88
+ model: str
89
+ choices: List[Choice]
90
+ usage: Usage
91
+ text: str
92
+
93
+
94
+ class ModelResponse:
95
+ def __init__(self, json_response: dict) -> None:
96
+ self.id = json_response['data']['poeBotCreate']['bot']['id']
97
+ self.name = json_response['data']['poeBotCreate']['bot']['displayName']
98
+ self.limit = json_response['data']['poeBotCreate']['bot']['messageLimit']['dailyLimit']
99
+ self.deleted = json_response['data']['poeBotCreate']['bot']['deletionState']
100
+
101
+
102
+ class Model:
103
+ @staticmethod
104
+ def create(
105
+ token: str,
106
+ model: str = 'gpt-3.5-turbo', # claude-instant
107
+ system_prompt: str = 'You are ChatGPT a large language model developed by Openai. Answer as consisely as possible',
108
+ description: str = 'gpt-3.5 language model from openai, skidded by poe.com',
109
+ handle: str = None,
110
+ ) -> ModelResponse:
111
+ if not handle:
112
+ handle = f'gptx{randint(1111111, 9999999)}'
113
+
114
+ client = Session()
115
+ client.cookies['p-b'] = token
116
+
117
+ formkey = extract_formkey(client.get('https://poe.com').text)
118
+ settings = client.get('https://poe.com/api/settings').json()
119
+
120
+ client.headers = {
121
+ 'host': 'poe.com',
122
+ 'origin': 'https://poe.com',
123
+ 'referer': 'https://poe.com/',
124
+ 'poe-formkey': formkey,
125
+ 'poe-tchannel': settings['tchannelData']['channel'],
126
+ 'user-agent': UserAgent().random,
127
+ 'connection': 'keep-alive',
128
+ 'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
129
+ 'sec-ch-ua-mobile': '?0',
130
+ 'sec-ch-ua-platform': '"macOS"',
131
+ 'content-type': 'application/json',
132
+ 'sec-fetch-site': 'same-origin',
133
+ 'sec-fetch-mode': 'cors',
134
+ 'sec-fetch-dest': 'empty',
135
+ 'accept': '*/*',
136
+ 'accept-encoding': 'gzip, deflate, br',
137
+ 'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
138
+ }
139
+
140
+ payload = dumps(
141
+ separators=(',', ':'),
142
+ obj={
143
+ 'queryName': 'CreateBotMain_poeBotCreate_Mutation',
144
+ 'variables': {
145
+ 'model': MODELS[model],
146
+ 'handle': handle,
147
+ 'prompt': system_prompt,
148
+ 'isPromptPublic': True,
149
+ 'introduction': '',
150
+ 'description': description,
151
+ 'profilePictureUrl': 'https://qph.fs.quoracdn.net/main-qimg-24e0b480dcd946e1cc6728802c5128b6',
152
+ 'apiUrl': None,
153
+ 'apiKey': ''.join(choices(ascii_letters + digits, k=32)),
154
+ 'isApiBot': False,
155
+ 'hasLinkification': False,
156
+ 'hasMarkdownRendering': False,
157
+ 'hasSuggestedReplies': False,
158
+ 'isPrivateBot': False,
159
+ },
160
+ 'query': 'mutation CreateBotMain_poeBotCreate_Mutation(\n $model: String!\n $handle: String!\n $prompt: String!\n $isPromptPublic: Boolean!\n $introduction: String!\n $description: String!\n $profilePictureUrl: String\n $apiUrl: String\n $apiKey: String\n $isApiBot: Boolean\n $hasLinkification: Boolean\n $hasMarkdownRendering: Boolean\n $hasSuggestedReplies: Boolean\n $isPrivateBot: Boolean\n) {\n poeBotCreate(model: $model, handle: $handle, promptPlaintext: $prompt, isPromptPublic: $isPromptPublic, introduction: $introduction, description: $description, profilePicture: $profilePictureUrl, apiUrl: $apiUrl, apiKey: $apiKey, isApiBot: $isApiBot, hasLinkification: $hasLinkification, hasMarkdownRendering: $hasMarkdownRendering, hasSuggestedReplies: $hasSuggestedReplies, isPrivateBot: $isPrivateBot) {\n status\n bot {\n id\n ...BotHeader_bot\n }\n }\n}\n\nfragment BotHeader_bot on Bot {\n displayName\n messageLimit {\n dailyLimit\n }\n ...BotImage_bot\n ...BotLink_bot\n ...IdAnnotation_node\n ...botHelpers_useViewerCanAccessPrivateBot\n ...botHelpers_useDeletion_bot\n}\n\nfragment BotImage_bot on Bot {\n displayName\n ...botHelpers_useDeletion_bot\n ...BotImage_useProfileImage_bot\n}\n\nfragment BotImage_useProfileImage_bot on Bot {\n image {\n __typename\n ... on LocalBotImage {\n localName\n }\n ... on UrlBotImage {\n url\n }\n }\n ...botHelpers_useDeletion_bot\n}\n\nfragment BotLink_bot on Bot {\n displayName\n}\n\nfragment IdAnnotation_node on Node {\n __isNode: __typename\n id\n}\n\nfragment botHelpers_useDeletion_bot on Bot {\n deletionState\n}\n\nfragment botHelpers_useViewerCanAccessPrivateBot on Bot {\n isPrivateBot\n viewerIsCreator\n}\n',
161
+ },
162
+ )
163
+
164
+ base_string = payload + client.headers['poe-formkey'] + 'WpuLMiXEKKE98j56k'
165
+ client.headers['poe-tag-id'] = md5(base_string.encode()).hexdigest()
166
+
167
+ response = client.post('https://poe.com/api/gql_POST', data=payload)
168
+
169
+ if 'success' not in response.text:
170
+ raise Exception(
171
+ '''
172
+ Bot creation Failed
173
+ !! Important !!
174
+ Bot creation was not enabled on this account
175
+ please use: quora.Account.create with enable_bot_creation set to True
176
+ '''
177
+ )
178
+
179
+ return ModelResponse(response.json())
180
+
181
+
182
+ class Account:
183
+ @staticmethod
184
+ def create(
185
+ proxy: Optional[str] = None,
186
+ logging: bool = False,
187
+ enable_bot_creation: bool = False,
188
+ ):
189
+ client = TLS(client_identifier='chrome110')
190
+ client.proxies = {'http': f'http://{proxy}', 'https': f'http://{proxy}'} if proxy else {}
191
+
192
+ mail_client = Emailnator()
193
+ mail_address = mail_client.get_mail()
194
+
195
+ if logging:
196
+ print('email', mail_address)
197
+
198
+ client.headers = {
199
+ 'authority': 'poe.com',
200
+ 'accept': '*/*',
201
+ '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',
202
+ 'content-type': 'application/json',
203
+ 'origin': 'https://poe.com',
204
+ 'poe-tag-id': 'null',
205
+ 'referer': 'https://poe.com/login',
206
+ 'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
207
+ 'sec-ch-ua-mobile': '?0',
208
+ 'sec-ch-ua-platform': '"macOS"',
209
+ 'sec-fetch-dest': 'empty',
210
+ 'sec-fetch-mode': 'cors',
211
+ 'sec-fetch-site': 'same-origin',
212
+ 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
213
+ 'poe-formkey': extract_formkey(client.get('https://poe.com/login').text),
214
+ 'poe-tchannel': client.get('https://poe.com/api/settings').json()['tchannelData']['channel'],
215
+ }
216
+
217
+ token = reCaptchaV3(
218
+ 'https://www.recaptcha.net/recaptcha/enterprise/anchor?ar=1&k=6LflhEElAAAAAI_ewVwRWI9hsyV4mbZnYAslSvlG&co=aHR0cHM6Ly9wb2UuY29tOjQ0Mw..&hl=en&v=4PnKmGB9wRHh1i04o7YUICeI&size=invisible&cb=bi6ivxoskyal'
219
+ )
220
+ # token = solver.recaptcha(sitekey='6LflhEElAAAAAI_ewVwRWI9hsyV4mbZnYAslSvlG',
221
+ # url = 'https://poe.com/login?redirect_url=%2F',
222
+ # version = 'v3',
223
+ # enterprise = 1,
224
+ # invisible = 1,
225
+ # action = 'login',)['code']
226
+
227
+ payload = dumps(
228
+ separators=(',', ':'),
229
+ obj={
230
+ 'queryName': 'MainSignupLoginSection_sendVerificationCodeMutation_Mutation',
231
+ 'variables': {
232
+ 'emailAddress': mail_address,
233
+ 'phoneNumber': None,
234
+ 'recaptchaToken': token,
235
+ },
236
+ 'query': 'mutation MainSignupLoginSection_sendVerificationCodeMutation_Mutation(\n $emailAddress: String\n $phoneNumber: String\n $recaptchaToken: String\n) {\n sendVerificationCode(verificationReason: login, emailAddress: $emailAddress, phoneNumber: $phoneNumber, recaptchaToken: $recaptchaToken) {\n status\n errorMessage\n }\n}\n',
237
+ },
238
+ )
239
+
240
+ base_string = payload + client.headers['poe-formkey'] + 'WpuLMiXEKKE98j56k'
241
+ client.headers['poe-tag-id'] = md5(base_string.encode()).hexdigest()
242
+
243
+ print(dumps(client.headers, indent=4))
244
+
245
+ response = client.post('https://poe.com/api/gql_POST', data=payload)
246
+
247
+ if 'automated_request_detected' in response.text:
248
+ print('please try using a proxy / wait for fix')
249
+
250
+ if 'Bad Request' in response.text:
251
+ if logging:
252
+ print('bad request, retrying...', response.json())
253
+ quit()
254
+
255
+ if logging:
256
+ print('send_code', response.json())
257
+
258
+ mail_content = mail_client.get_message()
259
+ mail_token = findall(r';">(\d{6,7})</div>', mail_content)[0]
260
+
261
+ if logging:
262
+ print('code', mail_token)
263
+
264
+ payload = dumps(
265
+ separators=(',', ':'),
266
+ obj={
267
+ 'queryName': 'SignupOrLoginWithCodeSection_signupWithVerificationCodeMutation_Mutation',
268
+ 'variables': {
269
+ 'verificationCode': str(mail_token),
270
+ 'emailAddress': mail_address,
271
+ 'phoneNumber': None,
272
+ },
273
+ 'query': 'mutation SignupOrLoginWithCodeSection_signupWithVerificationCodeMutation_Mutation(\n $verificationCode: String!\n $emailAddress: String\n $phoneNumber: String\n) {\n signupWithVerificationCode(verificationCode: $verificationCode, emailAddress: $emailAddress, phoneNumber: $phoneNumber) {\n status\n errorMessage\n }\n}\n',
274
+ },
275
+ )
276
+
277
+ base_string = payload + client.headers['poe-formkey'] + 'WpuLMiXEKKE98j56k'
278
+ client.headers['poe-tag-id'] = md5(base_string.encode()).hexdigest()
279
+
280
+ response = client.post('https://poe.com/api/gql_POST', data=payload)
281
+ if logging:
282
+ print('verify_code', response.json())
283
+
284
+ def get(self):
285
+ cookies = open(Path(__file__).resolve().parent / 'cookies.txt', 'r').read().splitlines()
286
+ return choice(cookies)
287
+
288
+ @staticmethod
289
+ def delete(token: str, proxy: Optional[str] = None):
290
+ client = PoeClient(token, proxy=proxy)
291
+ client.delete_account()
292
+
293
+
294
+ class StreamingCompletion:
295
+ @staticmethod
296
+ def create(
297
+ model: str = 'gpt-4',
298
+ custom_model: bool = None,
299
+ prompt: str = 'hello world',
300
+ token: str = '',
301
+ proxy: Optional[str] = None,
302
+ ) -> Generator[PoeResponse, None, None]:
303
+ _model = MODELS[model] if not custom_model else custom_model
304
+
305
+ proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False
306
+ client = PoeClient(token)
307
+ client.proxy = proxies
308
+
309
+ for chunk in client.send_message(_model, prompt):
310
+ yield PoeResponse(
311
+ **{
312
+ 'id': chunk['messageId'],
313
+ 'object': 'text_completion',
314
+ 'created': chunk['creationTime'],
315
+ 'model': _model,
316
+ 'text': chunk['text_new'],
317
+ 'choices': [
318
+ {
319
+ 'text': chunk['text_new'],
320
+ 'index': 0,
321
+ 'logprobs': None,
322
+ 'finish_reason': 'stop',
323
+ }
324
+ ],
325
+ 'usage': {
326
+ 'prompt_tokens': len(prompt),
327
+ 'completion_tokens': len(chunk['text_new']),
328
+ 'total_tokens': len(prompt) + len(chunk['text_new']),
329
+ },
330
+ }
331
+ )
332
+
333
+
334
+ class Completion:
335
+ @staticmethod
336
+ def create(
337
+ model: str = 'gpt-4',
338
+ custom_model: str = None,
339
+ prompt: str = 'hello world',
340
+ token: str = '',
341
+ proxy: Optional[str] = None,
342
+ ) -> PoeResponse:
343
+ _model = MODELS[model] if not custom_model else custom_model
344
+
345
+ proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False
346
+ client = PoeClient(token)
347
+ client.proxy = proxies
348
+
349
+ chunk = None
350
+ for response in client.send_message(_model, prompt):
351
+ chunk = response
352
+
353
+ return PoeResponse(
354
+ **{
355
+ 'id': chunk['messageId'],
356
+ 'object': 'text_completion',
357
+ 'created': chunk['creationTime'],
358
+ 'model': _model,
359
+ 'text': chunk['text'],
360
+ 'choices': [
361
+ {
362
+ 'text': chunk['text'],
363
+ 'index': 0,
364
+ 'logprobs': None,
365
+ 'finish_reason': 'stop',
366
+ }
367
+ ],
368
+ 'usage': {
369
+ 'prompt_tokens': len(prompt),
370
+ 'completion_tokens': len(chunk['text']),
371
+ 'total_tokens': len(prompt) + len(chunk['text']),
372
+ },
373
+ }
374
+ )
375
+
376
+
377
+ class Poe:
378
+ def __init__(
379
+ self,
380
+ model: str = 'ChatGPT',
381
+ driver: str = 'firefox',
382
+ download_driver: bool = False,
383
+ driver_path: Optional[str] = None,
384
+ cookie_path: str = './quora/cookie.json',
385
+ ):
386
+ # validating the model
387
+ if model and model not in MODELS:
388
+ raise RuntimeError('Sorry, the model you provided does not exist. Please check and try again.')
389
+ self.model = MODELS[model]
390
+ self.cookie_path = cookie_path
391
+ self.cookie = self.__load_cookie(driver, driver_path=driver_path)
392
+ self.client = PoeClient(self.cookie)
393
+
394
+ def __load_cookie(self, driver: str, driver_path: Optional[str] = None) -> str:
395
+ if (cookie_file := Path(self.cookie_path)).exists():
396
+ with cookie_file.open() as fp:
397
+ cookie = json.load(fp)
398
+ if datetime.fromtimestamp(cookie['expiry']) < datetime.now():
399
+ cookie = self.__register_and_get_cookie(driver, driver_path=driver_path)
400
+ else:
401
+ print('Loading the cookie from file')
402
+ else:
403
+ cookie = self.__register_and_get_cookie(driver, driver_path=driver_path)
404
+
405
+ return unquote(cookie['value'])
406
+
407
+ def __register_and_get_cookie(self, driver: str, driver_path: Optional[str] = None) -> dict:
408
+ mail_client = Emailnator()
409
+ mail_address = mail_client.get_mail()
410
+
411
+ driver = self.__resolve_driver(driver, driver_path=driver_path)
412
+ driver.get("https://www.poe.com")
413
+
414
+ # clicking use email button
415
+ driver.find_element(By.XPATH, '//button[contains(text(), "Use email")]').click()
416
+
417
+ email = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '//input[@type="email"]')))
418
+ email.send_keys(mail_address)
419
+ driver.find_element(By.XPATH, '//button[text()="Go"]').click()
420
+
421
+ code = findall(r';">(\d{6,7})</div>', mail_client.get_message())[0]
422
+ print(code)
423
+
424
+ verification_code = WebDriverWait(driver, 30).until(
425
+ EC.presence_of_element_located((By.XPATH, '//input[@placeholder="Code"]'))
426
+ )
427
+ verification_code.send_keys(code)
428
+ verify_button = EC.presence_of_element_located((By.XPATH, '//button[text()="Verify"]'))
429
+ login_button = EC.presence_of_element_located((By.XPATH, '//button[text()="Log In"]'))
430
+
431
+ WebDriverWait(driver, 30).until(EC.any_of(verify_button, login_button)).click()
432
+
433
+ cookie = driver.get_cookie('p-b')
434
+
435
+ with open(self.cookie_path, 'w') as fw:
436
+ json.dump(cookie, fw)
437
+
438
+ driver.close()
439
+ return cookie
440
+
441
+ @staticmethod
442
+ def __resolve_driver(driver: str, driver_path: Optional[str] = None) -> Union[Firefox, Chrome]:
443
+ options = FirefoxOptions() if driver == 'firefox' else ChromeOptions()
444
+ options.add_argument('-headless')
445
+
446
+ if driver_path:
447
+ options.binary_location = driver_path
448
+ try:
449
+ return Firefox(options=options) if driver == 'firefox' else Chrome(options=options)
450
+ except Exception:
451
+ raise Exception(SELENIUM_WEB_DRIVER_ERROR_MSG)
452
+
453
+ def chat(self, message: str, model: Optional[str] = None) -> str:
454
+ if model and model not in MODELS:
455
+ raise RuntimeError('Sorry, the model you provided does not exist. Please check and try again.')
456
+ model = MODELS[model] if model else self.model
457
+ response = None
458
+ for chunk in self.client.send_message(model, message):
459
+ response = chunk['text']
460
+ return response
461
+
462
+ def create_bot(self, name: str, /, prompt: str = '', base_model: str = 'ChatGPT', description: str = '') -> None:
463
+ if base_model not in MODELS:
464
+ raise RuntimeError('Sorry, the base_model you provided does not exist. Please check and try again.')
465
+
466
+ response = self.client.create_bot(
467
+ handle=name,
468
+ prompt=prompt,
469
+ base_model=MODELS[base_model],
470
+ description=description,
471
+ )
472
+ print(f'Successfully created bot with name: {response["bot"]["displayName"]}')
473
+
474
+ def list_bots(self) -> list:
475
+ return list(self.client.bot_names.values())
476
+
477
+ def delete_account(self) -> None:
478
+ self.client.delete_account()
gpt4free/quora/api.py ADDED
@@ -0,0 +1,551 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was taken from the repository poe-api https://github.com/ading2210/poe-api and is unmodified
2
+ # This file is licensed under the GNU GPL v3 and written by @ading2210
3
+
4
+ # license:
5
+ # ading2210/poe-api: a reverse engineered Python API wrapepr for Quora's Poe
6
+ # Copyright (C) 2023 ading2210
7
+
8
+ # This program is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+
21
+ import hashlib
22
+ import json
23
+ import logging
24
+ import queue
25
+ import random
26
+ import re
27
+ import threading
28
+ import time
29
+ import traceback
30
+ from pathlib import Path
31
+ from urllib.parse import urlparse
32
+
33
+ import requests
34
+ import requests.adapters
35
+ import websocket
36
+
37
+ parent_path = Path(__file__).resolve().parent
38
+ queries_path = parent_path / "graphql"
39
+ queries = {}
40
+
41
+ logging.basicConfig()
42
+ logger = logging.getLogger()
43
+
44
+ user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0"
45
+
46
+
47
+ def load_queries():
48
+ for path in queries_path.iterdir():
49
+ if path.suffix != ".graphql":
50
+ continue
51
+ with open(path) as f:
52
+ queries[path.stem] = f.read()
53
+
54
+
55
+ def generate_payload(query_name, variables):
56
+ return {"query": queries[query_name], "variables": variables}
57
+
58
+
59
+ def request_with_retries(method, *args, **kwargs):
60
+ attempts = kwargs.get("attempts") or 10
61
+ url = args[0]
62
+ for i in range(attempts):
63
+ r = method(*args, **kwargs)
64
+ if r.status_code == 200:
65
+ return r
66
+ logger.warn(
67
+ f"Server returned a status code of {r.status_code} while downloading {url}. Retrying ({i + 1}/{attempts})..."
68
+ )
69
+
70
+ raise RuntimeError(f"Failed to download {url} too many times.")
71
+
72
+
73
+ class Client:
74
+ gql_url = "https://poe.com/api/gql_POST"
75
+ gql_recv_url = "https://poe.com/api/receive_POST"
76
+ home_url = "https://poe.com"
77
+ settings_url = "https://poe.com/api/settings"
78
+
79
+ def __init__(self, token, proxy=None):
80
+ self.proxy = proxy
81
+ self.session = requests.Session()
82
+ self.adapter = requests.adapters.HTTPAdapter(pool_connections=100, pool_maxsize=100)
83
+ self.session.mount("http://", self.adapter)
84
+ self.session.mount("https://", self.adapter)
85
+
86
+ if proxy:
87
+ self.session.proxies = {"http": self.proxy, "https": self.proxy}
88
+ logger.info(f"Proxy enabled: {self.proxy}")
89
+
90
+ self.active_messages = {}
91
+ self.message_queues = {}
92
+
93
+ self.session.cookies.set("p-b", token, domain="poe.com")
94
+ self.headers = {
95
+ "User-Agent": user_agent,
96
+ "Referrer": "https://poe.com/",
97
+ "Origin": "https://poe.com",
98
+ }
99
+ self.session.headers.update(self.headers)
100
+
101
+ self.setup_connection()
102
+ self.connect_ws()
103
+
104
+ def setup_connection(self):
105
+ self.ws_domain = f"tch{random.randint(1, 1e6)}"
106
+ self.next_data = self.get_next_data(overwrite_vars=True)
107
+ self.channel = self.get_channel_data()
108
+ self.bots = self.get_bots(download_next_data=False)
109
+ self.bot_names = self.get_bot_names()
110
+
111
+ self.gql_headers = {
112
+ "poe-formkey": self.formkey,
113
+ "poe-tchannel": self.channel["channel"],
114
+ }
115
+ self.gql_headers = {**self.gql_headers, **self.headers}
116
+ self.subscribe()
117
+
118
+ def extract_formkey(self, html):
119
+ script_regex = r"<script>if\(.+\)throw new Error;(.+)</script>"
120
+ script_text = re.search(script_regex, html).group(1)
121
+ key_regex = r'var .="([0-9a-f]+)",'
122
+ key_text = re.search(key_regex, script_text).group(1)
123
+ cipher_regex = r".\[(\d+)\]=.\[(\d+)\]"
124
+ cipher_pairs = re.findall(cipher_regex, script_text)
125
+
126
+ formkey_list = [""] * len(cipher_pairs)
127
+ for pair in cipher_pairs:
128
+ formkey_index, key_index = map(int, pair)
129
+ formkey_list[formkey_index] = key_text[key_index]
130
+ formkey = "".join(formkey_list)
131
+
132
+ return formkey
133
+
134
+ def get_next_data(self, overwrite_vars=False):
135
+ logger.info("Downloading next_data...")
136
+
137
+ r = request_with_retries(self.session.get, self.home_url)
138
+ json_regex = r'<script id="__NEXT_DATA__" type="application\/json">(.+?)</script>'
139
+ json_text = re.search(json_regex, r.text).group(1)
140
+ next_data = json.loads(json_text)
141
+
142
+ if overwrite_vars:
143
+ self.formkey = self.extract_formkey(r.text)
144
+ self.viewer = next_data["props"]["pageProps"]["payload"]["viewer"]
145
+ self.next_data = next_data
146
+
147
+ return next_data
148
+
149
+ def get_bot(self, display_name):
150
+ url = f'https://poe.com/_next/data/{self.next_data["buildId"]}/{display_name}.json'
151
+
152
+ r = request_with_retries(self.session.get, url)
153
+
154
+ chat_data = r.json()["pageProps"]["payload"]["chatOfBotDisplayName"]
155
+ return chat_data
156
+
157
+ def get_bots(self, download_next_data=True):
158
+ logger.info("Downloading all bots...")
159
+ if download_next_data:
160
+ next_data = self.get_next_data(overwrite_vars=True)
161
+ else:
162
+ next_data = self.next_data
163
+
164
+ if not "availableBots" in self.viewer:
165
+ raise RuntimeError("Invalid token or no bots are available.")
166
+ bot_list = self.viewer["availableBots"]
167
+
168
+ threads = []
169
+ bots = {}
170
+
171
+ def get_bot_thread(bot):
172
+ chat_data = self.get_bot(bot["displayName"])
173
+ bots[chat_data["defaultBotObject"]["nickname"]] = chat_data
174
+
175
+ for bot in bot_list:
176
+ thread = threading.Thread(target=get_bot_thread, args=(bot,), daemon=True)
177
+ threads.append(thread)
178
+
179
+ for thread in threads:
180
+ thread.start()
181
+ for thread in threads:
182
+ thread.join()
183
+
184
+ self.bots = bots
185
+ self.bot_names = self.get_bot_names()
186
+ return bots
187
+
188
+ def get_bot_names(self):
189
+ bot_names = {}
190
+ for bot_nickname in self.bots:
191
+ bot_obj = self.bots[bot_nickname]["defaultBotObject"]
192
+ bot_names[bot_nickname] = bot_obj["displayName"]
193
+ return bot_names
194
+
195
+ def get_remaining_messages(self, chatbot):
196
+ chat_data = self.get_bot(self.bot_names[chatbot])
197
+ return chat_data["defaultBotObject"]["messageLimit"]["numMessagesRemaining"]
198
+
199
+ def get_channel_data(self, channel=None):
200
+ logger.info("Downloading channel data...")
201
+ r = request_with_retries(self.session.get, self.settings_url)
202
+ data = r.json()
203
+
204
+ return data["tchannelData"]
205
+
206
+ def get_websocket_url(self, channel=None):
207
+ if channel is None:
208
+ channel = self.channel
209
+ query = f'?min_seq={channel["minSeq"]}&channel={channel["channel"]}&hash={channel["channelHash"]}'
210
+ return f'wss://{self.ws_domain}.tch.{channel["baseHost"]}/up/{channel["boxName"]}/updates' + query
211
+
212
+ def send_query(self, query_name, variables):
213
+ for i in range(20):
214
+ json_data = generate_payload(query_name, variables)
215
+ payload = json.dumps(json_data, separators=(",", ":"))
216
+
217
+ base_string = payload + self.gql_headers["poe-formkey"] + "WpuLMiXEKKE98j56k"
218
+
219
+ headers = {
220
+ "content-type": "application/json",
221
+ "poe-tag-id": hashlib.md5(base_string.encode()).hexdigest(),
222
+ }
223
+ headers = {**self.gql_headers, **headers}
224
+
225
+ r = request_with_retries(self.session.post, self.gql_url, data=payload, headers=headers)
226
+
227
+ data = r.json()
228
+ if data["data"] is None:
229
+ logger.warn(f'{query_name} returned an error: {data["errors"][0]["message"]} | Retrying ({i + 1}/20)')
230
+ time.sleep(2)
231
+ continue
232
+
233
+ return r.json()
234
+
235
+ raise RuntimeError(f"{query_name} failed too many times.")
236
+
237
+ def subscribe(self):
238
+ logger.info("Subscribing to mutations")
239
+ result = self.send_query(
240
+ "SubscriptionsMutation",
241
+ {
242
+ "subscriptions": [
243
+ {
244
+ "subscriptionName": "messageAdded",
245
+ "query": queries["MessageAddedSubscription"],
246
+ },
247
+ {
248
+ "subscriptionName": "viewerStateUpdated",
249
+ "query": queries["ViewerStateUpdatedSubscription"],
250
+ },
251
+ ]
252
+ },
253
+ )
254
+
255
+ def ws_run_thread(self):
256
+ kwargs = {}
257
+ if self.proxy:
258
+ proxy_parsed = urlparse(self.proxy)
259
+ kwargs = {
260
+ "proxy_type": proxy_parsed.scheme,
261
+ "http_proxy_host": proxy_parsed.hostname,
262
+ "http_proxy_port": proxy_parsed.port,
263
+ }
264
+
265
+ self.ws.run_forever(**kwargs)
266
+
267
+ def connect_ws(self):
268
+ self.ws_connected = False
269
+ self.ws = websocket.WebSocketApp(
270
+ self.get_websocket_url(),
271
+ header={"User-Agent": user_agent},
272
+ on_message=self.on_message,
273
+ on_open=self.on_ws_connect,
274
+ on_error=self.on_ws_error,
275
+ on_close=self.on_ws_close,
276
+ )
277
+ t = threading.Thread(target=self.ws_run_thread, daemon=True)
278
+ t.start()
279
+ while not self.ws_connected:
280
+ time.sleep(0.01)
281
+
282
+ def disconnect_ws(self):
283
+ if self.ws:
284
+ self.ws.close()
285
+ self.ws_connected = False
286
+
287
+ def on_ws_connect(self, ws):
288
+ self.ws_connected = True
289
+
290
+ def on_ws_close(self, ws, close_status_code, close_message):
291
+ self.ws_connected = False
292
+ logger.warn(f"Websocket closed with status {close_status_code}: {close_message}")
293
+
294
+ def on_ws_error(self, ws, error):
295
+ self.disconnect_ws()
296
+ self.connect_ws()
297
+
298
+ def on_message(self, ws, msg):
299
+ try:
300
+ data = json.loads(msg)
301
+
302
+ if not "messages" in data:
303
+ return
304
+
305
+ for message_str in data["messages"]:
306
+ message_data = json.loads(message_str)
307
+ if message_data["message_type"] != "subscriptionUpdate":
308
+ continue
309
+ message = message_data["payload"]["data"]["messageAdded"]
310
+
311
+ copied_dict = self.active_messages.copy()
312
+ for key, value in copied_dict.items():
313
+ # add the message to the appropriate queue
314
+ if value == message["messageId"] and key in self.message_queues:
315
+ self.message_queues[key].put(message)
316
+ return
317
+
318
+ # indicate that the response id is tied to the human message id
319
+ elif key != "pending" and value is None and message["state"] != "complete":
320
+ self.active_messages[key] = message["messageId"]
321
+ self.message_queues[key].put(message)
322
+ return
323
+
324
+ except Exception:
325
+ logger.error(traceback.format_exc())
326
+ self.disconnect_ws()
327
+ self.connect_ws()
328
+
329
+ def send_message(self, chatbot, message, with_chat_break=False, timeout=20):
330
+ # if there is another active message, wait until it has finished sending
331
+ while None in self.active_messages.values():
332
+ time.sleep(0.01)
333
+
334
+ # None indicates that a message is still in progress
335
+ self.active_messages["pending"] = None
336
+
337
+ logger.info(f"Sending message to {chatbot}: {message}")
338
+
339
+ # reconnect websocket
340
+ if not self.ws_connected:
341
+ self.disconnect_ws()
342
+ self.setup_connection()
343
+ self.connect_ws()
344
+
345
+ message_data = self.send_query(
346
+ "SendMessageMutation",
347
+ {
348
+ "bot": chatbot,
349
+ "query": message,
350
+ "chatId": self.bots[chatbot]["chatId"],
351
+ "source": None,
352
+ "withChatBreak": with_chat_break,
353
+ },
354
+ )
355
+ del self.active_messages["pending"]
356
+
357
+ if not message_data["data"]["messageEdgeCreate"]["message"]:
358
+ raise RuntimeError(f"Daily limit reached for {chatbot}.")
359
+ try:
360
+ human_message = message_data["data"]["messageEdgeCreate"]["message"]
361
+ human_message_id = human_message["node"]["messageId"]
362
+ except TypeError:
363
+ raise RuntimeError(f"An unknown error occurred. Raw response data: {message_data}")
364
+
365
+ # indicate that the current message is waiting for a response
366
+ self.active_messages[human_message_id] = None
367
+ self.message_queues[human_message_id] = queue.Queue()
368
+
369
+ last_text = ""
370
+ message_id = None
371
+ while True:
372
+ try:
373
+ message = self.message_queues[human_message_id].get(timeout=timeout)
374
+ except queue.Empty:
375
+ del self.active_messages[human_message_id]
376
+ del self.message_queues[human_message_id]
377
+ raise RuntimeError("Response timed out.")
378
+
379
+ # only break when the message is marked as complete
380
+ if message["state"] == "complete":
381
+ if last_text and message["messageId"] == message_id:
382
+ break
383
+ else:
384
+ continue
385
+
386
+ # update info about response
387
+ message["text_new"] = message["text"][len(last_text) :]
388
+ last_text = message["text"]
389
+ message_id = message["messageId"]
390
+
391
+ yield message
392
+
393
+ del self.active_messages[human_message_id]
394
+ del self.message_queues[human_message_id]
395
+
396
+ def send_chat_break(self, chatbot):
397
+ logger.info(f"Sending chat break to {chatbot}")
398
+ result = self.send_query("AddMessageBreakMutation", {"chatId": self.bots[chatbot]["chatId"]})
399
+ return result["data"]["messageBreakCreate"]["message"]
400
+
401
+ def get_message_history(self, chatbot, count=25, cursor=None):
402
+ logger.info(f"Downloading {count} messages from {chatbot}")
403
+
404
+ messages = []
405
+ if cursor is None:
406
+ chat_data = self.get_bot(self.bot_names[chatbot])
407
+ if not chat_data["messagesConnection"]["edges"]:
408
+ return []
409
+ messages = chat_data["messagesConnection"]["edges"][:count]
410
+ cursor = chat_data["messagesConnection"]["pageInfo"]["startCursor"]
411
+ count -= len(messages)
412
+
413
+ cursor = str(cursor)
414
+ if count > 50:
415
+ messages = self.get_message_history(chatbot, count=50, cursor=cursor) + messages
416
+ while count > 0:
417
+ count -= 50
418
+ new_cursor = messages[0]["cursor"]
419
+ new_messages = self.get_message_history(chatbot, min(50, count), cursor=new_cursor)
420
+ messages = new_messages + messages
421
+ return messages
422
+ elif count <= 0:
423
+ return messages
424
+
425
+ result = self.send_query(
426
+ "ChatListPaginationQuery",
427
+ {"count": count, "cursor": cursor, "id": self.bots[chatbot]["id"]},
428
+ )
429
+ query_messages = result["data"]["node"]["messagesConnection"]["edges"]
430
+ messages = query_messages + messages
431
+ return messages
432
+
433
+ def delete_message(self, message_ids):
434
+ logger.info(f"Deleting messages: {message_ids}")
435
+ if not type(message_ids) is list:
436
+ message_ids = [int(message_ids)]
437
+
438
+ result = self.send_query("DeleteMessageMutation", {"messageIds": message_ids})
439
+
440
+ def purge_conversation(self, chatbot, count=-1):
441
+ logger.info(f"Purging messages from {chatbot}")
442
+ last_messages = self.get_message_history(chatbot, count=50)[::-1]
443
+ while last_messages:
444
+ message_ids = []
445
+ for message in last_messages:
446
+ if count == 0:
447
+ break
448
+ count -= 1
449
+ message_ids.append(message["node"]["messageId"])
450
+
451
+ self.delete_message(message_ids)
452
+
453
+ if count == 0:
454
+ return
455
+ last_messages = self.get_message_history(chatbot, count=50)[::-1]
456
+ logger.info(f"No more messages left to delete.")
457
+
458
+ def create_bot(
459
+ self,
460
+ handle,
461
+ prompt="",
462
+ base_model="chinchilla",
463
+ description="",
464
+ intro_message="",
465
+ api_key=None,
466
+ api_bot=False,
467
+ api_url=None,
468
+ prompt_public=True,
469
+ pfp_url=None,
470
+ linkification=False,
471
+ markdown_rendering=True,
472
+ suggested_replies=False,
473
+ private=False,
474
+ ):
475
+ result = self.send_query(
476
+ "PoeBotCreateMutation",
477
+ {
478
+ "model": base_model,
479
+ "handle": handle,
480
+ "prompt": prompt,
481
+ "isPromptPublic": prompt_public,
482
+ "introduction": intro_message,
483
+ "description": description,
484
+ "profilePictureUrl": pfp_url,
485
+ "apiUrl": api_url,
486
+ "apiKey": api_key,
487
+ "isApiBot": api_bot,
488
+ "hasLinkification": linkification,
489
+ "hasMarkdownRendering": markdown_rendering,
490
+ "hasSuggestedReplies": suggested_replies,
491
+ "isPrivateBot": private,
492
+ },
493
+ )
494
+
495
+ data = result["data"]["poeBotCreate"]
496
+ if data["status"] != "success":
497
+ raise RuntimeError(f"Poe returned an error while trying to create a bot: {data['status']}")
498
+ self.get_bots()
499
+ return data
500
+
501
+ def edit_bot(
502
+ self,
503
+ bot_id,
504
+ handle,
505
+ prompt="",
506
+ base_model="chinchilla",
507
+ description="",
508
+ intro_message="",
509
+ api_key=None,
510
+ api_url=None,
511
+ private=False,
512
+ prompt_public=True,
513
+ pfp_url=None,
514
+ linkification=False,
515
+ markdown_rendering=True,
516
+ suggested_replies=False,
517
+ ):
518
+ result = self.send_query(
519
+ "PoeBotEditMutation",
520
+ {
521
+ "baseBot": base_model,
522
+ "botId": bot_id,
523
+ "handle": handle,
524
+ "prompt": prompt,
525
+ "isPromptPublic": prompt_public,
526
+ "introduction": intro_message,
527
+ "description": description,
528
+ "profilePictureUrl": pfp_url,
529
+ "apiUrl": api_url,
530
+ "apiKey": api_key,
531
+ "hasLinkification": linkification,
532
+ "hasMarkdownRendering": markdown_rendering,
533
+ "hasSuggestedReplies": suggested_replies,
534
+ "isPrivateBot": private,
535
+ },
536
+ )
537
+
538
+ data = result["data"]["poeBotEdit"]
539
+ if data["status"] != "success":
540
+ raise RuntimeError(f"Poe returned an error while trying to edit a bot: {data['status']}")
541
+ self.get_bots()
542
+ return data
543
+
544
+ def delete_account(self) -> None:
545
+ response = self.send_query('SettingsDeleteAccountButton_deleteAccountMutation_Mutation', {})
546
+ data = response['data']['deleteAccount']
547
+ if 'viewer' not in data:
548
+ raise RuntimeError(f'Error occurred while deleting the account, Please try again!')
549
+
550
+
551
+ load_queries()
gpt4free/quora/backup-mail.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from json import loads
2
+ from re import findall
3
+ from time import sleep
4
+
5
+ from requests import Session
6
+
7
+
8
+ class Mail:
9
+ def __init__(self) -> None:
10
+ self.client = Session()
11
+ self.client.post("https://etempmail.com/")
12
+ self.cookies = {'acceptcookie': 'true'}
13
+ self.cookies["ci_session"] = self.client.cookies.get_dict()["ci_session"]
14
+ self.email = None
15
+
16
+ def get_mail(self):
17
+ respone = self.client.post("https://etempmail.com/getEmailAddress")
18
+ # cookies
19
+ self.cookies["lisansimo"] = eval(respone.text)["recover_key"]
20
+ self.email = eval(respone.text)["address"]
21
+ return self.email
22
+
23
+ def get_message(self):
24
+ print("Waiting for message...")
25
+ while True:
26
+ sleep(5)
27
+ respone = self.client.post("https://etempmail.com/getInbox")
28
+ mail_token = loads(respone.text)
29
+ print(self.client.cookies.get_dict())
30
+ if len(mail_token) == 1:
31
+ break
32
+
33
+ params = {
34
+ 'id': '1',
35
+ }
36
+ self.mail_context = self.client.post("https://etempmail.com/getInbox", params=params)
37
+ self.mail_context = eval(self.mail_context.text)[0]["body"]
38
+ return self.mail_context
39
+
40
+ # ,cookies=self.cookies
41
+ def get_verification_code(self):
42
+ message = self.mail_context
43
+ code = findall(r';">(\d{6,7})</div>', message)[0]
44
+ print(f"Verification code: {code}")
45
+ return code
gpt4free/quora/cookies.txt ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ SmPiNXZI9hBTuf3viz74PA==
2
+ zw7RoKQfeEehiaelYMRWeA==
3
+ NEttgJ_rRQdO05Tppx6hFw==
4
+ 3OnmC0r9njYdNWhWszdQJg==
5
+ 8hZKR7MxwUTEHvO45TEViw==
6
+ Eea6BqK0AmosTKzoI3AAow==
7
+ pUEbtxobN_QUSpLIR8RGww==
8
+ 9_dUWxKkHHhpQRSvCvBk2Q==
9
+ UV45rvGwUwi2qV9QdIbMcw==
10
+ cVIN0pK1Wx-F7zCdUxlYqA==
11
+ UP2wQVds17VFHh6IfCQFrA==
12
+ 18eKr0ME2Tzifdfqat38Aw==
13
+ FNgKEpc2r-XqWe0rHBfYpg==
14
+ juCAh6kB0sUpXHvKik2woA==
15
+ nBvuNYRLaE4xE4HuzBPiIQ==
16
+ oyae3iClomSrk6RJywZ4iw==
17
+ 1Z27Ul8BTdNOhncT5H6wdg==
18
+ wfUfJIlwQwUss8l-3kDt3w==
19
+ f6Jw_Nr0PietpNCtOCXJTw==
20
+ 6Jc3yCs7XhDRNHa4ZML09g==
21
+ 3vy44sIy-ZlTMofFiFDttw==
22
+ p9FbMGGiK1rShKgL3YWkDg==
23
+ pw6LI5Op84lf4HOY7fn91A==
24
+ QemKm6aothMvqcEgeKFDlQ==
25
+ cceZzucA-CEHR0Gt6VLYLQ==
26
+ JRRObMp2RHVn5u4730DPvQ==
27
+ XNt0wLTjX7Z-EsRR3TJMIQ==
28
+ csjjirAUKtT5HT1KZUq1kg==
29
+ 8qZdCatCPQZyS7jsO4hkdQ==
30
+ esnUxcBhvH1DmCJTeld0qw==
gpt4free/quora/graphql/AddHumanMessageMutation.graphql ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mutation AddHumanMessageMutation(
2
+ $chatId: BigInt!
3
+ $bot: String!
4
+ $query: String!
5
+ $source: MessageSource
6
+ $withChatBreak: Boolean! = false
7
+ ) {
8
+ messageCreateWithStatus(
9
+ chatId: $chatId
10
+ bot: $bot
11
+ query: $query
12
+ source: $source
13
+ withChatBreak: $withChatBreak
14
+ ) {
15
+ message {
16
+ id
17
+ __typename
18
+ messageId
19
+ text
20
+ linkifiedText
21
+ authorNickname
22
+ state
23
+ vote
24
+ voteReason
25
+ creationTime
26
+ suggestedReplies
27
+ chat {
28
+ id
29
+ shouldShowDisclaimer
30
+ }
31
+ }
32
+ messageLimit{
33
+ canSend
34
+ numMessagesRemaining
35
+ resetTime
36
+ shouldShowReminder
37
+ }
38
+ chatBreak {
39
+ id
40
+ __typename
41
+ messageId
42
+ text
43
+ linkifiedText
44
+ authorNickname
45
+ state
46
+ vote
47
+ voteReason
48
+ creationTime
49
+ suggestedReplies
50
+ }
51
+ }
52
+ }
gpt4free/quora/graphql/AddMessageBreakMutation.graphql ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mutation AddMessageBreakMutation($chatId: BigInt!) {
2
+ messageBreakCreate(chatId: $chatId) {
3
+ message {
4
+ id
5
+ __typename
6
+ messageId
7
+ text
8
+ linkifiedText
9
+ authorNickname
10
+ state
11
+ vote
12
+ voteReason
13
+ creationTime
14
+ suggestedReplies
15
+ }
16
+ }
17
+ }
gpt4free/quora/graphql/AutoSubscriptionMutation.graphql ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ mutation AutoSubscriptionMutation($subscriptions: [AutoSubscriptionQuery!]!) {
2
+ autoSubscribe(subscriptions: $subscriptions) {
3
+ viewer {
4
+ id
5
+ }
6
+ }
7
+ }
gpt4free/quora/graphql/BioFragment.graphql ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ fragment BioFragment on Viewer {
2
+ id
3
+ poeUser {
4
+ id
5
+ uid
6
+ bio
7
+ }
8
+ }
gpt4free/quora/graphql/ChatAddedSubscription.graphql ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ subscription ChatAddedSubscription {
2
+ chatAdded {
3
+ ...ChatFragment
4
+ }
5
+ }
gpt4free/quora/graphql/ChatFragment.graphql ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ fragment ChatFragment on Chat {
2
+ id
3
+ chatId
4
+ defaultBotNickname
5
+ shouldShowDisclaimer
6
+ }
gpt4free/quora/graphql/ChatListPaginationQuery.graphql ADDED
@@ -0,0 +1,378 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ query ChatListPaginationQuery(
2
+ $count: Int = 5
3
+ $cursor: String
4
+ $id: ID!
5
+ ) {
6
+ node(id: $id) {
7
+ __typename
8
+ ...ChatPageMain_chat_1G22uz
9
+ id
10
+ }
11
+ }
12
+
13
+ fragment BotImage_bot on Bot {
14
+ displayName
15
+ ...botHelpers_useDeletion_bot
16
+ ...BotImage_useProfileImage_bot
17
+ }
18
+
19
+ fragment BotImage_useProfileImage_bot on Bot {
20
+ image {
21
+ __typename
22
+ ... on LocalBotImage {
23
+ localName
24
+ }
25
+ ... on UrlBotImage {
26
+ url
27
+ }
28
+ }
29
+ ...botHelpers_useDeletion_bot
30
+ }
31
+
32
+ fragment ChatMessageDownvotedButton_message on Message {
33
+ ...MessageFeedbackReasonModal_message
34
+ ...MessageFeedbackOtherModal_message
35
+ }
36
+
37
+ fragment ChatMessageDropdownMenu_message on Message {
38
+ id
39
+ messageId
40
+ vote
41
+ text
42
+ author
43
+ ...chatHelpers_isBotMessage
44
+ }
45
+
46
+ fragment ChatMessageFeedbackButtons_message on Message {
47
+ id
48
+ messageId
49
+ vote
50
+ voteReason
51
+ ...ChatMessageDownvotedButton_message
52
+ }
53
+
54
+ fragment ChatMessageInputView_chat on Chat {
55
+ id
56
+ chatId
57
+ defaultBotObject {
58
+ nickname
59
+ messageLimit {
60
+ dailyBalance
61
+ shouldShowRemainingMessageCount
62
+ }
63
+ hasClearContext
64
+ isDown
65
+ ...botHelpers_useDeletion_bot
66
+ id
67
+ }
68
+ shouldShowDisclaimer
69
+ ...chatHelpers_useSendMessage_chat
70
+ ...chatHelpers_useSendChatBreak_chat
71
+ }
72
+
73
+ fragment ChatMessageInputView_edges on MessageEdge {
74
+ node {
75
+ ...chatHelpers_isChatBreak
76
+ ...chatHelpers_isHumanMessage
77
+ state
78
+ text
79
+ id
80
+ }
81
+ }
82
+
83
+ fragment ChatMessageOverflowButton_message on Message {
84
+ text
85
+ ...ChatMessageDropdownMenu_message
86
+ ...chatHelpers_isBotMessage
87
+ }
88
+
89
+ fragment ChatMessageSuggestedReplies_SuggestedReplyButton_chat on Chat {
90
+ ...chatHelpers_useSendMessage_chat
91
+ }
92
+
93
+ fragment ChatMessageSuggestedReplies_SuggestedReplyButton_message on Message {
94
+ messageId
95
+ }
96
+
97
+ fragment ChatMessageSuggestedReplies_chat on Chat {
98
+ ...ChatWelcomeView_chat
99
+ ...ChatMessageSuggestedReplies_SuggestedReplyButton_chat
100
+ defaultBotObject {
101
+ hasWelcomeTopics
102
+ id
103
+ }
104
+ }
105
+
106
+ fragment ChatMessageSuggestedReplies_message on Message {
107
+ suggestedReplies
108
+ ...ChatMessageSuggestedReplies_SuggestedReplyButton_message
109
+ }
110
+
111
+ fragment ChatMessage_chat on Chat {
112
+ defaultBotObject {
113
+ hasWelcomeTopics
114
+ hasSuggestedReplies
115
+ disclaimerText
116
+ messageLimit {
117
+ ...ChatPageRateLimitedBanner_messageLimit
118
+ }
119
+ ...ChatPageDisclaimer_bot
120
+ id
121
+ }
122
+ ...ChatMessageSuggestedReplies_chat
123
+ ...ChatWelcomeView_chat
124
+ }
125
+
126
+ fragment ChatMessage_message on Message {
127
+ id
128
+ messageId
129
+ text
130
+ author
131
+ linkifiedText
132
+ state
133
+ contentType
134
+ ...ChatMessageSuggestedReplies_message
135
+ ...ChatMessageFeedbackButtons_message
136
+ ...ChatMessageOverflowButton_message
137
+ ...chatHelpers_isHumanMessage
138
+ ...chatHelpers_isBotMessage
139
+ ...chatHelpers_isChatBreak
140
+ ...chatHelpers_useTimeoutLevel
141
+ ...MarkdownLinkInner_message
142
+ ...IdAnnotation_node
143
+ }
144
+
145
+ fragment ChatMessagesView_chat on Chat {
146
+ ...ChatMessage_chat
147
+ ...ChatWelcomeView_chat
148
+ ...IdAnnotation_node
149
+ defaultBotObject {
150
+ hasWelcomeTopics
151
+ messageLimit {
152
+ ...ChatPageRateLimitedBanner_messageLimit
153
+ }
154
+ id
155
+ }
156
+ }
157
+
158
+ fragment ChatMessagesView_edges on MessageEdge {
159
+ node {
160
+ id
161
+ messageId
162
+ creationTime
163
+ ...ChatMessage_message
164
+ ...chatHelpers_isBotMessage
165
+ ...chatHelpers_isHumanMessage
166
+ ...chatHelpers_isChatBreak
167
+ }
168
+ }
169
+
170
+ fragment ChatPageDeleteFooter_chat on Chat {
171
+ ...MessageDeleteConfirmationModal_chat
172
+ }
173
+
174
+ fragment ChatPageDisclaimer_bot on Bot {
175
+ disclaimerText
176
+ }
177
+
178
+ fragment ChatPageMainFooter_chat on Chat {
179
+ defaultBotObject {
180
+ ...ChatPageMainFooter_useAccessMessage_bot
181
+ id
182
+ }
183
+ ...ChatMessageInputView_chat
184
+ ...ChatPageShareFooter_chat
185
+ ...ChatPageDeleteFooter_chat
186
+ }
187
+
188
+ fragment ChatPageMainFooter_edges on MessageEdge {
189
+ ...ChatMessageInputView_edges
190
+ }
191
+
192
+ fragment ChatPageMainFooter_useAccessMessage_bot on Bot {
193
+ ...botHelpers_useDeletion_bot
194
+ ...botHelpers_useViewerCanAccessPrivateBot
195
+ }
196
+
197
+ fragment ChatPageMain_chat_1G22uz on Chat {
198
+ id
199
+ chatId
200
+ ...ChatPageShareFooter_chat
201
+ ...ChatPageDeleteFooter_chat
202
+ ...ChatMessagesView_chat
203
+ ...MarkdownLinkInner_chat
204
+ ...chatHelpers_useUpdateStaleChat_chat
205
+ ...ChatSubscriptionPaywallContextWrapper_chat
206
+ ...ChatPageMainFooter_chat
207
+ messagesConnection(last: $count, before: $cursor) {
208
+ edges {
209
+ ...ChatMessagesView_edges
210
+ ...ChatPageMainFooter_edges
211
+ ...MarkdownLinkInner_edges
212
+ node {
213
+ ...chatHelpers_useUpdateStaleChat_message
214
+ id
215
+ __typename
216
+ }
217
+ cursor
218
+ id
219
+ }
220
+ pageInfo {
221
+ hasPreviousPage
222
+ startCursor
223
+ }
224
+ id
225
+ }
226
+ }
227
+
228
+ fragment ChatPageRateLimitedBanner_messageLimit on MessageLimit {
229
+ numMessagesRemaining
230
+ }
231
+
232
+ fragment ChatPageShareFooter_chat on Chat {
233
+ chatId
234
+ }
235
+
236
+ fragment ChatSubscriptionPaywallContextWrapper_chat on Chat {
237
+ defaultBotObject {
238
+ messageLimit {
239
+ numMessagesRemaining
240
+ shouldShowRemainingMessageCount
241
+ }
242
+ ...SubscriptionPaywallModal_bot
243
+ id
244
+ }
245
+ }
246
+
247
+ fragment ChatWelcomeView_ChatWelcomeButton_chat on Chat {
248
+ ...chatHelpers_useSendMessage_chat
249
+ }
250
+
251
+ fragment ChatWelcomeView_chat on Chat {
252
+ ...ChatWelcomeView_ChatWelcomeButton_chat
253
+ defaultBotObject {
254
+ displayName
255
+ id
256
+ }
257
+ }
258
+
259
+ fragment IdAnnotation_node on Node {
260
+ __isNode: __typename
261
+ id
262
+ }
263
+
264
+ fragment MarkdownLinkInner_chat on Chat {
265
+ id
266
+ chatId
267
+ defaultBotObject {
268
+ nickname
269
+ id
270
+ }
271
+ ...chatHelpers_useSendMessage_chat
272
+ }
273
+
274
+ fragment MarkdownLinkInner_edges on MessageEdge {
275
+ node {
276
+ state
277
+ id
278
+ }
279
+ }
280
+
281
+ fragment MarkdownLinkInner_message on Message {
282
+ messageId
283
+ }
284
+
285
+ fragment MessageDeleteConfirmationModal_chat on Chat {
286
+ id
287
+ }
288
+
289
+ fragment MessageFeedbackOtherModal_message on Message {
290
+ id
291
+ messageId
292
+ }
293
+
294
+ fragment MessageFeedbackReasonModal_message on Message {
295
+ id
296
+ messageId
297
+ }
298
+
299
+ fragment SubscriptionPaywallModal_bot on Bot {
300
+ displayName
301
+ messageLimit {
302
+ dailyLimit
303
+ numMessagesRemaining
304
+ shouldShowRemainingMessageCount
305
+ resetTime
306
+ }
307
+ ...BotImage_bot
308
+ }
309
+
310
+ fragment botHelpers_useDeletion_bot on Bot {
311
+ deletionState
312
+ }
313
+
314
+ fragment botHelpers_useViewerCanAccessPrivateBot on Bot {
315
+ isPrivateBot
316
+ viewerIsCreator
317
+ }
318
+
319
+ fragment chatHelpers_isBotMessage on Message {
320
+ ...chatHelpers_isHumanMessage
321
+ ...chatHelpers_isChatBreak
322
+ }
323
+
324
+ fragment chatHelpers_isChatBreak on Message {
325
+ author
326
+ }
327
+
328
+ fragment chatHelpers_isHumanMessage on Message {
329
+ author
330
+ }
331
+
332
+ fragment chatHelpers_useSendChatBreak_chat on Chat {
333
+ id
334
+ chatId
335
+ defaultBotObject {
336
+ nickname
337
+ introduction
338
+ model
339
+ id
340
+ }
341
+ shouldShowDisclaimer
342
+ }
343
+
344
+ fragment chatHelpers_useSendMessage_chat on Chat {
345
+ id
346
+ chatId
347
+ defaultBotObject {
348
+ id
349
+ nickname
350
+ }
351
+ shouldShowDisclaimer
352
+ }
353
+
354
+ fragment chatHelpers_useTimeoutLevel on Message {
355
+ id
356
+ state
357
+ text
358
+ messageId
359
+ chat {
360
+ chatId
361
+ defaultBotNickname
362
+ id
363
+ }
364
+ }
365
+
366
+ fragment chatHelpers_useUpdateStaleChat_chat on Chat {
367
+ chatId
368
+ defaultBotObject {
369
+ contextClearWindowSecs
370
+ id
371
+ }
372
+ ...chatHelpers_useSendChatBreak_chat
373
+ }
374
+
375
+ fragment chatHelpers_useUpdateStaleChat_message on Message {
376
+ creationTime
377
+ ...chatHelpers_isChatBreak
378
+ }
gpt4free/quora/graphql/ChatPaginationQuery.graphql ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ query ChatPaginationQuery($bot: String!, $before: String, $last: Int! = 10) {
2
+ chatOfBot(bot: $bot) {
3
+ id
4
+ __typename
5
+ messagesConnection(before: $before, last: $last) {
6
+ pageInfo {
7
+ hasPreviousPage
8
+ }
9
+ edges {
10
+ node {
11
+ id
12
+ __typename
13
+ messageId
14
+ text
15
+ linkifiedText
16
+ authorNickname
17
+ state
18
+ vote
19
+ voteReason
20
+ creationTime
21
+ suggestedReplies
22
+ }
23
+ }
24
+ }
25
+ }
26
+ }
gpt4free/quora/graphql/ChatViewQuery.graphql ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ query ChatViewQuery($bot: String!) {
2
+ chatOfBot(bot: $bot) {
3
+ id
4
+ chatId
5
+ defaultBotNickname
6
+ shouldShowDisclaimer
7
+ }
8
+ }
gpt4free/quora/graphql/DeleteHumanMessagesMutation.graphql ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ mutation DeleteHumanMessagesMutation($messageIds: [BigInt!]!) {
2
+ messagesDelete(messageIds: $messageIds) {
3
+ viewer {
4
+ id
5
+ }
6
+ }
7
+ }
gpt4free/quora/graphql/DeleteMessageMutation.graphql ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ mutation deleteMessageMutation(
2
+ $messageIds: [BigInt!]!
3
+ ) {
4
+ messagesDelete(messageIds: $messageIds) {
5
+ edgeIds
6
+ }
7
+ }
gpt4free/quora/graphql/HandleFragment.graphql ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ fragment HandleFragment on Viewer {
2
+ id
3
+ poeUser {
4
+ id
5
+ uid
6
+ handle
7
+ }
8
+ }
gpt4free/quora/graphql/LoginWithVerificationCodeMutation.graphql ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mutation LoginWithVerificationCodeMutation(
2
+ $verificationCode: String!
3
+ $emailAddress: String
4
+ $phoneNumber: String
5
+ ) {
6
+ loginWithVerificationCode(
7
+ verificationCode: $verificationCode
8
+ emailAddress: $emailAddress
9
+ phoneNumber: $phoneNumber
10
+ ) {
11
+ status
12
+ }
13
+ }
gpt4free/quora/graphql/MessageAddedSubscription.graphql ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ subscription messageAdded (
2
+ $chatId: BigInt!
3
+ ) {
4
+ messageAdded(chatId: $chatId) {
5
+ id
6
+ messageId
7
+ creationTime
8
+ state
9
+ ...ChatMessage_message
10
+ ...chatHelpers_isBotMessage
11
+ }
12
+ }
13
+
14
+ fragment ChatMessageDownvotedButton_message on Message {
15
+ ...MessageFeedbackReasonModal_message
16
+ ...MessageFeedbackOtherModal_message
17
+ }
18
+
19
+ fragment ChatMessageDropdownMenu_message on Message {
20
+ id
21
+ messageId
22
+ vote
23
+ text
24
+ linkifiedText
25
+ ...chatHelpers_isBotMessage
26
+ }
27
+
28
+ fragment ChatMessageFeedbackButtons_message on Message {
29
+ id
30
+ messageId
31
+ vote
32
+ voteReason
33
+ ...ChatMessageDownvotedButton_message
34
+ }
35
+
36
+ fragment ChatMessageOverflowButton_message on Message {
37
+ text
38
+ ...ChatMessageDropdownMenu_message
39
+ ...chatHelpers_isBotMessage
40
+ }
41
+
42
+ fragment ChatMessageSuggestedReplies_SuggestedReplyButton_message on Message {
43
+ messageId
44
+ }
45
+
46
+ fragment ChatMessageSuggestedReplies_message on Message {
47
+ suggestedReplies
48
+ ...ChatMessageSuggestedReplies_SuggestedReplyButton_message
49
+ }
50
+
51
+ fragment ChatMessage_message on Message {
52
+ id
53
+ messageId
54
+ text
55
+ author
56
+ linkifiedText
57
+ state
58
+ ...ChatMessageSuggestedReplies_message
59
+ ...ChatMessageFeedbackButtons_message
60
+ ...ChatMessageOverflowButton_message
61
+ ...chatHelpers_isHumanMessage
62
+ ...chatHelpers_isBotMessage
63
+ ...chatHelpers_isChatBreak
64
+ ...chatHelpers_useTimeoutLevel
65
+ ...MarkdownLinkInner_message
66
+ }
67
+
68
+ fragment MarkdownLinkInner_message on Message {
69
+ messageId
70
+ }
71
+
72
+ fragment MessageFeedbackOtherModal_message on Message {
73
+ id
74
+ messageId
75
+ }
76
+
77
+ fragment MessageFeedbackReasonModal_message on Message {
78
+ id
79
+ messageId
80
+ }
81
+
82
+ fragment chatHelpers_isBotMessage on Message {
83
+ ...chatHelpers_isHumanMessage
84
+ ...chatHelpers_isChatBreak
85
+ }
86
+
87
+ fragment chatHelpers_isChatBreak on Message {
88
+ author
89
+ }
90
+
91
+ fragment chatHelpers_isHumanMessage on Message {
92
+ author
93
+ }
94
+
95
+ fragment chatHelpers_useTimeoutLevel on Message {
96
+ id
97
+ state
98
+ text
99
+ messageId
100
+ }
gpt4free/quora/graphql/MessageDeletedSubscription.graphql ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ subscription MessageDeletedSubscription($chatId: BigInt!) {
2
+ messageDeleted(chatId: $chatId) {
3
+ id
4
+ messageId
5
+ }
6
+ }
gpt4free/quora/graphql/MessageFragment.graphql ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fragment MessageFragment on Message {
2
+ id
3
+ __typename
4
+ messageId
5
+ text
6
+ linkifiedText
7
+ authorNickname
8
+ state
9
+ vote
10
+ voteReason
11
+ creationTime
12
+ suggestedReplies
13
+ }
gpt4free/quora/graphql/MessageRemoveVoteMutation.graphql ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ mutation MessageRemoveVoteMutation($messageId: BigInt!) {
2
+ messageRemoveVote(messageId: $messageId) {
3
+ message {
4
+ ...MessageFragment
5
+ }
6
+ }
7
+ }
gpt4free/quora/graphql/MessageSetVoteMutation.graphql ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ mutation MessageSetVoteMutation($messageId: BigInt!, $voteType: VoteType!, $reason: String) {
2
+ messageSetVote(messageId: $messageId, voteType: $voteType, reason: $reason) {
3
+ message {
4
+ ...MessageFragment
5
+ }
6
+ }
7
+ }
gpt4free/quora/graphql/PoeBotCreateMutation.graphql ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mutation CreateBotMain_poeBotCreate_Mutation(
2
+ $model: String!
3
+ $handle: String!
4
+ $prompt: String!
5
+ $isPromptPublic: Boolean!
6
+ $introduction: String!
7
+ $description: String!
8
+ $profilePictureUrl: String
9
+ $apiUrl: String
10
+ $apiKey: String
11
+ $isApiBot: Boolean
12
+ $hasLinkification: Boolean
13
+ $hasMarkdownRendering: Boolean
14
+ $hasSuggestedReplies: Boolean
15
+ $isPrivateBot: Boolean
16
+ ) {
17
+ poeBotCreate(model: $model, handle: $handle, promptPlaintext: $prompt, isPromptPublic: $isPromptPublic, introduction: $introduction, description: $description, profilePicture: $profilePictureUrl, apiUrl: $apiUrl, apiKey: $apiKey, isApiBot: $isApiBot, hasLinkification: $hasLinkification, hasMarkdownRendering: $hasMarkdownRendering, hasSuggestedReplies: $hasSuggestedReplies, isPrivateBot: $isPrivateBot) {
18
+ status
19
+ bot {
20
+ id
21
+ ...BotHeader_bot
22
+ }
23
+ }
24
+ }
25
+
26
+ fragment BotHeader_bot on Bot {
27
+ displayName
28
+ messageLimit {
29
+ dailyLimit
30
+ }
31
+ ...BotImage_bot
32
+ ...BotLink_bot
33
+ ...IdAnnotation_node
34
+ ...botHelpers_useViewerCanAccessPrivateBot
35
+ ...botHelpers_useDeletion_bot
36
+ }
37
+
38
+ fragment BotImage_bot on Bot {
39
+ displayName
40
+ ...botHelpers_useDeletion_bot
41
+ ...BotImage_useProfileImage_bot
42
+ }
43
+
44
+ fragment BotImage_useProfileImage_bot on Bot {
45
+ image {
46
+ __typename
47
+ ... on LocalBotImage {
48
+ localName
49
+ }
50
+ ... on UrlBotImage {
51
+ url
52
+ }
53
+ }
54
+ ...botHelpers_useDeletion_bot
55
+ }
56
+
57
+ fragment BotLink_bot on Bot {
58
+ displayName
59
+ }
60
+
61
+ fragment IdAnnotation_node on Node {
62
+ __isNode: __typename
63
+ id
64
+ }
65
+
66
+ fragment botHelpers_useDeletion_bot on Bot {
67
+ deletionState
68
+ }
69
+
70
+ fragment botHelpers_useViewerCanAccessPrivateBot on Bot {
71
+ isPrivateBot
72
+ viewerIsCreator
73
+ }
gpt4free/quora/graphql/PoeBotEditMutation.graphql ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mutation EditBotMain_poeBotEdit_Mutation(
2
+ $botId: BigInt!
3
+ $handle: String!
4
+ $description: String!
5
+ $introduction: String!
6
+ $isPromptPublic: Boolean!
7
+ $baseBot: String!
8
+ $profilePictureUrl: String
9
+ $prompt: String!
10
+ $apiUrl: String
11
+ $apiKey: String
12
+ $hasLinkification: Boolean
13
+ $hasMarkdownRendering: Boolean
14
+ $hasSuggestedReplies: Boolean
15
+ $isPrivateBot: Boolean
16
+ ) {
17
+ poeBotEdit(botId: $botId, handle: $handle, description: $description, introduction: $introduction, isPromptPublic: $isPromptPublic, model: $baseBot, promptPlaintext: $prompt, profilePicture: $profilePictureUrl, apiUrl: $apiUrl, apiKey: $apiKey, hasLinkification: $hasLinkification, hasMarkdownRendering: $hasMarkdownRendering, hasSuggestedReplies: $hasSuggestedReplies, isPrivateBot: $isPrivateBot) {
18
+ status
19
+ bot {
20
+ handle
21
+ id
22
+ }
23
+ }
24
+ }
gpt4free/quora/graphql/SendMessageMutation.graphql ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mutation chatHelpers_sendMessageMutation_Mutation(
2
+ $chatId: BigInt!
3
+ $bot: String!
4
+ $query: String!
5
+ $source: MessageSource
6
+ $withChatBreak: Boolean!
7
+ ) {
8
+ messageEdgeCreate(chatId: $chatId, bot: $bot, query: $query, source: $source, withChatBreak: $withChatBreak) {
9
+ chatBreak {
10
+ cursor
11
+ node {
12
+ id
13
+ messageId
14
+ text
15
+ author
16
+ suggestedReplies
17
+ creationTime
18
+ state
19
+ }
20
+ id
21
+ }
22
+ message {
23
+ cursor
24
+ node {
25
+ id
26
+ messageId
27
+ text
28
+ author
29
+ suggestedReplies
30
+ creationTime
31
+ state
32
+ chat {
33
+ shouldShowDisclaimer
34
+ id
35
+ }
36
+ }
37
+ id
38
+ }
39
+ }
40
+ }
gpt4free/quora/graphql/SendVerificationCodeForLoginMutation.graphql ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mutation SendVerificationCodeForLoginMutation(
2
+ $emailAddress: String
3
+ $phoneNumber: String
4
+ ) {
5
+ sendVerificationCode(
6
+ verificationReason: login
7
+ emailAddress: $emailAddress
8
+ phoneNumber: $phoneNumber
9
+ ) {
10
+ status
11
+ }
12
+ }
gpt4free/quora/graphql/SettingsDeleteAccountButton_deleteAccountMutation_Mutation.graphql ADDED
@@ -0,0 +1 @@
 
 
1
+ mutation SettingsDeleteAccountButton_deleteAccountMutation_Mutation{ deleteAccount { viewer { uid id } }}
gpt4free/quora/graphql/ShareMessagesMutation.graphql ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ mutation ShareMessagesMutation(
2
+ $chatId: BigInt!
3
+ $messageIds: [BigInt!]!
4
+ $comment: String
5
+ ) {
6
+ messagesShare(chatId: $chatId, messageIds: $messageIds, comment: $comment) {
7
+ shareCode
8
+ }
9
+ }
gpt4free/quora/graphql/SignupWithVerificationCodeMutation.graphql ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mutation SignupWithVerificationCodeMutation(
2
+ $verificationCode: String!
3
+ $emailAddress: String
4
+ $phoneNumber: String
5
+ ) {
6
+ signupWithVerificationCode(
7
+ verificationCode: $verificationCode
8
+ emailAddress: $emailAddress
9
+ phoneNumber: $phoneNumber
10
+ ) {
11
+ status
12
+ }
13
+ }
gpt4free/quora/graphql/StaleChatUpdateMutation.graphql ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ mutation StaleChatUpdateMutation($chatId: BigInt!) {
2
+ staleChatUpdate(chatId: $chatId) {
3
+ message {
4
+ ...MessageFragment
5
+ }
6
+ }
7
+ }
gpt4free/quora/graphql/SubscriptionsMutation.graphql ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ mutation subscriptionsMutation(
2
+ $subscriptions: [AutoSubscriptionQuery!]!
3
+ ) {
4
+ autoSubscribe(subscriptions: $subscriptions) {
5
+ viewer {
6
+ id
7
+ }
8
+ }
9
+ }
gpt4free/quora/graphql/SummarizePlainPostQuery.graphql ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ query SummarizePlainPostQuery($comment: String!) {
2
+ summarizePlainPost(comment: $comment)
3
+ }
gpt4free/quora/graphql/SummarizeQuotePostQuery.graphql ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ query SummarizeQuotePostQuery($comment: String, $quotedPostId: BigInt!) {
2
+ summarizeQuotePost(comment: $comment, quotedPostId: $quotedPostId)
3
+ }
gpt4free/quora/graphql/SummarizeSharePostQuery.graphql ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ query SummarizeSharePostQuery($comment: String!, $chatId: BigInt!, $messageIds: [BigInt!]!) {
2
+ summarizeSharePost(comment: $comment, chatId: $chatId, messageIds: $messageIds)
3
+ }