gpt4all

Форк
0
/
ApplicationSettings.qml 
311 строк · 10.2 Кб
1
import QtCore
2
import QtQuick
3
import QtQuick.Controls
4
import QtQuick.Controls.Basic
5
import QtQuick.Layouts
6
import QtQuick.Dialogs
7
import modellist
8
import mysettings
9
import network
10

11
MySettingsTab {
12
    onRestoreDefaultsClicked: {
13
        MySettings.restoreApplicationDefaults();
14
    }
15
    title: qsTr("Application")
16
    contentItem: GridLayout {
17
        id: applicationSettingsTabInner
18
        columns: 3
19
        rowSpacing: 10
20
        columnSpacing: 10
21
        MySettingsLabel {
22
            id: themeLabel
23
            text: qsTr("Theme")
24
            Layout.row: 1
25
            Layout.column: 0
26
        }
27
        MyComboBox {
28
            id: themeBox
29
            Layout.row: 1
30
            Layout.column: 1
31
            Layout.columnSpan: 1
32
            Layout.minimumWidth: 200
33
            Layout.fillWidth: false
34
            model: ["Dark", "Light", "LegacyDark"]
35
            Accessible.role: Accessible.ComboBox
36
            Accessible.name: qsTr("Color theme")
37
            Accessible.description: qsTr("Color theme for the chat client to use")
38
            function updateModel() {
39
                themeBox.currentIndex = themeBox.indexOfValue(MySettings.chatTheme);
40
            }
41
            Component.onCompleted: {
42
                themeBox.updateModel()
43
            }
44
            Connections {
45
                target: MySettings
46
                function onChatThemeChanged() {
47
                    themeBox.updateModel()
48
                }
49
            }
50
            onActivated: {
51
                MySettings.chatTheme = themeBox.currentText
52
            }
53
        }
54
        MySettingsLabel {
55
            id: fontLabel
56
            text: qsTr("Font Size")
57
            Layout.row: 2
58
            Layout.column: 0
59
        }
60
        MyComboBox {
61
            id: fontBox
62
            Layout.row: 2
63
            Layout.column: 1
64
            Layout.columnSpan: 1
65
            Layout.minimumWidth: 100
66
            Layout.fillWidth: false
67
            model: ["Small", "Medium", "Large"]
68
            Accessible.role: Accessible.ComboBox
69
            Accessible.name: qsTr("Font size")
70
            Accessible.description: qsTr("Font size of the chat client")
71
            function updateModel() {
72
                fontBox.currentIndex = fontBox.indexOfValue(MySettings.fontSize);
73
            }
74
            Component.onCompleted: {
75
                fontBox.updateModel()
76
            }
77
            Connections {
78
                target: MySettings
79
                function onFontSizeChanged() {
80
                    fontBox.updateModel()
81
                }
82
            }
83
            onActivated: {
84
                MySettings.fontSize = fontBox.currentText
85
            }
86
        }
87
        MySettingsLabel {
88
            id: deviceLabel
89
            text: qsTr("Device")
90
            Layout.row: 3
91
            Layout.column: 0
92
        }
93
        MyComboBox {
94
            id: deviceBox
95
            Layout.row: 3
96
            Layout.column: 1
97
            Layout.columnSpan: 1
98
            Layout.minimumWidth: 350
99
            Layout.fillWidth: false
100
            model: MySettings.deviceList
101
            Accessible.role: Accessible.ComboBox
102
            Accessible.name: qsTr("Device")
103
            Accessible.description: qsTr("Device of the chat client")
104
            function updateModel() {
105
                deviceBox.currentIndex = deviceBox.indexOfValue(MySettings.device);
106
            }
107
            Component.onCompleted: {
108
                deviceBox.updateModel()
109
            }
110
            Connections {
111
                target: MySettings
112
                function onDeviceChanged() {
113
                    deviceBox.updateModel()
114
                }
115
                function onDeviceListChanged() {
116
                    deviceBox.updateModel()
117
                }
118
            }
119
            onActivated: {
120
                MySettings.device = deviceBox.currentText
121
            }
122
        }
123
        MySettingsLabel {
124
            id: defaultModelLabel
125
            text: qsTr("Default model")
126
            Layout.row: 4
127
            Layout.column: 0
128
        }
129
        MyComboBox {
130
            id: comboBox
131
            Layout.row: 4
132
            Layout.column: 1
133
            Layout.columnSpan: 2
134
            Layout.minimumWidth: 350
135
            Layout.fillWidth: true
136
            model: ModelList.userDefaultModelList
137
            Accessible.role: Accessible.ComboBox
138
            Accessible.name: qsTr("Default model")
139
            Accessible.description: qsTr("Default model to use; the first item is the current default model")
140
            function updateModel() {
141
                comboBox.currentIndex = comboBox.indexOfValue(MySettings.userDefaultModel);
142
            }
143
            Component.onCompleted: {
144
                comboBox.updateModel()
145
            }
146
            Connections {
147
                target: MySettings
148
                function onUserDefaultModelChanged() {
149
                    comboBox.updateModel()
150
                }
151
            }
152
            onActivated: {
153
                MySettings.userDefaultModel = comboBox.currentText
154
            }
155
        }
156
        MySettingsLabel {
157
            id: modelPathLabel
158
            text: qsTr("Download path")
159
            Layout.row: 5
160
            Layout.column: 0
161
        }
162
        MyDirectoryField {
163
            id: modelPathDisplayField
164
            text: MySettings.modelPath
165
            font.pixelSize: theme.fontSizeLarge
166
            implicitWidth: 300
167
            Layout.row: 5
168
            Layout.column: 1
169
            Layout.fillWidth: true
170
            ToolTip.text: qsTr("Path where model files will be downloaded to")
171
            ToolTip.visible: hovered
172
            Accessible.role: Accessible.ToolTip
173
            Accessible.name: modelPathDisplayField.text
174
            Accessible.description: ToolTip.text
175
            onEditingFinished: {
176
                if (isValid) {
177
                    MySettings.modelPath = modelPathDisplayField.text
178
                } else {
179
                    text = MySettings.modelPath
180
                }
181
            }
182
        }
183
        MySettingsButton {
184
            Layout.row: 5
185
            Layout.column: 2
186
            text: qsTr("Browse")
187
            Accessible.description: qsTr("Choose where to save model files")
188
            onClicked: {
189
                openFolderDialog("file://" + MySettings.modelPath, function(selectedFolder) {
190
                    MySettings.modelPath = selectedFolder
191
                })
192
            }
193
        }
194
        MySettingsLabel {
195
            id: nThreadsLabel
196
            text: qsTr("CPU Threads")
197
            Layout.row: 6
198
            Layout.column: 0
199
        }
200
        MyTextField {
201
            text: MySettings.threadCount
202
            color: theme.textColor
203
            font.pixelSize: theme.fontSizeLarge
204
            ToolTip.text: qsTr("Amount of processing threads to use bounded by 1 and number of logical processors")
205
            ToolTip.visible: hovered
206
            Layout.row: 6
207
            Layout.column: 1
208
            validator: IntValidator {
209
                bottom: 1
210
            }
211
            onEditingFinished: {
212
                var val = parseInt(text)
213
                if (!isNaN(val)) {
214
                    MySettings.threadCount = val
215
                    focus = false
216
                } else {
217
                    text = MySettings.threadCount
218
                }
219
            }
220
            Accessible.role: Accessible.EditableText
221
            Accessible.name: nThreadsLabel.text
222
            Accessible.description: ToolTip.text
223
        }
224
        MySettingsLabel {
225
            id: saveChatsContextLabel
226
            text: qsTr("Save chats context to disk")
227
            Layout.row: 7
228
            Layout.column: 0
229
        }
230
        MyCheckBox {
231
            id: saveChatsContextBox
232
            Layout.row: 7
233
            Layout.column: 1
234
            checked: MySettings.saveChatsContext
235
            onClicked: {
236
                MySettings.saveChatsContext = !MySettings.saveChatsContext
237
            }
238
            ToolTip.text: qsTr("WARNING: Saving chats to disk can be ~2GB per chat")
239
            ToolTip.visible: hovered
240
        }
241
        MySettingsLabel {
242
            id: serverChatLabel
243
            text: qsTr("Enable API server")
244
            Layout.row: 8
245
            Layout.column: 0
246
        }
247
        MyCheckBox {
248
            id: serverChatBox
249
            Layout.row: 8
250
            Layout.column: 1
251
            checked: MySettings.serverChat
252
            onClicked: {
253
                MySettings.serverChat = !MySettings.serverChat
254
            }
255
            ToolTip.text: qsTr("WARNING: This enables the gui to act as a local REST web server(OpenAI API compliant) for API requests and will increase your RAM usage as well")
256
            ToolTip.visible: hovered
257
        }
258
        Rectangle {
259
            Layout.row: 9
260
            Layout.column: 0
261
            Layout.columnSpan: 3
262
            Layout.fillWidth: true
263
            height: 3
264
            color: theme.accentColor
265
        }
266
    }
267
    advancedSettings: GridLayout {
268
        columns: 3
269
        rowSpacing: 10
270
        columnSpacing: 10
271
        Rectangle {
272
            Layout.row: 2
273
            Layout.column: 0
274
            Layout.fillWidth: true
275
            Layout.columnSpan: 3
276
            height: 3
277
            color: theme.accentColor
278
        }
279
        MySettingsLabel {
280
            id: gpuOverrideLabel
281
            text: qsTr("Force Metal (macOS+arm)")
282
            Layout.row: 1
283
            Layout.column: 0
284
        }
285
        RowLayout {
286
            Layout.row: 1
287
            Layout.column: 1
288
            Layout.columnSpan: 2
289
            MyCheckBox {
290
                id: gpuOverrideBox
291
                checked: MySettings.forceMetal
292
                onClicked: {
293
                    MySettings.forceMetal = !MySettings.forceMetal
294
                }
295
            }
296

297
            Item {
298
                Layout.fillWidth: true
299
                Layout.alignment: Qt.AlignTop
300
                Layout.minimumHeight: warningLabel.height
301
                MySettingsLabel {
302
                    id: warningLabel
303
                    width: parent.width
304
                    color: theme.textErrorColor
305
                    wrapMode: Text.WordWrap
306
                    text: qsTr("WARNING: On macOS with arm (M1+) this setting forces usage of the GPU. Can cause crashes if the model requires more RAM than the system supports. Because of crash possibility the setting will not persist across restarts of the application. This has no effect on non-macs or intel.")
307
                }
308
            }
309
        }
310
    }
311
}
312

313

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.