Reverse Engineering of ChatGPT Web-Version
Project description
WebChatGPT
Reverse Engineering of ChatGPT in Python.
Unlike the official Openai library, this library makes REST-API calls to ChatGPT via the browser endpoints. No API-KEY required
from WebChatGPT import ChatGPT
bot = ChatGPT(
"<path-to-openai-cookies.json>"
)
response = bot.chat('<Your prompt'>)
print(response)
#Ouput : What can I do for you today?
$ python -m WebChatGPT interactive
╭────────────────────────────── WebChatGPT v0.0.1 ──────────────────────────────╮
│ │
│ Repo : https://github.com/Simatwa/WebChatGPT │
│ By : Smartwa │
│ │
╰───────────────────────────────────────────────────────────────────────────────╯
┌─[Smartwa@WebChatGPT](v0.0.1)
└──╼ ❯❯❯Hello there
General Kenobi! You've activated my nostalgia circuits. What can I do for you
today?
In terminal:
Prerequisites
- Python>=3.10 Installed
- Chrome or Firefox browser
- export-cookie-for-puppeteer extension installed.
Installation & usage
Installation
Either of the following ways will get you ready :
- From pypi:
pip install --upgrade webchatgpt
- From source
git clone https://github.com/Simatwa/WebChatGPT.git
cd WebChatGPT
pip install .
Usage
The script utilizes HTTP Cookies and OAuth to justify the REST-API requests at Openai.
In order to do that, we will use the export-cookie-for-puppeteer extension to extract the cookies which will later on used to retrieve the OAuth.
Procedure
- Login to https://chat.openai.com
- Upon successfull login, use Export cookie JSON File Puppeteer to export cookies.
By doing that you are good to go.
- Converse Interactively:
$ webchatgpt interactive -C <path-to-openai-cookie-file.json> -P "<your startup prompt though not a must>"
- Have a quick response
$ webchatgpt generate -C <path-to-openai-cookie-file.json> -P "<your prompt here>"
Alternatives to -C <path-to-openai-cookie-file.json>
:
On the current directory of your terminal,create a .env
file and save path to the cookie-file in the format :
openai_cookie_file=<path-to-cookie-file>
Or simply run $ webchatgpt <generate/interactive>
and then fill the prompt.
For more info; append --help
to the command
--help
to the command
$ webchatgpt --help
$ webchatgpt --help
Usage: webchatgpt [OPTIONS] COMMAND [ARGS]...
Reverse Engineered ChatGPT Web-version
Options:
--help Show this message and exit.
Commands:
generate Generate a quick response with ChatGPT
interactive Chat with ChatGPT interactively
$ webchatgpt generate --help
$ webchatgpt generate --help
Usage: webchatgpt generate [OPTIONS]
Generate a quick response with ChatGPT
Options:
-C, --cookie-path PATH Path to .json file containing cookies for
`chat.openai.com`
-M, --model TEXT ChatGPT's model to be used
-I, --index INTEGER Conversation index to resume from
-P, --prompt TEXT Start conversation with this messsage
--help Show this message and exit.
$ webchatgpt interactive --help
$ webchatgpt interactive --help
Usage: webchatgpt interactive [OPTIONS]
Chat with ChatGPT interactively
Options:
-C, --cookie-path PATH Path to .json file containing cookies for
`chat.openai.com`
-M, --model TEXT ChatGPT's model to be used
-I, --index INTEGER Conversation index to resume from
-P, --prompt TEXT Start conversation with this messsage
-B, --busy-bar-index INTEGER RANGE
Busy bar index [0:/, 1:■█■■■] [0<=x<=1]
--help Show this message and exit.
Running help
while in interactive prompt:
command | Action |
---|---|
help | Show this help info |
exit | Quits Program |
./<command> |
Run system command |
<any other> |
Interacts with ChatGPT |
If $ webchatgpt
doesn't look cool on you, there's this workaround python -m WebChatGPT
Developer Documentation
ToDo
- Stream Response
- Implement Your idea
- Fix my bad code.
Contributions
Anyone is free to fork, submit pull request as well as submitting issues.
Consider taking a look at the flow of events info for the case of a pull request.
Acknowledgements
Special Thanks
- You
To those wishing to use the Official Openai API endpoints + GoogleBard at console environment; purpose to check out GPT-CLI
Disclaimer
This project is a reverse-engineered implementation of the ChatGPT web version and is intended for educational and research purposes only. It is not affiliated with or endorsed by OpenAI. The code in this repository is based on reverse engineering efforts and may not perfectly replicate the functionalities or behavior of the original ChatGPT web version. Usage of this code is at your own risk, and the maintainers of this repository are not responsible for any misuse or unintended use of the generated content. Please refer to OpenAI's policies and terms of service regarding the use of their services and models. By using this repository, you agree to comply with all relevant laws and OpenAI's terms of service.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for webchatgpt-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e15a0c4755e9729931cae8f85ec610c82b512b5c04d7ac249b33146ba30d0800 |
|
MD5 | b84dfc57b013cb4cc50dbdb9eeb0ac63 |
|
BLAKE2b-256 | 5bf58214d60523a45ff76dd86cb4390a63f3db9602f612d6b008f92fe0dca40d |