Skip to content

Commit

Permalink
Merge pull request #191 from yjg30737/Dev
Browse files Browse the repository at this point in the history
v1.8.0
  • Loading branch information
yjg30737 authored Nov 16, 2024
2 parents 1f32376 + 200f8f3 commit d28dc75
Show file tree
Hide file tree
Showing 36 changed files with 723 additions and 1,116 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include pyqt_openai/ico/*
include pyqt_openai/prompt_res/*
include pyqt_openai/lang/*
include pyqt_openai/img/*

include pyqt_openai/icon.ico
7 changes: 5 additions & 2 deletions 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.1"
version = "1.8.0"
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 All @@ -21,9 +21,12 @@ dependencies = [
"openai",
"anthropic",
"google-generativeai",
"llama-index",
"replicate",

"llama-index",
"docx2txt",
"openpyxl",

"g4f",
"curl_cffi",
"litellm",
Expand Down
62 changes: 22 additions & 40 deletions 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.1"
__version__ = "1.8.0"
__author__ = "Jung Gyu Yoon"

# Constants
Expand Down Expand Up @@ -129,6 +129,8 @@ def move_bin(filename, dst_dir):
"https://github.com/yjg30737/pyqt-openai?tab=readme-ov-file#troubleshooting"
)

AWESOME_CHATGPT_PROMPTS_URL = "https://huggingface.co/datasets/fka/awesome-chatgpt-prompts/tree/main"

COLUMN_TO_EXCLUDE_FROM_SHOW_HIDE_CHAT = ["id"]
COLUMN_TO_EXCLUDE_FROM_SHOW_HIDE_IMAGE = ["id", "data"]
DEFAULT_LANGUAGE = "en_US"
Expand Down Expand Up @@ -206,6 +208,11 @@ def move_bin(filename, dst_dir):
ICON_REALTIME_API = os.path.join(ICON_PATH, "realtime_api.svg")
ICON_FILE = os.path.join(ICON_PATH, "file.svg")

## IMAGE
IMAGE_PATH = os.path.join(EXEC_PATH, "img")

IMAGE_IMPORT_PROMPT_WITH_CSV_RIGHT_FORM = os.path.join(IMAGE_PATH, "import_prompt_with_csv_right_form.png")

## CUSTOMIZE
DEFAULT_ICON_SIZE = (24, 24)
DEFAULT_USER_IMAGE_PATH = ICON_USER
Expand All @@ -228,6 +235,8 @@ def move_bin(filename, dst_dir):
DEFAULT_TOAST_BACKGROUND_COLOR = "#444444"
DEFAULT_TOAST_FOREGROUND_COLOR = "#EEEEEE"

DEFAULT_WARNING_COLOR = "#FFA500"

## MARKDOWN
# I am not planning to use it at the moment.
# DEFAULT_MARKDOWN_span_font = 'Courier New'
Expand Down Expand Up @@ -297,6 +306,7 @@ def move_bin(filename, dst_dir):
IMAGE_FILE_EXT_LIST_STR = "Image File (*.png *.jpg *.jpeg *.gif *.bmp)"
TEXT_FILE_EXT_LIST_STR = "Text File (*.txt)"
JSON_FILE_EXT_LIST_STR = "JSON File (*.json)"
CSV_FILE_EXT_LIST_STR = "CSV File (*.csv)"
READ_FILE_EXT_LIST_STR = f"{TEXT_FILE_EXT_LIST_STR};;{IMAGE_FILE_EXT_LIST_STR}"

## PROMPT
Expand Down Expand Up @@ -391,40 +401,15 @@ def move_bin(filename, dst_dir):

STT_MODEL = "whisper-1"

# Endpoint
# https://platform.openai.com/docs/models/model-endpoint-compatibility
OPENAI_ENDPOINT_DICT = {
"/v1/chat/completions": ["gpt-4o", "gpt-4o-mini", "o1-preview", "o1-mini"],
"/v1/completions": [
"text-davinci-003",
"text-davinci-002",
"text-curie-001",
"text-babbage-001",
"text-ada-001",
"davinci",
"curie",
"babbage",
"ada",
],
"/v1/edits": ["text-davinci-edit-001", "code-davinci-edit-001"],
"/v1/audio/transcriptions": ["whisper-1"],
"/v1/audio/translations": ["whisper-1"],
"/v1/fine-tunes": ["davinci", "curie", "babbage", "ada"],
"/v1/embeddings": ["text-embedding-ada-002", "text-search-ada-doc-001"],
"/vi/moderations": ["text-moderation-stable", "text-moderation-latest"],
}

DEFAULT_TOKEN_CHUNK_SIZE = 1024

# This doesn't need endpoint
DALLE_ARR = ["dall-e-2", "dall-e-3"]
OPENAI_DEFAULT_IMAGE_MODEL = "dall-e-3"

DEFAULT_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"

OPENAI_CHAT_ENDPOINT = "/v1/chat/completions"

# Other models' configuration data
DEFAULT_GEMINI_MODEL = "gemini/gemini-1.5-flash"
# This has to be managed separately since some of the arguments are different with usual models
O1_MODELS = ["o1-preview", "o1-mini"]

# Overall API configuration data
DEFAULT_API_CONFIGS = [
Expand All @@ -434,6 +419,7 @@ def move_bin(filename, dst_dir):
"env_var_name": "OPENAI_API_KEY",
"api_key": "",
"manual_url": HOW_TO_GET_OPENAI_API_KEY_URL,
"model_list": ["gpt-4o", "gpt-4o-mini"] + O1_MODELS
},
# Azure
{
Expand Down Expand Up @@ -493,13 +479,15 @@ def move_bin(filename, dst_dir):
"api_key": "",
"manual_url": HOW_TO_GET_GEMINI_API_KEY_URL,
"prefix": "gemini",
"model_list": ["gemini/gemini-1.5-flash", "gemini/gemini-1.5-pro"]
},
# Anthropic
{
"display_name": "Anthropic",
"env_var_name": "ANTHROPIC_API_KEY",
"api_key": "",
"manual_url": HOW_TO_GET_CLAUDE_API_KEY_URL,
"model_list": ["claude-3-haiku-20240307", "claude-3-5-sonnet-20240620"]
},
# AWS Sagemaker
{
Expand Down Expand Up @@ -903,10 +891,6 @@ def move_bin(filename, dst_dir):
},
]


# This has to be managed separately since some of the arguments are different with usual models
O1_MODELS = ["o1-preview", "o1-mini"]

DEFAULT_LLM = "gpt-4o"

G4F_PROVIDER_DEFAULT = "Auto"
Expand All @@ -915,17 +899,14 @@ def move_bin(filename, dst_dir):

G4F_DEFAULT_IMAGE_MODEL = "flux"

# Dictionary that stores the platform and model pairs
PROVIDER_MODEL_DICT = {
"OpenAI": ["gpt-4o", "gpt-4o-mini"] + O1_MODELS,
"Gemini": ["gemini/gemini-1.5-flash", "gemini/gemini-1.5-pro"],
"Anthropic": ["claude-3-5-sonnet-20240620"],
}

# Constants related to the number of messages LLM will store
MAXIMUM_MESSAGES_IN_PARAMETER = 40
MAXIMUM_MESSAGES_IN_PARAMETER_RANGE = 2, 1000

# llamaIndex
LLAMA_INDEX_DEFAULT_SUPPORTED_FORMATS_LIST = ['.txt']
LLAMA_INDEX_DEFAULT_ALL_SUPPORTED_FORMATS_LIST = ['.txt', '.docx', '.hwp', '.ipynb', '.csv', '.jpeg', '.jpg', '.mbox', '.md', '.mp3', '.mp4', '.pdf', '.png', '.ppt', '.pptx', '.pptm']

# PROMPT
## DEFAULT JSON FILENAME FOR PROMPT
AWESOME_CHATGPT_PROMPTS_FILENAME = "prompt_res/awesome_chatgpt_prompts.json"
Expand Down Expand Up @@ -1165,6 +1146,7 @@ def move_bin(filename, dst_dir):
# Llama Index
"use_llama_index": False,
"llama_index_directory": "",
"llama_index_supported_formats": LLAMA_INDEX_DEFAULT_SUPPORTED_FORMATS_LIST,
# Customize
"background_image": "",
"user_image": DEFAULT_USER_IMAGE_PATH,
Expand Down
5 changes: 1 addition & 4 deletions pyqt_openai/aboutDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ def __initUi(self):
descWidget3.setText(
f"""
<br/><br/>Contact: {CONTACT}<br/>
<p>Powered by PySide6</p>
<p>Powered by GPT4Free</p>
<p>Powered by LiteLLM</p>
<p>Powered by LlamaIndex</p>
<p>Powered by<br><br> PySide6, GPT4Free, LiteLLM,<br>LlamaIndex</p>
"""
)

Expand Down
8 changes: 4 additions & 4 deletions pyqt_openai/chat_widget/center/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ def __setEveryPromptCommands(self):
if group.prompt_type == "form":
value = ""
for entry in entries:
content = entry.content
if content and content.strip():
value += f"{entry.name}: {content}\n"
prompt = entry.prompt
if prompt and prompt.strip():
value += f"{entry.act}: {prompt}\n"
command_obj_lst.append({"name": group.name, "value": value})
elif group.prompt_type == "sentence":
for entry in entries:
command_obj_lst.append(
{"name": f"{entry.name}({group.name})", "value": entry.content}
{"name": f"{entry.act}({group.name})", "value": entry.prompt}
)
self.__p_grp = [
{"name": obj["name"], "value": obj["value"]} for obj in command_obj_lst
Expand Down
7 changes: 0 additions & 7 deletions pyqt_openai/chat_widget/chatMainWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ def __initUi(self):

self.__chatWidget.setG4F(self.__chatRightSideBarWidget.currentTabIdx())

try:
self.__chatRightSideBarWidget.onDirectorySelected.connect(
LLAMAINDEX_WRAPPER.set_directory
)
except Exception as e:
QMessageBox.critical(self, LangClass.TRANSLATIONS["Error"], str(e))

self.__promptGeneratorWidget = PromptGeneratorWidget()

self.__sideBarBtn = Button()
Expand Down
Loading

0 comments on commit d28dc75

Please sign in to comment.