Skip to content

Commit 3f0e3f0

Browse files
committed
Format, ready for paste txt file feature
1 parent cb4a6c8 commit 3f0e3f0

File tree

12 files changed

+79
-36
lines changed

12 files changed

+79
-36
lines changed

pyqt_openai/__init__.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,15 @@ def get_config_directory():
7676

7777
return config_dir
7878

79+
7980
BIN_DIR = get_config_directory()
8081

8182
UPDATER_NAME = "Updater.exe" if sys.platform == "win32" else "Updater"
8283

8384
# The default updater path (relative to the application's root directory) - For Windows
8485
UPDATER_PATH = os.path.join(BIN_DIR, UPDATER_NAME)
8586

87+
8688
# Move the binary file to the config folder to prevent "file not found" error
8789
def move_bin(filename, dst_dir):
8890
original_path = os.path.join(ROOT_DIR, filename)
@@ -91,6 +93,7 @@ def move_bin(filename, dst_dir):
9193
os.remove(dst_dir)
9294
shutil.move(original_path, dst_dir)
9395

96+
9497
move_bin(UPDATER_NAME, UPDATER_PATH)
9598

9699
CONTACT = "yjg30737@gmail.com"
@@ -240,7 +243,6 @@ def move_bin(filename, dst_dir):
240243
# DEFAULT_MARKDOWN_a_color = '#000'
241244

242245

243-
244246
command_key = "Ctrl"
245247
if sys.platform == "darwin":
246248
command_key = "Cmd"
@@ -431,13 +433,20 @@ def move_bin(filename, dst_dir):
431433
{"display_name": "OpenAI", "env_var_name": "OPENAI_API_KEY", "api_key": ""},
432434
{"display_name": "Gemini", "env_var_name": "GEMINI_API_KEY", "api_key": ""},
433435
{"display_name": "Claude", "env_var_name": "CLAUDE_API_KEY", "api_key": ""},
434-
435436
# For G4F only
436437
{"display_name": "DeepInfra", "env_var_name": "DEEPINFRA_API_KEY", "api_key": ""},
437438
{"display_name": "Groq", "env_var_name": "GROQ_API_KEY", "api_key": ""},
438-
{"display_name": "HuggingFace", "env_var_name": "HUGGINGFACE_API_KEY", "api_key": ""},
439+
{
440+
"display_name": "HuggingFace",
441+
"env_var_name": "HUGGINGFACE_API_KEY",
442+
"api_key": "",
443+
},
439444
{"display_name": "OpenRouter", "env_var_name": "OPENROUTER_API_KEY", "api_key": ""},
440-
{"display_name": "Perplexity API", "env_var_name": "PERPLEXITY_API_KEY", "api_key": ""}
445+
{
446+
"display_name": "Perplexity API",
447+
"env_var_name": "PERPLEXITY_API_KEY",
448+
"api_key": "",
449+
},
441450
]
442451

443452
# This has to be managed separately since some of the arguments are different with usual models
@@ -455,7 +464,7 @@ def move_bin(filename, dst_dir):
455464
PROVIDER_MODEL_DICT = {
456465
"OpenAI": ["gpt-4o", "gpt-4o-mini"] + O1_MODELS,
457466
"Gemini": ["gemini-1.5-flash", "gemini-1.5-pro"],
458-
"Claude": ["claude-3-5-sonnet-20240620"]
467+
"Claude": ["claude-3-5-sonnet-20240620"],
459468
}
460469

461470
# Constants related to the number of messages LLM will store
@@ -769,11 +778,13 @@ def move_bin(filename, dst_dir):
769778
},
770779
}
771780

781+
772782
# Dynamically add the API keys to the configuration data
773783
def update_general_config_with_api_keys(config_data, api_configs):
774784
for config in api_configs:
775785
config_data["General"][config["env_var_name"]] = config["api_key"]
776786

787+
777788
update_general_config_with_api_keys(CONFIG_DATA, DEFAULT_API_CONFIGS)
778789

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

pyqt_openai/chat_widget/center/aiChatUnit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
ICON_INFO,
77
ICON_FAVORITE_YES,
88
ICON_SPEAKER,
9-
WHISPER_TTS_MODEL, ICON_FILE,
9+
WHISPER_TTS_MODEL,
10+
ICON_FILE,
1011
)
1112
from pyqt_openai.config_loader import CONFIG_MANAGER
1213
from pyqt_openai.chat_widget.center.chatUnit import ChatUnit

pyqt_openai/chat_widget/center/chatHome.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
DEFAULT_APP_NAME,
99
HOW_TO_GET_OPENAI_API_KEY_URL,
1010
LARGE_LABEL_PARAM,
11-
MEDIUM_LABEL_PARAM, QUICKSTART_MANUAL_URL,
11+
MEDIUM_LABEL_PARAM,
12+
QUICKSTART_MANUAL_URL,
1213
)
1314
from pyqt_openai.lang.translations import LangClass
1415
from pyqt_openai.widgets.linkLabel import LinkLabel

pyqt_openai/chat_widget/center/chatUnit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
QVBoxLayout,
77
QHBoxLayout,
88
QSpacerItem,
9-
QSizePolicy, QLabel,
9+
QSizePolicy,
10+
QLabel,
1011
)
1112

1213
from pyqt_openai import DEFAULT_ICON_SIZE, ICON_COPY
@@ -26,7 +27,7 @@ def __initUi(self):
2627

2728
self._icon = RoundedImage()
2829
self._icon.setMaximumSize(*DEFAULT_ICON_SIZE)
29-
self._icon.setStyleSheet('margin-right: 3px;')
30+
self._icon.setStyleSheet("margin-right: 3px;")
3031

3132
self._nameLbl = QLabel()
3233

pyqt_openai/chat_widget/center/textEditPromptGroup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
PROMPT_END_KEY_NAME,
1111
PROMPT_JSON_KEY_NAME,
1212
CONTEXT_DELIMITER,
13-
IMAGE_FILE_EXT_LIST,
13+
IMAGE_FILE_EXT_LIST, TEXT_FILE_EXT_LIST,
1414
)
1515
from pyqt_openai.chat_widget.center.textEditPrompt import TextEditPrompt
1616
from pyqt_openai.lang.translations import LangClass
@@ -22,6 +22,7 @@ class TextEditPromptGroup(QWidget):
2222
onUpdateSuggestion = Signal()
2323
onSendKeySignalToSuggestion = Signal(str)
2424
onPasteFile = Signal(QByteArray)
25+
onPasteText = Signal(str)
2526

2627
def __init__(self, parent=None):
2728
super().__init__(parent)
@@ -153,6 +154,10 @@ def handleDrop(self, urls):
153154
with open(url, "rb") as f:
154155
data = f.read()
155156
self.onPasteFile.emit(data)
157+
elif Path(url).suffix in TEXT_FILE_EXT_LIST:
158+
with open(url, "r") as f:
159+
data = f.read()
160+
self.onPasteText.emit(data)
156161

157162
def handlePaste(self):
158163
clipboard = QApplication.clipboard()
@@ -181,6 +186,9 @@ def handlePaste(self):
181186

182187
# Emit the image data
183188
self.onPasteFile.emit(image_data)
189+
elif mime_data.hasText():
190+
text = mime_data.text()
191+
self.onPasteText.emit(text)
184192
else:
185193
self.__textEdit.paste()
186194

pyqt_openai/settings_dialog/apiWidget.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ def __initVal(self):
6464
"Gemini": HOW_TO_GET_GEMINI_API_KEY_URL,
6565
"Llama": HOW_TO_GET_LLAMA_API_KEY_URL,
6666
"Replicate": HOW_TO_REPLICATE,
67-
"DeepInfra": '',
68-
"Groq": '',
69-
"HuggingFace": '',
70-
"OpenRouter": '',
71-
"Perplexity API": '',
67+
"DeepInfra": "",
68+
"Groq": "",
69+
"HuggingFace": "",
70+
"OpenRouter": "",
71+
"Perplexity API": "",
7272
}[obj["display_name"]]
7373

7474
def __initUi(self):

pyqt_openai/settings_dialog/voiceSettingsWidget.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
from pyqt_openai import (
1414
WHISPER_TTS_VOICE_TYPE,
1515
WHISPER_TTS_VOICE_SPEED_RANGE,
16-
EDGE_TTS_VOICE_TYPE, DEFAULT_HIGHLIGHT_TEXT_COLOR,
16+
EDGE_TTS_VOICE_TYPE,
17+
DEFAULT_HIGHLIGHT_TEXT_COLOR,
1718
)
1819
from pyqt_openai.config_loader import CONFIG_MANAGER
1920
from pyqt_openai.lang.translations import LangClass

pyqt_openai/shortcutDialog.py

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

pyqt_openai/sqlite.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
PROMPT_GROUP_TABLE_NAME,
1616
PROMPT_ENTRY_TABLE_NAME,
1717
get_config_directory,
18-
DEFAULT_DATETIME_FORMAT, CHAT_FILE_TABLE_NAME,
18+
DEFAULT_DATETIME_FORMAT,
19+
CHAT_FILE_TABLE_NAME,
1920
)
2021
from pyqt_openai.config_loader import CONFIG_MANAGER
2122
from pyqt_openai.models import (

pyqt_openai/updateSoftwareDialog.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def __initUi(self):
5555
self.__updateManualLbl = QLabel()
5656

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

6163
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
@@ -70,10 +72,12 @@ def __initUi(self):
7072
self.__updateManualLbl.setText(
7173
f'<b>{LangClass.TRANSLATIONS["Update Available"]}</b>'
7274
+ f"""<br>
73-
For manual updates, please click the link for the latest version and install the file appropriate for your operating system.<br>
75+
For manual updates, please click the link for the latest version and install the file appropriate for your operating system.<br><br>
7476
Windows - Install via exe or zip<br>
7577
Linux - Install via tar.gz<br>
7678
macOS - Install via dmg<br>
79+
<br>
80+
If you want to enable automatic updates, please go to the settings and enable the option.
7781
"""
7882
)
7983
self.__updateManualLbl.setWordWrap(True)

0 commit comments

Comments
 (0)