An unofficial Python wrapper for OpenAI's ChatGPT API
Project description
UnlimitedGPT
This is a maintained, modified and improved package of the original pyChatGPT package. The original package is in slow development and has many issues. This package is actively maintained and updated.
An unofficial Python wrapper for OpenAI's ChatGPT API
Features
- Cloudflare's anti-bot protection bypass using
undetected_chromedriver
- Headless machines support
- Google Colab support
- Proxy support (only without basic auth)
Getting Started
This library is using only the
undetected_chromedriver
package to bypass Cloudflare's anti-bot protection.requests
module is not used due to the complexity of the protection. Please make sure you have Google Chrome / Chromium before using this wrapper.
Installation
pip install -U UnlimitedGPT
Usage
Obtaining session_token
- Go to https://chat.openai.com/chat and open the developer tools by
F12
. - Find the
__Secure-next-auth.session-token
cookie inApplication
>Storage
>Cookies
>https://chat.openai.com
. - Copy the value in the
Cookie Value
field.
Interactive mode
Currently, interactive mode is not supported in this package. But it will be added in the future.
Import as a module
from UnlimitedGPT import ChatGPT
session_token = 'abc123' # `__Secure-next-auth.session-token` cookie from https://chat.openai.com/chat
api = ChatGPT(
session_token, # Specify session token
conversation_id='some-random-uuid', # Specify conversation ID (Defaults to None)
proxy='https://proxy.example.com:8080', # Specify proxy (Defaults to None)
chrome_args=['--window-size=1920,768'], # Specify chrome args (optional)
disable_moderation=True, # Disable moderation (Defaults to False)
verbose=True, # Verbose mode (Defaults to False)
)
message = api.send_message('Hello, world!')
print(message.response, message.conversation_id)
api.reset_conversation() # reset the conversation
api.clear_conversations() # clear all conversations
api.switch_theme('DARK') # switch themes (DARK, LIGHT, SYSTEM, OPPOSITE)
data = api.get_session_data() # Returns SessionData object with some data, also User object inside of it
api.logout() # Logout from the session
api.switch_account("some-other-token") # Switch to another account
Frequently Asked Questions
When is proper documentation coming?
Documentation of every function, class and object will be coming very soon. For now, all information of current exisiting functions can be found here.
How do I get it to work on headless linux server?
# install chromium & X virtual framebuffer
sudo apt install chromium-browser xvfb
# start your script
python3 your_script.py
How do I get it to work on Google Colab?
It is normal for the seession to be crashed when installing dependencies. Just ignore the error and run your script.
# install dependencies
!apt install chromium-browser xvfb
!pip install -U selenium_profiles UnlimitedGPT
# install chromedriver
from selenium_profiles.utils.installer import install_chromedriver
install_chromedriver()
Insipration
This project is inspired by
Disclaimer
- This project is not affiliated with OpenAI in any way. Use at your own risk. I am not responsible for any damage caused by this project. Please read the OpenAI Terms of Service before using this project.
- This project is not built from scratch by me, I just modified, improved and fixed the original code of pyChatGPT since I noticed there were already some PRs and they were not responded to by the terry3041. I also added some new features to the package, and will keep on doing so.
License
This project is licensed under the GPLv3 License - see the LICENSE file for details.
Star History
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 UnlimitedGPT-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca5220bb9c0e63442b5e8dd10359289f0b979723e67619338abbd46e34144b1c |
|
MD5 | 5553856930258980cb739e4b82b2e6de |
|
BLAKE2b-256 | f61e677918ab503fcedc74f38708a2a621c04bc0afd25ee62fe6755c28f3433f |