Skip to content

Commit 4e62d4e

Browse files
authored
Merge pull request #142 from yjg30737/Dev
v1.0.0
2 parents cb9f5ff + 7d598dc commit 4e62d4e

File tree

95 files changed

+2528
-1924
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2528
-1924
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,5 @@ dmypy.json
134134
# pyqt_openai
135135
pyqt_openai/pyqt_openai.ini
136136
pyqt_openai/*.db
137-
pyqt_openai/test/
137+
pyqt_openai/test/
138+
pyqt_openai/config.yaml

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
include pyqt_openai/ico/*
22
include pyqt_openai/prompt_res/*
33
include pyqt_openai/lang/*
4-
include pyqt_openai/images/*
54

65
include pyqt_openai/icon.ico

pyproject.toml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,22 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "pyqt-openai"
77
version = "0.9.0"
8-
description = "PyQt/PySide multipurpose chatbot that user can use GPT, other AI models altogether"
8+
description = "Python multipurpose chatbot that user can use GPT, other AI models altogether"
99
authors = [{ name = "Jung Gyu Yoon", email = "[email protected]" }]
1010
license = { text = "MIT" }
1111
readme = "README.md"
1212
dependencies = [
13-
"PyQt5 >= 5.14",
14-
"PyQt6",
15-
"qtpy",
16-
"aiohttp",
13+
"PySide6",
1714
"openai",
1815
"pyperclip",
1916
"jinja2",
2017
"llama-index",
2118
"requests",
22-
"langchain",
23-
"pillow",
24-
"replicate",
25-
"toml"
19+
"replicate"
2620
]
2721
keywords = ['openai', 'pyqt', 'pyqt5', 'pyqt6', 'pyside6', 'chatbot', 'gpt', 'replicate']
2822

29-
requires-python = ">= 3.9"
30-
# 3.9
31-
# 3.10
23+
requires-python = ">= 3.11"
3224
# 3.11
3325
# 3.12
3426

@@ -39,8 +31,6 @@ classifiers = [
3931
"License :: OSI Approved :: MIT License",
4032
"Programming Language :: Python",
4133
"Programming Language :: Python :: 3",
42-
"Programming Language :: Python :: 3.9",
43-
"Programming Language :: Python :: 3.10",
4434
"Programming Language :: Python :: 3.11",
4535
"Programming Language :: Python :: 3.12",
4636
"Topic :: Software Development :: Libraries :: Application Frameworks",
@@ -52,7 +42,6 @@ homepage = "https://github.com/yjg30737/pyqt-openai.git"
5242

5343
[tool.setuptools]
5444
packages = ["pyqt_openai"]
55-
include_package_data = true
5645

5746
[project.gui-scripts]
5847
pyqt-openai = "pyqt_openai.main:main"

pyqt_openai/__init__.py

Lines changed: 122 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44

55
import json
66
import os
7-
from pathlib import Path
87

9-
import toml
8+
import tomllib # Python 3.11 built-in module
9+
from pathlib import Path
1010

1111
# Load the pyproject.toml file
1212
SRC_DIR = Path(__file__).resolve().parent
1313
ROOT_DIR = SRC_DIR.parent
1414
SETUP_FILENAME = ROOT_DIR / "pyproject.toml"
1515

16-
with open(SETUP_FILENAME, "r") as file:
17-
pyproject_data = toml.load(file)
16+
# Read the TOML file using tomllib (Python 3.11+)
17+
with open(SETUP_FILENAME, "rb") as file:
18+
pyproject_data = tomllib.load(file)
1819

1920
# For the sake of following the PEP8 standard, we will declare module-level dunder names.
2021
# PEP8 standard about dunder names: https://peps.python.org/pep-0008/#module-level-dunder-names
@@ -25,24 +26,29 @@
2526
# Constants
2627
# ----------------------------
2728
# APP
28-
APP_NAME = pyproject_data["project"]["name"]
29+
DEFAULT_APP_NAME = 'VividNode'
2930
CONTACT = pyproject_data["project"]["authors"][0]['email']
30-
APP_ICON = 'icon.ico'
31+
DEFAULT_APP_ICON = 'icon.ico'
3132
APP_INITIAL_WINDOW_SIZE = (1280, 768)
3233

3334
TRANSPARENT_RANGE = 20, 100
3435
TRANSPARENT_INIT_VAL = 100
3536

3637
LICENSE = pyproject_data["project"]["license"]['text']
3738
LICENSE_URL = 'https://github.com/yjg30737/pyqt-openai/blob/main/LICENSE'
39+
KOFI_URL = 'https://ko-fi.com/junggyuyoon'
3840
PAYPAL_URL = 'https://paypal.me/yjg30737'
39-
BUYMEACOFFEE_URL = 'https://www.buymeacoffee.com/yjg30737'
4041
GITHUB_URL = 'https://github.com/yjg30737/pyqt-openai'
4142
DISCORD_URL = 'https://discord.gg/cHekprskVE'
43+
44+
HOW_TO_GET_OPENAI_API_KEY_URL = 'https://medium.com/@yjg30737/how-to-get-your-openai-api-key-e2193850932e'
45+
HOW_TO_EXPORT_CHATGPT_CONVERSATION_HISTORY_URL = 'https://medium.com/@yjg30737/how-to-export-your-chatgpt-conversation-history-caa0946d6349'
46+
HOW_TO_REPLICATE = 'https://medium.com/@yjg30737/10a2cb983ceb'
47+
4248
COLUMN_TO_EXCLUDE_FROM_SHOW_HIDE_CHAT = ['id']
4349
COLUMN_TO_EXCLUDE_FROM_SHOW_HIDE_IMAGE = ['id', 'data']
4450
DEFAULT_LANGUAGE = 'en_US'
45-
LANGUAGE_FILE = 'translations.json'
51+
LANGUAGE_FILE = 'lang/translations.json'
4652
LANGUAGE_DICT = {
4753
"English": "en_US",
4854
"Spanish": "es_ES",
@@ -61,16 +67,19 @@
6167
"Portuguese": "pt_BR"
6268
}
6369

64-
MESSAGE_ADDITIONAL_HEIGHT = 40
6570
MESSAGE_PADDING = 16
6671
MESSAGE_MAXIMUM_HEIGHT = 800
6772
MAXIMUM_MESSAGES_IN_PARAMETER = 20
6873
MESSAGE_MAXIMUM_HEIGHT_RANGE = 300, 1000
6974
MAXIMUM_MESSAGES_IN_PARAMETER_RANGE = 2, 1000
7075

76+
CONTEXT_DELIMITER = '\n'*2
7177
PROMPT_IMAGE_SCALE = 200, 200
7278
TOAST_DURATION = 3
7379

80+
## OPENAI
81+
OPENAI_REQUEST_URL = 'https://api.openai.com/v1/models'
82+
7483
## PARAMETER - OPENAI CHAT
7584
OPENAI_TEMPERATURE_RANGE = 0, 2
7685
OPENAI_TEMPERATURE_STEP = 0.01
@@ -97,6 +106,7 @@
97106
ICON_EXPORT = 'ico/export.svg'
98107
ICON_FAVORITE_NO = 'ico/favorite_no.svg'
99108
ICON_FAVORITE_YES = 'ico/favorite_yes.svg'
109+
ICON_FOCUS_MODE = 'ico/focus_mode.svg'
100110
ICON_FULLSCREEN = 'ico/fullscreen.svg'
101111
ICON_GITHUB = 'ico/github.svg'
102112
ICON_HELP = 'ico/help.svg'
@@ -135,28 +145,49 @@
135145
DEFAULT_FOUND_TEXT_COLOR = '#00A2E8'
136146
DEFAULT_FOUND_TEXT_BG_COLOR = '#FFF200'
137147

148+
DEFAULT_LINK_COLOR = '#4F93FF'
149+
DEFAULT_LINK_HOVER_COLOR = '#FF0000'
150+
151+
DEFAULT_TOAST_BACKGROUND_COLOR = '#444444'
152+
DEFAULT_TOAST_FOREGROUND_COLOR = '#EEEEEE'
153+
154+
## MARKDOWN
155+
# I am not planning to use it at the moment.
156+
# DEFAULT_MARKDOWN_span_font = 'Courier New'
157+
# DEFAULT_MARKDOWN_span_color = '#000'
158+
# DEFAULT_MARKDOWN_ul_color = '#000'
159+
# DEFAULT_MARKDOWN_h1_color = '#000'
160+
# DEFAULT_MARKDOWN_h2_color = '#000'
161+
# DEFAULT_MARKDOWN_h3_color = '#000'
162+
# DEFAULT_MARKDOWN_h4_color = '#000'
163+
# DEFAULT_MARKDOWN_h5_color = '#000'
164+
# DEFAULT_MARKDOWN_h6_color = '#000'
165+
# DEFAULT_MARKDOWN_a_color = '#000'
166+
138167
## SHORTCUT
139-
DEFAULT_SHORTCUT_GENERAL_ACTION = 'Enter'
168+
DEFAULT_SHORTCUT_GENERAL_ACTION = 'Return'
140169
DEFAULT_SHORTCUT_FIND_PREV = 'Ctrl+Shift+D'
141170
DEFAULT_SHORTCUT_FIND_NEXT = 'Ctrl+D'
142171
DEFAULT_SHORTCUT_FIND_CLOSE = 'Escape'
143172
DEFAULT_SHORTCUT_PROMPT_BEGINNING = 'Ctrl+B'
144173
DEFAULT_SHORTCUT_PROMPT_ENDING = 'Ctrl+E'
145174
DEFAULT_SHORTCUT_SUPPORT_PROMPT_COMMAND = 'Ctrl+Shift+P'
175+
DEFAULT_SHORTCUT_SHOW_TOOLBAR = 'Ctrl+T'
176+
DEFAULT_SHORTCUT_SHOW_SECONDARY_TOOLBAR = 'Ctrl+Shift+T'
177+
DEFAULT_SHORTCUT_FOCUS_MODE = 'F10'
146178
DEFAULT_SHORTCUT_FULL_SCREEN = 'F11'
147179
DEFAULT_SHORTCUT_FIND = 'Ctrl+F'
148180
DEFAULT_SHORTCUT_JSON_MODE = 'Ctrl+J'
149181
DEFAULT_SHORTCUT_LEFT_SIDEBAR_WINDOW = 'Ctrl+L'
150182
DEFAULT_SHORTCUT_RIGHT_SIDEBAR_WINDOW = 'Ctrl+R'
151183
DEFAULT_SHORTCUT_CONTROL_PROMPT_WINDOW = 'Ctrl+Shift+C'
152184
DEFAULT_SHORTCUT_SETTING = 'Ctrl+Alt+S'
153-
DEFAULT_SHORTCUT_SEND = 'Ctrl+Enter'
185+
DEFAULT_SHORTCUT_SEND = 'Ctrl+Return'
154186

155187
## DIRECTORY PATH & FILE'S NAME
156188
MAIN_INDEX = 'main.py'
157189
IMAGE_DEFAULT_SAVE_DIRECTORY = 'image_result'
158-
LLAMA_INDEX_DEFAULT_READ_DIRECTORY = './example'
159-
INI_FILE_NAME = 'pyqt_openai.ini'
190+
INI_FILE_NAME = 'config.yaml'
160191
DB_FILE_NAME = 'conv'
161192
FILE_NAME_LENGTH = 32
162193
QFILEDIALOG_DEFAULT_DIRECTORY = os.path.expanduser('~')
@@ -179,6 +210,7 @@
179210
PROMPT_END_KEY_NAME = 'prompt_ending'
180211
PROMPT_NAME_REGEX = '^[a-zA-Z_0-9]+$'
181212
INDENT_SIZE = 4
213+
NOTIFIER_MAX_CHAR = 100
182214

183215
# DB
184216
DB_NAME_REGEX = '[a-zA-Z0-9]{1,20}'
@@ -264,6 +296,83 @@
264296
if os.path.exists(ALEX_BROGAN_PROMPT_FILENAME):
265297
ALEX_BROGAN_PROMPT = json.load(open(ALEX_BROGAN_PROMPT_FILENAME))[0]
266298

299+
# DEFAULT Configuration data for the application settings
300+
# Initialize here to avoid circular import
301+
# ----------------------------
302+
CONFIG_DATA = {
303+
'General': {
304+
'TAB_IDX': 0,
305+
'lang': 'English',
306+
'show_chat_list': True,
307+
'stream': True,
308+
'db': 'conv',
309+
'model': 'gpt-4o',
310+
'show_setting': True,
311+
'use_llama_index': False,
312+
'do_not_ask_again': False,
313+
'show_prompt': True,
314+
'system': 'You are a helpful assistant.',
315+
'notify_finish': True,
316+
'temperature': 1,
317+
'max_tokens': -1,
318+
'show_toolbar': True,
319+
'show_secondary_toolbar': True,
320+
'top_p': 1,
321+
'chat_column_to_show': ['id', 'name', 'insert_dt', 'update_dt'],
322+
'frequency_penalty': 0,
323+
'image_column_to_show': ['id', 'model', 'width', 'height', 'prompt', 'negative_prompt', 'n', 'quality', 'data', 'style', 'revised_prompt', 'update_dt', 'insert_dt'],
324+
'presence_penalty': 0,
325+
'json_object': False,
326+
'maximum_messages_in_parameter': MAXIMUM_MESSAGES_IN_PARAMETER,
327+
'show_as_markdown': True,
328+
'use_max_tokens': False,
329+
'background_image': '',
330+
'user_image': DEFAULT_USER_IMAGE_PATH,
331+
'ai_image': DEFAULT_AI_IMAGE_PATH,
332+
'font_size': DEFAULT_FONT_SIZE,
333+
'font_family': DEFAULT_FONT_FAMILY,
334+
'API_KEY': '',
335+
'llama_index_directory': '',
336+
'apply_user_defined_styles': False,
337+
'focus_mode': False,
338+
},
339+
'DALLE': {
340+
'quality': 'standard',
341+
'show_history': True,
342+
'n': 1,
343+
'show_setting': True,
344+
'size': '1024x1024',
345+
'directory': QFILEDIALOG_DEFAULT_DIRECTORY,
346+
'is_save': True,
347+
'continue_generation': False,
348+
'number_of_images_to_create': 2,
349+
'style': 'vivid',
350+
'response_format': 'b64_json',
351+
'save_prompt_as_text': True,
352+
'show_prompt_on_image': False,
353+
'prompt_type': 1,
354+
'width': 1024,
355+
'height': 1024,
356+
'prompt': "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
357+
},
358+
'REPLICATE': {
359+
'REPLICATE_API_TOKEN': '',
360+
'show_history': True,
361+
'model': 'stability-ai/sdxl:39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b',
362+
'show_setting': True,
363+
'width': 768,
364+
'height': 768,
365+
'prompt': "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
366+
'negative_prompt': "ugly, deformed, noisy, blurry, distorted",
367+
'directory': QFILEDIALOG_DEFAULT_DIRECTORY,
368+
'is_save': True,
369+
'continue_generation': False,
370+
'number_of_images_to_create': 2,
371+
'save_prompt_as_text': True,
372+
'show_prompt_on_image': False
373+
}
374+
}
375+
267376
# Update the __all__ list with the PEP8 standard dunder names
268377
__all__ = ['__version__',
269378
'__author__']

pyqt_openai/aboutDialog.py

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import datetime
2-
import pyqt_openai
32

4-
from qtpy.QtCore import Qt
5-
from qtpy.QtGui import QPixmap
6-
from qtpy.QtWidgets import QDialog, QPushButton, QHBoxLayout, QWidget, QVBoxLayout, QLabel
3+
from PySide6.QtCore import Qt
4+
from PySide6.QtGui import QPixmap
5+
from PySide6.QtWidgets import QDialog, QPushButton, QHBoxLayout, QWidget, QVBoxLayout, QLabel
76

8-
from pyqt_openai import APP_ICON, LICENSE_URL, GITHUB_URL, DISCORD_URL, APP_NAME, CONTACT
7+
import pyqt_openai
8+
from pyqt_openai import DEFAULT_APP_ICON, LICENSE_URL, DEFAULT_APP_NAME, CONTACT
99
from pyqt_openai.lang.translations import LangClass
1010
from pyqt_openai.widgets.linkLabel import LinkLabel
1111

@@ -22,13 +22,13 @@ def __initUi(self):
2222
self.__okBtn = QPushButton(LangClass.TRANSLATIONS['OK'])
2323
self.__okBtn.clicked.connect(self.accept)
2424

25-
p = QPixmap(APP_ICON)
25+
p = QPixmap(DEFAULT_APP_ICON)
2626
logoLbl = QLabel()
2727
logoLbl.setPixmap(p)
2828

2929
descWidget1 = QLabel()
3030
descWidget1.setText(f'''
31-
<h1>{APP_NAME}</h1>
31+
<h1>{DEFAULT_APP_NAME}</h1>
3232
Software Version {pyqt_openai.__version__}<br/><br/>
3333
© 2023 {datetime.datetime.now().year}. Used under the {pyqt_openai.LICENSE} License.<br/>
3434
Copyright (c) {datetime.datetime.now().year} {pyqt_openai.__author__}<br/>
@@ -41,36 +41,17 @@ def __initUi(self):
4141
descWidget3 = QLabel()
4242
descWidget3.setText(f'''
4343
<br/><br/>Contact: {CONTACT}<br/>
44-
<p>Powered by qtpy</p>
44+
<p>Powered by PySide6</p>
4545
''')
4646

4747
descWidget1.setAlignment(Qt.AlignmentFlag.AlignTop)
4848
descWidget2.setAlignment(Qt.AlignmentFlag.AlignTop)
4949
descWidget3.setAlignment(Qt.AlignmentFlag.AlignTop)
5050

51-
self.__githubLbl = LinkLabel()
52-
self.__githubLbl.setSvgFile(pyqt_openai.ICON_GITHUB)
53-
self.__githubLbl.setUrl(GITHUB_URL)
54-
55-
self.__discordLbl = LinkLabel()
56-
self.__discordLbl.setSvgFile(pyqt_openai.ICON_DISCORD)
57-
self.__discordLbl.setUrl(DISCORD_URL)
58-
self.__discordLbl.setFixedSize(22, 19)
59-
60-
lay = QHBoxLayout()
61-
lay.addWidget(self.__githubLbl)
62-
lay.addWidget(self.__discordLbl)
63-
lay.setAlignment(Qt.AlignmentFlag.AlignLeft)
64-
lay.setContentsMargins(0, 0, 0, 0)
65-
66-
linkWidget = QWidget()
67-
linkWidget.setLayout(lay)
68-
6951
lay = QVBoxLayout()
7052
lay.addWidget(descWidget1)
7153
lay.addWidget(descWidget2)
7254
lay.addWidget(descWidget3)
73-
lay.addWidget(linkWidget)
7455
lay.setAlignment(Qt.AlignmentFlag.AlignTop)
7556
lay.setContentsMargins(0, 0, 0, 0)
7657

0 commit comments

Comments
 (0)