Skip to main content

PyQt/PySide multipurpose chatbot that user can use GPT, other AI models altogether

Project description

pyqt-openai



Multi-purpose Text & Image Generation Desktop Chatbot (supporting various models including GPT).

Join our Discord Channel for questions or discussions! Also we need contributor. Feel free to join the server !

Email: yjg30737@gmail.com

image


This application is developed using PyQt/PySide.

It supports Windows, macOS, and Linux.

It uses SQLite as a database.

You can use OpenAI models (GPT-4, GPT-4 Mini, DALL-E, etc.) and Replicate image generation models with PyQt.

The major advantage of this package is that you don't need to know any language aside from Python.

If you want to study OpenAI with Python-only in a good old desktop software environment, this is for you.

You can select the model and adjust each parameter of OpenAI from the right sidebar.

Additionally, you can combine OpenAI with the Llama-Index feature to make the GPT model answer your questions based on the information you have provided!

If you have any questions or if you want to develop AI-related software with PyQt or PySide, feel free to join the Discord server!

If you would like to support this project, please click the button below to make a donation. Your contribution will greatly assist various projects, including this one!

Buy Me A Coffee Donate with PayPal

Table of Contents

Feature

  • Basically this is desktop application version of ChatGPT with image generation tool.
  • Conversation(=Thread) management
    • Add & delete conversations
    • Export & Import conversations (including import from ChatGPT)
    • "Favorite" feature
    • Support JSON mode
    • Everything above is saved in an SQLite database file named conv.db. (File's name can be changed by yourself)
  • Support text(.txt), image(.png, *.jpg) file uploading
  • Support controlling parameters(temperature, top_p, etc)
  • You can see the reason why stream is finished.
  • Support token count (only for non-streaming response)
  • Support prompt generator (manageable, autosaved in database)
    • Support import & export prompt group as JSON
  • Full screen feature
  • Support slash commands
  • Support beginning and ending part of the prompt
  • You can run this in background
    • Notification will pop up when response is generated
  • You can make window stack on top or control its transparency
  • Image generation (DALL-E3 from openai, a bunch of image models in Replicate)
    • Support saving generated image to local
    • Support continue generation
    • Notification when task completes
  • Support llamaindex
  • Support customizing feature (homepage, user and AI profile image, font settings)
  • Support light/dark theme based on your system settings (Above Qt6 only)

Supported Languages

  • English
  • Spanish
  • Chinese
  • Russian
  • Korean
  • French
  • German
  • Italian
  • Hindi
  • Arabic
  • Japanese
  • Bengali
  • Urdu
  • Indonesian
  • Portuguese

If you have any additional languages you would like to add, please feel free to make a request by mail, issue, discord, etc at any time.

Also you can submit a pull request if you want to update any words naturally by modify "translations.json" in "lang" directory.

Requirements

  • Python >= 3.9
  • qtpy - the package allowing you to write code that works with both PyQt5, PyQt6, PySide6
  • PyQt5 >= 5.14 or PyQt6 (or PySide6 if you want)
    • I personally recommend Qt6.
  • openai
  • aiohttp - for openai dependency
  • pyperclip - to copy prompt text from prompt generator
  • jinja2 - for saving the conversation with html file
  • llama-index - to fine-tune gpt with llamaindex
  • requests - for getting response from web
  • langchain - for connecting llama-index with gpt
  • pillow - for preventing ModuleNotFoundError from llama-index
  • replicate - for supporting Replicate
  • toml - For reading pyproject.toml below 3.11

You can install these requirements with only one line command "pip install -r requirements.txt". Just see "How to Install" section below.

Preview and Usage

Note: A lot of previews below are not from latest version. It is slightly different with current GUI. So if you want to really know what this looks like, see it by yourself :) But i will definitely change any image(s) which should be changed.

Overview

image You have to write your openai api key inside the red box. see How to install

You can change screen between text chatbot and image generating tool screen.

image

Using LlamaIndex

image

If you want to use this with your personal chatbot based on data you've given, then you can check the llamaindex checkbox and go to the tab, select the directory which includes .txt files containing the data.

Conversation

Preview 1

I recorded this preview long time ago so GUI is different from the current version, but way of operating it is pretty much the same.

https://user-images.githubusercontent.com/55078043/236583883-8e9732a3-1223-4b28-85f1-f60d8b2d6ced.mp4

Preview 2 (using prompt feature)

https://github.com/yjg30737/pyqt-openai/assets/55078043/841a1505-f1cc-452e-99ab-0a9c661e6ead

Conversation Save Feature

image

You can save checked conversation units to SQlite db file or compressed file (zip) which contains each conversation as text/html file.

Prompt Generator

How to Generate

This application has two types of prompts. One is "Properties" and the other one is "Template". Properties are sets of attributes that are useful for forming the premises of a question. Templates are sentences that correspond to a single command. You can input a command to generate a sentence. This can be used as a question in itself.

Both types can be managed as groups. After cloning or installing, if you run the program immediately, you will be able to see the default group and the items included in the group, just like the screen.

For properties, there is a group named "Default" that provides a set of attributes referenced here.

For templates, there are the "awesome_chatGPT_prompt" and "alex_brogan" (example prompt for Alex Brogan) groups provided. Any custom template items created prior to version 0.1.6 will be moved to the Miscellaneous group.

prompt_list_image

With using these prompts you can pretty much get any response you want.

You can use the additional prompt feature by "prompt menu" right next to "prompt input" field.

image

Since v0.1.6, awesome-chatgpt-prompt is included as template group by default.

Prompt Generator Preview

Generating the prompt (Properties)

https://github.com/yjg30737/pyqt-openai/assets/55078043/e168c0e6-41b4-4ad5-95e6-3c42c9c23602

I recorded using the Windows recording feature. As a result, the "Add Dialog" that prompts for entering a group name does not appear in the preview. When you add a group, you will see the Add Dialog as expected.

Then, how to generate template type prompt? Click any item in the group, it will be shown in the preview.

You can copy that generated text with clicking "copy" button and include it to your prompt input.

If you add a property group or template group with items, you can use it as a command by typing its name to the prompt input.

Use prompt as a command

https://github.com/yjg30737/pyqt-openai/assets/55078043/df0d3923-1fbe-4dda-af6f-4e4d1e572553

In this preview, i pressed the keyboard shortcut of each actions(show beginning, show ending, support prompt command) to use it rather than clicking them with mouse.

I made the command suggestion GUI resemble the Discord command autocomplete popup, with which a lot of people have become accustomed.

How to Install

  1. git clone ~
  2. cd pyqt-openai
  3. pip install -r requirements.txt --upgrade
  4. cd pyqt_openai
  5. You should put your api key in the line edit. You can get it in official site of openai. Sign up and log in before you get it.
  6. python main.py

Install with pyproject.toml

  1. git clone ~
  2. Run shell as Administrator
  3. cd pyqt-openai
  4. pip install .
  5. pyqt-openai

Note

If you use Linux and see this error:

qt.qpa.plugin: could not load the qt platform plugin "xcb" in "" even though it was found

this application failed to start because no qt platform plugin could be initialized, reinstalling the application may fix this problem

run this command:

sudo apt-get install libxcb-xinerama0

Troubleshooting

How to fix qt.qpa.plugin: Could not find the Qt platform plugin "windows" in "" error

Please check that the path does not contain any other invalid languages.

qtpy.QtBindingsNotFoundError: No Qt bindings could be found

First, do this:

pip uninstall -r requirements.txt

second, do this:

pip install -r requirements.txt --upgrade

then it will work :)

Disclaimer

Please do not distribute this commercially without my permission, by claiming it as your own creation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqt_openai-0.9.0.tar.gz (398.7 kB view details)

Uploaded Source

Built Distribution

pyqt_openai-0.9.0-py3-none-any.whl (406.1 kB view details)

Uploaded Python 3

File details

Details for the file pyqt_openai-0.9.0.tar.gz.

File metadata

  • Download URL: pyqt_openai-0.9.0.tar.gz
  • Upload date:
  • Size: 398.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for pyqt_openai-0.9.0.tar.gz
Algorithm Hash digest
SHA256 e44f453df13e5d8ad965a2bf8e79bd9063d3f885e89925e1d363abb055cc6afb
MD5 5a615a092724151ad78a6d0fd6ca76ab
BLAKE2b-256 5d50c79346ff706bb9e16d15f04539a1c10987a53b5b3bbf9f74214ddd6459c4

See more details on using hashes here.

File details

Details for the file pyqt_openai-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: pyqt_openai-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 406.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for pyqt_openai-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 375a9bbad5e8f0195450294008a2b837b001bb0dae10d8d30d6a369dee88b79e
MD5 37189c0e279a92ab82fa6dd9b9e02b34
BLAKE2b-256 f0673891b2267e8b0fa63706ca2d7728db3be85677da16c29d3404fb02d6ef63

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page