lsxk justest commited on
Commit
fe23c0b
0 Parent(s):

Duplicate from justest/gpt4free

Browse files

Co-authored-by: lw <[email protected]>

This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. .github/FUNDING.yml +3 -0
  3. .github/ISSUE_TEMPLATE/default_issue.md +33 -0
  4. .github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. .github/workflows/ci.yml +37 -0
  6. .gitignore +32 -0
  7. .vscode/settings.json +6 -0
  8. CODE_OF_CONDUCT.md +128 -0
  9. CONTRIBUTING.md +8 -0
  10. LEGAL_NOTICE.md +15 -0
  11. LICENSE +674 -0
  12. README.md +348 -0
  13. SECURITY.md +4 -0
  14. app.py +172 -0
  15. g4f/.v1/.dockerignore +9 -0
  16. g4f/.v1/CODE_OF_CONDUCT.md +128 -0
  17. g4f/.v1/CONTRIBUTING.md +8 -0
  18. g4f/.v1/Dockerfile +19 -0
  19. g4f/.v1/LICENSE +674 -0
  20. g4f/.v1/README.md +255 -0
  21. g4f/.v1/SECURITY.md +4 -0
  22. g4f/.v1/Singularity/gpt4free.sif +15 -0
  23. g4f/.v1/docker-compose.yaml +15 -0
  24. g4f/.v1/gpt4free/README.md +110 -0
  25. g4f/.v1/gpt4free/__init__.py +103 -0
  26. g4f/.v1/gpt4free/aiassist/README.md +19 -0
  27. g4f/.v1/gpt4free/aiassist/__init__.py +36 -0
  28. g4f/.v1/gpt4free/aicolors/__init__.py +30 -0
  29. g4f/.v1/gpt4free/aicolors/typings/__init__.py +9 -0
  30. g4f/.v1/gpt4free/deepai/README.md +26 -0
  31. g4f/.v1/gpt4free/deepai/__init__.py +46 -0
  32. g4f/.v1/gpt4free/forefront/README.md +19 -0
  33. g4f/.v1/gpt4free/forefront/__init__.py +214 -0
  34. g4f/.v1/gpt4free/forefront/typing.py +32 -0
  35. g4f/.v1/gpt4free/gptworldAi/README.md +25 -0
  36. g4f/.v1/gpt4free/gptworldAi/__init__.py +105 -0
  37. g4f/.v1/gpt4free/hpgptai/README.md +39 -0
  38. g4f/.v1/gpt4free/hpgptai/__init__.py +103 -0
  39. g4f/.v1/gpt4free/italygpt2/README.md +29 -0
  40. g4f/.v1/gpt4free/italygpt2/__init__.py +70 -0
  41. g4f/.v1/gpt4free/quora/README.md +77 -0
  42. g4f/.v1/gpt4free/quora/__init__.py +478 -0
  43. g4f/.v1/gpt4free/quora/api.py +558 -0
  44. g4f/.v1/gpt4free/quora/backup-mail.py +45 -0
  45. g4f/.v1/gpt4free/quora/cookies.txt +30 -0
  46. g4f/.v1/gpt4free/quora/graphql/AddHumanMessageMutation.graphql +52 -0
  47. g4f/.v1/gpt4free/quora/graphql/AddMessageBreakMutation.graphql +17 -0
  48. g4f/.v1/gpt4free/quora/graphql/AutoSubscriptionMutation.graphql +7 -0
  49. g4f/.v1/gpt4free/quora/graphql/BioFragment.graphql +8 -0
  50. g4f/.v1/gpt4free/quora/graphql/ChatAddedSubscription.graphql +5 -0
.gitattributes ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
.github/FUNDING.yml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ github: [onlp]
2
+ patreon: xtekky
3
+ ko_fi: xtekky
.github/ISSUE_TEMPLATE/default_issue.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: New Issue
3
+ about: 'Please use this template !!'
4
+ title: ''
5
+ labels: bug
6
+ assignees: xtekky
7
+
8
+ ---
9
+
10
+ **Known Issues** // delete this
11
+ - you.com issue / fix: use proxy, or vpn, your country is probably flagged
12
+ - forefront account creation error / use your own session or wait for fix
13
+
14
+
15
+ **Bug description**
16
+ What did you do, what happened, which file did you try to run, in which directory
17
+ Describe what you did after downloading repo, such as moving to this repo, running this file.
18
+
19
+ ex.
20
+ 1. Go to '...'
21
+ 2. Click on '....'
22
+ 3. Scroll down to '....'
23
+ 4. See error
24
+
25
+ **Screenshots**
26
+ If applicable, add screenshots to help explain your problem.
27
+
28
+ **Environement**
29
+ - python version
30
+ - location ( are you in a cloudfare flagged country ) ?
31
+
32
+ **Additional context**
33
+ Add any other context about the problem here.
.github/ISSUE_TEMPLATE/feature_request.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
.github/workflows/ci.yml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build and push `gpt4free` docker image
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - main
8
+ pull_request:
9
+ branches:
10
+ - main
11
+
12
+ jobs:
13
+ build-and-push:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v3
17
+
18
+ - name: Set up qemu
19
+ uses: docker/setup-qemu-action@v2
20
+
21
+ - name: Set up docker buildx
22
+ uses: docker/setup-buildx-action@v2
23
+
24
+ - name: Login to docker hub
25
+ uses: docker/login-action@v2
26
+ with:
27
+ username: ${{ secrets.DOCKER_USERNAME }}
28
+ password: ${{ secrets.DOCKER_PASSWORD }}
29
+
30
+ - name: Build and push docker image
31
+ uses: docker/build-push-action@v4
32
+ with:
33
+ context: .
34
+ platforms: linux/amd64,linux/arm64
35
+ push: ${{ github.ref == 'refs/heads/main' }}
36
+ tags: |
37
+ ${{ secrets.DOCKER_USERNAME }}/gpt4free:latest
.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/
.vscode/settings.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "[python]": {
3
+ "editor.defaultFormatter": "ms-python.autopep8"
4
+ },
5
+ "python.formatting.provider": "none"
6
+ }
CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ https://t.me/xtekky.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
CONTRIBUTING.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <img alt="gpt4free logo" src="https://user-images.githubusercontent.com/98614666/233799515-1a7cb6a3-b17f-42c4-956d-8d2a0664466f.png">
2
+
3
+ ### Please, follow these steps to contribute:
4
+ 1. Reverse a website from this list: [sites-to-reverse](https://github.com/xtekky/gpt4free/issues/40)
5
+ 2. Add it to [./testing](https://github.com/xtekky/gpt4free/tree/main/testing)
6
+ 3. Refractor it and add it to [./g4f](https://github.com/xtekky/gpt4free/tree/main/g4f)
7
+
8
+ ### We will be grateful to see you as a contributor!
LEGAL_NOTICE.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Legal Notice
2
+
3
+ This repository is _not_ associated with or endorsed by providers of the APIs contained in this GitHub repository. This project is intended **for educational purposes only**. This is just a little personal project. Sites may contact me to improve their security or request the removal of their site from this repository.
4
+
5
+ Please note the following:
6
+
7
+ 1. **Disclaimer**: The APIs, services, and trademarks mentioned in this repository belong to their respective owners. This project is _not_ claiming any right over them nor is it affiliated with or endorsed by any of the providers mentioned.
8
+
9
+ 2. **Responsibility**: The author of this repository is _not_ responsible for any consequences, damages, or losses arising from the use or misuse of this repository or the content provided by the third-party APIs. Users are solely responsible for their actions and any repercussions that may follow. We strongly recommend the users to follow the TOS of the each Website.
10
+
11
+ 3. **Educational Purposes Only**: This repository and its content are provided strictly for educational purposes. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations.
12
+
13
+ 4. **Indemnification**: Users agree to indemnify, defend, and hold harmless the author of this repository from and against any and all claims, liabilities, damages, losses, or expenses, including legal fees and costs, arising out of or in any way connected with their use or misuse of this repository, its content, or related third-party APIs.
14
+
15
+ 5. **Updates and Changes**: The author reserves the right to modify, update, or remove any content, information, or features in this repository at any time without prior notice. Users are responsible for regularly reviewing the content and any changes made to this repository.
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>.
README.md ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: gpt4free
3
+ emoji: 💻
4
+ colorFrom: gray
5
+ colorTo: blue
6
+ sdk: gradio
7
+ sdk_version: 3.36.0
8
+ app_file: app.py
9
+ duplicated_from: justest/gpt4free
10
+ ---
11
+
12
+ ![image](https://github.com/onlpx/gpt4free-v2/assets/98614666/7886223b-c1d1-4260-82aa-da5741f303bb)
13
+
14
+ By using this repository or any code related to it, you agree to the [legal notice](./LEGAL_NOTICE.md). The author is not responsible for any copies, forks, or reuploads made by other users. This is the author's only account and repository. To prevent impersonation or irresponsible actions, you may comply with the GNU GPL license this Repository uses.
15
+
16
+ This (quite censored) New Version of gpt4free, was just released, it may contain bugs, open an issue or contribute a PR when encountering one, some features were disabled.
17
+ Docker is for now not available but I would be happy if someone contributes a PR. The g4f GUI will be uploaded soon enough.
18
+
19
+ ## Table of Contents:
20
+
21
+ - [Getting Started](#getting-started)
22
+ + [Prerequisites](#prerequisites-)
23
+ + [Setting up the project](#setting-up-the-project-)
24
+ - [Usage](#usage)
25
+ * [The `g4f` Package](#the--g4f--package)
26
+ * [interference openai-proxy api](#interference-openai-proxy-api--use-with-openai-python-package-)
27
+ - [Models](#models)
28
+ * [gpt-3.5 / gpt-4](#gpt-35---gpt-4)
29
+ * [Other Models](#other-models)
30
+ - [Related gpt4free projects](#related-gpt4free-projects)
31
+ - [Contribute](#contribute)
32
+ - [ChatGPT clone](#chatgpt-clone)
33
+ - [Copyright](#copyright-)
34
+ - [Copyright Notice](#copyright-notice-)
35
+ - [Star History](#star-history)
36
+
37
+ ## Getting Started
38
+
39
+ #### Prerequisites:
40
+ 1. [Download and install Python](https://www.python.org/downloads/) (Version 3.x is recommended).
41
+
42
+ #### Setting up the project:
43
+ 1. Clone the GitHub repository:
44
+ ```
45
+ git clone https://github.com/xtekky/gpt4free.git
46
+ ```
47
+ 2. Navigate to the project directory:
48
+ ```
49
+ cd gpt4free
50
+ ```
51
+ 3. (Recommended) Create a virtual environment to manage Python packages for your project:
52
+ ```
53
+ python3 -m venv venv
54
+ ```
55
+ 4. Activate the virtual environment:
56
+ - On Windows:
57
+ ```
58
+ .\venv\Scripts\activate
59
+ ```
60
+ - On macOS and Linux:
61
+ ```
62
+ source venv/bin/activate
63
+ ```
64
+ 5. Install the required Python packages from `requirements.txt`:
65
+ ```
66
+ pip install -r requirements.txt
67
+ ```
68
+
69
+ 6. Create a `test.py` file in the root folder and start using the repo, further Instructions are below
70
+ ```py
71
+ import g4f
72
+
73
+ ...
74
+ ```
75
+
76
+ ## Usage
77
+
78
+ ### The `g4f` Package
79
+ ```py
80
+ import g4f
81
+
82
+
83
+ print(g4f.Provider.Ails.params) # supported args
84
+
85
+ # Automatic selection of provider
86
+
87
+ # streamed completion
88
+ response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', messages=[
89
+ {"role": "user", "content": "Hello world"}], stream=True)
90
+
91
+ for message in response:
92
+ print(message)
93
+
94
+ # normal response
95
+ response = g4f.ChatCompletion.create(model=g4f.Model.gpt_4, messages=[
96
+ {"role": "user", "content": "hi"}]) # alterative model setting
97
+
98
+ print(response)
99
+
100
+
101
+ # Set with provider
102
+ response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', provider=g4f.Provider.Forefront, messages=[
103
+ {"role": "user", "content": "Hello world"}], stream=True)
104
+
105
+ for message in response:
106
+ print(message)
107
+ ```
108
+
109
+ providers:
110
+ ```py
111
+ from g4f.Provider import (
112
+ Ails,
113
+ You,
114
+ Bing,
115
+ Yqcloud,
116
+ Theb,
117
+ Aichat,
118
+ Bard,
119
+ Vercel,
120
+ Forefront,
121
+ Lockchat,
122
+ Liaobots,
123
+ H2o,
124
+ ChatgptLogin,
125
+ DeepAi,
126
+ GetGpt
127
+ )
128
+
129
+ # usage:
130
+ response = g4f.ChatCompletion.create(..., provider=ProviderName)
131
+ ```
132
+
133
+ ### interference openai-proxy api (use with openai python package)
134
+
135
+ run server:
136
+ ```sh
137
+ python3 -m interference.app
138
+ ```
139
+
140
+ ```py
141
+ import openai
142
+
143
+ openai.api_key = ''
144
+ openai.api_base = 'http://127.0.0.1:1337'
145
+
146
+ chat_completion = openai.ChatCompletion.create(stream=True,
147
+ model='gpt-3.5-turbo', messages=[{'role': 'user', 'content': 'write a poem about a tree'}])
148
+
149
+ #print(chat_completion.choices[0].message.content)
150
+
151
+ for token in chat_completion:
152
+
153
+ content = token['choices'][0]['delta'].get('content')
154
+ if content != None:
155
+ print(content)
156
+ ```
157
+
158
+ ## Models
159
+
160
+ ### gpt-3.5 / gpt-4
161
+
162
+ | Website| Provider| gpt-3.5 | gpt-4 | Streaming | Status | Auth |
163
+ | --- | --- | --- | --- | --- | --- | --- |
164
+ | [bing.com](https://bing.com/chat) | `g4f.Provider.Bing` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
165
+ | [super.lockchat.app](http://super.lockchat.app) | `g4f.Provider.Lockchat` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
166
+ | [liaobots.com](https://liaobots.com) | `g4f.Provider.Liaobots` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ✔️ |
167
+ | [ai.ls](https://ai.ls) | `g4f.Provider.Ails` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
168
+ | [you.com](https://you.com) | `g4f.Provider.You` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
169
+ | [chat9.yqcloud.top](https://chat9.yqcloud.top/) | `g4f.Provider.Yqcloud` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
170
+ | [theb.ai](https://theb.ai) | `g4f.Provider.Theb` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
171
+ | [play.vercel.ai](https://play.vercel.ai) | `g4f.Provider.Vercel` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
172
+ | [forefront.com](https://forefront.com) | `g4f.Provider.Forefront` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
173
+ | [deepai.org](https://deepai.org) | `g4f.Provider.DeepAi` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
174
+ | [chat.getgpt.world](https://chat.getgpt.world/) | `g4f.Provider.GetGpt` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
175
+ | [chatgptlogin.ac](https://chatgptlogin.ac) | `g4f.Provider.ChatgptLogin` | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
176
+ | [chat-gpt.org](https://chat-gpt.org/chat) | `g4f.Provider.Aichat` | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
177
+ | [chat.acytoo.com](https://chat.acytoo.com) | `g4f.Provider.Acytoo` | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
178
+ | [aitianhu.com](https://aitianhu.com) | `g4f.Provider.AItianhu` | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
179
+ | [chat.dfehub.com](https://chat.dfehub.com) | `g4f.Provider.DFEHub` | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
180
+ | [free.easychat.work](https://free.easychat.work) | `g4f.Provider.EasyChat` | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
181
+
182
+
183
+ ### Other Models
184
+
185
+ | Model| Base Provider | Provider | Website |
186
+ | ------- | ----------- | ---- |---- |
187
+ | palm2 | Google | `g4f.Provider.Bard` | [bard.google.com](https://bard.google.com/) |
188
+ | falcon-40b | Huggingface | `g4f.Provider.H2o` | [H2o](https://www.h2o.ai/) |
189
+ | falcon-7b | Huggingface |`g4f.Provider.H2o` | [H2o](https://www.h2o.ai/) |
190
+ | llama-13b | Huggingface | `g4f.Provider.H2o`| [H2o](https://www.h2o.ai/) |
191
+ | claude-instant-v1-100k | Anthropic | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
192
+ | claude-instant-v1 | Anthropic | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
193
+ | claude-v1-100k | Anthropic | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
194
+ | claude-v1 | Anthropic | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
195
+ | alpaca-7b | Replicate | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
196
+ | stablelm-tuned-alpha-7b | Replicate | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
197
+ | bloom | Huggingface | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
198
+ | bloomz | Huggingface | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
199
+ | flan-t5-xxl | Huggingface | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
200
+ | flan-ul2 | Huggingface | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
201
+ | gpt-neox-20b | Huggingface | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
202
+ | oasst-sft-4-pythia-12b-epoch-3.5 |Huggingface | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
203
+ | santacoder | Huggingface | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
204
+ | command-medium-nightly | Cohere | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
205
+ | command-xlarge-nightly | Cohere | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
206
+ | code-cushman-001 | OpenAI | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
207
+ | code-davinci-002 | OpenAI | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
208
+ | text-ada-001 | OpenAI | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
209
+ | text-babbage-001 | OpenAI | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
210
+ | text-curie-001 | OpenAI | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
211
+ | text-davinci-002 | OpenAI | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
212
+ | text-davinci-003 | OpenAI | `g4f.Provider.Vercel` | [sdk.vercel.ai](https://sdk.vercel.ai/) |
213
+
214
+ ## Related gpt4free projects
215
+
216
+ <table>
217
+ <thead align="center">
218
+ <tr border: none;>
219
+ <td><b>🎁 Projects</b></td>
220
+ <td><b>⭐ Stars</b></td>
221
+ <td><b>📚 Forks</b></td>
222
+ <td><b>🛎 Issues</b></td>
223
+ <td><b>📬 Pull requests</b></td>
224
+ </tr>
225
+ </thead>
226
+ <tbody>
227
+ <tr>
228
+ <td><a href="https://github.com/xtekky/gpt4free"><b>gpt4free</b></a></td>
229
+ <td><a href="https://github.com/xtekky/gpt4free/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
230
+ <td><a href="https://github.com/xtekky/gpt4free/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
231
+ <td><a href="https://github.com/xtekky/gpt4free/issues"><img alt="Issues" src="https://img.shields.io/github/issues/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
232
+ <td><a href="https://github.com/xtekky/gpt4free/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
233
+ </tr>
234
+ <tr>
235
+ <td><a href="https://github.com/xiangsx/gpt4free-ts"><b>gpt4free-ts</b></a></td>
236
+ <td><a href="https://github.com/xiangsx/gpt4free-ts/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/xiangsx/gpt4free-ts?style=flat-square&labelColor=343b41"/></a></td>
237
+ <td><a href="https://github.com/xiangsx/gpt4free-ts/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/xiangsx/gpt4free-ts?style=flat-square&labelColor=343b41"/></a></td>
238
+ <td><a href="https://github.com/xiangsx/gpt4free-ts/issues"><img alt="Issues" src="https://img.shields.io/github/issues/xiangsx/gpt4free-ts?style=flat-square&labelColor=343b41"/></a></td>
239
+ <td><a href="https://github.com/xiangsx/gpt4free-ts/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/xiangsx/gpt4free-ts?style=flat-square&labelColor=343b41"/></a></td>
240
+ </tr>
241
+ <tr>
242
+ <td><a href="https://github.com/xtekky/chatgpt-clone"><b>ChatGPT-Clone</b></a></td>
243
+ <td><a href="https://github.com/xtekky/chatgpt-clone/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
244
+ <td><a href="https://github.com/xtekky/chatgpt-clone/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
245
+ <td><a href="https://github.com/xtekky/chatgpt-clone/issues"><img alt="Issues" src="https://img.shields.io/github/issues/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
246
+ <td><a href="https://github.com/xtekky/chatgpt-clone/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
247
+ </tr>
248
+ <tr>
249
+ <td><a href="https://github.com/mishalhossin/Discord-Chatbot-Gpt4Free"><b>ChatGpt Discord Bot</b></a></td>
250
+ <td><a href="https://github.com/mishalhossin/Discord-Chatbot-Gpt4Free/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/mishalhossin/Discord-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
251
+ <td><a href="https://github.com/mishalhossin/Discord-Chatbot-Gpt4Free/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/mishalhossin/Discord-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
252
+ <td><a href="https://github.com/mishalhossin/Discord-Chatbot-Gpt4Free/issues"><img alt="Issues" src="https://img.shields.io/github/issues/mishalhossin/Discord-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
253
+ <td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/mishalhossin/Discord-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
254
+ </tr>
255
+ <tr>
256
+ <td><a href="https://github.com/MIDORIBIN/langchain-gpt4free"><b>LangChain gpt4free</b></a></td>
257
+ <td><a href="https://github.com/MIDORIBIN/langchain-gpt4free/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/MIDORIBIN/langchain-gpt4free?style=flat-square&labelColor=343b41"/></a></td>
258
+ <td><a href="https://github.com/MIDORIBIN/langchain-gpt4free/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/MIDORIBIN/langchain-gpt4free?style=flat-square&labelColor=343b41"/></a></td>
259
+ <td><a href="https://github.com/MIDORIBIN/langchain-gpt4free/issues"><img alt="Issues" src="https://img.shields.io/github/issues/MIDORIBIN/langchain-gpt4free?style=flat-square&labelColor=343b41"/></a></td>
260
+ <td><a href="https://github.com/MIDORIBIN/langchain-gpt4free/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/MIDORIBIN/langchain-gpt4free?style=flat-square&labelColor=343b41"/></a></td>
261
+ </tr>
262
+ </tbody>
263
+ </table>
264
+
265
+ ## Contribute
266
+
267
+ to add another provider, its very simple:
268
+ 1. create a new file in [g4f/Provider/Providers](./g4f/Provider/Providers) with the name of the Provider
269
+ 2. in the file, paste the *Boilerplate* you can find in [g4f/Provider/Provider.py](./g4f/Provider/Provider.py):
270
+
271
+ ```py
272
+ import os
273
+ from ..typing import sha256, Dict, get_type_hints
274
+
275
+ url = None
276
+ model = None
277
+ supports_stream = False
278
+ needs_auth = False
279
+
280
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
281
+ return
282
+
283
+
284
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
285
+ '(%s)' % ', '.join(
286
+ [f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
287
+
288
+ ```
289
+
290
+ 3. Here, you can adjust the settings, for example if the website does support streaming, set `supports_stream` to `True`...
291
+ 4. Write code to request the provider in `_create_completion` and `yield` the response, *even if* its a one-time response, do not hesitate to look at other providers for inspiration
292
+ 5. Add the Provider Name in [g4f/Provider/__init__.py](./g4f/Provider/__init__.py)
293
+
294
+ ```py
295
+ from . import Provider
296
+ from .Providers import (
297
+ ...,
298
+ ProviderNameHere
299
+ )
300
+ ```
301
+
302
+ 6. You are done !, test the provider by calling it:
303
+ ```py
304
+ import g4f
305
+
306
+ response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', provider=g4f.Provider.PROVIDERNAME,
307
+ messages=[{"role": "user", "content": "test"}], stream=g4f.Provider.PROVIDERNAME.supports_stream)
308
+
309
+ for message in response:
310
+ print(message, flush=True, end='')
311
+ ```
312
+
313
+ ## ChatGPT clone
314
+
315
+ > Currently implementing new features and trying to scale it, please be patient it may be unstable
316
+ > https://chat.g4f.ai/chat
317
+ > This site was developed by me and includes **gpt-4/3.5**, **internet access** and **gpt-jailbreak's** like DAN
318
+ > Run locally here: https://github.com/xtekky/chatgpt-clone
319
+
320
+ ## Copyright:
321
+
322
+ This program is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.txt)
323
+
324
+ ## Copyright Notice:
325
+
326
+ ```
327
+ xtekky/gpt4free: Copyright (C) 2023 xtekky
328
+
329
+ This program is free software: you can redistribute it and/or modify
330
+ it under the terms of the GNU General Public License as published by
331
+ the Free Software Foundation, either version 3 of the License, or
332
+ (at your option) any later version.
333
+
334
+ This program is distributed in the hope that it will be useful,
335
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
336
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
337
+ GNU General Public License for more details.
338
+
339
+ You should have received a copy of the GNU General Public License
340
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
341
+ ```
342
+
343
+
344
+ ## Star History
345
+
346
+ <a href="https://github.com/xtekky/gpt4free/stargazers">
347
+ <img width="500" alt="Star History Chart" src="https://api.star-history.com/svg?repos=xtekky/gpt4free&type=Date">
348
+ </a>
SECURITY.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ ## Reporting a Vulnerability
2
+
3
+ Reporting a Vulnerability
4
+ Please report (suspected) security vulnerabilities to https://t.me/xtekky. You will receive a response within 48 hours. If the issue is confirmed, we will release a patch as soon as possible depending on complexity but historically within a few days.
app.py ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import g4f
2
+ import gradio as gr
3
+ from g4f.Provider import (
4
+ Ails,
5
+ You,
6
+ Bing,
7
+ Yqcloud,
8
+ Theb,
9
+ Aichat,
10
+ Bard,
11
+ Vercel,
12
+ Forefront,
13
+ Lockchat,
14
+ Liaobots,
15
+ H2o,
16
+ ChatgptLogin,
17
+ DeepAi,
18
+ GetGpt
19
+ )
20
+ import os
21
+ import json
22
+ import pandas as pd
23
+
24
+ from models_for_langchain.model import CustomLLM
25
+ from langchain.memory import ConversationBufferWindowMemory, ConversationTokenBufferMemory
26
+ from langchain import LLMChain, PromptTemplate
27
+ from langchain.prompts import (
28
+ ChatPromptTemplate,
29
+ PromptTemplate,
30
+ SystemMessagePromptTemplate,
31
+ AIMessagePromptTemplate,
32
+ HumanMessagePromptTemplate,
33
+ )
34
+
35
+ provider_dict = {
36
+ 'Ails': Ails,
37
+ 'You': You,
38
+ 'Bing': Bing,
39
+ 'Yqcloud': Yqcloud,
40
+ 'Theb': Theb,
41
+ 'Aichat': Aichat,
42
+ 'Bard': Bard,
43
+ 'Vercel': Vercel,
44
+ 'Forefront': Forefront,
45
+ 'Lockchat': Lockchat,
46
+ 'Liaobots': Liaobots,
47
+ 'H2o': H2o,
48
+ 'ChatgptLogin': ChatgptLogin,
49
+ 'DeepAi': DeepAi,
50
+ 'GetGpt': GetGpt
51
+ }
52
+
53
+ prompt_set_list = {}
54
+ for prompt_file in os.listdir("prompt_set"):
55
+ key = prompt_file
56
+ if '.csv' in key:
57
+ df = pd.read_csv("prompt_set/" + prompt_file)
58
+ prompt_dict = dict(zip(df['act'], df['prompt']))
59
+ else:
60
+ with open("prompt_set/" + prompt_file, encoding='utf-8') as f:
61
+ ds = json.load(f)
62
+ prompt_dict = {item["act"]: item["prompt"] for item in ds}
63
+ prompt_set_list[key] = prompt_dict
64
+
65
+ with gr.Blocks() as demo:
66
+ llm = CustomLLM()
67
+
68
+ template = """
69
+ Chat with human based on following instructions:
70
+ ```
71
+ {system_instruction}
72
+ ```
73
+ The following is a conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.
74
+ {{chat_history}}
75
+ Human: {{human_input}}
76
+ Chatbot:"""
77
+
78
+ memory = ConversationBufferWindowMemory(k=10, memory_key="chat_history")
79
+
80
+ chatbot = gr.Chatbot([], label='AI')
81
+ msg = gr.Textbox(value="", label='请输入:')
82
+ with gr.Row():
83
+ clear = gr.Button("清空对话", scale=2)
84
+ chat_mode = gr.Checkbox(value=True, label='聊天模式', interactive=True, scale=1)
85
+ system_msg = gr.Textbox(value="你是一名助手,可以解答问题。", label='系统提示')
86
+ with gr.Row():
87
+ default_prompt_set = "1 中文提示词.json"
88
+ prompt_set_name = gr.Dropdown(prompt_set_list.keys(), value=default_prompt_set, label='提示词集合')
89
+ prompt_name = gr.Dropdown(prompt_set_list[default_prompt_set].keys(), label='提示词', min_width=20)
90
+ with gr.Row():
91
+ model_name = gr.Dropdown(['gpt-3.5-turbo', 'gpt-4'], value='gpt-3.5-turbo', label='模型')
92
+ provider_name = gr.Dropdown(provider_dict.keys(), value='GetGpt', label='提供者', min_width=20)
93
+
94
+ def change_prompt_set(prompt_set_name):
95
+ return gr.Dropdown.update(choices=list(prompt_set_list[prompt_set_name].keys()))
96
+
97
+ def change_prompt(prompt_set_name, prompt_name):
98
+ return gr.update(value=prompt_set_list[prompt_set_name][prompt_name])
99
+
100
+ def user(user_message, history = []):
101
+ return gr.update(value="", interactive=False), history + [[user_message, None]]
102
+
103
+ def bot(history, model_name, provider_name, system_msg, chat_mode):
104
+ history[-1][1] = ''
105
+ if len(system_msg)>3000:
106
+ system_msg = system_msg[:2000] + system_msg[-1000:]
107
+
108
+ if not chat_mode:
109
+ global template, memory
110
+ llm.model_name = model_name
111
+ llm.provider_name = provider_name
112
+ prompt = PromptTemplate(
113
+ input_variables=["chat_history", "human_input"], template=template.format(system_instruction=system_msg)
114
+ )
115
+ llm_chain = LLMChain(
116
+ llm=llm,
117
+ prompt=prompt,
118
+ verbose=False,
119
+ memory=memory,
120
+ )
121
+ bot_msg = llm_chain.run(history[-1][0])
122
+ for c in bot_msg:
123
+ history[-1][1] += c
124
+ yield history
125
+ else:
126
+ prompt = """
127
+ 请你仔细阅读以下提示,然后针对用户的话进行回答。
128
+ 提示:
129
+ ```
130
+ {}
131
+ ```
132
+ 用户最新的话:
133
+ ```
134
+ {}
135
+ ```
136
+ 请回答:
137
+ """
138
+
139
+ # print(history)
140
+ messages = []
141
+ for user_message, assistant_message in history[:-1]:
142
+ messages.append({"role": "user", "content": user_message})
143
+ messages.append({"role": "assistant", "content": assistant_message})
144
+ messages.append({"role": "user", "content": history[-1][0]})
145
+ # print(messages)
146
+
147
+ bot_msg = g4f.ChatCompletion.create(
148
+ model=model_name,
149
+ provider=provider_dict[provider_name],
150
+ messages=messages,
151
+ stream=True)
152
+ for c in bot_msg:
153
+ history[-1][1] += c
154
+ print(c, flush=True, end='')
155
+ yield history
156
+
157
+ def empty_chat():
158
+ global memory
159
+ memory = ConversationBufferWindowMemory(k=10, memory_key="chat_history")
160
+ return None
161
+ response = msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
162
+ bot, [chatbot, model_name, provider_name, system_msg, chat_mode], chatbot
163
+ )
164
+ prompt_set_name.select(change_prompt_set, prompt_set_name, prompt_name)
165
+ prompt_name.select(change_prompt, [prompt_set_name, prompt_name], system_msg)
166
+
167
+ response.then(lambda: gr.update(interactive=True), None, [msg], queue=False)
168
+ clear.click(empty_chat, None, [chatbot], queue=False)
169
+
170
+ demo.title = "AI Chat"
171
+ demo.queue()
172
+ demo.launch()
g4f/.v1/.dockerignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Development
2
+ .dockerignore
3
+ .git
4
+ .gitignore
5
+ .github
6
+ .idea
7
+
8
+ # Application
9
+ venv/
g4f/.v1/CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ https://t.me/xtekky.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
g4f/.v1/CONTRIBUTING.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <img alt="gpt4free logo" src="https://user-images.githubusercontent.com/98614666/233799515-1a7cb6a3-b17f-42c4-956d-8d2a0664466f.png">
2
+
3
+ ### Please, follow these steps to contribute:
4
+ 1. Reverse a website from this list: [sites-to-reverse](https://github.com/xtekky/gpt4free/issues/40)
5
+ 2. Add it to [./testing](https://github.com/xtekky/gpt4free/tree/main/testing)
6
+ 3. Refractor it and add it to [./gpt4free](https://github.com/xtekky/gpt4free/tree/main/gpt4free)
7
+
8
+ ### We will be grateful to see you as a contributor!
g4f/.v1/Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11.3-slim
2
+
3
+ RUN apt-get update \
4
+ && apt-get install -y --no-install-recommends ffmpeg \
5
+ && apt-get -y clean \
6
+ && rm -rf /var/lib/apt/lists/*
7
+
8
+ COPY requirements.txt /tmp
9
+ RUN pip install --upgrade pip \
10
+ && pip install -r /tmp/requirements.txt \
11
+ && rm /tmp/requirements.txt
12
+
13
+ COPY . /root/gpt4free
14
+
15
+ WORKDIR /root/gpt4free
16
+
17
+ CMD ["streamlit", "run", "./gui/streamlit_app.py"]
18
+
19
+ EXPOSE 8501
g4f/.v1/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>.
g4f/.v1/README.md ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ **A major update is to come this week (statement written 14 Jun)**
2
+ **You may check these out in the meanwhile**:
3
+
4
+ - v2 prototype of gpt4free someone made: https://gitler.moe/g4f/gpt4free
5
+ - Discord bot with gpt-4 using poe.com: https://github.com/xtekky/gpt4free-discord
6
+
7
+ ______
8
+ What can I do to contribute ?
9
+ you reverse a site from this list: [sites-to-reverse](https://github.com/xtekky/gpt4free/issues/40), and add it to [`./testing`](https://github.com/xtekky/gpt4free/tree/main/testing) or refractor it and add it to [`./gpt4free`](https://github.com/xtekky/gpt4free/tree/main/gpt4free)
10
+
11
+ <p>You may join our discord: <a href="https://discord.com/invite/gpt4free">discord.gg/gpt4free<a> for further updates. <a href="https://discord.gg/gpt4free"><img align="center" alt="gpt4free Discord" width="22px" src="https://raw.githubusercontent.com/peterthehan/peterthehan/master/assets/discord.svg" /></a></p>
12
+
13
+
14
+ <img alt="gpt4free logo" src="https://user-images.githubusercontent.com/98614666/233799515-1a7cb6a3-b17f-42c4-956d-8d2a0664466f.png">
15
+
16
+ ## Legal Notice <a name="legal-notice"></a>
17
+
18
+ This repository is _not_ associated with or endorsed by providers of the APIs contained in this GitHub repository. This project is intended **for educational purposes only**. This is just a little personal project. Sites may contact me to improve their security or request the removal of their site from this repository.
19
+
20
+ Please note the following:
21
+
22
+ 1. **Disclaimer**: The APIs, services, and trademarks mentioned in this repository belong to their respective owners. This project is _not_ claiming any right over them nor is it affiliated with or endorsed by any of the providers mentioned.
23
+
24
+ 2. **Responsibility**: The author of this repository is _not_ responsible for any consequences, damages, or losses arising from the use or misuse of this repository or the content provided by the third-party APIs. Users are solely responsible for their actions and any repercussions that may follow. We strongly recommend the users to follow the TOS of the each Website.
25
+
26
+ 3. **Educational Purposes Only**: This repository and its content are provided strictly for educational purposes. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations.
27
+
28
+ 4. **Indemnification**: Users agree to indemnify, defend, and hold harmless the author of this repository from and against any and all claims, liabilities, damages, losses, or expenses, including legal fees and costs, arising out of or in any way connected with their use or misuse of this repository, its content, or related third-party APIs.
29
+
30
+ 5. **Updates and Changes**: The author reserves the right to modify, update, or remove any content, information, or features in this repository at any time without prior notice. Users are responsible for regularly reviewing the content and any changes made to this repository.
31
+
32
+ By using this repository or any code related to it, you agree to these terms. The author is not responsible for any copies, forks, or reuploads made by other users. This is the author's only account and repository. To prevent impersonation or irresponsible actions, you may comply with the GNU GPL license this Repository uses.
33
+
34
+ <br>
35
+
36
+ <img src="https://media.giphy.com/media/LnQjpWaON8nhr21vNW/giphy.gif" width="100" align="left">
37
+ Just API's from some language model sites.
38
+
39
+
40
+ # Related gpt4free projects
41
+
42
+ <table>
43
+ <thead align="center">
44
+ <tr border: none;>
45
+ <td><b>🎁 Projects</b></td>
46
+ <td><b>⭐ Stars</b></td>
47
+ <td><b>📚 Forks</b></td>
48
+ <td><b>🛎 Issues</b></td>
49
+ <td><b>📬 Pull requests</b></td>
50
+ </tr>
51
+ </thead>
52
+ <tbody>
53
+ <tr>
54
+ <td><a href="https://github.com/xtekky/gpt4free"><b>gpt4free</b></a></td>
55
+ <td><a href="https://github.com/xtekky/gpt4free/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
56
+ <td><a href="https://github.com/xtekky/gpt4free/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
57
+ <td><a href="https://github.com/xtekky/gpt4free/issues"><img alt="Issues" src="https://img.shields.io/github/issues/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
58
+ <td><a href="https://github.com/xtekky/gpt4free/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
59
+ </tr>
60
+ <tr>
61
+ <td><a href="https://github.com/xiangsx/gpt4free-ts"><b>gpt4free-ts</b></a></td>
62
+ <td><a href="https://github.com/xiangsx/gpt4free-ts/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/xiangsx/gpt4free-ts?style=flat-square&labelColor=343b41"/></a></td>
63
+ <td><a href="https://github.com/xiangsx/gpt4free-ts/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/xiangsx/gpt4free-ts?style=flat-square&labelColor=343b41"/></a></td>
64
+ <td><a href="https://github.com/xiangsx/gpt4free-ts/issues"><img alt="Issues" src="https://img.shields.io/github/issues/xiangsx/gpt4free-ts?style=flat-square&labelColor=343b41"/></a></td>
65
+ <td><a href="https://github.com/xiangsx/gpt4free-ts/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/xiangsx/gpt4free-ts?style=flat-square&labelColor=343b41"/></a></td>
66
+ </tr>
67
+ <tr>
68
+ <td><a href="https://github.com/xtekky/chatgpt-clone"><b>ChatGPT-Clone</b></a></td>
69
+ <td><a href="https://github.com/xtekky/chatgpt-clone/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
70
+ <td><a href="https://github.com/xtekky/chatgpt-clone/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
71
+ <td><a href="https://github.com/xtekky/chatgpt-clone/issues"><img alt="Issues" src="https://img.shields.io/github/issues/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
72
+ <td><a href="https://github.com/xtekky/chatgpt-clone/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
73
+ </tr>
74
+ <tr>
75
+ <td><a href="https://github.com/mishalhossin/Discord-Chatbot-Gpt4Free"><b>ChatGpt Discord Bot</b></a></td>
76
+ <td><a href="https://github.com/mishalhossin/Discord-Chatbot-Gpt4Free/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/mishalhossin/Discord-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
77
+ <td><a href="https://github.com/mishalhossin/Discord-Chatbot-Gpt4Free/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/mishalhossin/Discord-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
78
+ <td><a href="https://github.com/mishalhossin/Discord-Chatbot-Gpt4Free/issues"><img alt="Issues" src="https://img.shields.io/github/issues/mishalhossin/Discord-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
79
+ <td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/mishalhossin/Discord-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
80
+ </tr>
81
+ </tbody>
82
+ </table>
83
+
84
+
85
+ ## Table of Contents
86
+ | Section | Description | Link | Status |
87
+ | ------- | ----------- | ---- | ------ |
88
+ | **To do list** | List of tasks to be done | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#todo) | - |
89
+ | **Current Sites** | Current websites or platforms that can be used as APIs | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#current-sites) | - |
90
+ | **Best Sites for gpt4** | Recommended websites or platforms for gpt4 | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#best-sites) | - |
91
+ | **Streamlit GPT4Free GUI** | Web-based graphical user interface for interacting with gpt4free | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#streamlit-gpt4free-gui) | - |
92
+ | **Docker** | Instructions on how to run gpt4free in a Docker container | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#docker-instructions) | - |
93
+ | **ChatGPT clone** | A ChatGPT clone with new features and scalability | [![Link to Website](https://img.shields.io/badge/Link-Visit%20Site-blue)](https://chat.chatbot.sex/chat) | - |
94
+ | **How to install** | Instructions on how to install gpt4free | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#install) | - |
95
+ | **Usage Examples** | | | |
96
+ | `theb` | Example usage for theb (gpt-3.5) | [![Link to File](https://img.shields.io/badge/Link-Go%20to%20File-blue)](gpt4free/theb/README.md) | ![Active](https://img.shields.io/badge/Active-brightgreen) |
97
+ | `forefront` | Example usage for forefront (gpt-4) | [![Link to File](https://img.shields.io/badge/Link-Go%20to%20File-blue)](gpt4free/forefront/README.md) | ![Active](https://img.shields.io/badge/Active-brightgreen) | ||
98
+ | `quora (poe)` | Example usage for quora | [![Link to File](https://img.shields.io/badge/Link-Go%20to%20File-blue)](gpt4free/quora/README.md) | ![Active](https://img.shields.io/badge/Active-brightgreen) |
99
+ | `you` | Example usage for you | [![Link to File](https://img.shields.io/badge/Link-Go%20to%20File-blue)](gpt4free/you/README.md) | ![Active](https://img.shields.io/badge/Active-brightgreen) |
100
+ | `deepai` | Example usage for DeepAI (gpt-3.5, with chat) | [![Link to File](https://img.shields.io/badge/Link-Go%20to%20File-blue)](gpt4free/deepai/README.md) | ![Active](https://img.shields.io/badge/Active-brightgreen) |
101
+ | **Try it Out** | | | |
102
+ | Google Colab Jupyter Notebook | Example usage for gpt4free | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/DanielShemesh/gpt4free-colab/blob/main/gpt4free.ipynb) | - |
103
+ | replit Example (feel free to fork this repl) | Example usage for gpt4free | [![](https://img.shields.io/badge/Open%20in-Replit-1A1E27?logo=replit)](https://replit.com/@gpt4free/gpt4free-webui) | - |
104
+ | **Legal Notice** | Legal notice or disclaimer | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#legal-notice) | - |
105
+ | **Copyright** | Copyright information | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#copyright) | - |
106
+ | **Star History** | Star History | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#star-history) | - |
107
+
108
+
109
+ ## To do list <a name="todo"></a>
110
+
111
+ - [x] Add a GUI for the repo
112
+ - [ ] Make a general package named `gpt4free`, instead of different folders
113
+ - [ ] Live api status to know which are down and which can be used
114
+ - [ ] Integrate more API's in `./unfinished` as well as other ones in the lists
115
+ - [ ] Make an API to use as proxy for other projects
116
+ - [ ] Make a pypi package
117
+
118
+ ## Current Sites <a name="current-sites"></a>
119
+
120
+ | Website s | Model(s) |
121
+ | ------------------------------------------------ | -------------------------------- |
122
+ | [forefront.ai](https://chat.forefront.ai) | GPT-4/3.5 |
123
+ | [poe.com](https://poe.com) | GPT-4/3.5 |
124
+ | [writesonic.com](https://writesonic.com) | GPT-3.5 / Internet |
125
+ | [t3nsor.com](https://t3nsor.com) | GPT-3.5 |
126
+ | [you.com](https://you.com) | GPT-3.5 / Internet / good search |
127
+ | [sqlchat.ai](https://sqlchat.ai) | GPT-3.5 |
128
+ | [bard.google.com](https://bard.google.com) | custom / search |
129
+ | [bing.com/chat](https://bing.com/chat) | GPT-4/3.5 |
130
+ | [italygpt.it](https://italygpt.it) | GPT-3.5 |
131
+ | [deepai.org](https://deepai.org/chat) | GPT-3.5 / chat support |
132
+
133
+
134
+ ## Best sites <a name="best-sites"></a>
135
+
136
+ #### gpt-4
137
+
138
+ - [`/forefront`](gpt4free/forefront/README.md)
139
+
140
+ #### gpt-3.5
141
+
142
+ - [`/you`](gpt4free/you/README.md)
143
+
144
+ ## Install <a name="install"></a>
145
+
146
+ Download or clone this GitHub repo
147
+ install requirements with:
148
+
149
+ ```sh
150
+ python3 -m venv venv
151
+ . venv/bin/activate
152
+ pip3 install -r requirements.txt
153
+ ```
154
+
155
+ ## Install ffmpeg
156
+ ```sh
157
+ sudo apt-get install ffmpeg
158
+ ```
159
+
160
+ ## Connect VPN if needed and get proxy (Optional)
161
+ ```sh
162
+ echo "$http_proxy" # http://127.0.0.1:8889/
163
+ ```
164
+
165
+ ## Set proxy in gpt4free/you/__init__.py (Optional)
166
+ ```
167
+ diff --git a/gpt4free/you/__init__.py b/gpt4free/you/__init__.py
168
+ index 11847fb..59d1162 100644
169
+ --- a/gpt4free/you/__init__.py
170
+ +++ b/gpt4free/you/__init__.py
171
+ @@ -38,6 +38,7 @@ class Completion:
172
+ if chat is None:
173
+ chat = []
174
+
175
+ + proxy = '127.0.0.1:8889'
176
+ proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else {}
177
+
178
+ client = Session(client_identifier='chrome_108')
179
+ ```
180
+
181
+
182
+ ## To start gpt4free GUI <a name="streamlit-gpt4free-gui"></a>
183
+
184
+ ##### Note: streamlit app collects heavy analytics even when running locally. This includes events for every page load, form submission including metadata on queries (like length), browser and client information including host ips. These are all transmitted to a 3rd party analytics group, Segment.com.
185
+
186
+ Move `streamlit_app.py` from `./gui` to the base folder then run:
187
+ `streamlit run streamlit_app.py` or `python3 -m streamlit run streamlit_app.py`
188
+
189
+ ```sh
190
+ cp gui/streamlit_app.py .
191
+ streamlit run streamlit_app.py
192
+ ```
193
+
194
+
195
+ ## Docker <a name="docker-instructions"></a>
196
+
197
+ Build
198
+
199
+ ```
200
+ docker build -t gpt4free:latest .
201
+ ```
202
+
203
+ Run
204
+
205
+ ```
206
+ docker run -p 8501:8501 gpt4free:latest
207
+ ```
208
+
209
+ ## Deploy using docker-compose
210
+
211
+ Run the following:
212
+
213
+ ```
214
+ docker-compose up --build -d
215
+ ```
216
+
217
+ ## ChatGPT clone
218
+
219
+ > Currently implementing new features and trying to scale it, please be patient it may be unstable
220
+ > https://chat.g4f.ai/chat
221
+ > This site was developed by me and includes **gpt-4/3.5**, **internet access** and **gpt-jailbreak's** like DAN
222
+ > Run locally here: https://github.com/xtekky/chatgpt-clone
223
+
224
+ ## Copyright:
225
+
226
+ This program is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.txt)
227
+
228
+ Most code, with the exception of `quora/api.py` and `deepai/__init__.py` (by [ading2210](https://github.com/ading2210)), has been written by me, [xtekky](https://github.com/xtekky).
229
+
230
+ ### Copyright Notice: <a name="copyright"></a>
231
+
232
+ ```
233
+ xtekky/gpt4free: multiple reverse engineered language-model api's to decentralise the ai industry.
234
+ Copyright (C) 2023 xtekky
235
+
236
+ This program is free software: you can redistribute it and/or modify
237
+ it under the terms of the GNU General Public License as published by
238
+ the Free Software Foundation, either version 3 of the License, or
239
+ (at your option) any later version.
240
+
241
+ This program is distributed in the hope that it will be useful,
242
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
243
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
244
+ GNU General Public License for more details.
245
+
246
+ You should have received a copy of the GNU General Public License
247
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
248
+ ```
249
+
250
+
251
+ ## Star History <a name="star-history"></a>
252
+
253
+ <a href="https://github.com/xtekky/gpt4free/stargazers">
254
+ <img width="500" alt="Star History Chart" src="https://api.star-history.com/svg?repos=xtekky/gpt4free&type=Date">
255
+ </a>
g4f/.v1/SECURITY.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ ## Reporting a Vulnerability
2
+
3
+ Reporting a Vulnerability
4
+ Please report (suspected) security vulnerabilities to https://t.me/xtekky. You will receive a response within 48 hours. If the issue is confirmed, we will release a patch as soon as possible depending on complexity but historically within a few days.
g4f/.v1/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
g4f/.v1/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
g4f/.v1/gpt4free/README.md ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
46
+ ```
47
+
48
+ ### Invocation Arguments
49
+
50
+ `gpt4free.Completion.create()` method has two required arguments
51
+
52
+ 1. Provider: This is an enum representing different provider
53
+ 2. prompt: This is the user input
54
+
55
+ #### Keyword Arguments
56
+
57
+ Some of the keyword arguments are optional, while others are required.
58
+
59
+ - You:
60
+ - `safe_search`: boolean - default value is `False`
61
+ - `include_links`: boolean - default value is `False`
62
+ - `detailed`: boolean - default value is `False`
63
+ - Quora:
64
+ - `token`: str - this needs to be provided by the user
65
+ - `model`: str - default value is `gpt-4`.
66
+
67
+ (Available models: `['Sage', 'GPT-4', 'Claude+', 'Claude-instant', 'ChatGPT', 'Dragonfly', 'NeevaAI']`)
68
+ - ForeFront:
69
+ - `token`: str - this need to be provided by the user
70
+
71
+ - Theb:
72
+ (no keyword arguments required)
73
+
74
+ #### Token generation of quora
75
+ ```python
76
+ from gpt4free import quora
77
+
78
+ token = quora.Account.create(logging=False)
79
+ ```
80
+
81
+ ### Token generation of ForeFront
82
+ ```python
83
+ from gpt4free import forefront
84
+
85
+ token = forefront.Account.create(logging=False)
86
+ ```
87
+
88
+ ## Copyright:
89
+
90
+ This program is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.txt)
91
+
92
+ ### Copyright Notice: <a name="copyright"></a>
93
+
94
+ ```
95
+ xtekky/gpt4free: multiple reverse engineered language-model api's to decentralise the ai industry.
96
+ Copyright (C) 2023 xtekky
97
+
98
+ This program is free software: you can redistribute it and/or modify
99
+ it under the terms of the GNU General Public License as published by
100
+ the Free Software Foundation, either version 3 of the License, or
101
+ (at your option) any later version.
102
+
103
+ This program is distributed in the hope that it will be useful,
104
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
105
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
106
+ GNU General Public License for more details.
107
+
108
+ You should have received a copy of the GNU General Public License
109
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
110
+ ```
g4f/.v1/gpt4free/__init__.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from enum import Enum
2
+
3
+ from gpt4free import forefront
4
+ from gpt4free import quora
5
+ from gpt4free import theb
6
+ from gpt4free import usesless
7
+ from gpt4free import you
8
+ from gpt4free import aicolors
9
+ from gpt4free import deepai
10
+
11
+
12
+ class Provider(Enum):
13
+ """An enum representing different providers."""
14
+
15
+ You = "you"
16
+ Poe = "poe"
17
+ ForeFront = "fore_front"
18
+ Theb = "theb"
19
+ UseLess = "useless"
20
+ AiColors = "ai_colors"
21
+ DeepAI = "deepai"
22
+
23
+
24
+ class Completion:
25
+ """This class will be used for invoking the given provider"""
26
+
27
+ @staticmethod
28
+ def create(provider: Provider, prompt: str, **kwargs) -> str:
29
+ """
30
+ Invokes the given provider with given prompt and addition arguments and returns the string response
31
+
32
+ :param provider: an enum representing the provider to use while invoking
33
+ :param prompt: input provided by the user
34
+ :param kwargs: Additional keyword arguments to pass to the provider while invoking
35
+ :return: A string representing the response from the provider
36
+ """
37
+ if provider == Provider.Poe:
38
+ return Completion.__poe_service(prompt, **kwargs)
39
+ elif provider == Provider.You:
40
+ return Completion.__you_service(prompt, **kwargs)
41
+ elif provider == Provider.ForeFront:
42
+ return Completion.__fore_front_service(prompt, **kwargs)
43
+ elif provider == Provider.Theb:
44
+ return Completion.__theb_service(prompt, **kwargs)
45
+ elif provider == Provider.UseLess:
46
+ return Completion.__useless_service(prompt, **kwargs)
47
+ elif provider == Provider.AiColors:
48
+ return Completion.__ai_colors_service(prompt, **kwargs)
49
+ elif provider == Provider.DeepAI:
50
+ return Completion.__deepai_service(prompt, **kwargs)
51
+ else:
52
+ raise Exception("Provider not exist, Please try again")
53
+
54
+ @staticmethod
55
+ def __ai_colors_service(prompt: str):
56
+ return aicolors.Completion.create(prompt=prompt)
57
+
58
+ @staticmethod
59
+ def __useless_service(prompt: str, **kwargs) -> str:
60
+ return usesless.Completion.create(prompt=prompt, **kwargs)
61
+
62
+ @staticmethod
63
+ def __you_service(prompt: str, **kwargs) -> str:
64
+ return you.Completion.create(prompt, **kwargs).text
65
+
66
+ @staticmethod
67
+ def __poe_service(prompt: str, **kwargs) -> str:
68
+ return quora.Completion.create(prompt=prompt, **kwargs).text
69
+
70
+ @staticmethod
71
+ def __fore_front_service(prompt: str, **kwargs) -> str:
72
+ return forefront.Completion.create(prompt=prompt, **kwargs).text
73
+
74
+ @staticmethod
75
+ def __theb_service(prompt: str, **kwargs):
76
+ return "".join(theb.Completion.create(prompt=prompt))
77
+
78
+ @staticmethod
79
+ def __deepai_service(prompt: str, **kwargs):
80
+ return "".join(deepai.Completion.create(prompt=prompt))
81
+
82
+
83
+ class ChatCompletion:
84
+ """This class is used to execute a chat completion for a specified provider"""
85
+
86
+ @staticmethod
87
+ def create(provider: Provider, messages: list, **kwargs) -> str:
88
+ """
89
+ Invokes the given provider with given chat messages and addition arguments and returns the string response
90
+
91
+ :param provider: an enum representing the provider to use while invoking
92
+ :param messages: a list of chat messages, see the OpenAI docs for how to format this (https://platform.openai.com/docs/guides/chat/introduction)
93
+ :param kwargs: Additional keyword arguments to pass to the provider while invoking
94
+ :return: A string representing the response from the provider
95
+ """
96
+ if provider == Provider.DeepAI:
97
+ return ChatCompletion.__deepai_service(messages, **kwargs)
98
+ else:
99
+ raise Exception("Provider not exist, Please try again")
100
+
101
+ @staticmethod
102
+ def __deepai_service(messages: list, **kwargs):
103
+ return "".join(deepai.ChatCompletion.create(messages=messages))
g4f/.v1/gpt4free/aiassist/README.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiassist.site
2
+
3
+ ### Example: `aiassist` <a name="example-assist"></a>
4
+
5
+ ```python
6
+ import aiassist
7
+
8
+ question1 = "Who won the world series in 2020?"
9
+ req = aiassist.Completion.create(prompt=question1)
10
+ answer = req["text"]
11
+ message_id = req["parentMessageId"]
12
+
13
+ question2 = "Where was it played?"
14
+ req2 = aiassist.Completion.create(prompt=question2, parentMessageId=message_id)
15
+ answer2 = req2["text"]
16
+
17
+ print(answer)
18
+ print(answer2)
19
+ ```
g4f/.v1/gpt4free/aiassist/__init__.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import urllib.request
2
+ import json
3
+
4
+
5
+ class Completion:
6
+ @staticmethod
7
+ def create(
8
+ systemMessage: str = "You are a helpful assistant",
9
+ prompt: str = "",
10
+ parentMessageId: str = "",
11
+ temperature: float = 0.8,
12
+ top_p: float = 1,
13
+ ):
14
+ json_data = {
15
+ "prompt": prompt,
16
+ "options": {"parentMessageId": parentMessageId},
17
+ "systemMessage": systemMessage,
18
+ "temperature": temperature,
19
+ "top_p": top_p,
20
+ }
21
+
22
+ url = "http://43.153.7.56:8080/api/chat-process"
23
+ headers = {"Content-type": "application/json"}
24
+
25
+ data = json.dumps(json_data).encode("utf-8")
26
+ req = urllib.request.Request(url, data=data, headers=headers)
27
+ response = urllib.request.urlopen(req)
28
+ content = response.read().decode()
29
+
30
+ return Completion.__load_json(content)
31
+
32
+ @classmethod
33
+ def __load_json(cls, content) -> dict:
34
+ split = content.rsplit("\n", 1)[1]
35
+ to_json = json.loads(split)
36
+ return to_json
g4f/.v1/gpt4free/aicolors/__init__.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import fake_useragent
2
+ import requests
3
+ import json
4
+ from .typings import AiColorsResponse
5
+
6
+
7
+ class Completion:
8
+ @staticmethod
9
+ def create(
10
+ query: str = "",
11
+ ) -> AiColorsResponse:
12
+ headers = {
13
+ "authority": "jsuifmbqefnxytqwmaoy.functions.supabase.co",
14
+ "accept": "*/*",
15
+ "accept-language": "en-US,en;q=0.5",
16
+ "cache-control": "no-cache",
17
+ "sec-fetch-dest": "empty",
18
+ "sec-fetch-mode": "cors",
19
+ "sec-fetch-site": "same-origin",
20
+ "user-agent": fake_useragent.UserAgent().random,
21
+ }
22
+
23
+ json_data = {"query": query}
24
+
25
+ url = "https://jsuifmbqefnxytqwmaoy.functions.supabase.co/chatgpt"
26
+ request = requests.post(url, headers=headers, json=json_data, timeout=30)
27
+ data = request.json().get("text").get("content")
28
+ json_data = json.loads(data.replace("\n ", ""))
29
+
30
+ return AiColorsResponse(**json_data)
g4f/.v1/gpt4free/aicolors/typings/__init__.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class AiColorsResponse:
6
+ background: str
7
+ primary: str
8
+ accent: str
9
+ text: str
g4f/.v1/gpt4free/deepai/README.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DeepAI Wrapper
2
+ Written by [ading2210](https://github.com/ading2210/).
3
+
4
+ ## Examples:
5
+ These functions are generators which yield strings containing the newly generated text.
6
+
7
+ ### Completion:
8
+ ```python
9
+ for chunk in deepai.Completion.create("Who are you?"):
10
+ print(chunk, end="", flush=True)
11
+ print()
12
+ ```
13
+
14
+ ### Chat Completion:
15
+ Use the same format for the messages as you would for the [official OpenAI API](https://platform.openai.com/docs/guides/chat/introduction).
16
+ ```python
17
+ messages = [
18
+ {"role": "system", "content": "You are a helpful assistant."},
19
+ {"role": "user", "content": "Who won the world series in 2020?"},
20
+ {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
21
+ {"role": "user", "content": "Where was it played?"}
22
+ ]
23
+ for chunk in deepai.ChatCompletion.create(messages):
24
+ print(chunk, end="", flush=True)
25
+ print()
26
+ ```
g4f/.v1/gpt4free/deepai/__init__.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import json
3
+ import hashlib
4
+ import random
5
+ import string
6
+ from fake_useragent import UserAgent
7
+
8
+ class ChatCompletion:
9
+ @classmethod
10
+ def md5(self, text):
11
+ return hashlib.md5(text.encode()).hexdigest()[::-1]
12
+
13
+ @classmethod
14
+ def get_api_key(self, user_agent):
15
+ part1 = str(random.randint(0, 10**11))
16
+ part2 = self.md5(user_agent+self.md5(user_agent+self.md5(user_agent+part1+"x")))
17
+ return f"tryit-{part1}-{part2}"
18
+
19
+ @classmethod
20
+ def create(self, messages):
21
+ user_agent = UserAgent().random
22
+ api_key = self.get_api_key(user_agent)
23
+ headers = {
24
+ "api-key": api_key,
25
+ "user-agent": user_agent
26
+ }
27
+ files = {
28
+ "chat_style": (None, "chat"),
29
+ "chatHistory": (None, json.dumps(messages))
30
+ }
31
+
32
+ r = requests.post("https://api.deepai.org/chat_response", headers=headers, files=files, stream=True)
33
+
34
+ for chunk in r.iter_content(chunk_size=None):
35
+ r.raise_for_status()
36
+ yield chunk.decode()
37
+
38
+ class Completion:
39
+ @classmethod
40
+ def create(self, prompt):
41
+ return ChatCompletion.create([
42
+ {
43
+ "role": "user",
44
+ "content": prompt
45
+ }
46
+ ])
g4f/.v1/gpt4free/forefront/README.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Example: `forefront` (use like openai pypi package) <a name="example-forefront"></a>
2
+
3
+ ```python
4
+ from gpt4free import forefront
5
+
6
+
7
+ # create an account
8
+ account_data = forefront.Account.create(logging=False)
9
+
10
+ # get a response
11
+ for response in forefront.StreamingCompletion.create(
12
+ account_data=account_data,
13
+ prompt='hello world',
14
+ model='gpt-4'
15
+ ):
16
+ print(response.choices[0].text, end='')
17
+ print("")
18
+
19
+ ```
g4f/.v1/gpt4free/forefront/__init__.py ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import hashlib
2
+ from base64 import b64encode
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 Crypto.Cipher import AES
10
+ from Crypto.Random import get_random_bytes
11
+ from fake_useragent import UserAgent
12
+ from mailgw_temporary_email import Email
13
+ from requests import post
14
+ from tls_client import Session
15
+
16
+ from .typing import ForeFrontResponse, AccountData
17
+
18
+
19
+ class Account:
20
+ @staticmethod
21
+ def create(proxy: Optional[str] = None, logging: bool = False) -> AccountData:
22
+ proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False
23
+
24
+ start = time()
25
+
26
+ mail_client = Email()
27
+ mail_client.register()
28
+ mail_address = mail_client.address
29
+
30
+ client = Session(client_identifier='chrome110')
31
+ client.proxies = proxies
32
+ client.headers = {
33
+ 'origin': 'https://accounts.forefront.ai',
34
+ 'user-agent': UserAgent().random,
35
+ }
36
+
37
+ response = client.post(
38
+ 'https://clerk.forefront.ai/v1/client/sign_ups?_clerk_js_version=4.38.4',
39
+ data={'email_address': mail_address},
40
+ )
41
+
42
+ try:
43
+ trace_token = response.json()['response']['id']
44
+ if logging:
45
+ print(trace_token)
46
+ except KeyError:
47
+ raise RuntimeError('Failed to create account!')
48
+
49
+ response = client.post(
50
+ f'https://clerk.forefront.ai/v1/client/sign_ups/{trace_token}/prepare_verification?_clerk_js_version=4.38.4',
51
+ data={
52
+ 'strategy': 'email_link',
53
+ 'redirect_url': 'https://accounts.forefront.ai/sign-up/verify'
54
+ },
55
+ )
56
+
57
+ if logging:
58
+ print(response.text)
59
+
60
+ if 'sign_up_attempt' not in response.text:
61
+ raise RuntimeError('Failed to create account!')
62
+
63
+ while True:
64
+ sleep(5)
65
+ message_id = mail_client.message_list()[0]['id']
66
+ message = mail_client.message(message_id)
67
+ verification_url = findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', message["text"])[0]
68
+ if verification_url:
69
+ break
70
+
71
+ if logging:
72
+ print(verification_url)
73
+ client.get(verification_url)
74
+
75
+ response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4').json()
76
+ session_data = response['response']['sessions'][0]
77
+
78
+ user_id = session_data['user']['id']
79
+ session_id = session_data['id']
80
+ token = session_data['last_active_token']['jwt']
81
+
82
+ with open('accounts.txt', 'a') as f:
83
+ f.write(f'{mail_address}:{token}\n')
84
+
85
+ if logging:
86
+ print(time() - start)
87
+
88
+ return AccountData(token=token, user_id=user_id, session_id=session_id)
89
+
90
+
91
+ class StreamingCompletion:
92
+ @staticmethod
93
+ def create(
94
+ prompt: str,
95
+ account_data: AccountData,
96
+ chat_id=None,
97
+ action_type='new',
98
+ default_persona='607e41fe-95be-497e-8e97-010a59b2e2c0', # default
99
+ model='gpt-4',
100
+ proxy=None
101
+ ) -> Generator[ForeFrontResponse, None, None]:
102
+ token = account_data.token
103
+ if not chat_id:
104
+ chat_id = str(uuid4())
105
+
106
+ proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None
107
+ base64_data = b64encode((account_data.user_id + default_persona + chat_id).encode()).decode()
108
+ encrypted_signature = StreamingCompletion.__encrypt(base64_data, account_data.session_id)
109
+
110
+ headers = {
111
+ 'authority': 'chat-server.tenant-forefront-default.knative.chi.coreweave.com',
112
+ 'accept': '*/*',
113
+ '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',
114
+ 'cache-control': 'no-cache',
115
+ 'content-type': 'application/json',
116
+ 'origin': 'https://chat.forefront.ai',
117
+ 'pragma': 'no-cache',
118
+ 'referer': 'https://chat.forefront.ai/',
119
+ 'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
120
+ 'sec-ch-ua-mobile': '?0',
121
+ 'sec-ch-ua-platform': '"macOS"',
122
+ 'sec-fetch-dest': 'empty',
123
+ 'sec-fetch-mode': 'cors',
124
+ 'sec-fetch-site': 'cross-site',
125
+ 'authorization': f"Bearer {token}",
126
+ 'X-Signature': encrypted_signature,
127
+ 'user-agent': UserAgent().random,
128
+ }
129
+
130
+ json_data = {
131
+ 'text': prompt,
132
+ 'action': action_type,
133
+ 'parentId': chat_id,
134
+ 'workspaceId': chat_id,
135
+ 'messagePersona': default_persona,
136
+ 'model': model,
137
+ }
138
+
139
+ for chunk in post(
140
+ 'https://streaming.tenant-forefront-default.knative.chi.coreweave.com/chat',
141
+ headers=headers,
142
+ proxies=proxies,
143
+ json=json_data,
144
+ stream=True,
145
+ ).iter_lines():
146
+ if b'finish_reason":null' in chunk:
147
+ data = loads(chunk.decode('utf-8').split('data: ')[1])
148
+ token = data['choices'][0]['delta'].get('content')
149
+
150
+ if token is not None:
151
+ yield ForeFrontResponse(
152
+ **{
153
+ 'id': chat_id,
154
+ 'object': 'text_completion',
155
+ 'created': int(time()),
156
+ 'text': token,
157
+ 'model': model,
158
+ 'choices': [{'text': token, 'index': 0, 'logprobs': None, 'finish_reason': 'stop'}],
159
+ 'usage': {
160
+ 'prompt_tokens': len(prompt),
161
+ 'completion_tokens': len(token),
162
+ 'total_tokens': len(prompt) + len(token),
163
+ },
164
+ }
165
+ )
166
+
167
+ @staticmethod
168
+ def __encrypt(data: str, key: str) -> str:
169
+ hash_key = hashlib.sha256(key.encode()).digest()
170
+ iv = get_random_bytes(16)
171
+ cipher = AES.new(hash_key, AES.MODE_CBC, iv)
172
+ encrypted_data = cipher.encrypt(StreamingCompletion.__pad_data(data.encode()))
173
+ return iv.hex() + encrypted_data.hex()
174
+
175
+ @staticmethod
176
+ def __pad_data(data: bytes) -> bytes:
177
+ block_size = AES.block_size
178
+ padding_size = block_size - len(data) % block_size
179
+ padding = bytes([padding_size] * padding_size)
180
+ return data + padding
181
+
182
+
183
+ class Completion:
184
+ @staticmethod
185
+ def create(
186
+ prompt: str,
187
+ account_data: AccountData,
188
+ chat_id=None,
189
+ action_type='new',
190
+ default_persona='607e41fe-95be-497e-8e97-010a59b2e2c0', # default
191
+ model='gpt-4',
192
+ proxy=None
193
+ ) -> ForeFrontResponse:
194
+ text = ''
195
+ final_response = None
196
+ for response in StreamingCompletion.create(
197
+ account_data=account_data,
198
+ chat_id=chat_id,
199
+ prompt=prompt,
200
+ action_type=action_type,
201
+ default_persona=default_persona,
202
+ model=model,
203
+ proxy=proxy
204
+ ):
205
+ if response:
206
+ final_response = response
207
+ text += response.text
208
+
209
+ if final_response:
210
+ final_response.text = text
211
+ else:
212
+ raise RuntimeError('Unable to get the response, Please try again')
213
+
214
+ return final_response
g4f/.v1/gpt4free/forefront/typing.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
+
28
+
29
+ class AccountData(BaseModel):
30
+ token: str
31
+ user_id: str
32
+ session_id: str
g4f/.v1/gpt4free/gptworldAi/README.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # gptworldAi
2
+ Written by [hp_mzx](https://github.com/hpsj).
3
+
4
+ ## Examples:
5
+ ### Completion:
6
+ ```python
7
+ for chunk in gptworldAi.Completion.create("你是谁", "127.0.0.1:7890"):
8
+ print(chunk, end="", flush=True)
9
+ print()
10
+ ```
11
+
12
+ ### Chat Completion:
13
+ Support context
14
+ ```python
15
+ message = []
16
+ while True:
17
+ prompt = input("请输入问题:")
18
+ message.append({"role": "user","content": prompt})
19
+ text = ""
20
+ for chunk in gptworldAi.ChatCompletion.create(message,'127.0.0.1:7890'):
21
+ text = text+chunk
22
+ print(chunk, end="", flush=True)
23
+ print()
24
+ message.append({"role": "assistant", "content": text})
25
+ ```
g4f/.v1/gpt4free/gptworldAi/__init__.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ @Time : 2023/5/23 13:37
4
+ @Auth : Hp_mzx
5
+ @File :__init__.py.py
6
+ @IDE :PyCharm
7
+ """
8
+ import json
9
+ import uuid
10
+ import random
11
+ import binascii
12
+ import requests
13
+ import Crypto.Cipher.AES as AES
14
+ from fake_useragent import UserAgent
15
+
16
+ class ChatCompletion:
17
+ @staticmethod
18
+ def create(messages:[],proxy: str = None):
19
+ url = "https://chat.getgpt.world/api/chat/stream"
20
+ headers = {
21
+ "Content-Type": "application/json",
22
+ "Referer": "https://chat.getgpt.world/",
23
+ 'user-agent': UserAgent().random,
24
+ }
25
+ proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None
26
+ data = json.dumps({
27
+ "messages": messages,
28
+ "frequency_penalty": 0,
29
+ "max_tokens": 4000,
30
+ "model": "gpt-3.5-turbo",
31
+ "presence_penalty": 0,
32
+ "temperature": 1,
33
+ "top_p": 1,
34
+ "stream": True,
35
+ "uuid": str(uuid.uuid4())
36
+ })
37
+ signature = ChatCompletion.encrypt(data)
38
+ res = requests.post(url, headers=headers, data=json.dumps({"signature": signature}), proxies=proxies,stream=True)
39
+ for chunk in res.iter_content(chunk_size=None):
40
+ res.raise_for_status()
41
+ datas = chunk.decode('utf-8').split('data: ')
42
+ for data in datas:
43
+ if not data or "[DONE]" in data:
44
+ continue
45
+ data_json = json.loads(data)
46
+ content = data_json['choices'][0]['delta'].get('content')
47
+ if content:
48
+ yield content
49
+
50
+
51
+ @staticmethod
52
+ def random_token(e):
53
+ token = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
54
+ n = len(token)
55
+ return "".join([token[random.randint(0, n - 1)] for i in range(e)])
56
+
57
+ @staticmethod
58
+ def encrypt(e):
59
+ t = ChatCompletion.random_token(16).encode('utf-8')
60
+ n = ChatCompletion.random_token(16).encode('utf-8')
61
+ r = e.encode('utf-8')
62
+ cipher = AES.new(t, AES.MODE_CBC, n)
63
+ ciphertext = cipher.encrypt(ChatCompletion.__pad_data(r))
64
+ return binascii.hexlify(ciphertext).decode('utf-8') + t.decode('utf-8') + n.decode('utf-8')
65
+
66
+ @staticmethod
67
+ def __pad_data(data: bytes) -> bytes:
68
+ block_size = AES.block_size
69
+ padding_size = block_size - len(data) % block_size
70
+ padding = bytes([padding_size] * padding_size)
71
+ return data + padding
72
+
73
+
74
+ class Completion:
75
+ @staticmethod
76
+ def create(prompt:str,proxy:str=None):
77
+ return ChatCompletion.create([
78
+ {
79
+ "content": "You are ChatGPT, a large language model trained by OpenAI.\nCarefully heed the user's instructions. \nRespond using Markdown.",
80
+ "role": "system"
81
+ },
82
+ {"role": "user", "content": prompt}
83
+ ], proxy)
84
+
85
+
86
+ if __name__ == '__main__':
87
+ # single completion
88
+ text = ""
89
+ for chunk in Completion.create("你是谁", "127.0.0.1:7890"):
90
+ text = text + chunk
91
+ print(chunk, end="", flush=True)
92
+ print()
93
+
94
+
95
+ #chat completion
96
+ message = []
97
+ while True:
98
+ prompt = input("请输入问题:")
99
+ message.append({"role": "user","content": prompt})
100
+ text = ""
101
+ for chunk in ChatCompletion.create(message,'127.0.0.1:7890'):
102
+ text = text+chunk
103
+ print(chunk, end="", flush=True)
104
+ print()
105
+ message.append({"role": "assistant", "content": text})
g4f/.v1/gpt4free/hpgptai/README.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HpgptAI
2
+ Written by [hp_mzx](https://github.com/hpsj).
3
+
4
+ ## Examples:
5
+ ### Completion:
6
+ ```python
7
+ res = hpgptai.Completion.create("你是谁","127.0.0.1:7890")
8
+ print(res["reply"])
9
+ ```
10
+
11
+ ### Chat Completion:
12
+ Support context
13
+ ```python
14
+ messages = [
15
+ {
16
+ "content": "你是谁",
17
+ "html": "你是谁",
18
+ "id": hpgptai.ChatCompletion.randomStr(),
19
+ "role": "user",
20
+ "who": "User: ",
21
+ },
22
+ {
23
+ "content": "我是一位AI助手,专门为您提供各种服务和支持。我可以回答您的问题,帮助您解决问题,提供相关信息,并执行一些任务。请随时告诉我您需要什么帮助。",
24
+ "html": "我是一位AI助手,专门为您提供各种服务和支持。我可以回答您的问题,帮助您解决问题,提供相关信息,并执行一些任务。请随时告诉我您需要什么帮助。",
25
+ "id": hpgptai.ChatCompletion.randomStr(),
26
+ "role": "assistant",
27
+ "who": "AI: ",
28
+ },
29
+ {
30
+ "content": "我上一句问的是什么?",
31
+ "html": "我上一句问的是什么?",
32
+ "id": hpgptai.ChatCompletion.randomStr(),
33
+ "role": "user",
34
+ "who": "User: ",
35
+ },
36
+ ]
37
+ res = hpgptai.ChatCompletion.create(messages,proxy="127.0.0.1:7890")
38
+ print(res["reply"])
39
+ ```
g4f/.v1/gpt4free/hpgptai/__init__.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ @Time : 2023/5/22 14:04
4
+ @Auth : Hp_mzx
5
+ @File :__init__.py.py
6
+ @IDE :PyCharm
7
+ """
8
+ import re
9
+ import json
10
+ import base64
11
+ import random
12
+ import string
13
+ import requests
14
+ from fake_useragent import UserAgent
15
+
16
+
17
+ class ChatCompletion:
18
+ @staticmethod
19
+ def create(
20
+ messages: list,
21
+ context: str = "Converse as if you were an AI assistant. Be friendly, creative.",
22
+ restNonce: str = None,
23
+ proxy: str = None
24
+ ):
25
+ url = "https://chatgptlogin.ac/wp-json/ai-chatbot/v1/chat"
26
+ if not restNonce:
27
+ restNonce = ChatCompletion.get_restNonce(proxy)
28
+ headers = {
29
+ "Content-Type": "application/json",
30
+ "X-Wp-Nonce": restNonce
31
+ }
32
+ proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None
33
+ data = {
34
+ "env": "chatbot",
35
+ "session": "N/A",
36
+ "prompt": ChatCompletion.__build_prompt(context, messages),
37
+ "context": context,
38
+ "messages": messages,
39
+ "newMessage": messages[-1]["content"],
40
+ "userName": "<div class=\"mwai-name-text\">User:</div>",
41
+ "aiName": "<div class=\"mwai-name-text\">AI:</div>",
42
+ "model": "gpt-3.5-turbo",
43
+ "temperature": 0.8,
44
+ "maxTokens": 1024,
45
+ "maxResults": 1,
46
+ "apiKey": "",
47
+ "service": "openai",
48
+ "embeddingsIndex": "",
49
+ "stop": "",
50
+ "clientId": ChatCompletion.randomStr(),
51
+ }
52
+ res = requests.post(url=url, data=json.dumps(data), headers=headers, proxies=proxies)
53
+ if res.status_code == 200:
54
+ return res.json()
55
+ return res.text
56
+
57
+ @staticmethod
58
+ def randomStr():
59
+ return ''.join(random.choices(string.ascii_lowercase + string.digits, k=34))[:11]
60
+
61
+ @classmethod
62
+ def __build_prompt(cls, context: str, message: list, isCasuallyFineTuned=False, last=15):
63
+ prompt = context + '\n\n' if context else ''
64
+ message = message[-last:]
65
+ if isCasuallyFineTuned:
66
+ lastLine = message[-1]
67
+ prompt = lastLine.content + ""
68
+ return prompt
69
+ conversation = [x["who"] + x["content"] for x in message]
70
+ prompt += '\n'.join(conversation)
71
+ prompt += '\n' + "AI: "
72
+ return prompt
73
+
74
+ @classmethod
75
+ def get_restNonce(cls, proxy: str = None):
76
+ url = "https://chatgptlogin.ac/"
77
+ headers = {
78
+ "Referer": "https://chatgptlogin.ac/",
79
+ "User-Agent": UserAgent().random
80
+ }
81
+ proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None
82
+ res = requests.get(url, headers=headers, proxies=proxies)
83
+ src = re.search(
84
+ 'class="mwai-chat mwai-chatgpt">.*<span>Send</span></button></div></div></div> <script defer src="(.*?)">',
85
+ res.text).group(1)
86
+ decoded_string = base64.b64decode(src.split(",")[-1]).decode('utf-8')
87
+ restNonce = re.search(r"let restNonce = '(.*?)';", decoded_string).group(1)
88
+ return restNonce
89
+
90
+
91
+ class Completion:
92
+ @staticmethod
93
+ def create(prompt: str, proxy: str):
94
+ messages = [
95
+ {
96
+ "content": prompt,
97
+ "html": prompt,
98
+ "id": ChatCompletion.randomStr(),
99
+ "role": "user",
100
+ "who": "User: ",
101
+ },
102
+ ]
103
+ return ChatCompletion.create(messages=messages, proxy=proxy)
g4f/.v1/gpt4free/italygpt2/README.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Itagpt2(Rewrite)
2
+ Written by [sife-shuo](https://github.com/sife-shuo/).
3
+
4
+ ## Description
5
+ Unlike gpt4free. italygpt in the pypi package, italygpt2 supports stream calls and has changed the request sending method to enable continuous and logical conversations.
6
+
7
+ The speed will increase when calling the conversation multiple times.
8
+
9
+ ### Completion:
10
+ ```python
11
+ account_data=italygpt2.Account.create()
12
+ for chunk in italygpt2.Completion.create(account_data=account_data,prompt="Who are you?"):
13
+ print(chunk, end="", flush=True)
14
+ print()
15
+ ```
16
+
17
+ ### Chat
18
+ Like most chatgpt projects, format is supported.
19
+ Use the same format for the messages as you would for the [official OpenAI API](https://platform.openai.com/docs/guides/chat/introduction).
20
+ ```python
21
+ messages = [
22
+ {"role": "system", "content": ""},#...
23
+ {"role": "user", "content": ""}#....
24
+ ]
25
+ account_data=italygpt2.Account.create()
26
+ for chunk in italygpt2.Completion.create(account_data=account_data,prompt="Who are you?",message=messages):
27
+ print(chunk, end="", flush=True)
28
+ print()
29
+ ```
g4f/.v1/gpt4free/italygpt2/__init__.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ import requests
3
+ import hashlib
4
+ from fake_useragent import UserAgent
5
+ class Account:
6
+ @staticmethod
7
+ def create():
8
+ r=requests.get("https://italygpt.it/",headers=Account._header)
9
+ f=r.text
10
+ tid=re.search('<input type=\"hidden\" name=\"next_id\" id=\"next_id\" value=\"(\w+)\">',f).group(1)
11
+ if len(tid)==0:
12
+ raise RuntimeError("NetWorkError:failed to get id.")
13
+ else:
14
+ Account._tid=tid
15
+ Account._raw="[]"
16
+ return Account
17
+ def next(next_id:str)->str:
18
+ Account._tid=next_id
19
+ return Account._tid
20
+ def get()->str:
21
+ return Account._tid
22
+ _header={
23
+ "Host": "italygpt.it",
24
+ "Referer":"https://italygpt.it/",
25
+ "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",#UserAgent().random,
26
+ "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
27
+ "Accept-Language":"zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
28
+ "Upgrade-Insecure-Requests":"1",
29
+ "Sec-Fetch-Dest":"document",
30
+ "Sec-Fetch-Mode":"navigate",
31
+ "Sec-Fetch-Site":"none",
32
+ "Sec-Fetch-User":"?1",
33
+ "Connection":"keep-alive",
34
+ "Alt-Used":"italygpt.it",
35
+ "Pragma":"no-cache",
36
+ "Cache-Control":"no-cache",
37
+ "TE": "trailers"
38
+ }
39
+ def settraw(raws:str):
40
+ Account._raw=raws
41
+ return Account._raw
42
+ def gettraw():
43
+ return Account._raw
44
+
45
+ class Completion:
46
+ @staticmethod
47
+ def create(
48
+ account_data,
49
+ prompt: str,
50
+ message=False
51
+ ):
52
+ param={
53
+ "prompt":prompt.replace(" ","+"),
54
+ "creative":"off",
55
+ "internet":"false",
56
+ "detailed":"off",
57
+ "current_id":"0",
58
+ "code":"",
59
+ "gpt4":"false",
60
+ "raw_messages":account_data.gettraw(),
61
+ "hash":hashlib.sha256(account_data.get().encode()).hexdigest()
62
+ }
63
+ if(message):
64
+ param["raw_messages"]=str(message)
65
+ r = requests.get("https://italygpt.it/question",headers=account_data._header,params=param,stream=True)
66
+ account_data.next(r.headers["Next_id"])
67
+ account_data.settraw(r.headers["Raw_messages"])
68
+ for chunk in r.iter_content(chunk_size=None):
69
+ r.raise_for_status()
70
+ yield chunk.decode()
g4f/.v1/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
+ ```
g4f/.v1/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. Answer as consisely as possible',
108
+ description: str = 'gpt-3.5 language model',
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()
g4f/.v1/gpt4free/quora/api.py ADDED
@@ -0,0 +1,558 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 retry_request(method, *args, **kwargs):
60
+ """Retry a request with 10 attempts by default, delay increases exponentially"""
61
+ max_attempts: int = kwargs.pop("max_attempts", 10)
62
+ delay = kwargs.pop("delay", 1)
63
+ url = args[0]
64
+
65
+ for attempt in range(1, max_attempts + 1):
66
+ try:
67
+ response = method(*args, **kwargs)
68
+ response.raise_for_status()
69
+ return response
70
+ except Exception as error:
71
+ logger.warning(
72
+ f"Attempt {attempt}/{max_attempts} failed with error: {error}. "
73
+ f"Retrying in {delay} seconds..."
74
+ )
75
+ time.sleep(delay)
76
+ delay *= 2
77
+ raise RuntimeError(f"Failed to download {url} after {max_attempts} attempts.")
78
+
79
+
80
+ class Client:
81
+ gql_url = "https://poe.com/api/gql_POST"
82
+ gql_recv_url = "https://poe.com/api/receive_POST"
83
+ home_url = "https://poe.com"
84
+ settings_url = "https://poe.com/api/settings"
85
+
86
+ def __init__(self, token, proxy=None):
87
+ self.proxy = proxy
88
+ self.session = requests.Session()
89
+ self.adapter = requests.adapters.HTTPAdapter(pool_connections=100, pool_maxsize=100)
90
+ self.session.mount("http://", self.adapter)
91
+ self.session.mount("https://", self.adapter)
92
+
93
+ if proxy:
94
+ self.session.proxies = {"http": self.proxy, "https": self.proxy}
95
+ logger.info(f"Proxy enabled: {self.proxy}")
96
+
97
+ self.active_messages = {}
98
+ self.message_queues = {}
99
+
100
+ self.session.cookies.set("p-b", token, domain="poe.com")
101
+ self.headers = {
102
+ "User-Agent": user_agent,
103
+ "Referrer": "https://poe.com/",
104
+ "Origin": "https://poe.com",
105
+ }
106
+ self.session.headers.update(self.headers)
107
+
108
+ self.setup_connection()
109
+ self.connect_ws()
110
+
111
+ def setup_connection(self):
112
+ self.ws_domain = f"tch{random.randint(1, 1e6)}"
113
+ self.next_data = self.get_next_data(overwrite_vars=True)
114
+ self.channel = self.get_channel_data()
115
+ self.bots = self.get_bots(download_next_data=False)
116
+ self.bot_names = self.get_bot_names()
117
+
118
+ self.gql_headers = {
119
+ "poe-formkey": self.formkey,
120
+ "poe-tchannel": self.channel["channel"],
121
+ }
122
+ self.gql_headers = {**self.gql_headers, **self.headers}
123
+ self.subscribe()
124
+
125
+ def extract_formkey(self, html):
126
+ script_regex = r"<script>if\(.+\)throw new Error;(.+)</script>"
127
+ script_text = re.search(script_regex, html).group(1)
128
+ key_regex = r'var .="([0-9a-f]+)",'
129
+ key_text = re.search(key_regex, script_text).group(1)
130
+ cipher_regex = r".\[(\d+)\]=.\[(\d+)\]"
131
+ cipher_pairs = re.findall(cipher_regex, script_text)
132
+
133
+ formkey_list = [""] * len(cipher_pairs)
134
+ for pair in cipher_pairs:
135
+ formkey_index, key_index = map(int, pair)
136
+ formkey_list[formkey_index] = key_text[key_index]
137
+ formkey = "".join(formkey_list)
138
+
139
+ return formkey
140
+
141
+ def get_next_data(self, overwrite_vars=False):
142
+ logger.info("Downloading next_data...")
143
+
144
+ r = retry_request(self.session.get, self.home_url)
145
+ json_regex = r'<script id="__NEXT_DATA__" type="application\/json">(.+?)</script>'
146
+ json_text = re.search(json_regex, r.text).group(1)
147
+ next_data = json.loads(json_text)
148
+
149
+ if overwrite_vars:
150
+ self.formkey = self.extract_formkey(r.text)
151
+ self.viewer = next_data["props"]["pageProps"]["payload"]["viewer"]
152
+ self.next_data = next_data
153
+
154
+ return next_data
155
+
156
+ def get_bot(self, display_name):
157
+ url = f'https://poe.com/_next/data/{self.next_data["buildId"]}/{display_name}.json'
158
+
159
+ r = retry_request(self.session.get, url)
160
+
161
+ chat_data = r.json()["pageProps"]["payload"]["chatOfBotDisplayName"]
162
+ return chat_data
163
+
164
+ def get_bots(self, download_next_data=True):
165
+ logger.info("Downloading all bots...")
166
+ if download_next_data:
167
+ next_data = self.get_next_data(overwrite_vars=True)
168
+ else:
169
+ next_data = self.next_data
170
+
171
+ if not "viewerBotList" in self.viewer:
172
+ raise RuntimeError("Invalid token or no bots are available.")
173
+ bot_list = self.viewer["viewerBotList"]
174
+
175
+ threads = []
176
+ bots = {}
177
+
178
+ def get_bot_thread(bot):
179
+ chat_data = self.get_bot(bot["displayName"])
180
+ bots[chat_data["defaultBotObject"]["nickname"]] = chat_data
181
+
182
+ for bot in bot_list:
183
+ thread = threading.Thread(target=get_bot_thread, args=(bot,), daemon=True)
184
+ threads.append(thread)
185
+
186
+ for thread in threads:
187
+ thread.start()
188
+ for thread in threads:
189
+ thread.join()
190
+
191
+ self.bots = bots
192
+ self.bot_names = self.get_bot_names()
193
+ return bots
194
+
195
+ def get_bot_names(self):
196
+ bot_names = {}
197
+ for bot_nickname in self.bots:
198
+ bot_obj = self.bots[bot_nickname]["defaultBotObject"]
199
+ bot_names[bot_nickname] = bot_obj["displayName"]
200
+ return bot_names
201
+
202
+ def get_remaining_messages(self, chatbot):
203
+ chat_data = self.get_bot(self.bot_names[chatbot])
204
+ return chat_data["defaultBotObject"]["messageLimit"]["numMessagesRemaining"]
205
+
206
+ def get_channel_data(self, channel=None):
207
+ logger.info("Downloading channel data...")
208
+ r = retry_request(self.session.get, self.settings_url)
209
+ data = r.json()
210
+
211
+ return data["tchannelData"]
212
+
213
+ def get_websocket_url(self, channel=None):
214
+ if channel is None:
215
+ channel = self.channel
216
+ query = f'?min_seq={channel["minSeq"]}&channel={channel["channel"]}&hash={channel["channelHash"]}'
217
+ return f'wss://{self.ws_domain}.tch.{channel["baseHost"]}/up/{channel["boxName"]}/updates' + query
218
+
219
+ def send_query(self, query_name, variables):
220
+ for i in range(20):
221
+ json_data = generate_payload(query_name, variables)
222
+ payload = json.dumps(json_data, separators=(",", ":"))
223
+
224
+ base_string = payload + self.gql_headers["poe-formkey"] + "WpuLMiXEKKE98j56k"
225
+
226
+ headers = {
227
+ "content-type": "application/json",
228
+ "poe-tag-id": hashlib.md5(base_string.encode()).hexdigest(),
229
+ }
230
+ headers = {**self.gql_headers, **headers}
231
+
232
+ r = retry_request(self.session.post, self.gql_url, data=payload, headers=headers)
233
+
234
+ data = r.json()
235
+ if data["data"] is None:
236
+ logger.warn(f'{query_name} returned an error: {data["errors"][0]["message"]} | Retrying ({i + 1}/20)')
237
+ time.sleep(2)
238
+ continue
239
+
240
+ return r.json()
241
+
242
+ raise RuntimeError(f"{query_name} failed too many times.")
243
+
244
+ def subscribe(self):
245
+ logger.info("Subscribing to mutations")
246
+ result = self.send_query(
247
+ "SubscriptionsMutation",
248
+ {
249
+ "subscriptions": [
250
+ {
251
+ "subscriptionName": "messageAdded",
252
+ "query": queries["MessageAddedSubscription"],
253
+ },
254
+ {
255
+ "subscriptionName": "viewerStateUpdated",
256
+ "query": queries["ViewerStateUpdatedSubscription"],
257
+ },
258
+ ]
259
+ },
260
+ )
261
+
262
+ def ws_run_thread(self):
263
+ kwargs = {}
264
+ if self.proxy:
265
+ proxy_parsed = urlparse(self.proxy)
266
+ kwargs = {
267
+ "proxy_type": proxy_parsed.scheme,
268
+ "http_proxy_host": proxy_parsed.hostname,
269
+ "http_proxy_port": proxy_parsed.port,
270
+ }
271
+
272
+ self.ws.run_forever(**kwargs)
273
+
274
+ def connect_ws(self):
275
+ self.ws_connected = False
276
+ self.ws = websocket.WebSocketApp(
277
+ self.get_websocket_url(),
278
+ header={"User-Agent": user_agent},
279
+ on_message=self.on_message,
280
+ on_open=self.on_ws_connect,
281
+ on_error=self.on_ws_error,
282
+ on_close=self.on_ws_close,
283
+ )
284
+ t = threading.Thread(target=self.ws_run_thread, daemon=True)
285
+ t.start()
286
+ while not self.ws_connected:
287
+ time.sleep(0.01)
288
+
289
+ def disconnect_ws(self):
290
+ if self.ws:
291
+ self.ws.close()
292
+ self.ws_connected = False
293
+
294
+ def on_ws_connect(self, ws):
295
+ self.ws_connected = True
296
+
297
+ def on_ws_close(self, ws, close_status_code, close_message):
298
+ self.ws_connected = False
299
+ logger.warn(f"Websocket closed with status {close_status_code}: {close_message}")
300
+
301
+ def on_ws_error(self, ws, error):
302
+ self.disconnect_ws()
303
+ self.connect_ws()
304
+
305
+ def on_message(self, ws, msg):
306
+ try:
307
+ data = json.loads(msg)
308
+
309
+ if not "messages" in data:
310
+ return
311
+
312
+ for message_str in data["messages"]:
313
+ message_data = json.loads(message_str)
314
+ if message_data["message_type"] != "subscriptionUpdate":
315
+ continue
316
+ message = message_data["payload"]["data"]["messageAdded"]
317
+
318
+ copied_dict = self.active_messages.copy()
319
+ for key, value in copied_dict.items():
320
+ # add the message to the appropriate queue
321
+ if value == message["messageId"] and key in self.message_queues:
322
+ self.message_queues[key].put(message)
323
+ return
324
+
325
+ # indicate that the response id is tied to the human message id
326
+ elif key != "pending" and value is None and message["state"] != "complete":
327
+ self.active_messages[key] = message["messageId"]
328
+ self.message_queues[key].put(message)
329
+ return
330
+
331
+ except Exception:
332
+ logger.error(traceback.format_exc())
333
+ self.disconnect_ws()
334
+ self.connect_ws()
335
+
336
+ def send_message(self, chatbot, message, with_chat_break=False, timeout=20):
337
+ # if there is another active message, wait until it has finished sending
338
+ while None in self.active_messages.values():
339
+ time.sleep(0.01)
340
+
341
+ # None indicates that a message is still in progress
342
+ self.active_messages["pending"] = None
343
+
344
+ logger.info(f"Sending message to {chatbot}: {message}")
345
+
346
+ # reconnect websocket
347
+ if not self.ws_connected:
348
+ self.disconnect_ws()
349
+ self.setup_connection()
350
+ self.connect_ws()
351
+
352
+ message_data = self.send_query(
353
+ "SendMessageMutation",
354
+ {
355
+ "bot": chatbot,
356
+ "query": message,
357
+ "chatId": self.bots[chatbot]["chatId"],
358
+ "source": None,
359
+ "withChatBreak": with_chat_break,
360
+ },
361
+ )
362
+ del self.active_messages["pending"]
363
+
364
+ if not message_data["data"]["messageEdgeCreate"]["message"]:
365
+ raise RuntimeError(f"Daily limit reached for {chatbot}.")
366
+ try:
367
+ human_message = message_data["data"]["messageEdgeCreate"]["message"]
368
+ human_message_id = human_message["node"]["messageId"]
369
+ except TypeError:
370
+ raise RuntimeError(f"An unknown error occurred. Raw response data: {message_data}")
371
+
372
+ # indicate that the current message is waiting for a response
373
+ self.active_messages[human_message_id] = None
374
+ self.message_queues[human_message_id] = queue.Queue()
375
+
376
+ last_text = ""
377
+ message_id = None
378
+ while True:
379
+ try:
380
+ message = self.message_queues[human_message_id].get(timeout=timeout)
381
+ except queue.Empty:
382
+ del self.active_messages[human_message_id]
383
+ del self.message_queues[human_message_id]
384
+ raise RuntimeError("Response timed out.")
385
+
386
+ # only break when the message is marked as complete
387
+ if message["state"] == "complete":
388
+ if last_text and message["messageId"] == message_id:
389
+ break
390
+ else:
391
+ continue
392
+
393
+ # update info about response
394
+ message["text_new"] = message["text"][len(last_text) :]
395
+ last_text = message["text"]
396
+ message_id = message["messageId"]
397
+
398
+ yield message
399
+
400
+ del self.active_messages[human_message_id]
401
+ del self.message_queues[human_message_id]
402
+
403
+ def send_chat_break(self, chatbot):
404
+ logger.info(f"Sending chat break to {chatbot}")
405
+ result = self.send_query("AddMessageBreakMutation", {"chatId": self.bots[chatbot]["chatId"]})
406
+ return result["data"]["messageBreakCreate"]["message"]
407
+
408
+ def get_message_history(self, chatbot, count=25, cursor=None):
409
+ logger.info(f"Downloading {count} messages from {chatbot}")
410
+
411
+ messages = []
412
+ if cursor is None:
413
+ chat_data = self.get_bot(self.bot_names[chatbot])
414
+ if not chat_data["messagesConnection"]["edges"]:
415
+ return []
416
+ messages = chat_data["messagesConnection"]["edges"][:count]
417
+ cursor = chat_data["messagesConnection"]["pageInfo"]["startCursor"]
418
+ count -= len(messages)
419
+
420
+ cursor = str(cursor)
421
+ if count > 50:
422
+ messages = self.get_message_history(chatbot, count=50, cursor=cursor) + messages
423
+ while count > 0:
424
+ count -= 50
425
+ new_cursor = messages[0]["cursor"]
426
+ new_messages = self.get_message_history(chatbot, min(50, count), cursor=new_cursor)
427
+ messages = new_messages + messages
428
+ return messages
429
+ elif count <= 0:
430
+ return messages
431
+
432
+ result = self.send_query(
433
+ "ChatListPaginationQuery",
434
+ {"count": count, "cursor": cursor, "id": self.bots[chatbot]["id"]},
435
+ )
436
+ query_messages = result["data"]["node"]["messagesConnection"]["edges"]
437
+ messages = query_messages + messages
438
+ return messages
439
+
440
+ def delete_message(self, message_ids):
441
+ logger.info(f"Deleting messages: {message_ids}")
442
+ if not type(message_ids) is list:
443
+ message_ids = [int(message_ids)]
444
+
445
+ result = self.send_query("DeleteMessageMutation", {"messageIds": message_ids})
446
+
447
+ def purge_conversation(self, chatbot, count=-1):
448
+ logger.info(f"Purging messages from {chatbot}")
449
+ last_messages = self.get_message_history(chatbot, count=50)[::-1]
450
+ while last_messages:
451
+ message_ids = []
452
+ for message in last_messages:
453
+ if count == 0:
454
+ break
455
+ count -= 1
456
+ message_ids.append(message["node"]["messageId"])
457
+
458
+ self.delete_message(message_ids)
459
+
460
+ if count == 0:
461
+ return
462
+ last_messages = self.get_message_history(chatbot, count=50)[::-1]
463
+ logger.info(f"No more messages left to delete.")
464
+
465
+ def create_bot(
466
+ self,
467
+ handle,
468
+ prompt="",
469
+ base_model="chinchilla",
470
+ description="",
471
+ intro_message="",
472
+ api_key=None,
473
+ api_bot=False,
474
+ api_url=None,
475
+ prompt_public=True,
476
+ pfp_url=None,
477
+ linkification=False,
478
+ markdown_rendering=True,
479
+ suggested_replies=False,
480
+ private=False,
481
+ ):
482
+ result = self.send_query(
483
+ "PoeBotCreateMutation",
484
+ {
485
+ "model": base_model,
486
+ "handle": handle,
487
+ "prompt": prompt,
488
+ "isPromptPublic": prompt_public,
489
+ "introduction": intro_message,
490
+ "description": description,
491
+ "profilePictureUrl": pfp_url,
492
+ "apiUrl": api_url,
493
+ "apiKey": api_key,
494
+ "isApiBot": api_bot,
495
+ "hasLinkification": linkification,
496
+ "hasMarkdownRendering": markdown_rendering,
497
+ "hasSuggestedReplies": suggested_replies,
498
+ "isPrivateBot": private,
499
+ },
500
+ )
501
+
502
+ data = result["data"]["poeBotCreate"]
503
+ if data["status"] != "success":
504
+ raise RuntimeError(f"Poe returned an error while trying to create a bot: {data['status']}")
505
+ self.get_bots()
506
+ return data
507
+
508
+ def edit_bot(
509
+ self,
510
+ bot_id,
511
+ handle,
512
+ prompt="",
513
+ base_model="chinchilla",
514
+ description="",
515
+ intro_message="",
516
+ api_key=None,
517
+ api_url=None,
518
+ private=False,
519
+ prompt_public=True,
520
+ pfp_url=None,
521
+ linkification=False,
522
+ markdown_rendering=True,
523
+ suggested_replies=False,
524
+ ):
525
+ result = self.send_query(
526
+ "PoeBotEditMutation",
527
+ {
528
+ "baseBot": base_model,
529
+ "botId": bot_id,
530
+ "handle": handle,
531
+ "prompt": prompt,
532
+ "isPromptPublic": prompt_public,
533
+ "introduction": intro_message,
534
+ "description": description,
535
+ "profilePictureUrl": pfp_url,
536
+ "apiUrl": api_url,
537
+ "apiKey": api_key,
538
+ "hasLinkification": linkification,
539
+ "hasMarkdownRendering": markdown_rendering,
540
+ "hasSuggestedReplies": suggested_replies,
541
+ "isPrivateBot": private,
542
+ },
543
+ )
544
+
545
+ data = result["data"]["poeBotEdit"]
546
+ if data["status"] != "success":
547
+ raise RuntimeError(f"Poe returned an error while trying to edit a bot: {data['status']}")
548
+ self.get_bots()
549
+ return data
550
+
551
+ def delete_account(self) -> None:
552
+ response = self.send_query('SettingsDeleteAccountButton_deleteAccountMutation_Mutation', {})
553
+ data = response['data']['deleteAccount']
554
+ if 'viewer' not in data:
555
+ raise RuntimeError(f'Error occurred while deleting the account, Please try again!')
556
+
557
+
558
+ load_queries()
g4f/.v1/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
g4f/.v1/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==
g4f/.v1/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
+ }
g4f/.v1/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
+ }
g4f/.v1/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
+ }
g4f/.v1/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
+ }
g4f/.v1/gpt4free/quora/graphql/ChatAddedSubscription.graphql ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ subscription ChatAddedSubscription {
2
+ chatAdded {
3
+ ...ChatFragment
4
+ }
5
+ }