|
|
|
@ -2,6 +2,7 @@ import QtCore
|
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Controls.Basic
|
|
|
|
|
import QtQuick.Dialogs
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import download
|
|
|
|
|
import network
|
|
|
|
@ -31,12 +32,15 @@ Dialog {
|
|
|
|
|
property int defaultTopK: 40
|
|
|
|
|
property int defaultMaxLength: 4096
|
|
|
|
|
property int defaultPromptBatchSize: 9
|
|
|
|
|
property real defaultRepeatPenalty: 1.10
|
|
|
|
|
property int defaultRepeatPenaltyTokens: 64
|
|
|
|
|
property int defaultThreadCount: 0
|
|
|
|
|
property string defaultPromptTemplate: "### Instruction:
|
|
|
|
|
The prompt below is a question to answer, a task to complete, or a conversation to respond to; decide which and write an appropriate response.
|
|
|
|
|
### Prompt:
|
|
|
|
|
%1
|
|
|
|
|
### Response:\n"
|
|
|
|
|
property string defaultModelPath: Download.defaultLocalModelsPath()
|
|
|
|
|
|
|
|
|
|
property alias temperature: settings.temperature
|
|
|
|
|
property alias topP: settings.topP
|
|
|
|
@ -44,7 +48,10 @@ The prompt below is a question to answer, a task to complete, or a conversation
|
|
|
|
|
property alias maxLength: settings.maxLength
|
|
|
|
|
property alias promptBatchSize: settings.promptBatchSize
|
|
|
|
|
property alias promptTemplate: settings.promptTemplate
|
|
|
|
|
property alias repeatPenalty: settings.repeatPenalty
|
|
|
|
|
property alias repeatPenaltyTokens: settings.repeatPenaltyTokens
|
|
|
|
|
property alias threadCount: settings.threadCount
|
|
|
|
|
property alias modelPath: settings.modelPath
|
|
|
|
|
|
|
|
|
|
Settings {
|
|
|
|
|
id: settings
|
|
|
|
@ -54,23 +61,34 @@ The prompt below is a question to answer, a task to complete, or a conversation
|
|
|
|
|
property int maxLength: settingsDialog.defaultMaxLength
|
|
|
|
|
property int promptBatchSize: settingsDialog.defaultPromptBatchSize
|
|
|
|
|
property int threadCount: settingsDialog.defaultThreadCount
|
|
|
|
|
property real repeatPenalty: settingsDialog.defaultRepeatPenalty
|
|
|
|
|
property int repeatPenaltyTokens: settingsDialog.defaultRepeatPenaltyTokens
|
|
|
|
|
property string promptTemplate: settingsDialog.defaultPromptTemplate
|
|
|
|
|
property string modelPath: settingsDialog.defaultModelPath
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function restoreDefaults() {
|
|
|
|
|
|
|
|
|
|
function restoreGenerationDefaults() {
|
|
|
|
|
settings.temperature = defaultTemperature;
|
|
|
|
|
settings.topP = defaultTopP;
|
|
|
|
|
settings.topK = defaultTopK;
|
|
|
|
|
settings.maxLength = defaultMaxLength;
|
|
|
|
|
settings.promptBatchSize = defaultPromptBatchSize;
|
|
|
|
|
settings.promptTemplate = defaultPromptTemplate;
|
|
|
|
|
settings.threadCount = defaultThreadCount
|
|
|
|
|
settings.sync()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function restoreApplicationDefaults() {
|
|
|
|
|
settings.modelPath = settingsDialog.defaultModelPath;
|
|
|
|
|
settings.threadCount = defaultThreadCount
|
|
|
|
|
Download.downloadLocalModelsPath = settings.modelPath;
|
|
|
|
|
LLM.threadCount = settings.threadCount;
|
|
|
|
|
settings.sync()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
LLM.threadCount = settings.threadCount;
|
|
|
|
|
Download.downloadLocalModelsPath = settings.modelPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component.onDestruction: {
|
|
|
|
@ -80,9 +98,33 @@ The prompt below is a question to answer, a task to complete, or a conversation
|
|
|
|
|
Item {
|
|
|
|
|
Accessible.role: Accessible.Dialog
|
|
|
|
|
Accessible.name: qsTr("Settings dialog")
|
|
|
|
|
Accessible.description: qsTr("Dialog containing various settings for model text generation")
|
|
|
|
|
Accessible.description: qsTr("Dialog containing various application settings")
|
|
|
|
|
}
|
|
|
|
|
TabBar {
|
|
|
|
|
id: settingsTabBar
|
|
|
|
|
width: parent.width
|
|
|
|
|
TabButton {
|
|
|
|
|
text: qsTr("Generation")
|
|
|
|
|
Accessible.role: Accessible.Button
|
|
|
|
|
Accessible.name: qsTr("Generation settings")
|
|
|
|
|
Accessible.description: qsTr("Settings related to how the model generates text")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TabButton {
|
|
|
|
|
text: qsTr("Application")
|
|
|
|
|
Accessible.role: Accessible.Button
|
|
|
|
|
Accessible.name: qsTr("Application settings")
|
|
|
|
|
Accessible.description: qsTr("Settings related to general behavior of the application")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StackLayout {
|
|
|
|
|
anchors.top: settingsTabBar.bottom
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
width: parent.width
|
|
|
|
|
currentIndex: settingsTabBar.currentIndex
|
|
|
|
|
Item {
|
|
|
|
|
id: generationSettingsTab
|
|
|
|
|
GridLayout {
|
|
|
|
|
columns: 2
|
|
|
|
|
rowSpacing: 2
|
|
|
|
@ -265,16 +307,15 @@ The prompt below is a question to answer, a task to complete, or a conversation
|
|
|
|
|
Accessible.name: batchSizeLabel.text
|
|
|
|
|
Accessible.description: ToolTip.text
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Label {
|
|
|
|
|
id: nThreadsLabel
|
|
|
|
|
text: qsTr("CPU Threads")
|
|
|
|
|
id: repeatPenaltyLabel
|
|
|
|
|
text: qsTr("Repeat Penalty:")
|
|
|
|
|
color: theme.textColor
|
|
|
|
|
Layout.row: 5
|
|
|
|
|
Layout.column: 0
|
|
|
|
|
}
|
|
|
|
|
TextField {
|
|
|
|
|
text: settingsDialog.threadCount.toString()
|
|
|
|
|
text: settings.repeatPenalty.toString()
|
|
|
|
|
color: theme.textColor
|
|
|
|
|
background: Rectangle {
|
|
|
|
|
implicitWidth: 150
|
|
|
|
@ -282,23 +323,58 @@ The prompt below is a question to answer, a task to complete, or a conversation
|
|
|
|
|
radius: 10
|
|
|
|
|
}
|
|
|
|
|
padding: 10
|
|
|
|
|
ToolTip.text: qsTr("Amount of processing threads to use, a setting of 0 will use the lesser of 4 or your number of CPU threads")
|
|
|
|
|
ToolTip.text: qsTr("Amount to penalize reptetitiveness of the output")
|
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
|
Layout.row: 5
|
|
|
|
|
Layout.column: 1
|
|
|
|
|
validator: DoubleValidator {}
|
|
|
|
|
onAccepted: {
|
|
|
|
|
var val = parseFloat(text)
|
|
|
|
|
if (!isNaN(val)) {
|
|
|
|
|
settings.repeatPenalty = val
|
|
|
|
|
settings.sync()
|
|
|
|
|
focus = false
|
|
|
|
|
} else {
|
|
|
|
|
text = settings.repeatPenalty.toString()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Accessible.role: Accessible.EditableText
|
|
|
|
|
Accessible.name: repeatPenaltyLabel.text
|
|
|
|
|
Accessible.description: ToolTip.text
|
|
|
|
|
}
|
|
|
|
|
Label {
|
|
|
|
|
id: repeatPenaltyTokensLabel
|
|
|
|
|
text: qsTr("Repeat Penalty Tokens:")
|
|
|
|
|
color: theme.textColor
|
|
|
|
|
Layout.row: 6
|
|
|
|
|
Layout.column: 0
|
|
|
|
|
}
|
|
|
|
|
TextField {
|
|
|
|
|
text: settings.repeatPenaltyTokens.toString()
|
|
|
|
|
color: theme.textColor
|
|
|
|
|
background: Rectangle {
|
|
|
|
|
implicitWidth: 150
|
|
|
|
|
color: theme.backgroundLighter
|
|
|
|
|
radius: 10
|
|
|
|
|
}
|
|
|
|
|
padding: 10
|
|
|
|
|
ToolTip.text: qsTr("How far back in output to apply repeat penalty")
|
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
|
Layout.row: 6
|
|
|
|
|
Layout.column: 1
|
|
|
|
|
validator: IntValidator { bottom: 1 }
|
|
|
|
|
onAccepted: {
|
|
|
|
|
var val = parseInt(text)
|
|
|
|
|
if (!isNaN(val)) {
|
|
|
|
|
settingsDialog.threadCount = val
|
|
|
|
|
LLM.threadCount = val
|
|
|
|
|
settings.repeatPenaltyTokens = val
|
|
|
|
|
settings.sync()
|
|
|
|
|
focus = false
|
|
|
|
|
} else {
|
|
|
|
|
text = settingsDialog.threadCount.toString()
|
|
|
|
|
text = settings.repeatPenaltyTokens.toString()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Accessible.role: Accessible.EditableText
|
|
|
|
|
Accessible.name: nThreadsLabel.text
|
|
|
|
|
Accessible.name: repeatPenaltyTokensLabel.text
|
|
|
|
|
Accessible.description: ToolTip.text
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -306,11 +382,11 @@ The prompt below is a question to answer, a task to complete, or a conversation
|
|
|
|
|
id: promptTemplateLabel
|
|
|
|
|
text: qsTr("Prompt Template:")
|
|
|
|
|
color: theme.textColor
|
|
|
|
|
Layout.row: 6
|
|
|
|
|
Layout.row: 7
|
|
|
|
|
Layout.column: 0
|
|
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
Layout.row: 6
|
|
|
|
|
Layout.row: 7
|
|
|
|
|
Layout.column: 1
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
height: 200
|
|
|
|
@ -354,7 +430,108 @@ The prompt below is a question to answer, a task to complete, or a conversation
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Button {
|
|
|
|
|
Layout.row: 7
|
|
|
|
|
Layout.row: 8
|
|
|
|
|
Layout.column: 1
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
padding: 15
|
|
|
|
|
contentItem: Text {
|
|
|
|
|
text: qsTr("Restore Defaults")
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
color: theme.textColor
|
|
|
|
|
Accessible.role: Accessible.Button
|
|
|
|
|
Accessible.name: text
|
|
|
|
|
Accessible.description: qsTr("Restores the settings dialog to a default state")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
|
opacity: .5
|
|
|
|
|
border.color: theme.backgroundLightest
|
|
|
|
|
border.width: 1
|
|
|
|
|
radius: 10
|
|
|
|
|
color: theme.backgroundLight
|
|
|
|
|
}
|
|
|
|
|
onClicked: {
|
|
|
|
|
settingsDialog.restoreGenerationDefaults()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Item {
|
|
|
|
|
id: systemSettingsTab
|
|
|
|
|
GridLayout {
|
|
|
|
|
columns: 3
|
|
|
|
|
rowSpacing: 2
|
|
|
|
|
columnSpacing: 10
|
|
|
|
|
width: parent.width
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
FolderDialog {
|
|
|
|
|
id: modelPathDialog
|
|
|
|
|
title: "Please choose a directory"
|
|
|
|
|
onAccepted: {
|
|
|
|
|
Download.downloadLocalModelsPath = selectedFolder
|
|
|
|
|
settings.modelPath = Download.downloadLocalModelsPath
|
|
|
|
|
settings.sync()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Label {
|
|
|
|
|
id: modelPathLabel
|
|
|
|
|
text: qsTr("Model file path:")
|
|
|
|
|
color: theme.textColor
|
|
|
|
|
Layout.row: 1
|
|
|
|
|
Layout.column: 0
|
|
|
|
|
}
|
|
|
|
|
TextField {
|
|
|
|
|
id: modelPathDisplayLabel
|
|
|
|
|
text: settings.modelPath
|
|
|
|
|
color: theme.textColor
|
|
|
|
|
readOnly: true
|
|
|
|
|
Layout.row: 1
|
|
|
|
|
Layout.column: 1
|
|
|
|
|
}
|
|
|
|
|
Button {
|
|
|
|
|
Layout.row: 1
|
|
|
|
|
Layout.column: 2
|
|
|
|
|
text: qsTr("Browse")
|
|
|
|
|
onClicked: modelPathDialog.open()
|
|
|
|
|
}
|
|
|
|
|
Label {
|
|
|
|
|
id: nThreadsLabel
|
|
|
|
|
text: qsTr("CPU Threads:")
|
|
|
|
|
color: theme.textColor
|
|
|
|
|
Layout.row: 2
|
|
|
|
|
Layout.column: 0
|
|
|
|
|
}
|
|
|
|
|
TextField {
|
|
|
|
|
text: settingsDialog.threadCount.toString()
|
|
|
|
|
color: theme.textColor
|
|
|
|
|
background: Rectangle {
|
|
|
|
|
implicitWidth: 150
|
|
|
|
|
color: theme.backgroundLighter
|
|
|
|
|
radius: 10
|
|
|
|
|
}
|
|
|
|
|
padding: 10
|
|
|
|
|
ToolTip.text: qsTr("Amount of processing threads to use, a setting of 0 will use the lesser of 4 or your number of CPU threads")
|
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
|
Layout.row: 2
|
|
|
|
|
Layout.column: 1
|
|
|
|
|
validator: IntValidator { bottom: 1 }
|
|
|
|
|
onAccepted: {
|
|
|
|
|
var val = parseInt(text)
|
|
|
|
|
if (!isNaN(val)) {
|
|
|
|
|
settingsDialog.threadCount = val
|
|
|
|
|
LLM.threadCount = val
|
|
|
|
|
settings.sync()
|
|
|
|
|
focus = false
|
|
|
|
|
} else {
|
|
|
|
|
text = settingsDialog.threadCount.toString()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Accessible.role: Accessible.EditableText
|
|
|
|
|
Accessible.name: nThreadsLabel.text
|
|
|
|
|
Accessible.description: ToolTip.text
|
|
|
|
|
}
|
|
|
|
|
Button {
|
|
|
|
|
Layout.row: 3
|
|
|
|
|
Layout.column: 1
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
padding: 15
|
|
|
|
@ -375,8 +552,11 @@ The prompt below is a question to answer, a task to complete, or a conversation
|
|
|
|
|
color: theme.backgroundLight
|
|
|
|
|
}
|
|
|
|
|
onClicked: {
|
|
|
|
|
settingsDialog.restoreDefaults()
|
|
|
|
|
settingsDialog.restoreApplicationDefaults()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|