VOOZH about

URL: https://pypi.org/project/pyChatGPT/

โ‡ฑ pyChatGPT ยท PyPI


Skip to main content

pyChatGPT 0.4.3.3

pip install pyChatGPT

Latest release

Released:

An unofficial Python wrapper for OpenAI's ChatGPT API

Navigation

Verified details

These details have been verified by PyPI
Maintainers
๐Ÿ‘ Avatar for terry3041 from gravatar.com
terry3041

Unverified details

These details have not been verified by PyPI
Project links
Meta
  • License: GNU General Public License v3 (GPLv3)
  • Author: terry3041
  • Requires: Python >=3.7
Classifiers

Project description

pyChatGPT

๐Ÿ‘ PyPi
๐Ÿ‘ License
๐Ÿ‘ PyPi

An unofficial Python wrapper for OpenAI's ChatGPT API

Features

  • Cloudflare's anti-bot protection bypass using undetected_chromedriver
  • OpenAI / Google / Microsoft login support (experimental)
  • Captcha solvers support (2Captcha, PyPasser)
  • Headless machines support
  • Proxy support (only without basic auth)

Getting Started

Since version 0.3.0, this library is using only the undetected_chromedriver to bypass Cloudflare's anti-bot protection. requests module is no longer used due to the complexity of the protection. Please make sure you have Google Chrome / Chromium before using this wrapper.

Installation

pipinstall-UpyChatGPT

Usage

Obtaining session_token

  1. Go to https://chat.openai.com/chat and open the developer tools by F12.
  2. Find the __Secure-next-auth.session-token cookie in Application > Storage > Cookies > https://chat.openai.com.
  3. Copy the value in the Cookie Value field.

๐Ÿ‘ image

Interactive mode

python3-mpyChatGPT

Import as a module

from pyChatGPT import ChatGPT

session_token = 'abc123' # `__Secure-next-auth.session-token` cookie from https://chat.openai.com/chat
api = ChatGPT(session_token) # auth with session token
api = ChatGPT(session_token, conversation_id='some-random-uuid') # specify conversation id
api = ChatGPT(session_token, proxy='https://proxy.example.com:8080') # specify proxy
api = ChatGPT(session_token, chrome_args=['--window-size=1920,768']) # specify chrome args
api = ChatGPT(session_token, moderation=False) # disable moderation
api = ChatGPT(session_token, verbose=True) # verbose mode (print debug messages)

# auth with google login
api = ChatGPT(auth_type='google', email='example@gmail.com', password='password')
# auth with microsoft login
api = ChatGPT(auth_type='microsoft', email='example@gmail.com', password='password')
# auth with openai login (captcha solving using speech-to-text engine)
api = ChatGPT(auth_type='openai', email='example@gmail.com', password='password')
# auth with openai login (manual captcha solving)
api = ChatGPT(
 auth_type='openai', captcha_solver=None,
 email='example@gmail.com', password='password'
)
# auth with openai login (2captcha for captcha solving)
api = ChatGPT(
 auth_type='openai', captcha_solver='2captcha', solver_apikey='abc',
 email='example@gmail.com', password='password'
)
# reuse cookies generated by successful login before login,
# if `login_cookies_path` does not exist, it will process logining with `auth_type`, and save cookies to `login_cookies_path`
# only works when `auth_type` is `openai` or `google`
api = ChatGPT(auth_type='openai', email='example@xxx.com', password='password',
 login_cookies_path='your_cookies_path',
)

resp = api.send_message('Hello, world!')
print(resp['message'])

api.reset_conversation() # reset the conversation
api.clear_conversations() # clear all conversations
api.refresh_chat_page() # refresh the chat page

Frequently Asked Questions

How do I get it to work on headless linux server?

# install chromium & X virtual framebuffer
sudoaptinstallchromium-browserxvfb

# start your script
python3your_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 pyChatGPT

# install chromedriver
from selenium_profiles.utils.installer import install_chromedriver
install_chromedriver()
# start your script as normal
!python3 -m pyChatGPT

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.

License

This project is licensed under the GPLv3 License - see the LICENSE file for details.

Project details

Verified details

These details have been verified by PyPI
Maintainers
๐Ÿ‘ Avatar for terry3041 from gravatar.com
terry3041

Unverified details

These details have not been verified by PyPI
Project links
Meta
  • License: GNU General Public License v3 (GPLv3)
  • Author: terry3041
  • Requires: Python >=3.7
Classifiers

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

pyChatGPT-0.4.3.3.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

Filter files by name, interpreter, ABI, and platform.

If you're not sure about the file name format, learn more about wheel file names.

Copy a direct link to the current filters

pyChatGPT-0.4.3.3-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file pyChatGPT-0.4.3.3.tar.gz.

File metadata

  • Download URL: pyChatGPT-0.4.3.3.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for pyChatGPT-0.4.3.3.tar.gz
Algorithm Hash digest
SHA256 33671607fd70a4f2efdb0a9d0915d117f0ba1e266643b47ffa207e4c23f99612
MD5 f20b09b9cac80de41a93003763ba3cfc
BLAKE2b-256 52119aa77973e364019b67c05613f19a2bb043ad0f537a3bf3cf9e20f38e22f8

See more details on using hashes here.

File details

Details for the file pyChatGPT-0.4.3.3-py3-none-any.whl.

File metadata

  • Download URL: pyChatGPT-0.4.3.3-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for pyChatGPT-0.4.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ce737e2ace30af107e577b65d21f5dc419102eb0be7c551281d7936f11f4bc2e
MD5 23dbd6ecb877ebf67100e59c646949af
BLAKE2b-256 493aee2af2f891f3a30ee7c48b307f25eb22c8a3a501eb4dcf0b3f5eb4f747d2

See more details on using hashes here.

Supported by

๐Ÿ‘ Image
AWS Cloud computing and Security Sponsor ๐Ÿ‘ Image
Datadog Monitoring ๐Ÿ‘ Image
Depot Continuous Integration ๐Ÿ‘ Image
Fastly CDN ๐Ÿ‘ Image
Google Download Analytics ๐Ÿ‘ Image
Pingdom Monitoring ๐Ÿ‘ Image
Sentry Error logging ๐Ÿ‘ Image
StatusPage Status page