Code Monkey home page Code Monkey logo

chatgpt-gui's Introduction

ChatGPT-GUI

MIT License PyPI Python CPython


An unofficial GUI app for ChatGPT.


Note: This project is in a public alpha, and as such, many features are not complete.

Other Documents:

Table of Contents

Disclaimer:

ChatGPT-GUI is in no way associated with, endorsed by, or otherwise affiliated with OpenAI.

About:

ChatGPT-GUI is an application written using Qt for Python that allows you to easily talk to Assistant, the AI based on ChatGPT.

This project is a fork of my other project, HaloInfiniteGetter.

If you like this application, be sure to star :)

Features:

  • [x] Email/Password Login to ChatGPT Without Browser
    • (Captcha solving is untested but implemented)
  • Proxy Settings
    • Supported Protocols are HTTP and SOCKS5
  • Executable Script in PATH (chatgpt)
  • Desktop & Start Menu Shorcuts
  • Session (token) Persistence
  • Automatic Access Token Refreshing
  • Multiple Concurrent Conversations
  • Conversation Saving & Loading
  • Multi-line input
  • Exception Reporter & Traceback Viewer
  • Themes
    • Builtin themes are: [Breeze Dark, Breeze Light, and Legacy]

Todo:

  • Pretty Conversation Views
  • Retry AI Message

How to Use:

Installation:

  • First, install Python 3.10 using this link
  • Then, open command prompt (Win + R -- type in "cmd") and type pip install chatgpt-gui
    • Optionally, to install the latest unstable version, type pip install git+https://github.com/Cubicpath/ChatGPT-GUI.git
  • And you are done! To launch the program simply type chatgpt
    • Once launched, you can create a desktop shortcut by using the Create Desktop Shortcut tool under the Tools context menu

Authentication:

Thanks to rawandahmad698 and tls-client, there exists a method to authenticate without messing around with tokens or the browser. Simply sign in from the app itself!.

Google Chrome is currently required to automatically bypass cloudflare.

Email & Password login is currently not working. Refer to session token authentication in the meantime.

Sign In

Session Token Guide:

  • Sign in to ChatGPT on your browser
  • Navigate to the Cookies for chat.openai.com
  • Double-click the __Secure-next-auth.session-token cookie value and copy with CTRL + C
  • Open the Settings window, unlock the input by pressing the "Edit Session Token" button, then paste the copied value.
  • Press the Set button, and you should now be authenticated!

Session Data:

Session data is stored in a hidden file (~/.config/chatgpt_gui/.session.json), for persistence. When you sign out or clear your session token, it automatically deletes all session data.

If you ever need to directly edit your session data, it follows the following format:

{
  "user": {
    "id": "Your user id (starting with a 'user-' prefix)",
    "name": "Your username (usually same as your email)",
    "email": "The email tied to your session",
    "image": "Link to your profiles image (usually same as your picture)",
    "picture": "Link to your profile picture",
    "groups": [],
    "features": []
  },
  "cloudflare": {
    "bm": "Value of the __cf_bm cookie",
    "clearance": "Value of the cf_clearance cookie",
    "expires": "1h from the time cf_clearance is acquired"
  },
  "expires": "Automatically acquired after refresh_auth()",
  "token": "Value of the __Secure-next-auth.session-token cookie",
  "user_agent": "User Agent the Client/Authenticator use"
}

Saving/Loading Conversations

You can save your currently selected conversation with ChatGPT by right-clicking any tab and pressing the Export Conversation To... button. This will open a file dialog where you can rename your conversation anything, which will show when loaded.

You can load a conversation that was previously saved by pressing the Import Conversation From... button, and selecting the JSON file containing the conversation.

By default, all conversations are stored in the ~/.cache/chatgpt_gui/ directory. But you can choose any folder when exporting.

NOTE: Conversations from one account CANNOT be accessed from another.

Conversation Format:

Conversations are stored as a linear list of messages, where each message is a response to the one before it. All UUID's are tracked, which allows the Client to continue conversations after import.

They are stored in the following data format:

{
  "id": "Conversation UUID",
  "messages": [
    {
      "id": "Message UUID",
      "role": "user",
      "content": {
        "content_type": "text",
        "parts": [
          "Your message to ChatGPT"
        ]
      }
    },
    {
      "id": "Message UUID",
      "role": "assistant",
      "content": {
        "content_type": "text",
        "parts": [
          "Response from ChatGPT"
        ]
      }
    }
  ]
}

Themes:

Themes are a way to style already-existing elements (Think CSS). They are held in a directory with their resources and stylesheet in the same folder level.

Theme File Structure:

../
│
├───[theme_id]/
│       ├─── [icon1_name].svg
│       ├─── [icon2_name].svg
│       ├─── [icon3_name].svg
│       └─── stylesheet.qss
│

The current builtin themes are:

  • Breeze Dark
  • Breeze Light
  • Legacy (Default Qt)

While the current breeze themes are slightly modified versions, you can view the original themes at BreezeStyleSheets.

chatgpt-gui's People

Contributors

cubicpath avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

chatgpt-gui's Issues

[Bug]: Blocked by Cloudflare hCaptcha

Contact Details

[email protected]

What happened?

ChatGPT's new cloudflare hCaptcha implementation is blocking the use of unofficial apis. When making a request to https://chat.openai.com, you must pass a security check, which involves a JS challenge and a 1x1 pixel transparent.gif resource.

Once you pass the security check, the browser stores a cf_clearance cookie which has a 1-year expiration (The token itself should have a 15-45 minute expiration, as documented here). If this cookie is missing or invalid, you will need to pass the security check again before accessing the website, even if you have a valid session/access token.

Version

v0.3.3

What operating system are you using?

Windows

Relevant log output

Traceback for UnicodeDecodeError
-----------------------------------
'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

  File "C:\Projects\Programs\Python\ChatGPT-GUI\src\chatgpt_gui\gui\widgets\conversation_view.py", line 137, in send_message
    app().client.send_message(message, self.conversation)  # type: ignore

  File "C:\Projects\Programs\Python\ChatGPT-GUI\src\chatgpt_gui\network\client\chatgpt.py", line 324, in send_message
    if not (models := self.get_models()):

  File "C:\Projects\Programs\Python\ChatGPT-GUI\src\chatgpt_gui\network\client\chatgpt.py", line 292, in get_models
    return self._get('backend-api/models').json.get('models')

  File "C:\Projects\Programs\Python\ChatGPT-GUI\src\chatgpt_gui\network\manager.py", line 903, in json
    return json_.loads(data.decode(encoding=encoding))

[Bug]: (RuntimeError) Couldn't start Chrome webdriver. Make sure you have Google Chrome installed

Contact Details

No response

What happened?

A bug happened! (i have google installed) as i am using it now.

Version

v0.4.1

What operating system are you using?

Windows

Relevant log output

RuntimeError: Couldn't start Chrome webdriver. Make sure you have Google Chrome installed

File "C:\%USERNAME%s\%USERNAME%\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatgpt_gui\gui\widgets\conversation_view.py", line 145, in send_message
    app().client.send_message(message, self.conversation)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\%USERNAME%s\%USERNAME%\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatgpt_gui\network\client\chatgpt.py", line 347, in send_message
    if not (models := self.get_models()):
                      ^^^^^^^^^^^^^^^^^

  File "C:\%USERNAME%s\%USERNAME%\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatgpt_gui\network\client\chatgpt.py", line 309, in get_models
    return self._get('backend-api/models').json.get('models')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\%USERNAME%s\%USERNAME%\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatgpt_gui\network\client\chatgpt.py", line 266, in _get
    self.refresh_auth()

  File "C:\%USERNAME%s\%USERNAME%\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatgpt_gui\network\client\chatgpt.py", line 422, in refresh_auth
    self.authenticator.cloudflare_clearance()

  File "C:\%USERNAME%s\%USERNAME%\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatgpt_gui\network\client\auth.py", line 400, in cloudflare_clearance
    raise RuntimeError('Couldn\'t start Chrome webdriver. Make sure you have Google Chrome installed.') from e

[Bug]: (KeyError) ''

Contact Details

No response

What happened?

A bug happened!

Version

v0.1

What operating system are you using?

Windows

Relevant log output

KeyError: ''

File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\gui\windows\application.py", line 202, in receive_message
    self.append_to_output(tr('gui.output_text.ai_prompt', message))

  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\gui\aliases.py", line 30, in tr
    return app().translator(key, *args, **kwargs)

  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\lang.py", line 371, in __call__
    return self.get_translation(key, *args, **kwargs)

  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\lang.py", line 389, in get_translation
    return self.language.get(key, *args, **kwargs)

  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\lang.py", line 327, in get
    return format_value(result, *args, _language=self, _key_eval=key_eval)

  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\lang.py", line 97, in format_value
    value = value.replace(rec_match, _language.get_raw(rec_match.strip('{}')))

  File "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\lang.py", line 340, in get_raw
    return self._data[key]

[Bug]: (JSONDecodeError) Expecting value: line 1 column 1 (char 0)

Contact Details

No response

What happened?

A bug happened!

Version

v0.4

What operating system are you using?

Windows

Relevant log output

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\gui\widgets\conversation_view.py", line 137, in send_message
    app().client.send_message(message, self.conversation)  # type: ignore

  File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\network\client\chatgpt.py", line 341, in send_message
    if not (models := self.get_models()):

  File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\network\client\chatgpt.py", line 303, in get_models
    return self._get('backend-api/models').json.get('models')

  File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\network\client\chatgpt.py", line 265, in _get
    self.refresh_auth()

  File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\network\client\chatgpt.py", line 427, in refresh_auth
    if user := response.json.get('user'):

  File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\site-packages\chatgpt_gui\network\manager.py", line 903, in json
    return json_.loads(data.decode(encoding=encoding))

  File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)

  File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

  File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None

[Feature]: OpenAI Authenticator

Contact Details

[email protected]

Feature Request

Currently, ChatGPT-GUI requires the user to provide a session cookie for authentication. This cookie only last a month maximum, and cannot be automatically renewed without another login through the browser.

The proposed solution is an Authenticator class which handles email & password logins for https://chat.openai.com, without a browser. It would keep track of when the credentials expire and login either manually, or after that time has passed. The Authenticator would also handle captchas, letting the user solve them with a popup window.

Cannot install chat-gpt gui

ERROR: Ignored the following versions that require a different python version: 0.1 Requires-Python >=3.10; 0.1.1 Requires-Python >=3.10; 0.1.dev1 Requires-Python >=3.10; 0.2 Requires-Python >=3.10; 0.3 Requires-Python >=3.10; 0.3.1 Requires-Python >=3.10; 0.3.2 Requires-Python >=3.10; 0.3.3 Requires-Python >=3.10; 0.4 Requires-Python >=3.10; 0.4.1 Requires-Python >=3.10
ERROR: Could not find a version that satisfies the requirement chatgpt-gui (from versions: none)
ERROR: No matching distribution found for chatgpt-gui

i have python 3.10.0 on root path
image

[Feature]: Use of API Keys (as an option) instead of Browser User Sessions

Contact Details

No response

Feature Request

By using an API Key, you can essentially bypass the queue that you would get with User Sessions in a browser. OpenAI currently does not put a queue on direct API requests as far as I know. Response time is actually a little bit faster as well; about the same as the new monetized version of ChatGPT.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.