19
19
from je_editor .pyside_ui .main_ui .main_editor import EditorMain
20
20
21
21
22
- def set_ai_config ():
23
- # Set and output AI a config file
24
- set_ai_config_dialog = SetAIDialog ()
25
- set_ai_config_dialog .show ()
26
-
27
-
28
22
class ChatUI (QWidget ):
29
23
30
24
def __init__ (self , main_window : EditorMain ):
@@ -53,9 +47,9 @@ def __init__(self, main_window: EditorMain):
53
47
self .font_size_combobox .currentTextChanged .connect (self .update_panel_text_size )
54
48
# Buttons
55
49
self .set_ai_config_button = QPushButton (language_wrapper .language_word_dict .get ("chat_ui_set_ai_button" ))
56
- self .set_ai_config_button .clicked .connect (set_ai_config )
50
+ self .set_ai_config_button .clicked .connect (self . set_ai_config )
57
51
self .load_ai_config_button = QPushButton (language_wrapper .language_word_dict .get ("chat_ui_load_ai_button" ))
58
- self .load_ai_config_button .clicked .connect (self .load_ai_config )
52
+ self .load_ai_config_button .clicked .connect (lambda : self .load_ai_config ( show_load_complete = True ) )
59
53
self .call_ai_model_button = QPushButton (language_wrapper .language_word_dict .get ("chat_ui_call_ai_model_button" ))
60
54
self .call_ai_model_button .clicked .connect (self .call_ai_model )
61
55
# Add to layout
@@ -70,6 +64,8 @@ def __init__(self, main_window: EditorMain):
70
64
# Variable
71
65
self .ai_config : AIConfig = ai_config
72
66
self .lang_chain_interface : Union [LangChainInterface , None ] = None
67
+ self .set_ai_config_dialog = None
68
+ # Timer to pop queue
73
69
self .pull_message_timer = QTimer (self )
74
70
self .pull_message_timer .setInterval (1000 )
75
71
self .pull_message_timer .timeout .connect (self .pull_message )
@@ -84,7 +80,7 @@ def update_panel_text_size(self):
84
80
self .chat_panel .setFont (
85
81
QFontDatabase .font (self .font ().family (), "" , int (self .font_size_combobox .currentText ())))
86
82
87
- def load_ai_config (self ):
83
+ def load_ai_config (self , show_load_complete : bool = False ):
88
84
ai_config_file = Path (str (Path .cwd ()) + "/" + ".jeditor/ai_config.json" )
89
85
if ai_config_file .exists ():
90
86
with open (ai_config_file , "r" , encoding = "utf-8" ):
@@ -101,6 +97,12 @@ def load_ai_config(self):
101
97
chat_model = ai_info .get ("chat_model" ),
102
98
prompt_template = ai_info .get ("prompt_template" ),
103
99
)
100
+ if show_load_complete :
101
+ load_complete = QMessageBox (self )
102
+ load_complete .setWindowTitle (language_wrapper .language_word_dict .get ("load_ai_messagebox_title" ))
103
+ load_complete .setText (language_wrapper .language_word_dict .get ("load_ai_messagebox_text" ))
104
+ load_complete .exec ()
105
+
104
106
105
107
def call_ai_model (self ):
106
108
if isinstance (self .lang_chain_interface , LangChainInterface ):
@@ -121,3 +123,8 @@ def pull_message(self):
121
123
ai_response = ai_config .message_queue .get_nowait ()
122
124
self .chat_panel .appendPlainText (ai_response )
123
125
self .chat_panel .appendPlainText ("\n " )
126
+
127
+ def set_ai_config (self ):
128
+ # Set and output AI a config file
129
+ self .set_ai_config_dialog = SetAIDialog ()
130
+ self .set_ai_config_dialog .show ()
0 commit comments