1
1
from PySide6 .QtWidgets import (
2
2
QApplication , QWidget , QPushButton , QVBoxLayout , QTabWidget ,
3
- QTextEdit , QSplitter , QFrame , QStyleFactory , QLabel , QGridLayout , QMenuBar
3
+ QTextEdit , QSplitter , QFrame , QStyleFactory , QLabel , QGridLayout , QMenuBar , QCheckBox
4
4
)
5
5
from PySide6 .QtCore import Qt , QThread , Signal , QUrl
6
6
from PySide6 .QtWebEngineWidgets import QWebEngineView
7
7
import os
8
+ import yaml
8
9
from initialize import determine_compute_device , is_nvidia_gpu , get_os_name
9
10
from download_model import download_embedding_model
10
11
from select_model import select_embedding_model_directory
@@ -33,15 +34,14 @@ def init_ui(self):
33
34
self .setGeometry (300 , 300 , 975 , 975 )
34
35
self .setMinimumSize (450 , 510 )
35
36
36
- # Left panel setup with grid layout
37
+ # Left frame setup
37
38
self .left_frame = QFrame ()
38
39
grid_layout = QGridLayout ()
39
40
40
- # Tab widget spanning two columns
41
41
tab_widget = create_tabs ()
42
- grid_layout .addWidget (tab_widget , 0 , 0 , 1 , 2 ) # Span two columns
42
+ grid_layout .addWidget (tab_widget , 0 , 0 , 1 , 2 )
43
43
44
- # Button definitions and positions in the grid
44
+ # Button definitions and positions
45
45
button_data = [
46
46
("Download Embedding Model" , lambda : download_embedding_model (self )),
47
47
("Set Embedding Model Directory" , select_embedding_model_directory ),
@@ -59,7 +59,7 @@ def init_ui(self):
59
59
self .left_frame .setLayout (grid_layout )
60
60
main_splitter .addWidget (self .left_frame )
61
61
62
- # Right panel setup
62
+ # Right frame setup
63
63
right_frame = QFrame ()
64
64
right_vbox = QVBoxLayout ()
65
65
@@ -73,13 +73,14 @@ def init_ui(self):
73
73
74
74
submit_questions_button = QPushButton ("Submit Questions" )
75
75
submit_questions_button .clicked .connect (self .on_submit_button_clicked )
76
-
77
76
right_vbox .addWidget (submit_questions_button )
78
77
79
- # Define widget containing buttons
80
- button_row_widget = create_button_row (self .on_submit_button_clicked )
78
+ # Add Test Embeddings Checkbox
79
+ self .test_embeddings_checkbox = QCheckBox ("Test Embeddings" )
80
+ self .test_embeddings_checkbox .stateChanged .connect (self .on_test_embeddings_changed )
81
+ right_vbox .addWidget (self .test_embeddings_checkbox )
81
82
82
- # Add widgets from button_module.py
83
+ button_row_widget = create_button_row ( self . on_submit_button_clicked )
83
84
right_vbox .addWidget (button_row_widget )
84
85
85
86
right_frame .setLayout (right_vbox )
@@ -90,7 +91,6 @@ def init_ui(self):
90
91
main_layout .addWidget (main_splitter )
91
92
main_layout .addWidget (self .metrics_bar )
92
93
93
- # Create menu bar
94
94
def init_menu (self ):
95
95
self .menu_bar = QMenuBar (self )
96
96
self .theme_menu = self .menu_bar .addMenu ('Themes' )
@@ -116,6 +116,18 @@ def on_submit_button_clicked(self):
116
116
self .submit_button_thread .responseSignal .connect (self .update_response )
117
117
self .submit_button_thread .start ()
118
118
119
+ def on_test_embeddings_changed (self ):
120
+ script_dir = os .path .dirname (os .path .realpath (__file__ ))
121
+ config_path = os .path .join (script_dir , 'config.yaml' )
122
+
123
+ with open (config_path , 'r' ) as file :
124
+ config = yaml .safe_load (file )
125
+
126
+ config ['test_embeddings' ] = self .test_embeddings_checkbox .isChecked ()
127
+
128
+ with open (config_path , 'w' ) as file :
129
+ yaml .dump (config , file )
130
+
119
131
def update_response (self , response ):
120
132
self .read_only_text .setPlainText (response )
121
133
0 commit comments