/chatgpt-python

Unofficial Python SDK for OpenAI's ChatGPT

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

PyPi License

ChatGPT Python SDK

Buy Me A Coffee

Install or update

pip install -U chatgpt

Create a file with your credentials

⚠️   Please, update the library. Note the change in the config file.

Create the file config.json in your working directory:

{
    "email": "email@example.org",
    "password": "xxx"
}

Usage

CLI

You can launch the CLI with:

chatgpt

or

python -m chatgpt

These are the available commands:

  • reset: forget the context of the current conversation.
  • clear: clear the terminal.
  • exit: exit the CLI.

SDK

from chatgpt import Conversation

conversation = Conversation()
print(
    conversation.chat(
        "We are going to start a conversation. "
        "I will speak English and you will speak Portuguese."
    )
)
print(conversation.chat("What's the color of the sky?"))

# The AI will forget it was speaking Portuguese
conversation.reset()
print(conversation.chat("What's the color of the sun?"))