Skip to main content

PyQt OpenAI example

Project description

pyqt-openai

Example of using OpenAI with PyQt (Python cross-platform GUI toolkit)

This shows an example of using OpenAI with PyQt as a chatbot.

Even though this project has become too huge to be called an 'example'.

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

If you want to study openai with Python-only good old desktop software, this is for you.

The OpenAI model this package uses is the gpt-3.5-turbo model(which is nearly as functional as ChatGPT) by default. You can use gpt-4 as well.

Image generation feature available since v0.0.16. You can see the detail in official OpenAI site. Currently this feature is very basic now.

This is using sqlite as a database.

You can select the model at the right side bar.

An internet connection is required.

Contact

You can join pyqt-openai's Discord Server to have a conversation about it or AI-related stuff 🙂

Note

Some of the features are still being tested.

I recommend to install sqlite management software. It's not necessary to run this app (obviously), but it's good practice to manage database about conversation history with AI and to know how this works.

Feature

  • basically this is desktop application version of ChatGPT

    • text streaming (enable by default, you can disable it)

    • AI remembers past conversation

  • conversation management

    • add & delete conversations

    • save conversations

    • rename conversation

    • everything above is saved in an SQLite database file named conv.db.

  • support GPT-4 and every other models below GPT3

  • support prompt generator (manageable)

  • support beginning and ending part of the prompt

  • support image generation with DALL-E

  • you can run this in background application

    • notification will pop up when response is generated
  • you can make window stack on top or control its transparency

Requirements

  • qtpy - the package allowing you to write code that works with both PyQt and PySide

  • PyQt5 >= 5.14 or PySide6

  • openai

Preview

This is using GPT-3.5 turbo model by default.

Homepage

image

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

Overview

image

Conversation preview

Preview Image

image

Preview Video

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

Prompt Generator

Preview 1 (v0.1.22)

https://user-images.githubusercontent.com/55078043/236584481-b7bb5246-6bf4-4343-ba6c-a343bb11cda7.mp4

Preview 2 (v0.1.3)

https://user-images.githubusercontent.com/55078043/236658468-9947a417-99b3-4e44-8849-a676308a0239.mp4

So sorry to weak preview, but i have a lot of idea about this prompt generator! Just wait.

How to play

  1. git clone ~

  2. from the root directory, type "cd pyqt_openai"

  3. 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. By the way, this is free trial, not permanently free. See this after you have logged in.

Be sure, this is a very important API key that belongs to you only, so you should remember it and keep it secure.

  1. python main.py

If installation doesn't work, check the troubleshooting below.

Troubleshooting

If you see this error while installing the openai package


subprocess-exited-with-error

you can shout a curse word and just download the package itself from pypi.

Unzip it, access the package directory, type


python setup.py install

That will install the openai.

TODO list

  • support Stable Diffusion

  • show the explanation of every model and terms related to AI (e.g. temperature, topp..)

  • save conversation history with other format (xlsx, csv, etc.)

  • tokenizer

  • highlight the source (optional, eventually)

  • support multiple language

  • use SQLAlchemy (maybe not)

  • show reason when the chat input is disabled for some reasons

  • add the basic example sources of making deep learning model with PyTorch (eventually)

See Also

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.1.3.tar.gz (47.2 kB view details)

Uploaded Source

Built Distribution

pyqt_openai-0.1.3-py3-none-any.whl (59.8 kB view details)

Uploaded Python 3

File details

Details for the file pyqt-openai-0.1.3.tar.gz.

File metadata

  • Download URL: pyqt-openai-0.1.3.tar.gz
  • Upload date:
  • Size: 47.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for pyqt-openai-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9823184542f21092e035b9ce2d2a40a66e3e76730a31b1d0e648ce65bb780826
MD5 8358c5c6e067157e766a6db42bb9ec7e
BLAKE2b-256 dfbac457953856fc8fc47850994070dea7f4369a854200a514877bf295d0b940

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyqt_openai-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 59.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for pyqt_openai-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f967eafd64c94b07ea83aa883d794b79daa96990eaa16a7318fe357e6c4b6842
MD5 482b395abc5a11f75ef4fc8f797fa462
BLAKE2b-256 ccb464974eb26249dd6e2c7e9979a56712e51d012ed507d1cab48e6b7ee09c24

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