Skip to content

Repository files navigation

ChatGPT

Reverse Engineered ChatGPT by OpenAI. Extensible for chatbots etc.

Disclaimer

This is not an official OpenAI product. This is a personal project and is not affiliated with OpenAI in any way. Don't sue me

This is a library and not intended for direct CLI use

The CLI functionality is for demo and testing only.

@rawandahmad698 has a much better CLI tool at

PyChatGPT

Urgent help needed

  • Writing tests
  • More verbose error handling
  • Decrecate bs4 in favor of pure requests

Wiki is now open to all contributors

Features

image

  • No moderation
  • Programmable

Setup

Install

pip3 install revChatGPT --upgrade

Email and password authentication

{
"email": "<YOUR_EMAIL>",
"password": "<YOUR_PASSWORD>"
}

Save this in config.json in current working directory

Legacy authentication or if using Google Auth Go to https://chat.openai.com/chat and log in or sign up
  1. Open console with F12
  2. Open Application tab > Cookies image
  3. Copy the value for __Secure-next-auth.session-token and paste it into config.json.example under session_token. You do not need to fill out Authorizationimage
  4. Save the modified file to config.json (In the current working directory)

Running

 $ python3 -m revChatGPT ChatGPT - A command-line interface to OpenAI's ChatGPT (https://chat.openai.com/chat)
Repo: github.com/acheong08/ChatGPT
Arguments: Use --stream to enable data streaming. (Doesn't work on MacOS)
Type '!help' to show commands
Press enter twice to submit your question.
You: !help
!help - Show this message
!reset - Forget the current conversation
!refresh - Refresh the session authentication
!exit - Exit the program

Refresh every so often in case the token expires.

Development:

pip3 install revChatGPT --upgrade

fromrevChatGPT.revChatGPTimportChatbotimportjson# Get your config in JSONconfig= {
"email": "<YOUR_EMAIL>",
"password": "<YOUR_PASSWORD>"
}
chatbot=Chatbot(config, conversation_id=None)
chatbot.reset_chat() # Forgets conversationchatbot.refresh_session() # Uses the session_token to get a new bearer tokenresp=chatbot.get_chat_response(prompt, output="text") # Sends a request to the API and returns the response by OpenAIresp['message'] # The message sent by the responseresp['conversation_id'] # The current conversation idresp['parent_id'] # The ID of the response# This returns a stream of text (live update)resp=chatbot.get_chat_response(prompt, output="stream") formessageinresp: # You have to loop through the response streamprint(line['message']) # Same format as text return type
...

This can be imported to projects for bots and much more. You can have multiple independent conversations by keeping track of the conversation_id.

Awesome ChatGPT

My list

If you have a cool project you want added to the list, open an issue.

Star History

Star History Chart

About

Lightweight package for interacting with ChatGPT's API by OpenAI. Uses reverse engineered official API.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages