mirror of
https://github.com/nomic-ai/gpt4all
synced 2024-11-02 09:40:42 +00:00
Make the settings dialog persist across sessions.
This commit is contained in:
parent
294f2d6041
commit
670bbe4db5
78
main.qml
78
main.qml
@ -1,3 +1,4 @@
|
|||||||
|
import QtCore
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Controls.Basic
|
import QtQuick.Controls.Basic
|
||||||
@ -114,24 +115,27 @@ Window {
|
|||||||
%1
|
%1
|
||||||
### Response:\n"
|
### Response:\n"
|
||||||
|
|
||||||
property string promptTemplate: ""
|
Settings {
|
||||||
property real temperature: 0.0
|
id: settings
|
||||||
property real topP: 0.0
|
property string promptTemplate: settingsDialog.defaultPromptTemplate
|
||||||
property int topK: 0
|
property real temperature: settingsDialog.defaultTemperature
|
||||||
property int maxLength: 0
|
property real topP: settingsDialog.defaultTopP
|
||||||
property int promptBatchSize: 0
|
property int topK: settingsDialog.defaultTopK
|
||||||
|
property int maxLength: settingsDialog.defaultMaxLength
|
||||||
function restoreDefaults() {
|
property int promptBatchSize: settingsDialog.defaultPromptBatchSize
|
||||||
temperature = defaultTemperature;
|
|
||||||
topP = defaultTopP;
|
|
||||||
topK = defaultTopK;
|
|
||||||
maxLength = defaultMaxLength;
|
|
||||||
promptBatchSize = defaultPromptBatchSize;
|
|
||||||
promptTemplate = defaultPromptTemplate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
function restoreDefaults() {
|
||||||
restoreDefaults();
|
settings.temperature = defaultTemperature;
|
||||||
|
settings.topP = defaultTopP;
|
||||||
|
settings.topK = defaultTopK;
|
||||||
|
settings.maxLength = defaultMaxLength;
|
||||||
|
settings.promptBatchSize = defaultPromptBatchSize;
|
||||||
|
settings.promptTemplate = defaultPromptTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onDestruction: {
|
||||||
|
settings.sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
@ -153,7 +157,7 @@ Window {
|
|||||||
Layout.column: 0
|
Layout.column: 0
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: settingsDialog.temperature.toString()
|
text: settings.temperature.toString()
|
||||||
ToolTip.text: qsTr("Temperature increases the chances of choosing less likely tokens - higher temperature gives more creative but less predictable outputs")
|
ToolTip.text: qsTr("Temperature increases the chances of choosing less likely tokens - higher temperature gives more creative but less predictable outputs")
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
Layout.row: 0
|
Layout.row: 0
|
||||||
@ -162,10 +166,11 @@ Window {
|
|||||||
onAccepted: {
|
onAccepted: {
|
||||||
var val = parseFloat(text)
|
var val = parseFloat(text)
|
||||||
if (!isNaN(val)) {
|
if (!isNaN(val)) {
|
||||||
settingsDialog.temperature = val
|
settings.temperature = val
|
||||||
|
settings.sync()
|
||||||
focus = false
|
focus = false
|
||||||
} else {
|
} else {
|
||||||
text = settingsDialog.temperature.toString()
|
text = settings.temperature.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Accessible.role: Accessible.EditableText
|
Accessible.role: Accessible.EditableText
|
||||||
@ -179,7 +184,7 @@ Window {
|
|||||||
Layout.column: 0
|
Layout.column: 0
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: settingsDialog.topP.toString()
|
text: settings.topP.toString()
|
||||||
ToolTip.text: qsTr("Only the most likely tokens up to a total probability of top_p can be chosen, prevents choosing highly unlikely tokens, aka Nucleus Sampling")
|
ToolTip.text: qsTr("Only the most likely tokens up to a total probability of top_p can be chosen, prevents choosing highly unlikely tokens, aka Nucleus Sampling")
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
Layout.row: 1
|
Layout.row: 1
|
||||||
@ -188,10 +193,11 @@ Window {
|
|||||||
onAccepted: {
|
onAccepted: {
|
||||||
var val = parseFloat(text)
|
var val = parseFloat(text)
|
||||||
if (!isNaN(val)) {
|
if (!isNaN(val)) {
|
||||||
settingsDialog.topP = val
|
settings.topP = val
|
||||||
|
settings.sync()
|
||||||
focus = false
|
focus = false
|
||||||
} else {
|
} else {
|
||||||
text = settingsDialog.topP.toString()
|
text = settings.topP.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Accessible.role: Accessible.EditableText
|
Accessible.role: Accessible.EditableText
|
||||||
@ -205,7 +211,7 @@ Window {
|
|||||||
Layout.column: 0
|
Layout.column: 0
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: settingsDialog.topK.toString()
|
text: settings.topK.toString()
|
||||||
ToolTip.text: qsTr("Only the top K most likely tokens will be chosen from")
|
ToolTip.text: qsTr("Only the top K most likely tokens will be chosen from")
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
Layout.row: 2
|
Layout.row: 2
|
||||||
@ -214,10 +220,11 @@ Window {
|
|||||||
onAccepted: {
|
onAccepted: {
|
||||||
var val = parseInt(text)
|
var val = parseInt(text)
|
||||||
if (!isNaN(val)) {
|
if (!isNaN(val)) {
|
||||||
settingsDialog.topK = val
|
settings.topK = val
|
||||||
|
settings.sync()
|
||||||
focus = false
|
focus = false
|
||||||
} else {
|
} else {
|
||||||
text = settingsDialog.topK.toString()
|
text = settings.topK.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Accessible.role: Accessible.EditableText
|
Accessible.role: Accessible.EditableText
|
||||||
@ -231,7 +238,7 @@ Window {
|
|||||||
Layout.column: 0
|
Layout.column: 0
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: settingsDialog.maxLength.toString()
|
text: settings.maxLength.toString()
|
||||||
ToolTip.text: qsTr("Maximum length of response in tokens")
|
ToolTip.text: qsTr("Maximum length of response in tokens")
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
Layout.row: 3
|
Layout.row: 3
|
||||||
@ -240,10 +247,11 @@ Window {
|
|||||||
onAccepted: {
|
onAccepted: {
|
||||||
var val = parseInt(text)
|
var val = parseInt(text)
|
||||||
if (!isNaN(val)) {
|
if (!isNaN(val)) {
|
||||||
settingsDialog.maxLength = val
|
settings.maxLength = val
|
||||||
|
settings.sync()
|
||||||
focus = false
|
focus = false
|
||||||
} else {
|
} else {
|
||||||
text = settingsDialog.maxLength.toString()
|
text = settings.maxLength.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Accessible.role: Accessible.EditableText
|
Accessible.role: Accessible.EditableText
|
||||||
@ -258,7 +266,7 @@ Window {
|
|||||||
Layout.column: 0
|
Layout.column: 0
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: settingsDialog.promptBatchSize.toString()
|
text: settings.promptBatchSize.toString()
|
||||||
ToolTip.text: qsTr("Amount of prompt tokens to process at once, higher values can speed up reading prompts but will use more RAM")
|
ToolTip.text: qsTr("Amount of prompt tokens to process at once, higher values can speed up reading prompts but will use more RAM")
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
Layout.row: 4
|
Layout.row: 4
|
||||||
@ -267,10 +275,11 @@ Window {
|
|||||||
onAccepted: {
|
onAccepted: {
|
||||||
var val = parseInt(text)
|
var val = parseInt(text)
|
||||||
if (!isNaN(val)) {
|
if (!isNaN(val)) {
|
||||||
settingsDialog.promptBatchSize = val
|
settings.promptBatchSize = val
|
||||||
|
settings.sync()
|
||||||
focus = false
|
focus = false
|
||||||
} else {
|
} else {
|
||||||
text = settingsDialog.promptBatchSize.toString()
|
text = settings.promptBatchSize.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Accessible.role: Accessible.EditableText
|
Accessible.role: Accessible.EditableText
|
||||||
@ -322,7 +331,7 @@ Window {
|
|||||||
radius: 5
|
radius: 5
|
||||||
Label {
|
Label {
|
||||||
id: promptTemplateLabelHelp
|
id: promptTemplateLabelHelp
|
||||||
visible: settingsDialog.promptTemplate.indexOf("%1") == -1
|
visible: settings.promptTemplate.indexOf("%1") === -1
|
||||||
font.bold: true
|
font.bold: true
|
||||||
color: "red"
|
color: "red"
|
||||||
text: qsTr("Prompt template must contain %1 to be replaced with the user's input.")
|
text: qsTr("Prompt template must contain %1 to be replaced with the user's input.")
|
||||||
@ -334,10 +343,11 @@ Window {
|
|||||||
id: templateScrollView
|
id: templateScrollView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
TextArea {
|
TextArea {
|
||||||
text: settingsDialog.promptTemplate
|
text: settings.promptTemplate
|
||||||
wrapMode: TextArea.Wrap
|
wrapMode: TextArea.Wrap
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
settingsDialog.promptTemplate = text
|
settings.promptTemplate = text
|
||||||
|
settings.sync()
|
||||||
}
|
}
|
||||||
bottomPadding: 10
|
bottomPadding: 10
|
||||||
Accessible.role: Accessible.EditableText
|
Accessible.role: Accessible.EditableText
|
||||||
|
Loading…
Reference in New Issue
Block a user