Package: webchatgpt
WebChatGPTReverse Engineeringof ChatGPT in Python.Unlike theofficial Openai library, this library makes REST-API calls toChatGPTvia thebrowserendpoints.No API-KEY required[!CAUTION]Currentlyvery unreliable!fromWebChatGPTimportChatGPTbot=ChatGPT("<path-to-openai-cookies.json>")response=bot.chat('<Your prompt>')print(response)#Ouput : What can I do for you today?PrerequisitesPython>=3.10 InstalledChrome or Firefox browserexport-cookie-for-puppeteerextension installed.Installation & usageInstallationEither of the following ways will get you ready :From pypi:pip install --upgrade webchatgptFrom sourcepip install git+https://github.com/Simatwa/WebChatGPT.gitUsageThe script utilizesHTTP CookiesandOAuthto justify the REST-API requests atOpenai.In order to do that, we will use theexport-cookie-for-puppeteerextension to extract the cookies which will later on used to retrieve the OAuth.ProcedureLogin tohttps://chat.openai.comUpon successfull login, useExport cookie JSON File Puppeteerto export cookies. If you haven't installed the extension, here are  the quick installation links for you.Google ChromeFirefoxBy doing that you are good to go.Converse Interactively:$ webchatgpt interactive -C <path-to-openai-cookie-file.json> "<your startup prompt though not a must>"Have a quick response$ webchatgpt generate -C <path-to-openai-cookie-file.json> "<your prompt here>"Sincegenerateis the default option so something like this will this workout.$ webchatgpt -C <path-to-openai-cookie-file.json> "<your prompt>"Alternatives to-C <path-to-openai-cookie-file.json>:On the current directory of yourterminal,create a.envfile and save path to the cookie-file in the format :openai_cookie_file=<path-to-cookie-file>Or simply make path to the cookie file an environment variable identified byopenai_cookie_file. By that you'll just have to use less commands to get your work done e.gwebchatgpt "Nmap command for scanning SMB vulnerabilty on 192.168.0.1" -q | grep '$' > scan_smb.shFor more info; append--helpto the command$ webchatgpt --helpUsage: 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 --helpUsage: 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 --helpUsage: 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.Runninghwhile in interactive prompt:╒════╤════════════════════════╤═══════════════════════════════════════╕
│    │ Command                │ Action                                │
╞════╪════════════════════════╪═══════════════════════════════════════╡
│  0 │ h                      │ Show this help info                   │
├────┼────────────────────────┼───────────────────────────────────────┤
│  1 │ history                │ Show conversation history             │
├────┼────────────────────────┼───────────────────────────────────────┤
│  2 │ share                  │ Share conversation by link            │
├────┼────────────────────────┼───────────────────────────────────────┤
│  3 │ stop_share             │ Revoke shared conversation link       │
├────┼────────────────────────┼───────────────────────────────────────┤
│  4 │ rename                 │ Rename conversation title             │
├────┼────────────────────────┼───────────────────────────────────────┤
│  5 │ archive                │ Archive or unarchive a conversation   │
├────┼────────────────────────┼───────────────────────────────────────┤
│  6 │ shared_conversations   │ Show shared conversations             │
├────┼────────────────────────┼───────────────────────────────────────┤
│  7 │ previous_conversations │ Show previous conversations           │
├────┼────────────────────────┼───────────────────────────────────────┤
│  8 │ delete_conversation    │ Delete a particular conversation      │
├────┼────────────────────────┼───────────────────────────────────────┤
│  9 │ prompts                │ Generate random prompts               │
├────┼────────────────────────┼───────────────────────────────────────┤
│ 10 │ account_info           │ ChatGPT account info/setings          │
├────┼────────────────────────┼───────────────────────────────────────┤
│ 11 │ ask                    │ Show raw response from ChatGPT        │
├────┼────────────────────────┼───────────────────────────────────────┤
│ 12 │ auth                   │ Show current user auth info           │
├────┼────────────────────────┼───────────────────────────────────────┤
│ 13 │ migrate                │ Shift to another conversation         │
├────┼────────────────────────┼───────────────────────────────────────┤
│ 14 │ set_theme              │ Set theme for displaying codes        │
├────┼────────────────────────┼───────────────────────────────────────┤
│ 15 │ copy_this              │ Copy last response                    │
├────┼────────────────────────┼───────────────────────────────────────┤
│ 16 │ with_copied            │ Attach last copied text to the prompt │
├────┼────────────────────────┼───────────────────────────────────────┤
│ 17 │ clear                  │ Clear console                         │
├────┼────────────────────────┼───────────────────────────────────────┤
│ 18 │ ./<command>            │ Run system command                    │
├────┼────────────────────────┼───────────────────────────────────────┤
│ 19 │ <any other>            │ Interact with ChatGPT                 │
├────┼────────────────────────┼───────────────────────────────────────┤
│ 20 │ exit                   │ Quit Program                          │
╘════╧════════════════════════╧═══════════════════════════════════════╛If$ webchatgptdoesn't look cool on you, there's this workaroundpython -m WebChatGPTStarting fromv0.2.4onwards, shortcut to$ webchatgptis$ wbc.Developer DocumentationToDoStream ResponseCreate new conversationImplement Your ideaFix my bad code.ContributionsAnyone is free tofork, submitpull requestas well as submittingissues.Consider taking a look at theflow of events infofor the case of apull request.AcknowledgementsHttp-Tracker.export-cookie-for-puppeteerSpecial ThanksYouIf you don't want to follow all those steps; there this script that works out of the box. No API key needed at all, not even the cookies. Just installation and you're good to go. Check outtgpt2.To those wishing to use the Official Openai API endpoints + GoogleBard at console environment; purpose to check outGPT-CLIDisclaimerThis 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.