gpt4all

Форк
0
/
ModelSettings.qml 
792 строки · 30.2 Кб
1
import QtCore
2
import QtQuick
3
import QtQuick.Controls
4
import QtQuick.Controls.Basic
5
import QtQuick.Layouts
6
import modellist
7
import mysettings
8

9
MySettingsTab {
10
    onRestoreDefaultsClicked: {
11
        MySettings.restoreModelDefaults(root.currentModelInfo);
12
    }
13
    title: qsTr("Model/Character Settings")
14
    contentItem: GridLayout {
15
        id: root
16
        columns: 3
17
        rowSpacing: 10
18
        columnSpacing: 10
19

20
        property var currentModelName: comboBox.currentText
21
        property var currentModelId: comboBox.currentValue
22
        property var currentModelInfo: ModelList.modelInfo(root.currentModelId)
23

24
        MySettingsLabel {
25
            id: label
26
            Layout.row: 0
27
            Layout.column: 0
28
            text: qsTr("Model/Character")
29
        }
30

31
        RowLayout {
32
            Layout.fillWidth: true
33
            Layout.row: 1
34
            Layout.column: 0
35
            Layout.columnSpan: 2
36
            height: label.height + 20
37
            spacing: 10
38

39
            MyComboBox {
40
                id: comboBox
41
                Layout.fillWidth: true
42
                model: ModelList.installedModels
43
                valueRole: "id"
44
                textRole: "name"
45
                currentIndex: 0
46
                contentItem: Text {
47
                    leftPadding: 10
48
                    rightPadding: 20
49
                    text: comboBox.currentText
50
                    font: comboBox.font
51
                    color: theme.textColor
52
                    verticalAlignment: Text.AlignVCenter
53
                    elide: Text.ElideRight
54
                }
55
                delegate: ItemDelegate {
56
                    width: comboBox.width
57
                    contentItem: Text {
58
                        text: name
59
                        color: theme.textColor
60
                        font: comboBox.font
61
                        elide: Text.ElideRight
62
                        verticalAlignment: Text.AlignVCenter
63
                    }
64
                    background: Rectangle {
65
                        color: highlighted ? theme.lightContrast : theme.darkContrast
66
                    }
67
                    highlighted: comboBox.highlightedIndex === index
68
                }
69
            }
70

71
            MySettingsButton {
72
                id: cloneButton
73
                text: qsTr("Clone")
74
                onClicked: {
75
                    var id = ModelList.clone(root.currentModelInfo);
76
                    comboBox.currentIndex = comboBox.indexOfValue(id);
77
                }
78
            }
79

80
            MySettingsDestructiveButton {
81
                id: removeButton
82
                enabled: root.currentModelInfo.isClone
83
                text: qsTr("Remove")
84
                onClicked: {
85
                    ModelList.remove(root.currentModelInfo);
86
                    comboBox.currentIndex = 0;
87
                }
88
            }
89
        }
90

91
        RowLayout {
92
            Layout.row: 2
93
            Layout.column: 0
94
            Layout.topMargin: 15
95
            spacing: 10
96
            MySettingsLabel {
97
                id: uniqueNameLabel
98
                text: qsTr("Unique Name")
99
            }
100
            MySettingsLabel {
101
                id: uniqueNameLabelHelp
102
                visible: false
103
                text: qsTr("Must contain a non-empty unique name that does not match any existing model/character.")
104
                color: theme.textErrorColor
105
                wrapMode: TextArea.Wrap
106
            }
107
        }
108

109
        MyTextField {
110
            id: uniqueNameField
111
            text: root.currentModelName
112
            font.pixelSize: theme.fontSizeLarge
113
            enabled: root.currentModelInfo.isClone || root.currentModelInfo.description === ""
114
            Layout.row: 3
115
            Layout.column: 0
116
            Layout.columnSpan: 2
117
            Layout.fillWidth: true
118
            Connections {
119
                target: MySettings
120
                function onNameChanged() {
121
                    uniqueNameField.text = root.currentModelInfo.name;
122
                }
123
            }
124
            Connections {
125
                target: root
126
                function onCurrentModelInfoChanged() {
127
                    uniqueNameField.text = root.currentModelInfo.name;
128
                }
129
            }
130
            onTextChanged: {
131
                if (text !== "" && ModelList.isUniqueName(text)) {
132
                    MySettings.setModelName(root.currentModelInfo, text);
133
                }
134
                uniqueNameLabelHelp.visible = root.currentModelInfo.name !== "" &&
135
                    (text === "" || (text !== root.currentModelInfo.name && !ModelList.isUniqueName(text)));
136
            }
137
        }
138

139
        MySettingsLabel {
140
            text: qsTr("Model File")
141
            Layout.row: 4
142
            Layout.column: 0
143
            Layout.topMargin: 15
144
        }
145

146
        MyTextField {
147
            text: root.currentModelInfo.filename
148
            font.pixelSize: theme.fontSizeLarge
149
            enabled: false
150
            Layout.row: 5
151
            Layout.column: 0
152
            Layout.columnSpan: 2
153
            Layout.fillWidth: true
154
        }
155

156
        MySettingsLabel {
157
            visible: !root.currentModelInfo.isOnline
158
            text: qsTr("System Prompt")
159
            Layout.row: 6
160
            Layout.column: 0
161
            Layout.topMargin: 15
162
        }
163

164
        Rectangle {
165
            id: systemPrompt
166
            visible: !root.currentModelInfo.isOnline
167
            Layout.row: 7
168
            Layout.column: 0
169
            Layout.columnSpan: 2
170
            Layout.fillWidth: true
171
            color: "transparent"
172
            Layout.minimumHeight: Math.max(100, systemPromptArea.contentHeight + 20)
173
            MyTextArea {
174
                id: systemPromptArea
175
                anchors.fill: parent
176
                text: root.currentModelInfo.systemPrompt
177
                Connections {
178
                    target: MySettings
179
                    function onSystemPromptChanged() {
180
                        systemPromptArea.text = root.currentModelInfo.systemPrompt;
181
                    }
182
                }
183
                Connections {
184
                    target: root
185
                    function onCurrentModelInfoChanged() {
186
                        systemPromptArea.text = root.currentModelInfo.systemPrompt;
187
                    }
188
                }
189
                onTextChanged: {
190
                    MySettings.setModelSystemPrompt(root.currentModelInfo, text)
191
                }
192
                Accessible.role: Accessible.EditableText
193
                ToolTip.text: qsTr("The systemPrompt allows instructions to the model at the beginning of a chat.\nNOTE: A longer, detailed system prompt can lead to higher quality answers, but can also slow down generation.")
194
                ToolTip.visible: hovered
195
                ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
196
            }
197
        }
198

199
        RowLayout {
200
            Layout.row: 8
201
            Layout.column: 0
202
            Layout.columnSpan: 2
203
            Layout.topMargin: 15
204
            spacing: 10
205
            MySettingsLabel {
206
                id: promptTemplateLabel
207
                text: qsTr("Prompt Template")
208
            }
209
            MySettingsLabel {
210
                id: promptTemplateLabelHelp
211
                text: qsTr("Must contain the string \"%1\" to be replaced with the user's input.")
212
                color: theme.textErrorColor
213
                visible: templateTextArea.text.indexOf("%1") === -1
214
                wrapMode: TextArea.Wrap
215
            }
216
        }
217

218
        Rectangle {
219
            id: promptTemplate
220
            Layout.row: 9
221
            Layout.column: 0
222
            Layout.columnSpan: 2
223
            Layout.fillWidth: true
224
            Layout.minimumHeight: Math.max(100, templateTextArea.contentHeight + 20)
225
            color: "transparent"
226
            clip: true
227
            MyTextArea {
228
                id: templateTextArea
229
                anchors.fill: parent
230
                text: root.currentModelInfo.promptTemplate
231
                Connections {
232
                    target: MySettings
233
                    function onPromptTemplateChanged() {
234
                        templateTextArea.text = root.currentModelInfo.promptTemplate;
235
                    }
236
                }
237
                Connections {
238
                    target: root
239
                    function onCurrentModelInfoChanged() {
240
                        templateTextArea.text = root.currentModelInfo.promptTemplate;
241
                    }
242
                }
243
                onTextChanged: {
244
                    if (templateTextArea.text.indexOf("%1") !== -1) {
245
                        MySettings.setModelPromptTemplate(root.currentModelInfo, text)
246
                    }
247
                }
248
                Accessible.role: Accessible.EditableText
249
                Accessible.name: promptTemplateLabel.text
250
                Accessible.description: promptTemplateLabelHelp.text
251
                ToolTip.text: qsTr("The prompt template partially determines how models will respond to prompts.\nNOTE: A longer, detailed template can lead to higher quality answers, but can also slow down generation.")
252
                ToolTip.visible: hovered
253
                ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
254
            }
255
        }
256

257
        Rectangle {
258
            id: optionalImageRect
259
            visible: false // FIXME: for later
260
            Layout.row: 2
261
            Layout.column: 1
262
            Layout.rowSpan: 5
263
            Layout.alignment: Qt.AlignHCenter
264
            Layout.fillHeight: true
265
            Layout.maximumWidth: height
266
            Layout.topMargin: 35
267
            Layout.bottomMargin: 35
268
            Layout.leftMargin: 35
269
            width: 3000
270
            radius: 10
271
            color: "transparent"
272
            Item {
273
                anchors.centerIn: parent
274
                height: childrenRect.height
275
                Image {
276
                    id: img
277
                    anchors.horizontalCenter: parent.horizontalCenter
278
                    width: 100
279
                    height: 100
280
                    source: "qrc:/gpt4all/icons/image.svg"
281
                }
282
                Text {
283
                    text: qsTr("Add\noptional image")
284
                    font.pixelSize: theme.fontSizeLarge
285
                    anchors.top: img.bottom
286
                    anchors.horizontalCenter: parent.horizontalCenter
287
                    wrapMode: TextArea.Wrap
288
                    horizontalAlignment: Qt.AlignHCenter
289
                    color: theme.mutedTextColor
290
                }
291
            }
292
        }
293

294
        MySettingsLabel {
295
            text: qsTr("Generation Settings")
296
            Layout.row: 10
297
            Layout.column: 0
298
            Layout.columnSpan: 2
299
            Layout.topMargin: 15
300
            Layout.alignment: Qt.AlignHCenter
301
            Layout.minimumWidth: promptTemplate.width
302
            horizontalAlignment: Qt.AlignHCenter
303
            font.pixelSize: theme.fontSizeLarge
304
            font.bold: true
305
        }
306

307
        GridLayout {
308
            Layout.row: 11
309
            Layout.column: 0
310
            Layout.columnSpan: 2
311
            Layout.topMargin: 15
312
            Layout.fillWidth: true
313
            Layout.minimumWidth: promptTemplate.width
314
            columns: 4
315
            rowSpacing: 10
316
            columnSpacing: 10
317

318
            MySettingsLabel {
319
                id: contextLengthLabel
320
                visible: !root.currentModelInfo.isOnline
321
                text: qsTr("Context Length")
322
                Layout.row: 0
323
                Layout.column: 0
324
            }
325
            MyTextField {
326
                id: contextLengthField
327
                visible: !root.currentModelInfo.isOnline
328
                text: root.currentModelInfo.contextLength
329
                font.pixelSize: theme.fontSizeLarge
330
                color: theme.textColor
331
                ToolTip.text: qsTr("Maximum combined prompt/response tokens before information is lost.\nUsing more context than the model was trained on will yield poor results.\nNOTE: Does not take effect until you reload the model.")
332
                ToolTip.visible: hovered
333
                Layout.row: 0
334
                Layout.column: 1
335
                Connections {
336
                    target: MySettings
337
                    function onContextLengthChanged() {
338
                        contextLengthField.text = root.currentModelInfo.contextLength;
339
                    }
340
                }
341
                Connections {
342
                    target: root
343
                    function onCurrentModelInfoChanged() {
344
                        contextLengthField.text = root.currentModelInfo.contextLength;
345
                    }
346
                }
347
                onEditingFinished: {
348
                    var val = parseInt(text)
349
                    if (isNaN(val)) {
350
                        text = root.currentModelInfo.contextLength
351
                    } else {
352
                        if (val < 8) {
353
                            val = 8
354
                            contextLengthField.text = val
355
                        } else if (val > root.currentModelInfo.maxContextLength) {
356
                            val = root.currentModelInfo.maxContextLength
357
                            contextLengthField.text = val
358
                        }
359
                        MySettings.setModelContextLength(root.currentModelInfo, val)
360
                        focus = false
361
                    }
362
                }
363
                Accessible.role: Accessible.EditableText
364
                Accessible.name: contextLengthLabel.text
365
                Accessible.description: ToolTip.text
366
            }
367

368
            MySettingsLabel {
369
                id: tempLabel
370
                text: qsTr("Temperature")
371
                Layout.row: 1
372
                Layout.column: 2
373
            }
374

375
            MyTextField {
376
                id: temperatureField
377
                text: root.currentModelInfo.temperature
378
                font.pixelSize: theme.fontSizeLarge
379
                color: theme.textColor
380
                ToolTip.text: qsTr("Temperature increases the chances of choosing less likely tokens.\nNOTE: Higher temperature gives more creative but less predictable outputs.")
381
                ToolTip.visible: hovered
382
                Layout.row: 1
383
                Layout.column: 3
384
                validator: DoubleValidator {
385
                    locale: "C"
386
                }
387
                Connections {
388
                    target: MySettings
389
                    function onTemperatureChanged() {
390
                        temperatureField.text = root.currentModelInfo.temperature;
391
                    }
392
                }
393
                Connections {
394
                    target: root
395
                    function onCurrentModelInfoChanged() {
396
                        temperatureField.text = root.currentModelInfo.temperature;
397
                    }
398
                }
399
                onEditingFinished: {
400
                    var val = parseFloat(text)
401
                    if (!isNaN(val)) {
402
                        MySettings.setModelTemperature(root.currentModelInfo, val)
403
                        focus = false
404
                    } else {
405
                        text = root.currentModelInfo.temperature
406
                    }
407
                }
408
                Accessible.role: Accessible.EditableText
409
                Accessible.name: tempLabel.text
410
                Accessible.description: ToolTip.text
411
            }
412
            MySettingsLabel {
413
                id: topPLabel
414
                text: qsTr("Top P")
415
                Layout.row: 2
416
                Layout.column: 0
417
            }
418
            MyTextField {
419
                id: topPField
420
                text: root.currentModelInfo.topP
421
                color: theme.textColor
422
                font.pixelSize: theme.fontSizeLarge
423
                ToolTip.text: qsTr("Only the most likely tokens up to a total probability of top_p can be chosen.\nNOTE: Prevents choosing highly unlikely tokens, aka Nucleus Sampling")
424
                ToolTip.visible: hovered
425
                Layout.row: 2
426
                Layout.column: 1
427
                validator: DoubleValidator {
428
                    locale: "C"
429
                }
430
                Connections {
431
                    target: MySettings
432
                    function onTopPChanged() {
433
                        topPField.text = root.currentModelInfo.topP;
434
                    }
435
                }
436
                Connections {
437
                    target: root
438
                    function onCurrentModelInfoChanged() {
439
                        topPField.text = root.currentModelInfo.topP;
440
                    }
441
                }
442
                onEditingFinished: {
443
                    var val = parseFloat(text)
444
                    if (!isNaN(val)) {
445
                        MySettings.setModelTopP(root.currentModelInfo, val)
446
                        focus = false
447
                    } else {
448
                        text = root.currentModelInfo.topP
449
                    }
450
                }
451
                Accessible.role: Accessible.EditableText
452
                Accessible.name: topPLabel.text
453
                Accessible.description: ToolTip.text
454
            }
455
            MySettingsLabel {
456
                id: minPLabel 
457
                text: qsTr("Min P")
458
                Layout.row: 3
459
                Layout.column: 0
460
            }
461
            MyTextField {
462
                id: minPField
463
                text: root.currentModelInfo.minP
464
                color: theme.textColor
465
                font.pixelSize: theme.fontSizeLarge
466
                ToolTip.text: qsTr("Sets the minimum relative probability for a token to be considered.")
467
                ToolTip.visible: hovered
468
                Layout.row: 3
469
                Layout.column: 1
470
                validator: DoubleValidator {
471
                    locale: "C"
472
                }
473
                Connections {
474
                    target: MySettings
475
                    function onMinPChanged() {
476
                        minPField.text = root.currentModelInfo.minP;
477
                    }
478
                }
479
                Connections {
480
                    target: root
481
                    function onCurrentModelInfoChanged() {
482
                        minPField.text = root.currentModelInfo.minP;
483
                    }
484
                }
485
                onEditingFinished: {
486
                    var val = parseFloat(text)
487
                    if (!isNaN(val)) {
488
                        MySettings.setModelMinP(root.currentModelInfo, val)
489
                        focus = false
490
                    } else {
491
                        text = root.currentModelInfo.minP
492
                    }
493
                }
494
                Accessible.role: Accessible.EditableText
495
                Accessible.name: minPLabel.text
496
                Accessible.description: ToolTip.text
497
            }
498

499
            MySettingsLabel {
500
                id: topKLabel
501
                visible: !root.currentModelInfo.isOnline
502
                text: qsTr("Top K")
503
                Layout.row: 2
504
                Layout.column: 2
505
            }
506
            MyTextField {
507
                id: topKField
508
                visible: !root.currentModelInfo.isOnline
509
                text: root.currentModelInfo.topK
510
                color: theme.textColor
511
                font.pixelSize: theme.fontSizeLarge
512
                ToolTip.text: qsTr("Only the top K most likely tokens will be chosen from")
513
                ToolTip.visible: hovered
514
                Layout.row: 2
515
                Layout.column: 3
516
                validator: IntValidator {
517
                    bottom: 1
518
                }
519
                Connections {
520
                    target: MySettings
521
                    function onTopKChanged() {
522
                        topKField.text = root.currentModelInfo.topK;
523
                    }
524
                }
525
                Connections {
526
                    target: root
527
                    function onCurrentModelInfoChanged() {
528
                        topKField.text = root.currentModelInfo.topK;
529
                    }
530
                }
531
                onEditingFinished: {
532
                    var val = parseInt(text)
533
                    if (!isNaN(val)) {
534
                        MySettings.setModelTopK(root.currentModelInfo, val)
535
                        focus = false
536
                    } else {
537
                        text = root.currentModelInfo.topK
538
                    }
539
                }
540
                Accessible.role: Accessible.EditableText
541
                Accessible.name: topKLabel.text
542
                Accessible.description: ToolTip.text
543
            }
544
            MySettingsLabel {
545
                id: maxLengthLabel
546
                visible: !root.currentModelInfo.isOnline
547
                text: qsTr("Max Length")
548
                Layout.row: 0
549
                Layout.column: 2
550
            }
551
            MyTextField {
552
                id: maxLengthField
553
                visible: !root.currentModelInfo.isOnline
554
                text: root.currentModelInfo.maxLength
555
                color: theme.textColor
556
                font.pixelSize: theme.fontSizeLarge
557
                ToolTip.text: qsTr("Maximum length of response in tokens")
558
                ToolTip.visible: hovered
559
                Layout.row: 0
560
                Layout.column: 3
561
                validator: IntValidator {
562
                    bottom: 1
563
                }
564
                Connections {
565
                    target: MySettings
566
                    function onMaxLengthChanged() {
567
                        maxLengthField.text = root.currentModelInfo.maxLength;
568
                    }
569
                }
570
                Connections {
571
                    target: root
572
                    function onCurrentModelInfoChanged() {
573
                        maxLengthField.text = root.currentModelInfo.maxLength;
574
                    }
575
                }
576
                onEditingFinished: {
577
                    var val = parseInt(text)
578
                    if (!isNaN(val)) {
579
                        MySettings.setModelMaxLength(root.currentModelInfo, val)
580
                        focus = false
581
                    } else {
582
                        text = root.currentModelInfo.maxLength
583
                    }
584
                }
585
                Accessible.role: Accessible.EditableText
586
                Accessible.name: maxLengthLabel.text
587
                Accessible.description: ToolTip.text
588
            }
589

590
            MySettingsLabel {
591
                id: batchSizeLabel
592
                visible: !root.currentModelInfo.isOnline
593
                text: qsTr("Prompt Batch Size")
594
                Layout.row: 1
595
                Layout.column: 0
596
            }
597
            MyTextField {
598
                id: batchSizeField
599
                visible: !root.currentModelInfo.isOnline
600
                text: root.currentModelInfo.promptBatchSize
601
                color: theme.textColor
602
                font.pixelSize: theme.fontSizeLarge
603
                ToolTip.text: qsTr("Amount of prompt tokens to process at once.\nNOTE: Higher values can speed up reading prompts but will use more RAM")
604
                ToolTip.visible: hovered
605
                Layout.row: 1
606
                Layout.column: 1
607
                validator: IntValidator {
608
                    bottom: 1
609
                }
610
                Connections {
611
                    target: MySettings
612
                    function onPromptBatchSizeChanged() {
613
                        batchSizeField.text = root.currentModelInfo.promptBatchSize;
614
                    }
615
                }
616
                Connections {
617
                    target: root
618
                    function onCurrentModelInfoChanged() {
619
                        batchSizeField.text = root.currentModelInfo.promptBatchSize;
620
                    }
621
                }
622
                onEditingFinished: {
623
                    var val = parseInt(text)
624
                    if (!isNaN(val)) {
625
                        MySettings.setModelPromptBatchSize(root.currentModelInfo, val)
626
                        focus = false
627
                    } else {
628
                        text = root.currentModelInfo.promptBatchSize
629
                    }
630
                }
631
                Accessible.role: Accessible.EditableText
632
                Accessible.name: batchSizeLabel.text
633
                Accessible.description: ToolTip.text
634
            }
635
            MySettingsLabel {
636
                id: repeatPenaltyLabel
637
                visible: !root.currentModelInfo.isOnline
638
                text: qsTr("Repeat Penalty")
639
                Layout.row: 4
640
                Layout.column: 2
641
            }
642
            MyTextField {
643
                id: repeatPenaltyField
644
                visible: !root.currentModelInfo.isOnline
645
                text: root.currentModelInfo.repeatPenalty
646
                color: theme.textColor
647
                font.pixelSize: theme.fontSizeLarge
648
                ToolTip.text: qsTr("Amount to penalize repetitiveness of the output")
649
                ToolTip.visible: hovered
650
                Layout.row: 4
651
                Layout.column: 3
652
                validator: DoubleValidator {
653
                    locale: "C"
654
                }
655
                Connections {
656
                    target: MySettings
657
                    function onRepeatPenaltyChanged() {
658
                        repeatPenaltyField.text = root.currentModelInfo.repeatPenalty;
659
                    }
660
                }
661
                Connections {
662
                    target: root
663
                    function onCurrentModelInfoChanged() {
664
                        repeatPenaltyField.text = root.currentModelInfo.repeatPenalty;
665
                    }
666
                }
667
                onEditingFinished: {
668
                    var val = parseFloat(text)
669
                    if (!isNaN(val)) {
670
                        MySettings.setModelRepeatPenalty(root.currentModelInfo, val)
671
                        focus = false
672
                    } else {
673
                        text = root.currentModelInfo.repeatPenalty
674
                    }
675
                }
676
                Accessible.role: Accessible.EditableText
677
                Accessible.name: repeatPenaltyLabel.text
678
                Accessible.description: ToolTip.text
679
            }
680
            MySettingsLabel {
681
                id: repeatPenaltyTokensLabel
682
                visible: !root.currentModelInfo.isOnline
683
                text: qsTr("Repeat Penalty Tokens")
684
                Layout.row: 3
685
                Layout.column: 2
686
            }
687
            MyTextField {
688
                id: repeatPenaltyTokenField
689
                visible: !root.currentModelInfo.isOnline
690
                text: root.currentModelInfo.repeatPenaltyTokens
691
                color: theme.textColor
692
                font.pixelSize: theme.fontSizeLarge
693
                ToolTip.text: qsTr("How far back in output to apply repeat penalty")
694
                ToolTip.visible: hovered
695
                Layout.row: 3
696
                Layout.column: 3
697
                validator: IntValidator {
698
                    bottom: 1
699
                }
700
                Connections {
701
                    target: MySettings
702
                    function onRepeatPenaltyTokensChanged() {
703
                        repeatPenaltyTokenField.text = root.currentModelInfo.repeatPenaltyTokens;
704
                    }
705
                }
706
                Connections {
707
                    target: root
708
                    function onCurrentModelInfoChanged() {
709
                        repeatPenaltyTokenField.text = root.currentModelInfo.repeatPenaltyTokens;
710
                    }
711
                }
712
                onEditingFinished: {
713
                    var val = parseInt(text)
714
                    if (!isNaN(val)) {
715
                        MySettings.setModelRepeatPenaltyTokens(root.currentModelInfo, val)
716
                        focus = false
717
                    } else {
718
                        text = root.currentModelInfo.repeatPenaltyTokens
719
                    }
720
                }
721
                Accessible.role: Accessible.EditableText
722
                Accessible.name: repeatPenaltyTokensLabel.text
723
                Accessible.description: ToolTip.text
724
            }
725

726
            MySettingsLabel {
727
                id: gpuLayersLabel
728
                visible: !root.currentModelInfo.isOnline
729
                text: qsTr("GPU Layers")
730
                Layout.row: 4
731
                Layout.column: 0
732
            }
733
            MyTextField {
734
                id: gpuLayersField
735
                visible: !root.currentModelInfo.isOnline
736
                text: root.currentModelInfo.gpuLayers
737
                font.pixelSize: theme.fontSizeLarge
738
                color: theme.textColor
739
                ToolTip.text: qsTr("How many GPU layers to load into VRAM. Decrease this if GPT4All runs out of VRAM while loading this model.\nLower values increase CPU load and RAM usage, and make inference slower.\nNOTE: Does not take effect until you reload the model.")
740
                ToolTip.visible: hovered
741
                Layout.row: 4
742
                Layout.column: 1
743
                Connections {
744
                    target: MySettings
745
                    function onGpuLayersChanged() {
746
                        gpuLayersField.text = root.currentModelInfo.gpuLayers
747
                    }
748
                }
749
                Connections {
750
                    target: root
751
                    function onCurrentModelInfoChanged() {
752
                        if (root.currentModelInfo.gpuLayers === 100) {
753
                            gpuLayersField.text = root.currentModelInfo.maxGpuLayers
754
                        } else {
755
                            gpuLayersField.text = root.currentModelInfo.gpuLayers
756
                        }
757
                    }
758
                }
759
                onEditingFinished: {
760
                    var val = parseInt(text)
761
                    if (isNaN(val)) {
762
                        gpuLayersField.text = root.currentModelInfo.gpuLayers
763
                    } else {
764
                        if (val < 1) {
765
                            val = 1
766
                            gpuLayersField.text = val
767
                        } else if (val > root.currentModelInfo.maxGpuLayers) {
768
                            val = root.currentModelInfo.maxGpuLayers
769
                            gpuLayersField.text = val
770
                        }
771
                        MySettings.setModelGpuLayers(root.currentModelInfo, val)
772
                        focus = false
773
                    }
774
                }
775
                Accessible.role: Accessible.EditableText
776
                Accessible.name: gpuLayersLabel.text
777
                Accessible.description: ToolTip.text
778
            }
779
        }
780

781
        Rectangle {
782
            Layout.row: 12
783
            Layout.column: 0
784
            Layout.columnSpan: 2
785
            Layout.topMargin: 15
786
            Layout.fillWidth: true
787
            Layout.minimumWidth: promptTemplate.width
788
            height: 3
789
            color: theme.accentColor
790
        }
791
    }
792
}
793

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

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

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

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