1- from pyqt_openai import *
1+ """
2+ This file is used to store the constants and the global variables that are used throughout the application.
3+ """
4+
5+ import json
6+ import os
7+ from pathlib import Path
8+
9+ import toml
10+
11+ # Load the pyproject.toml file
12+ SRC_DIR = Path (__file__ ).resolve ().parent
13+ ROOT_DIR = SRC_DIR .parent
14+ SETUP_FILENAME = ROOT_DIR / "pyproject.toml"
15+
16+ with open (SETUP_FILENAME , "r" ) as file :
17+ pyproject_data = toml .load (file )
18+
19+ # For the sake of following the PEP8 standard, we will declare module-level dunder names.
20+ # PEP8 standard about dunder names: https://peps.python.org/pep-0008/#module-level-dunder-names
21+
22+ __version__ = pyproject_data ["project" ]["version" ]
23+ __author__ = pyproject_data ["project" ]["authors" ][0 ]['name' ]
24+
25+ # Constants
26+ # ----------------------------
27+ # APP
28+ APP_NAME = pyproject_data ["project" ]["name" ]
29+ CONTACT = pyproject_data ["project" ]["authors" ][0 ]['email' ]
30+ APP_ICON = 'icon.png'
31+ APP_INITIAL_WINDOW_SIZE = (1280 , 768 )
32+ LICENSE_URL = 'https://github.com/yjg30737/pyqt-openai/blob/main/LICENSE'
33+ PAYPAL_URL = 'https://paypal.me/yjg30737'
34+ BUYMEACOFFEE_URL = 'https://www.buymeacoffee.com/yjg30737'
35+ GITHUB_URL = 'https://github.com/yjg30737/pyqt-openai'
36+ DISCORD_URL = 'https://discord.gg/cHekprskVE'
37+ COLUMN_TO_EXCLUDE_FROM_SHOW_HIDE = ['id' ]
38+ DEFAULT_LANGUAGE = 'en_US'
39+ LANGUAGE_FILE = 'translations.json'
40+ LANGUAGE_DICT = {
41+ "English" : "en_US" ,
42+ "Spanish" : "es_ES" ,
43+ "Chinese" : "zh_CN" ,
44+ "Russian" : "ru_RU" ,
45+ "Korean" : "ko_KR" ,
46+ "French" : "fr_FR" ,
47+ "German" : "de_DE" ,
48+ "Italian" : "it_IT" ,
49+ "Hindi" : "hi_IN" ,
50+ "Arabic" : "ar_AE" ,
51+ "Japanese" : "ja_JP" ,
52+ "Bengali" : "bn_IN" ,
53+ "Urdu" : "ur_PK" ,
54+ "Indonesian" : "id_ID" ,
55+ "Portuguese" : "pt_BR"
56+ }
57+
58+ ## ICONS
59+ ICON_ADD = 'ico/add.svg'
60+ ICON_CASE = 'ico/case.svg'
61+ ICON_CLOSE = 'ico/close.svg'
62+ ICON_COPY = 'ico/copy.svg'
63+ ICON_CUSTOMIZE = 'ico/customize.svg'
64+ ICON_DELETE = 'ico/delete.svg'
65+ ICON_DISCORD = 'ico/discord.svg'
66+ ICON_EXPORT = 'ico/export.svg'
67+ ICON_FAVORITE_NO = 'ico/favorite_no.svg'
68+ ICON_FAVORITE_YES = 'ico/favorite_yes.svg'
69+ ICON_FULLSCREEN = 'ico/fullscreen.svg'
70+ ICON_GITHUB = 'ico/github.svg'
71+ ICON_HELP = 'ico/help.svg'
72+ ICON_HISTORY = 'ico/history.svg'
73+ ICON_IMPORT = 'ico/import.svg'
74+ ICON_INFO = 'ico/info.svg'
75+ ICON_NEXT = 'ico/next.svg'
76+ ICON_OPENAI = 'ico/openai.png'
77+ ICON_PREV = 'ico/prev.svg'
78+ ICON_PROMPT = 'ico/prompt.svg'
79+ ICON_QUESTION = 'ico/question.svg'
80+ ICON_REFRESH = 'ico/refresh.svg'
81+ ICON_REGEX = 'ico/regex.svg'
82+ ICON_SAVE = 'ico/save.svg'
83+ ICON_SEARCH = 'ico/search.svg'
84+ ICON_SETTING = 'ico/setting.svg'
85+ ICON_SIDEBAR = 'ico/sidebar.svg'
86+ ICON_STACKONTOP = 'ico/stackontop.svg'
87+ ICON_USER = 'ico/user.png'
88+ ICON_VERTICAL_THREE_DOTS = 'ico/vertical_three_dots.svg'
89+ ICON_WORD = 'ico/word.svg'
90+
91+ ## CUSTOMIZE
92+ DEFAULT_ICON_SIZE = (24 , 24 )
93+ DEFAULT_USER_IMAGE_PATH = ICON_USER
94+ DEFAULT_AI_IMAGE_PATH = ICON_OPENAI
95+ DEFAULT_FONT_SIZE = 12
96+ DEFAULT_FONT_FAMILY = 'Arial'
97+ FONT_FAMILY_FOR_SOURCE = 'Courier'
98+
99+ ## SHORTCUT
100+ SHORTCUT_GENERAL_ACTION = 'Enter'
101+ SHORTCUT_FIND_PREV = 'Ctrl+Shift+D'
102+ SHORTCUT_FIND_NEXT = 'Ctrl+D'
103+ SHORTCUT_FIND_CLOSE = 'Escape'
104+ SHORTCUT_PROMPT_BEGINNING = 'Ctrl+B'
105+ SHORTCUT_PROMPT_ENDING = 'Ctrl+E'
106+ SHORTCUT_SUPPORT_PROMPT_COMMAND = 'Ctrl+Shift+P'
107+ SHORTCUT_FULL_SCREEN = 'F11'
108+
109+ ## DIRECTORY PATH & FILE'S NAME
110+ MAIN_INDEX = 'main.py'
111+ IMAGE_DEFAULT_SAVE_DIRECTORY = 'image_result'
112+ LLAMA_INDEX_DEFAULT_READ_DIRECTORY = './example'
113+ INI_FILE_NAME = 'pyqt_openai.ini'
114+ DB_FILE_NAME = 'conv'
115+
116+ ## EXTENSIONS
117+ IMAGE_FILE_EXT = 'Image File (*.jpg *.png)'
118+ TEXT_FILE_EXT = 'Text File (*.txt)'
119+ JSON_FILE_EXT = 'JSON File (*.json)'
120+ READ_FILE_EXT = f'{ TEXT_FILE_EXT } ;;{ IMAGE_FILE_EXT } '
121+
122+ ## LINK
123+ CHATGPT_IMPORT_MANUAL_LINK_1 = 'https://cdn.discordapp.com/attachments/1089739277379846226/1259834113884557362/image.png?ex=66a6d4b3&is=66a58333&hm=3544e9a6ec1610bc552f93b794e113c48c1505d5ba820628b9cd68876597f7dc&'
124+ CHATGPT_IMPORT_MANUAL_LINK_2 = 'https://cdn.discordapp.com/attachments/1089739277379846226/1265952420773498880/image.png?ex=66a6ad51&is=66a55bd1&hm=0279112be31354eb1a45f1d72d28363285dd6b640854b6dc98e58de98f4fc349&'
125+
126+ ## PROMPT
127+ PROMPT_BEGINNING_KEY_NAME = 'prompt_beginning'
128+ PROMPT_JSON_KEY_NAME = 'prompt_json'
129+ PROMPT_MAIN_KEY_NAME = 'prompt_main'
130+ PROMPT_END_KEY_NAME = 'prompt_ending'
131+ PROMPT_NAME_REGEX = '^[a-zA-Z_0-9]+$'
132+ INDENT_SIZE = 4
133+
134+ # DB
135+ DB_NAME_REGEX = '[a-zA-Z0-9]{1,20}'
136+
137+ THREAD_TABLE_NAME_OLD = 'conv_tb'
138+ THREAD_TRIGGER_NAME_OLD = 'conv_tr'
139+ MESSAGE_TABLE_NAME_OLD = 'conv_unit_tb'
140+
141+ THREAD_TABLE_NAME = 'thread_tb'
142+ THREAD_TRIGGER_NAME = 'thread_tr'
143+ MESSAGE_TABLE_NAME = 'message_tb'
144+
145+ IMAGE_TABLE_NAME = 'image_tb'
146+
147+ THREAD_MESSAGE_INSERTED_TR_NAME_OLD = 'conv_tb_updated_by_unit_inserted_tr'
148+ THREAD_MESSAGE_UPDATED_TR_NAME_OLD = 'conv_tb_updated_by_unit_updated_tr'
149+ THREAD_MESSAGE_DELETED_TR_NAME_OLD = 'conv_tb_updated_by_unit_deleted_tr'
150+
151+ THREAD_MESSAGE_INSERTED_TR_NAME = 'thread_message_inserted_tr'
152+ THREAD_MESSAGE_UPDATED_TR_NAME = 'thread_message_updated_tr'
153+ THREAD_MESSAGE_DELETED_TR_NAME = 'thread_message_deleted_tr'
154+
155+ THREAD_ORDERBY = 'update_dt'
156+
157+ PROPERTY_PROMPT_GROUP_TABLE_NAME_OLD = 'prop_prompt_grp_tb'
158+ PROPERTY_PROMPT_UNIT_TABLE_NAME_OLD = 'prop_prompt_unit_tb'
159+ TEMPLATE_PROMPT_GROUP_TABLE_NAME_OLD = 'template_prompt_grp_tb'
160+ TEMPLATE_PROMPT_TABLE_NAME_OLD = 'template_prompt_tb'
161+ PROPERTY_PROMPT_UNIT_DEFAULT_VALUE = [{'name' : 'Task' , 'content' : '' },
162+ {'name' : 'Topic' , 'content' : '' },
163+ {'name' : 'Style' , 'content' : '' },
164+ {'name' : 'Tone' , 'content' : '' },
165+ {'name' : 'Audience' , 'content' : '' },
166+ {'name' : 'Length' , 'content' : '' },
167+ {'name' : 'Form' , 'content' : '' }]
168+
169+ PROMPT_GROUP_TABLE_NAME = 'prompt_group_tb'
170+ PROMPT_ENTRY_TABLE_NAME = 'prompt_entry_tb'
171+
172+ # DEFAULT JSON FILENAME FOR PROMPT
173+ AWESOME_CHATGPT_PROMPTS_FILENAME = 'prompt_res/awesome_chatgpt_prompts.json'
174+ ALEX_BROGAN_PROMPT_FILENAME = 'prompt_res/alex_brogan.json'
175+
176+ FORM_PROMPT_GROUP_SAMPLE = json .dumps ([
177+ {
178+ "name" : 'Default' ,
179+ "data" : PROPERTY_PROMPT_UNIT_DEFAULT_VALUE
180+ }
181+ ], indent = 4 )
182+
183+ SENTENCE_PROMPT_GROUP_SAMPLE = '''[
184+ {
185+ "name": "alex_brogan",
186+ "data": [
187+ {
188+ "name": "sample_1",
189+ "content": "Identify the 20% of [topic or skill] that will yield 80% of the desired results and provide a focused learning plan to master it."
190+ },
191+ {
192+ "name": "sample_2",
193+ "content": "Explain [topic or skill] in the simplest terms possible as if teaching it to a complete beginner. Identify gaps in my understanding and suggest resources to fill them."
194+ }
195+ ]
196+ },
197+ {
198+ "name": "awesome_chatGPT_prompts",
199+ "data": [
200+ {
201+ "name": "linux_terminal",
202+ "content": "I want you to act as a linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. do not write explanations. do not type commands unless I instruct you to do so. when i need to tell you something in english, i will do so by putting text inside curly brackets {like this}. my first command is pwd"
203+ },
204+ {
205+ "name": "english_translator_and_improver",
206+ "content": "I want you to act as an English translator, spelling corrector and improver. I will speak to you in any language and you will detect the language, translate it and answer in the corrected and improved version of my text, in English. I want you to replace my simplified A0-level words and sentences with more beautiful and elegant, upper level English words and sentences. Keep the meaning same, but make them more literary. I want you to only reply the correction, the improvements and nothing else, do not write explanations. My first sentence is \" istanbulu cok seviyom burada olmak cok guzel\" "
207+ },
208+ ]
209+ }
210+ ]'''
211+
212+ # Load the default prompt
213+ if os .path .exists (AWESOME_CHATGPT_PROMPTS_FILENAME ):
214+ AWESOME_CHATGPT_PROMPTS = json .load (open (AWESOME_CHATGPT_PROMPTS_FILENAME ))[0 ]
215+ if os .path .exists (ALEX_BROGAN_PROMPT_FILENAME ):
216+ ALEX_BROGAN_PROMPT = json .load (open (ALEX_BROGAN_PROMPT_FILENAME ))[0 ]
217+
218+ # Update the __all__ list with the PEP8 standard dunder names
219+ __all__ = ['__version__' ,
220+ '__author__' ]
221+
222+ # Update the __all__ list with the constants
223+ __all__ .extend ([name for name , value in globals ().items () if name .isupper ()])
0 commit comments