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