Skip to content

Commit 3fcb0ee

Browse files
committed
Update
1 parent 41c67cf commit 3fcb0ee

File tree

9 files changed

+61
-12
lines changed

9 files changed

+61
-12
lines changed

pyqt_openai/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,7 @@ def move_bin(filename, dst_dir):
11391139
"model",
11401140
"width",
11411141
"height",
1142+
"provider",
11421143
"prompt",
11431144
"negative_prompt",
11441145
"n",

pyqt_openai/aboutDialog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __initUi(self):
5454
<p>Powered by PySide6</p>
5555
<p>Powered by GPT4Free</p>
5656
<p>Powered by LiteLLM</p>
57+
<p>Powered by LlamaIndex</p>
5758
"""
5859
)
5960

pyqt_openai/chat_widget/right_sidebar/usingAPIPage.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
init_llama,
4141
)
4242
from pyqt_openai.widgets.linkLabel import LinkLabel
43-
from pyqt_openai.widgets.modernButton import ModernButton
43+
from pyqt_openai.widgets.APIInputButton import APIInputButton
4444

4545

4646
class UsingAPIPage(QWidget):
@@ -123,15 +123,12 @@ def __initUi(self):
123123
modelSearchBar.setText(self.__model)
124124
modelSearchBar.textChanged.connect(self.__modelChanged)
125125

126-
prefixListBtn = ModernButton()
127-
prefixListBtn.setText("Prefix List")
128-
129126
lay = QHBoxLayout()
130127
lay.addWidget(QLabel(LangClass.TRANSLATIONS["Model"]))
131128
lay.addWidget(modelSearchBar)
132129
lay.setContentsMargins(0, 0, 0, 0)
133130

134-
setApiBtn = ModernButton()
131+
setApiBtn = APIInputButton()
135132
# TODO LANGUAGE
136133
setApiBtn.setText("Set API Key")
137134

pyqt_openai/dalle_widget/dalleRightSideBar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pyqt_openai.dalle_widget.dalleThread import DallEThread
1414
from pyqt_openai.lang.translations import LangClass
1515
from pyqt_openai.widgets.imageControlWidget import ImageControlWidget
16-
from pyqt_openai.widgets.modernButton import ModernButton
16+
from pyqt_openai.widgets.APIInputButton import APIInputButton
1717

1818

1919
class DallERightSideBarWidget(ImageControlWidget):
@@ -51,7 +51,7 @@ def _initUi(self):
5151
super()._initUi()
5252

5353
# TODO LANGUAGE
54-
self.__setApiBtn = ModernButton()
54+
self.__setApiBtn = APIInputButton()
5555
self.__setApiBtn.setText("Set API Key")
5656

5757
self.__promptTypeToShowRadioGrpBox = QGroupBox(

pyqt_openai/replicate_widget/replicateRightSideBar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pyqt_openai.lang.translations import LangClass
1414
from pyqt_openai.replicate_widget.replicateThread import ReplicateThread
1515
from pyqt_openai.widgets.imageControlWidget import ImageControlWidget
16-
from pyqt_openai.widgets.modernButton import ModernButton
16+
from pyqt_openai.widgets.APIInputButton import APIInputButton
1717

1818

1919
class ReplicateRightSideBarWidget(ImageControlWidget):
@@ -49,7 +49,7 @@ def _initUi(self):
4949
super()._initUi()
5050

5151
# TODO LANGUAGE
52-
self.__setApiBtn = ModernButton()
52+
self.__setApiBtn = APIInputButton()
5353
self.__setApiBtn.setText("Set API Key")
5454

5555
self.__modelTextEdit = QPlainTextEdit()

pyqt_openai/settings_dialog/apiWidget.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __initVal(self):
3939
def __initUi(self):
4040
self.setWindowTitle("API Key")
4141

42-
columns = ["Provider", "API Key", "Get API Key"]
42+
columns = ["Provider", "API Key", "Manual URL"]
4343
self.__tableWidget = QTableWidget()
4444
self.__tableWidget.setColumnCount(len(columns))
4545
self.__tableWidget.setHorizontalHeaderLabels(columns)
@@ -51,6 +51,8 @@ def __initUi(self):
5151
for i, obj in enumerate(self.__api_keys):
5252
self.__tableWidget.insertRow(i)
5353
modelItem = QTableWidgetItem(obj["display_name"])
54+
# Make item not editable
55+
modelItem.setFlags(modelItem.flags() & ~Qt.ItemFlag.ItemIsEditable)
5456
self.__tableWidget.setItem(i, 0, modelItem)
5557

5658
apiKeyLineEdit = QLineEdit(obj["api_key"])

pyqt_openai/util/common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
OPENAI_CHAT_ENDPOINT,
6767
STT_MODEL,
6868
DEFAULT_DATETIME_FORMAT,
69-
DEFAULT_TOKEN_CHUNK_SIZE,
69+
DEFAULT_TOKEN_CHUNK_SIZE, DEFAULT_API_CONFIGS,
7070
)
7171
from pyqt_openai.config_loader import CONFIG_MANAGER
7272
from pyqt_openai.globals import (
@@ -1335,3 +1335,7 @@ def stream_to_speakers(voice_provider, input_args):
13351335
stream_thread = TTSThread(voice_provider, input_args)
13361336
pyqt_openai.util.common.current_tts_thread = stream_thread
13371337
return stream_thread
1338+
1339+
1340+
def get_litellm_prefixes():
1341+
return [{'Provider': obj.get('display_name', ''), 'Prefix': obj.get('prefix', '')} for obj in DEFAULT_API_CONFIGS]

pyqt_openai/widgets/modernButton.py renamed to pyqt_openai/widgets/APIInputButton.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pyqt_openai.settings_dialog.settingsDialog import SettingsDialog
66

77

8-
class ModernButton(QPushButton):
8+
class APIInputButton(QPushButton):
99
def __init__(self, base_color="#007BFF"):
1010
super().__init__()
1111
self.setObjectName("modernButton")
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from PySide6.QtCore import Qt
2+
from PySide6.QtGui import QFont
3+
from PySide6.QtWidgets import QDialog, QLabel, QHBoxLayout, QTableWidget
4+
5+
from pyqt_openai import SMALL_LABEL_PARAM
6+
from pyqt_openai.util.common import get_litellm_prefixes
7+
8+
9+
class ModelInputManualDialog(QDialog):
10+
def __init__(self, parent=None):
11+
super().__init__(parent)
12+
self.__initVal()
13+
self.__initUi()
14+
15+
def __initVal(self):
16+
self.__warningMessage = (
17+
"💡 <b>Tip</b> For models other than OpenAI and Anthropic, enter the model name as `[ProviderName]/[ModelName]`.\n\n"
18+
"🔗 For details on `ProviderName` and `ModelName`, check out the "
19+
"<a href='https://docs.litellm.ai/docs/providers'>LiteLLM documentation</a>! 😊\n\n"
20+
"⚠️ Note: Some models may not support <b>JSON Mode</b> or <b>LlamaIndex</b> features."
21+
)
22+
23+
def __initUi(self):
24+
self.__warningLbl = QLabel()
25+
self.__warningLbl.setStyleSheet("color: orange;")
26+
self.__warningLbl.setOpenExternalLinks(True)
27+
self.__warningLbl.setFont(QFont(SMALL_LABEL_PARAM))
28+
self.__warningLbl.setText(self.__warningMessage)
29+
self.__warningLbl.setTextInteractionFlags(
30+
Qt.TextInteractionFlag.TextSelectableByMouse
31+
)
32+
33+
# prefixTable = QTableWidget()
34+
# prefixes = get_litellm_prefixes()
35+
# prefixTable.setColumnCount(len(list(prefixes[0].keys())))
36+
# prefixTable.setHorizontalHeaderLabels(list(prefixes[0].keys()))
37+
# for prefix in prefixes:
38+
# prefixTable.insertRow(prefixTable.rowCount())
39+
# prefixTable.setItem(prefixTable.rowCount() - 1, 0, QLabel(prefix))
40+
41+
lay = QHBoxLayout()
42+
lay.addWidget(self.__warningLbl)
43+
# lay.addWidget(prefixTable)
44+
self.setLayout(lay)

0 commit comments

Comments
 (0)