Skip to content

Commit

Permalink
Merge pull request #188 from yjg30737/Dev
Browse files Browse the repository at this point in the history
v1.7.1
  • Loading branch information
yjg30737 authored Nov 14, 2024
2 parents 99d37a2 + 7963285 commit 1f32376
Show file tree
Hide file tree
Showing 43 changed files with 169 additions and 156 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyqt-openai"
version = "1.7.0"
version = "1.7.1"
description = "Python multipurpose chatbot that user can use GPT, other AI models altogether (Release Name: VividNode)"
authors = [{ name = "Jung Gyu Yoon", email = "[email protected]" }]
license = { text = "MIT" }
Expand Down
3 changes: 2 additions & 1 deletion pyqt_openai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# For the sake of following the PEP8 standard, we will declare module-level dunder names.
# PEP8 standard about dunder names: https://peps.python.org/pep-0008/#module-level-dunder-names

__version__ = "1.7.0"
__version__ = "1.7.1"
__author__ = "Jung Gyu Yoon"

# Constants
Expand Down Expand Up @@ -1139,6 +1139,7 @@ def move_bin(filename, dst_dir):
"model",
"width",
"height",
"provider",
"prompt",
"negative_prompt",
"n",
Expand Down
1 change: 1 addition & 0 deletions pyqt_openai/aboutDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __initUi(self):
<p>Powered by PySide6</p>
<p>Powered by GPT4Free</p>
<p>Powered by LiteLLM</p>
<p>Powered by LlamaIndex</p>
"""
)

Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/chat_widget/center/aiChatUnit.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pyqt_openai.chat_widget.center.responseInfoDialog import ResponseInfoDialog
from pyqt_openai.models import ChatMessageContainer
from pyqt_openai.globals import DB
from pyqt_openai.util.script import stream_to_speakers
from pyqt_openai.util.common import stream_to_speakers
from pyqt_openai.widgets.button import Button
from pyqt_openai.widgets.fileTableDialog import FileTableDialog

Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/chat_widget/center/chatBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pyqt_openai.chat_widget.center.userChatUnit import UserChatUnit
from pyqt_openai.models import ChatMessageContainer
from pyqt_openai.globals import DB
from pyqt_openai.util.script import is_valid_regex
from pyqt_openai.util.common import is_valid_regex


class ChatBrowser(QScrollArea):
Expand Down
9 changes: 4 additions & 5 deletions pyqt_openai/chat_widget/center/chatWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
from pyqt_openai.chat_widget.center.chatHome import ChatHome
from pyqt_openai.chat_widget.center.menuWidget import MenuWidget
from pyqt_openai.chat_widget.center.prompt import Prompt
from pyqt_openai.chat_widget.llamaOpenAIThread import LlamaOpenAIThread
from pyqt_openai.chat_widget.llamaIndexThread import LlamaIndexThread
from pyqt_openai.config_loader import CONFIG_MANAGER
from pyqt_openai.globals import LLAMAINDEX_WRAPPER, DB
from pyqt_openai.util.script import get_argument, ChatThread
from pyqt_openai.util.common import get_argument, ChatThread
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.models import ChatMessageContainer
from pyqt_openai.widgets.notifier import NotifierWidget
Expand Down Expand Up @@ -261,10 +261,9 @@ def __chat(self):
query_text = self.__prompt.getContent()
self.__browser.showLabel(query_text, False, container)

# Get parameters for OpenAI
# Run a different thread based on whether the llama-index is enabled or not.
if is_llama_available:
# Run a different thread based on whether the llama-index is enabled or not.
self.__t = LlamaOpenAIThread(
self.__t = LlamaIndexThread(
param, container, LLAMAINDEX_WRAPPER, query_text
)
else:
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/chat_widget/center/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
UploadedImageFileWidget,
)
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.util.script import (
from pyqt_openai.util.common import (
get_content_of_text_file_for_send,
RecorderThread,
STTThread,
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/chat_widget/center/responseInfoDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pyqt_openai.lang.translations import LangClass
from pyqt_openai.models import ChatMessageContainer
from pyqt_openai.util.script import getSeparator
from pyqt_openai.util.common import getSeparator


class ResponseInfoDialog(QDialog):
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/chat_widget/chatMainWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
CustomizeParamsContainer,
)
from pyqt_openai.globals import DB, LLAMAINDEX_WRAPPER
from pyqt_openai.util.script import (
from pyqt_openai.util.common import (
open_directory,
get_generic_ext_out_of_qt_ext,
message_list_to_txt,
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/chat_widget/left_sidebar/chatImportDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
HOW_TO_EXPORT_CHATGPT_CONVERSATION_HISTORY_URL,
)
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.util.script import (
from pyqt_openai.util.common import (
get_chatgpt_data_for_import,
get_chatgpt_data_for_preview,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


# Should combine with ChatThread
class LlamaOpenAIThread(QThread):
class LlamaIndexThread(QThread):
replyGenerated = Signal(str, bool, ChatMessageContainer)
streamFinished = Signal(ChatMessageContainer)

Expand Down Expand Up @@ -37,6 +37,15 @@ def run(self):
self.replyGenerated.emit(chunk, True, self.__info)
else:
self.__info.content = resp.response
# self.__info.prompt_tokens = ""
# self.__info.completion_tokens = ""
# self.__info.total_tokens = ""

self.__info.finish_reason = "stop"

if self.__input_args["stream"]:
self.streamFinished.emit(self.__info)
else:
self.replyGenerated.emit(self.__info.content, False, self.__info)
except Exception as e:
self.__info.finish_reason = "Error"
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/chat_widget/prompt_gen_widget/formPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
)
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.globals import DB
from pyqt_openai.util.script import open_directory, get_prompt_data
from pyqt_openai.util.common import open_directory, get_prompt_data
from pyqt_openai.widgets.button import Button


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)

from pyqt_openai.lang.translations import LangClass
from pyqt_openai.util.script import is_prompt_entry_name_valid, getSeparator
from pyqt_openai.util.common import is_prompt_entry_name_valid, getSeparator


class PromptEntryDirectInputDialog(QDialog):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
)

from pyqt_openai.lang.translations import LangClass
from pyqt_openai.util.script import is_prompt_group_name_valid, getSeparator
from pyqt_openai.util.common import is_prompt_group_name_valid, getSeparator


class PromptGroupDirectInputDialog(QDialog):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from pyqt_openai import SENTENCE_PROMPT_GROUP_SAMPLE, FORM_PROMPT_GROUP_SAMPLE
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.util.script import showJsonSample
from pyqt_openai.util.common import showJsonSample
from pyqt_openai.widgets.checkBoxListWidget import CheckBoxListWidget
from pyqt_openai.widgets.jsonEditor import JSONEditor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
FORM_PROMPT_GROUP_SAMPLE,
)
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.util.script import (
from pyqt_openai.util.common import (
validate_prompt_group_json,
is_prompt_group_name_valid,
showJsonSample,
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/chat_widget/prompt_gen_widget/sentencePage.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
)
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.globals import DB
from pyqt_openai.util.script import open_directory, get_prompt_data
from pyqt_openai.util.common import open_directory, get_prompt_data
from pyqt_openai.widgets.button import Button


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from pyqt_openai import TEXT_FILE_EXT_LIST, QFILEDIALOG_DEFAULT_DIRECTORY
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.util.script import getSeparator
from pyqt_openai.util.common import getSeparator


class FileListWidget(QWidget):
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/chat_widget/right_sidebar/modelSearchBar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QLineEdit, QCompleter

from pyqt_openai.util.script import get_chat_model
from pyqt_openai.util.common import get_chat_model


class ModelSearchBar(QLineEdit):
Expand Down
9 changes: 3 additions & 6 deletions pyqt_openai/chat_widget/right_sidebar/usingAPIPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
from pyqt_openai.chat_widget.right_sidebar.modelSearchBar import ModelSearchBar
from pyqt_openai.config_loader import CONFIG_MANAGER
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.util.script import (
from pyqt_openai.util.common import (
getSeparator,
init_llama,
)
from pyqt_openai.widgets.linkLabel import LinkLabel
from pyqt_openai.widgets.modernButton import ModernButton
from pyqt_openai.widgets.APIInputButton import APIInputButton


class UsingAPIPage(QWidget):
Expand Down Expand Up @@ -123,15 +123,12 @@ def __initUi(self):
modelSearchBar.setText(self.__model)
modelSearchBar.textChanged.connect(self.__modelChanged)

prefixListBtn = ModernButton()
prefixListBtn.setText("Prefix List")

lay = QHBoxLayout()
lay.addWidget(QLabel(LangClass.TRANSLATIONS["Model"]))
lay.addWidget(modelSearchBar)
lay.setContentsMargins(0, 0, 0, 0)

setApiBtn = ModernButton()
setApiBtn = APIInputButton()
# TODO LANGUAGE
setApiBtn.setText("Set API Key")

Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/chat_widget/right_sidebar/usingG4FPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pyqt_openai import G4F_PROVIDER_DEFAULT
from pyqt_openai.config_loader import CONFIG_MANAGER
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.util.script import (
from pyqt_openai.util.common import (
get_g4f_providers,
get_g4f_models_by_provider,
get_chat_model,
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/customizeDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pyqt_openai.fontWidget import FontWidget
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.models import CustomizeParamsContainer
from pyqt_openai.util.script import getSeparator
from pyqt_openai.util.common import getSeparator
from pyqt_openai.widgets.circleProfileImage import RoundedImage
from pyqt_openai.widgets.findPathWidget import FindPathWidget
from pyqt_openai.widgets.normalImageView import NormalImageView
Expand Down
4 changes: 2 additions & 2 deletions pyqt_openai/dalle_widget/dalleRightSideBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pyqt_openai.dalle_widget.dalleThread import DallEThread
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.widgets.imageControlWidget import ImageControlWidget
from pyqt_openai.widgets.modernButton import ModernButton
from pyqt_openai.widgets.APIInputButton import APIInputButton


class DallERightSideBarWidget(ImageControlWidget):
Expand Down Expand Up @@ -51,7 +51,7 @@ def _initUi(self):
super()._initUi()

# TODO LANGUAGE
self.__setApiBtn = ModernButton()
self.__setApiBtn = APIInputButton()
self.__setApiBtn.setText("Set API Key")

self.__promptTypeToShowRadioGrpBox = QGroupBox(
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/dalle_widget/dalleThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pyqt_openai.models import ImagePromptContainer
from pyqt_openai.globals import OPENAI_CLIENT
from pyqt_openai.util.script import generate_random_prompt
from pyqt_openai.util.common import generate_random_prompt


class DallEThread(QThread):
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/doNotAskAgainDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)

from pyqt_openai.lang.translations import LangClass
from pyqt_openai.util.script import getSeparator
from pyqt_openai.util.common import getSeparator


class DoNotAskAgainDialog(QDialog):
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/g4f_image_widget/g4fImageRightSideBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pyqt_openai.config_loader import CONFIG_MANAGER
from pyqt_openai.g4f_image_widget.g4fImageThread import G4FImageThread
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.util.script import (
from pyqt_openai.util.common import (
get_g4f_image_providers,
get_g4f_image_models_from_provider,
get_g4f_image_models,
Expand Down
4 changes: 2 additions & 2 deletions pyqt_openai/g4f_image_widget/g4fImageThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from pyqt_openai import G4F_PROVIDER_DEFAULT
from pyqt_openai.globals import G4F_CLIENT
from pyqt_openai.models import ImagePromptContainer
from pyqt_openai.util.replicate_script import download_image_as_base64
from pyqt_openai.util.script import generate_random_prompt, convert_to_provider
from pyqt_openai.util.replicate import download_image_as_base64
from pyqt_openai.util.common import generate_random_prompt, convert_to_provider


class G4FImageThread(QThread):
Expand Down
6 changes: 3 additions & 3 deletions pyqt_openai/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from openai import OpenAI

from pyqt_openai.sqlite import SqliteDatabase
from pyqt_openai.util.llamapage_script import GPTLLamaIndexWrapper
from pyqt_openai.util.replicate_script import ReplicateWrapper
from pyqt_openai.util.llamaindex import LlamaIndexWrapper
from pyqt_openai.util.replicate import ReplicateWrapper

DB = SqliteDatabase()

LLAMAINDEX_WRAPPER = GPTLLamaIndexWrapper()
LLAMAINDEX_WRAPPER = LlamaIndexWrapper()

G4F_CLIENT = Client()

Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from pyqt_openai.config_loader import CONFIG_MANAGER

from pyqt_openai.mainWindow import MainWindow
from pyqt_openai.util.script import handle_exception
from pyqt_openai.util.common import handle_exception
from pyqt_openai.updateSoftwareDialog import update_software
from pyqt_openai.sqlite import get_db_filename

Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
from pyqt_openai.settings_dialog.settingsDialog import SettingsDialog
from pyqt_openai.shortcutDialog import ShortcutDialog
from pyqt_openai.updateSoftwareDialog import update_software
from pyqt_openai.util.script import (
from pyqt_openai.util.common import (
restart_app,
show_message_box_after_change_to_restart,
set_auto_start_windows,
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/replicate_widget/replicateMainWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pyqt_openai.replicate_widget.replicateRightSideBar import (
ReplicateRightSideBarWidget,
)
from pyqt_openai.util.script import (
from pyqt_openai.util.common import (
get_image_filename_for_saving,
open_directory,
get_image_prompt_filename_for_saving,
Expand Down
4 changes: 2 additions & 2 deletions pyqt_openai/replicate_widget/replicateRightSideBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pyqt_openai.lang.translations import LangClass
from pyqt_openai.replicate_widget.replicateThread import ReplicateThread
from pyqt_openai.widgets.imageControlWidget import ImageControlWidget
from pyqt_openai.widgets.modernButton import ModernButton
from pyqt_openai.widgets.APIInputButton import APIInputButton


class ReplicateRightSideBarWidget(ImageControlWidget):
Expand Down Expand Up @@ -49,7 +49,7 @@ def _initUi(self):
super()._initUi()

# TODO LANGUAGE
self.__setApiBtn = ModernButton()
self.__setApiBtn = APIInputButton()
self.__setApiBtn.setText("Set API Key")

self.__modelTextEdit = QPlainTextEdit()
Expand Down
2 changes: 1 addition & 1 deletion pyqt_openai/replicate_widget/replicateThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pyqt_openai.globals import REPLICATE_CLIENT
from pyqt_openai.models import ImagePromptContainer
from pyqt_openai.util.script import generate_random_prompt
from pyqt_openai.util.common import generate_random_prompt


class ReplicateThread(QThread):
Expand Down
Loading

0 comments on commit 1f32376

Please sign in to comment.