Skip to content

Commit fad2395

Browse files
committed
Bump ver, format
1 parent 549783f commit fad2395

File tree

13 files changed

+147
-81
lines changed

13 files changed

+147
-81
lines changed

pyqt_openai/__init__.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# For the sake of following the PEP8 standard, we will declare module-level dunder names.
2424
# PEP8 standard about dunder names: https://peps.python.org/pep-0008/#module-level-dunder-names
2525

26-
__version__ = "1.5.0"
26+
__version__ = "1.6.0"
2727
__author__ = "Jung Gyu Yoon"
2828

2929
# Constants
@@ -37,6 +37,7 @@
3737
# For Windows
3838
AUTOSTART_REGISTRY_KEY = r"Software\Microsoft\Windows\CurrentVersion\Run"
3939

40+
4041
# Check if the application is frozen (compiled with PyInstaller)
4142
# If this is main.py, it will return False, that means it is not frozen.
4243
def is_frozen():
@@ -81,6 +82,7 @@ def get_config_directory():
8182
# The default updater path (relative to the application's root directory) - For Windows
8283
UPDATER_PATH = os.path.join(UPDATE_DIR, "Updater.exe")
8384

85+
8486
# Move the Updater.exe to the config folder
8587
def move_updater():
8688
original_updater_path = os.path.join(ROOT_DIR, "Updater.exe")
@@ -357,7 +359,12 @@ def move_updater():
357359
WHISPER_TTS_MODEL = "tts-1"
358360

359361
## EDGE-TTS (TTS)
360-
EDGE_TTS_VOICE_TYPE = ["en-GB-SoniaNeural", "en-US-GuyNeural", "en-US-JennyNeural", "en-US-AvaMultilingualNeural"]
362+
EDGE_TTS_VOICE_TYPE = [
363+
"en-GB-SoniaNeural",
364+
"en-US-GuyNeural",
365+
"en-US-JennyNeural",
366+
"en-US-AvaMultilingualNeural",
367+
]
361368

362369
# TTS in general
363370
TTS_DEFAULT_PROVIDER = "OpenAI"
@@ -675,19 +682,17 @@ def move_updater():
675682
"GEMINI_API_KEY": "",
676683
"CLAUDE_API_KEY": "",
677684
"LLAMA_API_KEY": "",
678-
'show_realtime_api': False,
679-
685+
"show_realtime_api": False,
680686
# G4F
681687
"g4f_model": DEFAULT_LLM,
682688
"provider": G4F_PROVIDER_DEFAULT,
683689
"g4f_use_chat_history": G4F_USE_CHAT_HISTORY,
684-
685690
# STT and TTS settings
686691
"voice_provider": TTS_DEFAULT_PROVIDER,
687692
"voice": TTS_DEFAULT_VOICE,
688693
"voice_speed": TTS_DEFAULT_SPEED,
689694
"auto_play_voice": TTS_DEFAULT_AUTO_PLAY,
690-
"auto_stop_silence_duration": TTS_DEFAULT_AUTO_STOP_SILENCE_DURATION
695+
"auto_stop_silence_duration": TTS_DEFAULT_AUTO_STOP_SILENCE_DURATION,
691696
},
692697
"DALLE": {
693698
"quality": "standard",
@@ -698,7 +703,6 @@ def move_updater():
698703
"width": 1024,
699704
"height": 1024,
700705
"prompt_type": 1,
701-
702706
"show_history": True,
703707
"show_setting": True,
704708
"prompt": "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
@@ -714,7 +718,6 @@ def move_updater():
714718
"model": "stability-ai/sdxl:39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b",
715719
"width": 768,
716720
"height": 768,
717-
718721
"show_history": True,
719722
"show_setting": True,
720723
"prompt": "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
@@ -724,13 +727,11 @@ def move_updater():
724727
"number_of_images_to_create": 2,
725728
"save_prompt_as_text": True,
726729
"show_prompt_on_image": False,
727-
728730
"negative_prompt": "ugly, deformed, noisy, blurry, distorted",
729731
},
730732
"G4F_IMAGE": {
731733
"model": G4F_DEFAULT_IMAGE_MODEL,
732734
"provider": G4F_PROVIDER_DEFAULT,
733-
734735
"show_history": True,
735736
"show_setting": True,
736737
"prompt": "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
@@ -740,11 +741,11 @@ def move_updater():
740741
"number_of_images_to_create": 2,
741742
"save_prompt_as_text": True,
742743
"show_prompt_on_image": False,
743-
744744
"negative_prompt": "ugly, deformed, noisy, blurry, distorted",
745-
}
745+
},
746746
}
747747

748+
748749
# Dynamically add the API keys to the configuration data
749750
def update_general_config_with_api_keys(config_data, api_configs):
750751
for config in api_configs:
@@ -754,7 +755,7 @@ def update_general_config_with_api_keys(config_data, api_configs):
754755
update_general_config_with_api_keys(CONFIG_DATA, DEFAULT_API_CONFIGS)
755756

756757
# Set the default llama index cache directory for preventing any issues such as PermissionError
757-
os.environ['NLTK_DATA'] = os.path.join(get_config_directory(), "llama_index_cache")
758+
os.environ["NLTK_DATA"] = os.path.join(get_config_directory(), "llama_index_cache")
758759

759760
# Update the __all__ list with the PEP8 standard dunder names
760761
__all__ = ["__version__", "__author__"]

pyqt_openai/chat_widget/center/realtimeApiWidget.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ def __init__(self, parent=None):
1313
def initUI(self):
1414
lay = QVBoxLayout()
1515

16-
title = QLabel('Coming Soon...', self)
16+
title = QLabel("Coming Soon...", self)
1717
title.setFont(QFont(*LARGE_LABEL_PARAM))
1818
title.setAlignment(Qt.AlignmentFlag.AlignCenter)
1919

2020
lay.addWidget(title)
2121

22-
self.setLayout(lay)
22+
self.setLayout(lay)

pyqt_openai/chat_widget/chatMainWidget.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
QSplitter,
99
QFileDialog,
1010
QMessageBox,
11-
QPushButton, QStackedWidget,
11+
QPushButton,
12+
QStackedWidget,
1213
)
1314

1415
from pyqt_openai import (
@@ -22,7 +23,8 @@
2223
DEFAULT_SHORTCUT_LEFT_SIDEBAR_WINDOW,
2324
DEFAULT_SHORTCUT_CONTROL_PROMPT_WINDOW,
2425
DEFAULT_SHORTCUT_RIGHT_SIDEBAR_WINDOW,
25-
QFILEDIALOG_DEFAULT_DIRECTORY, ICON_REALTIME_API,
26+
QFILEDIALOG_DEFAULT_DIRECTORY,
27+
ICON_REALTIME_API,
2628
)
2729
from pyqt_openai.chat_widget.center.realtimeApiWidget import RealtimeApiWidget
2830
from pyqt_openai.config_loader import CONFIG_MANAGER
@@ -62,7 +64,9 @@ def __initVal(self):
6264
self.__notify_finish = CONFIG_MANAGER.get_general_property("notify_finish")
6365

6466
self.__show_chat_list = CONFIG_MANAGER.get_general_property("show_chat_list")
65-
self.__show_realtime_api = CONFIG_MANAGER.get_general_property("show_realtime_api")
67+
self.__show_realtime_api = CONFIG_MANAGER.get_general_property(
68+
"show_realtime_api"
69+
)
6670
self.__show_setting = CONFIG_MANAGER.get_general_property("show_setting")
6771
self.__show_prompt = CONFIG_MANAGER.get_general_property("show_prompt")
6872

@@ -118,9 +122,7 @@ def __initUi(self):
118122

119123
self.__useRealtimeApiBtn = Button()
120124
self.__useRealtimeApiBtn.setStyleAndIcon(ICON_REALTIME_API)
121-
self.__useRealtimeApiBtn.setToolTip(
122-
LangClass.TRANSLATIONS["Use Realtime API"]
123-
)
125+
self.__useRealtimeApiBtn.setToolTip(LangClass.TRANSLATIONS["Use Realtime API"])
124126
self.__useRealtimeApiBtn.setCheckable(True)
125127
self.__useRealtimeApiBtn.setChecked(self.__show_realtime_api)
126128
self.__useRealtimeApiBtn.toggled.connect(self.toggleRealtimeApiScreen)
@@ -243,7 +245,9 @@ def toggleSideBar(self, x):
243245
def toggleRealtimeApiScreen(self, x):
244246
self.__centerWidget.setCurrentIndex(1 if x else 0)
245247
self.__show_realtime_api = x
246-
CONFIG_MANAGER.set_general_property("show_realtime_api", self.__show_realtime_api)
248+
CONFIG_MANAGER.set_general_property(
249+
"show_realtime_api", self.__show_realtime_api
250+
)
247251

248252
def toggleSetting(self, x):
249253
self.__chatRightSideBarWidget.setVisible(x)

pyqt_openai/config_loader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def set_g4f_image_property(self, key, value):
125125
self.config["G4F_IMAGE"][key] = value
126126
self._save_yaml()
127127

128+
128129
def update_api_key(yaml_file_path):
129130
with open(yaml_file_path, "r") as file:
130131
data = yaml.safe_load(file)

pyqt_openai/g4f_image_widget/g4fImageHome.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ def __init__(self, parent=None):
1212

1313
def __initUi(self):
1414
# TODO LANGUAGE
15-
title = QLabel("Welcome to GPT4Free\n" +
16-
"Image Generation Page !", self)
15+
title = QLabel("Welcome to GPT4Free\n" + "Image Generation Page !", self)
1716
title.setFont(QFont(*LARGE_LABEL_PARAM))
1817
title.setAlignment(Qt.AlignmentFlag.AlignCenter)
1918

20-
description = QLabel("Generate images for free with the power of G4F." + CONTEXT_DELIMITER)
19+
description = QLabel(
20+
"Generate images for free with the power of G4F." + CONTEXT_DELIMITER
21+
)
2122

2223
description.setFont(QFont(*MEDIUM_LABEL_PARAM))
2324
description.setAlignment(Qt.AlignmentFlag.AlignCenter)

pyqt_openai/g4f_image_widget/g4fImageRightSideBar.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55
QPlainTextEdit,
66
QFormLayout,
77
QLabel,
8-
QSplitter, QComboBox,
8+
QSplitter,
9+
QComboBox,
910
)
1011

1112
from pyqt_openai.config_loader import CONFIG_MANAGER
1213
from pyqt_openai.g4f_image_widget.g4fImageThread import G4FImageThread
1314
from pyqt_openai.lang.translations import LangClass
14-
from pyqt_openai.util.script import get_g4f_image_providers, get_g4f_image_models_from_provider, get_g4f_image_models
15+
from pyqt_openai.util.script import (
16+
get_g4f_image_providers,
17+
get_g4f_image_models_from_provider,
18+
get_g4f_image_models,
19+
)
1520
from pyqt_openai.widgets.imageControlWidget import ImageControlWidget
1621

1722

pyqt_openai/g4f_image_widget/g4fImageThread.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ def stop(self):
2929
def run(self):
3030
try:
3131
provider = G4F_PROVIDER_DEFAULT
32-
if self.__input_args['provider'] != G4F_PROVIDER_DEFAULT:
33-
provider = self.__input_args['provider']
34-
self.__input_args["provider"] = convert_to_provider(self.__input_args['provider'])
32+
if self.__input_args["provider"] != G4F_PROVIDER_DEFAULT:
33+
provider = self.__input_args["provider"]
34+
self.__input_args["provider"] = convert_to_provider(
35+
self.__input_args["provider"]
36+
)
3537

3638
for _ in range(self.__number_of_images):
3739
if self.__stop:
@@ -45,9 +47,7 @@ def run(self):
4547
images.provider = self.__input_args["provider"]
4648
else:
4749
del self.__input_args["provider"]
48-
response = images.generate(
49-
**self.__input_args
50-
)
50+
response = images.generate(**self.__input_args)
5151
arg = {
5252
**self.__input_args,
5353
"provider": provider,
@@ -58,4 +58,4 @@ def run(self):
5858
self.replyGenerated.emit(result)
5959
self.allReplyGenerated.emit()
6060
except Exception as e:
61-
self.errorGenerated.emit(str(e))
61+
self.errorGenerated.emit(str(e))

pyqt_openai/mainWindow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
ICON_PAYPAL,
4545
ICON_KOFI,
4646
ICON_PATREON,
47-
PATREON_URL, ICON_UPDATE, ICON_SHORTCUT,
47+
PATREON_URL,
48+
ICON_UPDATE,
49+
ICON_SHORTCUT,
4850
)
4951
from pyqt_openai.aboutDialog import AboutDialog
5052
from pyqt_openai.chat_widget.chatMainWidget import ChatMainWidget

pyqt_openai/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
DEFAULT_AI_IMAGE_PATH,
1414
MAXIMUM_MESSAGES_IN_PARAMETER,
1515
TTS_DEFAULT_VOICE,
16-
TTS_DEFAULT_SPEED, TTS_DEFAULT_AUTO_PLAY, TTS_DEFAULT_AUTO_STOP_SILENCE_DURATION, TTS_DEFAULT_PROVIDER,
16+
TTS_DEFAULT_SPEED,
17+
TTS_DEFAULT_AUTO_PLAY,
18+
TTS_DEFAULT_AUTO_STOP_SILENCE_DURATION,
19+
TTS_DEFAULT_PROVIDER,
1720
)
1821
from pyqt_openai.lang.translations import LangClass
1922

@@ -149,6 +152,7 @@ class SettingsParamsContainer(Container):
149152
auto_play_voice: bool = TTS_DEFAULT_AUTO_PLAY
150153
auto_stop_silence_duration: int = TTS_DEFAULT_AUTO_STOP_SILENCE_DURATION
151154

155+
152156
@dataclass
153157
class CustomizeParamsContainer(Container):
154158
background_image: str = ""

pyqt_openai/settings_dialog/voiceSettingsWidget.py

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
from PySide6.QtWidgets import QWidget, QComboBox, QFormLayout, QDoubleSpinBox, QGroupBox, QVBoxLayout, QSpinBox, \
2-
QCheckBox, QLabel
3-
4-
from pyqt_openai import WHISPER_TTS_VOICE_TYPE, WHISPER_TTS_VOICE_SPEED_RANGE, EDGE_TTS_VOICE_TYPE
1+
from PySide6.QtWidgets import (
2+
QWidget,
3+
QComboBox,
4+
QFormLayout,
5+
QDoubleSpinBox,
6+
QGroupBox,
7+
QVBoxLayout,
8+
QSpinBox,
9+
QCheckBox,
10+
QLabel,
11+
)
12+
13+
from pyqt_openai import (
14+
WHISPER_TTS_VOICE_TYPE,
15+
WHISPER_TTS_VOICE_SPEED_RANGE,
16+
EDGE_TTS_VOICE_TYPE,
17+
)
518
from pyqt_openai.config_loader import CONFIG_MANAGER
619
from pyqt_openai.lang.translations import LangClass
720

@@ -17,22 +30,28 @@ def __initVal(self):
1730
self.voice = CONFIG_MANAGER.get_general_property("voice")
1831
self.speed = CONFIG_MANAGER.get_general_property("voice_speed")
1932
self.auto_play = CONFIG_MANAGER.get_general_property("auto_play_voice")
20-
self.auto_stop_silence_duration = CONFIG_MANAGER.get_general_property("auto_stop_silence_duration")
33+
self.auto_stop_silence_duration = CONFIG_MANAGER.get_general_property(
34+
"auto_stop_silence_duration"
35+
)
2136

2237
def __initUi(self):
2338
ttsGrpBox = QGroupBox("Text to Speech")
2439

2540
self.__voiceProviderCmbBox = QComboBox()
26-
self.__voiceProviderCmbBox.addItems(['OpenAI', 'edge-tts'])
41+
self.__voiceProviderCmbBox.addItems(["OpenAI", "edge-tts"])
2742
self.__voiceProviderCmbBox.setCurrentText(self.voice_provider)
28-
self.__voiceProviderCmbBox.currentTextChanged.connect(self.__voiceProviderChanged)
43+
self.__voiceProviderCmbBox.currentTextChanged.connect(
44+
self.__voiceProviderChanged
45+
)
2946

3047
# TODO LANGUAGE
31-
self.__warningLbl = QLabel("You need to install mpv to use edge-tts. "
32-
"<a href='https://mpv.io/installation/'>Link</a>")
48+
self.__warningLbl = QLabel(
49+
"You need to install mpv to use edge-tts. "
50+
"<a href='https://mpv.io/installation/'>Link</a>"
51+
)
3352
self.__warningLbl.setOpenExternalLinks(True)
3453
self.__warningLbl.setStyleSheet("color: yellow;")
35-
self.__warningLbl.setVisible(self.voice_provider == 'edge-tts')
54+
self.__warningLbl.setVisible(self.voice_provider == "edge-tts")
3655

3756
detailsGroupBox = QGroupBox("Details")
3857

@@ -46,7 +65,9 @@ def __initUi(self):
4665
self.__speedSpinBox.setValue(float(self.speed))
4766

4867
# Auto-Play voice when response is received
49-
self.__autoPlayChkBox = QCheckBox("Auto-Play Voice when Response is Received (Work in Progress)")
68+
self.__autoPlayChkBox = QCheckBox(
69+
"Auto-Play Voice when Response is Received (Work in Progress)"
70+
)
5071
self.__autoPlayChkBox.setChecked(self.auto_play)
5172
# TODO implement auto-play voice in v1.7.0
5273
self.__autoPlayChkBox.setEnabled(False)
@@ -74,7 +95,10 @@ def __initUi(self):
7495
self.__autoStopSilenceDurationSpinBox.setEnabled(False)
7596

7697
lay = QFormLayout()
77-
lay.addRow("Auto-Stop Silence Duration (Work in Progress)", self.__autoStopSilenceDurationSpinBox)
98+
lay.addRow(
99+
"Auto-Stop Silence Duration (Work in Progress)",
100+
self.__autoStopSilenceDurationSpinBox,
101+
)
78102

79103
sttGrpBox.setLayout(lay)
80104

@@ -94,11 +118,11 @@ def getParam(self):
94118
}
95119

96120
def __voiceProviderChanged(self, text):
97-
f = text == 'OpenAI'
121+
f = text == "OpenAI"
98122
if f:
99123
self.__voiceCmbBox.clear()
100124
self.__voiceCmbBox.addItems(WHISPER_TTS_VOICE_TYPE)
101125
else:
102126
self.__voiceCmbBox.clear()
103127
self.__voiceCmbBox.addItems(EDGE_TTS_VOICE_TYPE)
104-
self.__warningLbl.setVisible(not f)
128+
self.__warningLbl.setVisible(not f)

0 commit comments

Comments
 (0)