-
Notifications
You must be signed in to change notification settings - Fork 8
/
SettingsPage.qml
321 lines (269 loc) · 11.5 KB
/
SettingsPage.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Intellicute
import core
Page {
id: root
required property var settings
signal cancel
signal accept
signal reset
function applySettings() {
root.settings.tts.autoplay = autoplayCheckbox.checked
root.settings.tts.watson.use = useWatsonCheckbox.checked
root.settings.tts.watson.voice = voiceComboBox.currentText
root.settings.tts.locale = localeComboBox.currentText
root.settings.tts.watson.apiKey = watsonApiKeyTextField.text
root.settings.tts.watson.apiUrl = watsonApiUrlTextField.text
root.settings.chat.defaultMessages = JSON.parse(messageModel.jsonString)
root.settings.chat.temperature = temperatureSlider.value
root.settings.chat.topP = topPSlider.value
root.settings.chat.frequencyPenalty = frequencyPenaltySlider.value
root.settings.chat.presencePenalty = presencePenaltySlider.value
root.settings.chat.maxTokens = maxTokensSpinBox.value
root.settings.openai.accessToken = openAiAccessTokenTextField.text
}
QtObject {
id: d
readonly property var watsonVoices: ["de-DE_DieterV3Voice", "de-DE_BirgitV3Voice", "en-US_AllisonV3Voice", "en-US_LisaV3Voice", "en-US_MichaelV3Voice", "es-ES_EnriqueV3Voice", "es-ES_LauraV3Voice", "es-LA_SofiaV3Voice", "es-US_SofiaV3Voice", "fr-FR_ReneeV3Voice", "it-IT_FrancescaV3Voice", "ja-JP_EmiV3Voice", "ko-KR_YoungmiV3Voice", "pt-BR_IsabelaV3Voice", "zh-CN_LiNaVoice", "zh-CN_WangWeiVoice", "zh-CN_ZhangJingVoice"]
readonly property var openAiModels: ["gpt-3.5-turbo"]
}
component ValueSlider: RowLayout {
property alias value: control.value
property alias slider: control
Label {
text: control.from
}
Slider {
id: control
Layout.fillWidth: true
from: 0
to: 1
stepSize: 0.1
handle: Rectangle {
x: control.leftPadding + control.visualPosition * (control.availableWidth - width)
y: control.topPadding + control.availableHeight / 2 - height / 2
implicitWidth: 32
implicitHeight: 32
radius: width / 2.0
color: control.pressed ? "#f0f0f0" : "#f6f6f6"
border.color: "#bdbebf"
Label {
anchors.centerIn: parent
text: control.value.toFixed(1)
}
}
}
Label {
text: control.to
}
}
component HidableTextField: RowLayout {
property alias text: control.text
property alias textField: control
property alias hidden: button.checked
TextField {
id: control
Layout.fillWidth: true
echoMode: !button.checked ? TextInput.Password : TextInput.Normal
}
ToolButton {
id: button
text: control.echoMode == TextInput.Normal ? "\uf070" : "\uf06e"
font.family: "FontAwesome"
checkable: true
}
}
ColumnLayout {
anchors.fill: parent
anchors.margins: Style.singleMargin
ScrollView {
id: scrollView
readonly property bool scrollBarRequired: scrollView.contentHeight
> scrollView.availableHeight
contentWidth: availableWidth
Layout.fillWidth: true
Layout.fillHeight: true
ScrollBar.vertical.policy: scrollBarRequired ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
ColumnLayout {
id: settingsContent
width: scrollView.availableWidth
- (scrollView.scrollBarRequired ? scrollView.ScrollBar.vertical.width
+ Style.singleMargin : 0)
height: implicitHeight > scrollView.availableHeight ? implicitHeight : scrollView.availableHeight
ColumnLayout {
Layout.fillWidth: true
Layout.fillHeight: true
GroupBox {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.preferredHeight: 300
title: qsTr("Default Messages")
clip: true
ChatView {
anchors.fill: parent
anchors.margins: Style.singleMargin
model: OpenAIMessageModel {
id: messageModel
jsonString: JSON.stringify(
root.settings.chat.defaultMessages)
}
}
}
GroupBox {
Layout.fillWidth: true
title: qsTr("Chat Settings")
GridLayout {
anchors.fill: parent
columns: 2
Label {
text: qsTr("Temperature")
}
ValueSlider {
id: temperatureSlider
Layout.fillWidth: true
slider.value: root.settings.chat.temperature
}
Label {
text: qsTr("Top P")
}
ValueSlider {
id: topPSlider
Layout.fillWidth: true
slider.value: root.settings.chat.topP
}
Label {
text: qsTr("Frequency Penalty")
}
ValueSlider {
id: frequencyPenaltySlider
Layout.fillWidth: true
slider.value: root.settings.chat.frequencyPenalty
}
Label {
text: qsTr("Presence Penalty")
}
ValueSlider {
id: presencePenaltySlider
Layout.fillWidth: true
slider.value: root.settings.chat.presencePenalty
}
Label {
text: qsTr("Max Tokens")
}
SpinBox {
id: maxTokensSpinBox
value: root.settings.chat.maxTokens
from: 1
to: 2048
editable: true
}
Label {
text: qsTr("OpenAI API Access Token")
}
HidableTextField {
id: openAiAccessTokenTextField
Layout.fillWidth: true
text: root.settings.openai.accessToken
}
}
}
GroupBox {
Layout.fillWidth: true
title: qsTr("TTS Settings")
GridLayout {
anchors.fill: parent
columns: 2
CheckBox {
id: autoplayCheckbox
Layout.columnSpan: 2
text: qsTr("Auto Speak")
checked: root.settings.tts.autoplay
}
Label {
text: qsTr("TTS Locale")
}
ComboBox {
id: localeComboBox
model: ["de", "en", "es", "fr", "it", "ja", "ko", "pt", "zh"]
currentIndex: model.indexOf(
root.settings.tts.locale)
}
GroupBox {
label: CheckBox {
id: useWatsonCheckbox
text: qsTr("Use Watson TTS")
checked: root.settings.tts.watson.use
}
Layout.columnSpan: 2
Layout.fillWidth: true
GridLayout {
anchors.fill: parent
enabled: useWatsonCheckbox.checked
columns: 2
Label {
text: qsTr("Voice")
}
ComboBox {
id: voiceComboBox
Layout.fillWidth: true
model: d.watsonVoices
currentIndex: d.watsonVoices.indexOf(
root.settings.tts.watson.voice)
}
Label {
text: qsTr("IBM Watson API Key")
}
HidableTextField {
id: watsonApiKeyTextField
Layout.fillWidth: true
text: root.settings.tts.watson.apiKey
}
Label {
text: qsTr("IBM Watson API URL")
}
HidableTextField {
id: watsonApiUrlTextField
Layout.fillWidth: true
text: root.settings.tts.watson.apiUrl
}
}
}
}
}
}
Item {
Layout.fillHeight: true
}
}
}
RowLayout {
Button {
id: rejectButton
text: qsTr("Cancel")
onClicked: {
root.cancel()
}
}
Button {
id: resetButton
text: qsTr("Reset to Defaults")
onClicked: {
root.reset()
}
}
Item {
Layout.fillWidth: true
}
Button {
id: closeButton
text: qsTr("Apply")
onClicked: {
root.applySettings()
root.accept()
}
}
}
}
}