Skip to content

Commit 5466d04

Browse files
committed
Remove llama-api, Update GUI, Add missing shortcuts to shortcut explorer dialog, support manual update, set manual update to default, change updateSoftwareDialog.py for supporting manual update feature
1 parent d993ab6 commit 5466d04

File tree

10 files changed

+76
-51
lines changed

10 files changed

+76
-51
lines changed

pyqt_openai/__init__.py

Lines changed: 29 additions & 28 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.6.0"
26+
__version__ = "1.5.0"
2727
__author__ = "Jung Gyu Yoon"
2828

2929
# Constants
@@ -79,11 +79,9 @@ def get_config_directory():
7979
BIN_DIR = get_config_directory()
8080

8181
UPDATER_NAME = "Updater.exe" if sys.platform == "win32" else "Updater"
82-
EDGE_TTS_NAME = "edge-tts.exe" if sys.platform == "win32" else "edge-tts"
8382

8483
# The default updater path (relative to the application's root directory) - For Windows
8584
UPDATER_PATH = os.path.join(BIN_DIR, UPDATER_NAME)
86-
EDGE_TTS_PATH = os.path.join(BIN_DIR, EDGE_TTS_NAME)
8785

8886
# Move the binary file to the config folder to prevent "file not found" error
8987
def move_bin(filename, dst_dir):
@@ -94,7 +92,6 @@ def move_bin(filename, dst_dir):
9492
shutil.move(original_path, dst_dir)
9593

9694
move_bin(UPDATER_NAME, UPDATER_PATH)
97-
move_bin(EDGE_TTS_NAME, EDGE_TTS_PATH)
9895

9996
CONTACT = "yjg30737@gmail.com"
10097
APP_INITIAL_WINDOW_SIZE = (1280, 768)
@@ -270,6 +267,10 @@ def move_bin(filename, dst_dir):
270267
DEFAULT_SHORTCUT_SETTING = f"{command_key}+Alt+S"
271268
DEFAULT_SHORTCUT_SEND = f"{command_key}+Return"
272269

270+
DEFAULT_SWITCH_PROMPT_UP = f"{command_key}+Up"
271+
DEFAULT_SWITCH_PROMPT_DOWN = f"{command_key}+Down"
272+
273+
273274
## DIRECTORY PATH & FILE'S NAME
274275
MAIN_INDEX = "main.py"
275276
IMAGE_DEFAULT_SAVE_DIRECTORY = "image_result"
@@ -430,7 +431,6 @@ def move_bin(filename, dst_dir):
430431
{"display_name": "OpenAI", "env_var_name": "OPENAI_API_KEY", "api_key": ""},
431432
{"display_name": "Gemini", "env_var_name": "GEMINI_API_KEY", "api_key": ""},
432433
{"display_name": "Claude", "env_var_name": "CLAUDE_API_KEY", "api_key": ""},
433-
{"display_name": "Llama", "env_var_name": "LLAMA_API_KEY", "api_key": ""},
434434

435435
# For G4F only
436436
{"display_name": "DeepInfra", "env_var_name": "DEEPINFRA_API_KEY", "api_key": ""},
@@ -455,8 +455,7 @@ def move_bin(filename, dst_dir):
455455
PROVIDER_MODEL_DICT = {
456456
"OpenAI": ["gpt-4o", "gpt-4o-mini"] + O1_MODELS,
457457
"Gemini": ["gemini-1.5-flash", "gemini-1.5-pro"],
458-
"Claude": ["claude-3-5-sonnet-20240620"],
459-
"Llama": ["llama3-70b"],
458+
"Claude": ["claude-3-5-sonnet-20240620"]
460459
}
461460

462461
# Constants related to the number of messages LLM will store
@@ -652,24 +651,25 @@ def move_bin(filename, dst_dir):
652651
# ----------------------------
653652
CONFIG_DATA = {
654653
"General": {
655-
"TAB_IDX": 0,
654+
# Language
656655
"lang": "English",
657-
"show_chat_list": True,
658-
"stream": True,
656+
# DB
659657
"db": "conv",
660-
"model": DEFAULT_LLM,
658+
# GUI & Application settings
659+
"TAB_IDX": 0,
660+
"show_chat_list": True,
661661
"show_setting": True,
662-
"use_llama_index": False,
663662
"do_not_ask_again": False,
664663
"show_prompt": True,
665-
"system": "You are a helpful assistant.",
666664
"notify_finish": True,
667-
"temperature": 1,
668-
"max_tokens": -1,
669665
"show_secondary_toolbar": True,
670-
"top_p": 1,
666+
"focus_mode": False,
667+
"show_as_markdown": True,
668+
"show_realtime_api": False,
669+
"run_at_startup": True,
670+
"manual_update": True,
671+
# Columns
671672
"chat_column_to_show": ["id", "name", "insert_dt", "update_dt"],
672-
"frequency_penalty": 0,
673673
"image_column_to_show": [
674674
"id",
675675
"model",
@@ -685,25 +685,28 @@ def move_bin(filename, dst_dir):
685685
"update_dt",
686686
"insert_dt",
687687
],
688+
# Parameters
689+
"model": DEFAULT_LLM,
690+
"system": "You are a helpful assistant.",
691+
"stream": True,
692+
"temperature": 1,
693+
"max_tokens": -1,
694+
"top_p": 1,
695+
"frequency_penalty": 0,
688696
"presence_penalty": 0,
689697
"json_object": False,
690698
"maximum_messages_in_parameter": MAXIMUM_MESSAGES_IN_PARAMETER,
691-
"show_as_markdown": True,
692-
"run_at_startup": True,
693699
"use_max_tokens": False,
700+
# Llama Index
701+
"use_llama_index": False,
702+
"llama_index_directory": "",
703+
# Customize
694704
"background_image": "",
695705
"user_image": DEFAULT_USER_IMAGE_PATH,
696706
"ai_image": DEFAULT_AI_IMAGE_PATH,
697707
"font_size": DEFAULT_FONT_SIZE,
698708
"font_family": DEFAULT_FONT_FAMILY,
699-
"llama_index_directory": "",
700709
"apply_user_defined_styles": False,
701-
"focus_mode": False,
702-
"OPENAI_API_KEY": "",
703-
"GEMINI_API_KEY": "",
704-
"CLAUDE_API_KEY": "",
705-
"LLAMA_API_KEY": "",
706-
"show_realtime_api": False,
707710
# G4F
708711
"g4f_model": DEFAULT_LLM,
709712
"provider": G4F_PROVIDER_DEFAULT,
@@ -766,13 +769,11 @@ def move_bin(filename, dst_dir):
766769
},
767770
}
768771

769-
770772
# Dynamically add the API keys to the configuration data
771773
def update_general_config_with_api_keys(config_data, api_configs):
772774
for config in api_configs:
773775
config_data["General"][config["env_var_name"]] = config["api_key"]
774776

775-
776777
update_general_config_with_api_keys(CONFIG_DATA, DEFAULT_API_CONFIGS)
777778

778779
# Set the default llama index cache directory for preventing any issues such as PermissionError

pyqt_openai/chat_widget/center/aiChatUnit.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def __initAIChatUi(self):
5050
self.__speakerBtn.toggled.connect(self.__speak)
5151
self.thread = None
5252

53-
self.getMenuWidget().layout().insertWidget(2, self.__favoriteBtn)
54-
self.getMenuWidget().layout().insertWidget(3, self.__infoBtn)
55-
self.getMenuWidget().layout().insertWidget(4, self.__speakerBtn)
53+
self.getMenuWidget().layout().insertWidget(3, self.__favoriteBtn)
54+
self.getMenuWidget().layout().insertWidget(4, self.__infoBtn)
55+
self.getMenuWidget().layout().insertWidget(5, self.__speakerBtn)
5656

5757
self.setBackgroundRole(QPalette.ColorRole.AlternateBase)
5858
self.setAutoFillBackground(True)
@@ -81,6 +81,7 @@ def __showFileListDialog(self):
8181
def afterResponse(self, arg):
8282
self.toggleGUI(True)
8383
self.__result_info = arg
84+
self._nameLbl.setText(arg.model)
8485
self.__favorite(True if arg.favorite else False, insert_f=False)
8586

8687
if arg.is_json_response_available:
@@ -95,10 +96,6 @@ def toggleGUI(self, f: bool):
9596
self.__infoBtn.setEnabled(f)
9697
self.__speakerBtn.setEnabled(f)
9798

98-
def __setResponseInfo(self, arg: ChatMessageContainer):
99-
self.__result_info = arg
100-
self.__favorite(True if arg.favorite else False, insert_f=False)
101-
10299
def getResponseInfo(self):
103100
"""
104101
Get the response information

pyqt_openai/chat_widget/center/chatHome.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
DEFAULT_APP_NAME,
99
HOW_TO_GET_OPENAI_API_KEY_URL,
1010
LARGE_LABEL_PARAM,
11-
MEDIUM_LABEL_PARAM,
11+
MEDIUM_LABEL_PARAM, QUICKSTART_MANUAL_URL,
1212
)
1313
from pyqt_openai.lang.translations import LangClass
1414
from pyqt_openai.widgets.linkLabel import LinkLabel
@@ -30,7 +30,7 @@ def __initUi(self):
3030

3131
self.__quickStartManualLbl = LinkLabel()
3232
self.__quickStartManualLbl.setText(LangClass.TRANSLATIONS["Quick Start Manual"])
33-
self.__quickStartManualLbl.setUrl(HOW_TO_GET_OPENAI_API_KEY_URL)
33+
self.__quickStartManualLbl.setUrl(QUICKSTART_MANUAL_URL)
3434
self.__quickStartManualLbl.setFont(QFont(*MEDIUM_LABEL_PARAM))
3535
self.__quickStartManualLbl.setAlignment(Qt.AlignmentFlag.AlignCenter)
3636

pyqt_openai/chat_widget/center/chatUnit.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
QVBoxLayout,
77
QHBoxLayout,
88
QSpacerItem,
9-
QSizePolicy,
9+
QSizePolicy, QLabel,
1010
)
1111

1212
from pyqt_openai import DEFAULT_ICON_SIZE, ICON_COPY
@@ -26,12 +26,16 @@ def __initUi(self):
2626

2727
self._icon = RoundedImage()
2828
self._icon.setMaximumSize(*DEFAULT_ICON_SIZE)
29+
self._icon.setStyleSheet('margin-right: 3px;')
30+
31+
self._nameLbl = QLabel()
2932

3033
self._copyBtn = Button()
3134
self._copyBtn.setStyleAndIcon(ICON_COPY)
3235
self._copyBtn.clicked.connect(self.__copy)
3336

3437
lay.addWidget(self._icon)
38+
lay.addWidget(self._nameLbl)
3539
lay.addSpacerItem(QSpacerItem(10, 10, QSizePolicy.Policy.MinimumExpanding))
3640
lay.addWidget(self._copyBtn)
3741
lay.setContentsMargins(2, 2, 2, 2)

pyqt_openai/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class SettingsParamsContainer(Container):
145145
show_as_markdown: bool = True
146146
apply_user_defined_styles: bool = False
147147
run_at_startup: bool = True
148+
manual_update: bool = True
148149

149150
voice_provider: str = TTS_DEFAULT_PROVIDER
150151
voice: str = TTS_DEFAULT_VOICE

pyqt_openai/settings_dialog/generalSettingsWidget.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __initVal(self):
5454
)
5555
self.show_as_markdown = CONFIG_MANAGER.get_general_property("show_as_markdown")
5656
self.run_at_startup = CONFIG_MANAGER.get_general_property("run_at_startup")
57+
self.manual_update = CONFIG_MANAGER.get_general_property("manual_update")
5758

5859
def __initUi(self):
5960
# Language setting
@@ -108,13 +109,25 @@ def __initUi(self):
108109
)
109110
self.__runAtStartupCheckBox.setChecked(self.run_at_startup)
110111

112+
self.__manual_updateCheckBox = QCheckBox(
113+
LangClass.TRANSLATIONS["Manual Update"]
114+
)
115+
self.__manual_updateCheckBox.setChecked(self.manual_update)
116+
117+
self.__manual_UpdateWarning = QLabel(
118+
LangClass.TRANSLATIONS["Auto-update is supported on Windows only."]
119+
)
120+
self.__manual_UpdateWarning.setStyleSheet("color: orange;")
121+
111122
lay = QVBoxLayout()
112123
lay.addWidget(langWidget)
113124
lay.addLayout(dbLayout)
114125
lay.addWidget(self.__doNotAskAgainCheckBox)
115126
lay.addWidget(self.__notifyFinishCheckBox)
116127
lay.addWidget(self.__showSecondaryToolBarChkBox)
117128
lay.addWidget(self.__runAtStartupCheckBox)
129+
lay.addWidget(self.__manual_updateCheckBox)
130+
lay.addWidget(self.__manual_UpdateWarning)
118131

119132
generalGrpBox = QGroupBox(LangClass.TRANSLATIONS["General"])
120133
generalGrpBox.setLayout(lay)
@@ -236,4 +249,5 @@ def getParam(self):
236249
"maximum_messages_in_parameter": self.__maximumMessagesInParameterSpinBox.value(),
237250
"show_as_markdown": self.__show_as_markdown.isChecked(),
238251
"run_at_startup": self.__runAtStartupCheckBox.isChecked(),
252+
"manual_update": self.__manual_updateCheckBox.isChecked(),
239253
}

pyqt_openai/settings_dialog/voiceSettingsWidget.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __initUi(self):
4848
self.__warningLbl = QLabel(
4949
"You need to install mpv to use edge-tts. "
5050
"<a href='https://mpv.io/installation/'>Link</a>"
51+
"<br>Also edge-tts can only be used when run with python."
5152
)
5253
self.__warningLbl.setOpenExternalLinks(True)
5354
self.__warningLbl.setStyleSheet(f"color: {DEFAULT_HIGHLIGHT_TEXT_COLOR};")

pyqt_openai/shortcutDialog.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
DEFAULT_SHORTCUT_SETTING,
1616
DEFAULT_SHORTCUT_SEND,
1717
DEFAULT_SHORTCUT_SHOW_SECONDARY_TOOLBAR,
18-
DEFAULT_SHORTCUT_FOCUS_MODE,
18+
DEFAULT_SHORTCUT_FOCUS_MODE, DEFAULT_SWITCH_PROMPT_UP, DEFAULT_SWITCH_PROMPT_DOWN,
1919
)
2020
from pyqt_openai.lang.translations import LangClass
2121

@@ -84,6 +84,14 @@ def __init__(self, parent=None):
8484
"label": LangClass.TRANSLATIONS["Send"],
8585
"value": DEFAULT_SHORTCUT_SEND,
8686
},
87+
"SWITCH_PROMPT_UP": {
88+
"label": LangClass.TRANSLATIONS["Switch Prompt Up"],
89+
"value": DEFAULT_SWITCH_PROMPT_UP,
90+
},
91+
"SWITCH_PROMPT_DOWN": {
92+
"label": LangClass.TRANSLATIONS["Switch Prompt Down"],
93+
"value": DEFAULT_SWITCH_PROMPT_DOWN,
94+
},
8795
}
8896
self.__initUi()
8997

pyqt_openai/updateSoftwareDialog.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
UPDATER_PATH,
2222
is_frozen,
2323
)
24+
from pyqt_openai.config_loader import CONFIG_MANAGER
2425
from pyqt_openai.lang.translations import LangClass
2526

2627

@@ -54,8 +55,7 @@ def __initUi(self):
5455
self.__updateManualLbl = QLabel()
5556

5657
lay.addWidget(self.releaseNoteBrowser)
57-
58-
if sys.platform == "win32":
58+
if sys.platform == "win32" and not CONFIG_MANAGER.get_general_property('manual_update'):
5959
update_url = f"https://github.com/{self.__owner}/{self.__repo}/releases/download/{self.__recent_version}/VividNode.zip"
6060

6161
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
@@ -69,13 +69,14 @@ def __initUi(self):
6969
else:
7070
self.__updateManualLbl.setText(
7171
f'<b>{LangClass.TRANSLATIONS["Update Available"]}</b>'
72-
+ f"""<br>
73-
Automatic updates are currently supported only on Windows.
74-
For manual updates, please click the link for the latest version and install the file appropriate for your operating system.
75-
Linux - Install via tar
76-
macOS - Install via dmg
72+
+ f"""<br>
73+
For manual updates, please click the link for the latest version and install the file appropriate for your operating system.<br>
74+
Windows - Install via exe or zip<br>
75+
Linux - Install via tar.gz<br>
76+
macOS - Install via dmg<br>
7777
"""
7878
)
79+
self.__updateManualLbl.setWordWrap(True)
7980
lay.addWidget(self.__updateManualLbl)
8081

8182

pyqt_openai/util/script.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
OPENAI_CHAT_ENDPOINT,
6666
STT_MODEL,
6767
DEFAULT_DATETIME_FORMAT,
68-
DEFAULT_TOKEN_CHUNK_SIZE, EDGE_TTS_PATH,
68+
DEFAULT_TOKEN_CHUNK_SIZE
6969
)
7070
from pyqt_openai.config_loader import CONFIG_MANAGER
7171
from pyqt_openai.globals import (
@@ -1159,12 +1159,10 @@ def run(self):
11591159
print(f"Media file: {mp3_fname}")
11601160
print(f"Subtitle file: {vtt_fname}\n")
11611161

1162-
_edge_tts_path = "edge-tts" if not is_frozen() else EDGE_TTS_PATH
1163-
11641162
if sys.platform == "win32":
11651163
with subprocess.Popen(
11661164
[
1167-
_edge_tts_path,
1165+
"edge-tts",
11681166
f"--write-media={mp3_fname}",
11691167
f"--write-subtitles={vtt_fname}",
11701168
f"--voice={self.input_args['voice']}",
@@ -1176,7 +1174,7 @@ def run(self):
11761174
else:
11771175
with subprocess.Popen(
11781176
[
1179-
_edge_tts_path,
1177+
"edge-tts",
11801178
f"--write-media={mp3_fname}",
11811179
f"--write-subtitles={vtt_fname}",
11821180
f"--voice={self.input_args['voice']}",

0 commit comments

Comments
 (0)