2023-04-23 10:58:07 +00:00
import QtCore
import QtQuick
import QtQuick . Controls
2023-04-24 03:56:33 +00:00
import QtQuick . Controls . Basic
2023-04-25 14:57:40 +00:00
import QtQuick . Dialogs
2023-04-23 10:58:07 +00:00
import QtQuick . Layouts
2023-06-05 13:23:43 +00:00
import Qt . labs . folderlistmodel
2023-06-22 19:44:49 +00:00
import chatlistmodel
2023-04-23 10:58:07 +00:00
import download
2023-06-22 19:44:49 +00:00
import modellist
2023-04-23 10:58:07 +00:00
import network
import llm
Dialog {
id: settingsDialog
modal: true
opacity: 0.9
2023-05-23 02:13:42 +00:00
padding: 20
bottomPadding: 30
2023-04-23 10:58:07 +00:00
background: Rectangle {
anchors.fill: parent
2023-04-23 13:42:35 +00:00
color: theme . backgroundDarkest
2023-04-23 10:58:07 +00:00
border.width: 1
2023-04-23 13:42:35 +00:00
border.color: theme . dialogBorder
2023-04-23 10:58:07 +00:00
radius: 10
}
2023-05-03 00:31:17 +00:00
onOpened: {
Network . sendSettingsDialog ( ) ;
}
2023-06-22 19:44:49 +00:00
property var currentChat: ChatListModel . currentChat
2023-05-09 21:10:47 +00:00
2023-04-23 13:42:35 +00:00
Theme {
id: theme
}
2023-06-05 01:37:28 +00:00
property real defaultTemperature: 0.7
property real defaultTopP: 0.1
2023-04-23 10:58:07 +00:00
property int defaultTopK: 40
property int defaultMaxLength: 4096
2023-06-05 01:37:28 +00:00
property int defaultPromptBatchSize: 128
property real defaultRepeatPenalty: 1.18
2023-04-25 14:57:40 +00:00
property int defaultRepeatPenaltyTokens: 64
2023-04-24 19:24:55 +00:00
property int defaultThreadCount: 0
2023-05-05 16:30:11 +00:00
property bool defaultSaveChats: false
2023-05-15 22:36:41 +00:00
property bool defaultSaveChatGPTChats: true
2023-05-11 20:46:25 +00:00
property bool defaultServerChat: false
2023-05-03 16:19:14 +00:00
property string defaultPromptTemplate: " # # # Human:
2023-04-23 10:58:07 +00:00
% 1
2023-05-03 16:19:14 +00:00
# # # Assistant: \ n "
2023-06-22 19:44:49 +00:00
property string defaultModelPath: ModelList . defaultLocalModelsPath ( )
2023-05-09 21:10:47 +00:00
property string defaultUserDefaultModel: "Application default"
2023-04-23 10:58:07 +00:00
property alias temperature: settings . temperature
property alias topP: settings . topP
property alias topK: settings . topK
property alias maxLength: settings . maxLength
property alias promptBatchSize: settings . promptBatchSize
property alias promptTemplate: settings . promptTemplate
2023-04-25 14:57:40 +00:00
property alias repeatPenalty: settings . repeatPenalty
property alias repeatPenaltyTokens: settings . repeatPenaltyTokens
2023-04-24 19:24:55 +00:00
property alias threadCount: settings . threadCount
2023-05-05 16:30:11 +00:00
property alias saveChats: settings . saveChats
2023-05-15 22:36:41 +00:00
property alias saveChatGPTChats: settings . saveChatGPTChats
2023-05-11 20:46:25 +00:00
property alias serverChat: settings . serverChat
2023-04-25 14:57:40 +00:00
property alias modelPath: settings . modelPath
2023-05-09 21:10:47 +00:00
property alias userDefaultModel: settings . userDefaultModel
2023-04-23 10:58:07 +00:00
Settings {
id: settings
property real temperature: settingsDialog . defaultTemperature
property real topP: settingsDialog . defaultTopP
property int topK: settingsDialog . defaultTopK
property int maxLength: settingsDialog . defaultMaxLength
property int promptBatchSize: settingsDialog . defaultPromptBatchSize
2023-04-24 19:24:55 +00:00
property int threadCount: settingsDialog . defaultThreadCount
2023-05-05 16:30:11 +00:00
property bool saveChats: settingsDialog . defaultSaveChats
2023-05-15 22:36:41 +00:00
property bool saveChatGPTChats: settingsDialog . defaultSaveChatGPTChats
2023-05-11 20:46:25 +00:00
property bool serverChat: settingsDialog . defaultServerChat
2023-04-25 14:57:40 +00:00
property real repeatPenalty: settingsDialog . defaultRepeatPenalty
property int repeatPenaltyTokens: settingsDialog . defaultRepeatPenaltyTokens
2023-04-23 10:58:07 +00:00
property string promptTemplate: settingsDialog . defaultPromptTemplate
2023-04-25 14:57:40 +00:00
property string modelPath: settingsDialog . defaultModelPath
2023-05-09 21:10:47 +00:00
property string userDefaultModel: settingsDialog . defaultUserDefaultModel
2023-04-23 10:58:07 +00:00
}
2023-04-25 14:57:40 +00:00
function restoreGenerationDefaults ( ) {
2023-04-25 17:00:28 +00:00
settings . temperature = defaultTemperature
settings . topP = defaultTopP
settings . topK = defaultTopK
settings . maxLength = defaultMaxLength
settings . promptBatchSize = defaultPromptBatchSize
settings . promptTemplate = defaultPromptTemplate
2023-05-08 16:20:02 +00:00
settings . repeatPenalty = defaultRepeatPenalty
settings . repeatPenaltyTokens = defaultRepeatPenaltyTokens
2023-04-23 10:58:07 +00:00
settings . sync ( )
2023-04-25 14:57:40 +00:00
}
function restoreApplicationDefaults ( ) {
2023-04-25 17:00:28 +00:00
settings . modelPath = settingsDialog . defaultModelPath
2023-04-25 14:57:40 +00:00
settings . threadCount = defaultThreadCount
2023-05-05 16:30:11 +00:00
settings . saveChats = defaultSaveChats
2023-05-15 22:36:41 +00:00
settings . saveChatGPTChats = defaultSaveChatGPTChats
2023-05-11 20:46:25 +00:00
settings . serverChat = defaultServerChat
2023-05-09 21:10:47 +00:00
settings . userDefaultModel = defaultUserDefaultModel
2023-06-22 19:44:49 +00:00
ModelList . localModelsPath = settings . modelPath
2023-04-25 17:00:28 +00:00
LLM . threadCount = settings . threadCount
2023-05-11 20:46:25 +00:00
LLM . serverEnabled = settings . serverChat
2023-06-22 19:44:49 +00:00
ChatListModel . shouldSaveChats = settings . saveChats
2023-06-26 20:43:37 +00:00
ChatListModel . shouldSaveChatGPTChats = settings . saveChatGPTChats
2023-04-25 14:57:40 +00:00
settings . sync ( )
2023-04-24 19:24:55 +00:00
}
Component.onCompleted: {
2023-04-25 17:00:28 +00:00
LLM . threadCount = settings . threadCount
2023-05-11 20:46:25 +00:00
LLM . serverEnabled = settings . serverChat
2023-06-22 19:44:49 +00:00
ChatListModel . shouldSaveChats = settings . saveChats
ChatListModel . shouldSaveChatGPTChats = settings . saveChatGPTChats
ModelList . localModelsPath = settings . modelPath
2023-04-23 10:58:07 +00:00
}
2023-04-28 14:48:48 +00:00
Connections {
target: settingsDialog
function onClosed ( ) {
settings . sync ( )
}
2023-04-23 10:58:07 +00:00
}
Item {
Accessible.role: Accessible . Dialog
Accessible.name: qsTr ( "Settings dialog" )
2023-04-25 14:57:40 +00:00
Accessible.description: qsTr ( "Dialog containing various application settings" )
2023-04-23 10:58:07 +00:00
}
2023-04-25 14:57:40 +00:00
TabBar {
id: settingsTabBar
2023-05-23 18:50:10 +00:00
width: parent . width / 1.25
2023-05-23 02:13:42 +00:00
z: 200
2023-04-25 17:00:28 +00:00
2023-04-25 14:57:40 +00:00
TabButton {
2023-04-25 17:00:28 +00:00
id: genSettingsButton
contentItem: IconLabel {
color: theme . textColor
font.bold: genSettingsButton . checked
text: qsTr ( "Generation" )
}
background: Rectangle {
color: genSettingsButton . checked ? theme.backgroundDarkest : theme . backgroundLight
2023-05-21 19:28:23 +00:00
Rectangle {
anchors.top: parent . top
anchors.left: parent . left
anchors.right: parent . right
2023-05-23 02:13:42 +00:00
height: genSettingsButton . checked
color: theme . tabBorder
}
Rectangle {
anchors.bottom: parent . bottom
anchors.left: parent . left
anchors.right: parent . right
height: ! genSettingsButton . checked
2023-05-21 19:28:23 +00:00
color: theme . tabBorder
}
Rectangle {
anchors.top: parent . top
anchors.bottom: parent . bottom
anchors.left: parent . left
2023-05-23 02:13:42 +00:00
width: genSettingsButton . checked
2023-05-21 19:28:23 +00:00
color: theme . tabBorder
}
Rectangle {
anchors.top: parent . top
anchors.bottom: parent . bottom
anchors.right: parent . right
2023-05-23 02:13:42 +00:00
width: genSettingsButton . checked
2023-05-21 19:28:23 +00:00
color: theme . tabBorder
}
2023-04-25 17:00:28 +00:00
}
2023-04-25 14:57:40 +00:00
Accessible.role: Accessible . Button
Accessible.name: qsTr ( "Generation settings" )
Accessible.description: qsTr ( "Settings related to how the model generates text" )
}
2023-04-23 10:58:07 +00:00
2023-04-25 14:57:40 +00:00
TabButton {
2023-04-25 17:00:28 +00:00
id: appSettingsButton
contentItem: IconLabel {
color: theme . textColor
font.bold: appSettingsButton . checked
text: qsTr ( "Application" )
}
background: Rectangle {
color: appSettingsButton . checked ? theme.backgroundDarkest : theme . backgroundLight
2023-05-21 19:28:23 +00:00
Rectangle {
anchors.top: parent . top
anchors.left: parent . left
anchors.right: parent . right
2023-05-23 02:13:42 +00:00
height: appSettingsButton . checked
color: theme . tabBorder
}
Rectangle {
anchors.bottom: parent . bottom
anchors.left: parent . left
anchors.right: parent . right
height: ! appSettingsButton . checked
2023-05-21 19:28:23 +00:00
color: theme . tabBorder
}
Rectangle {
anchors.top: parent . top
anchors.bottom: parent . bottom
anchors.left: parent . left
2023-05-23 02:13:42 +00:00
width: appSettingsButton . checked
2023-05-21 19:28:23 +00:00
color: theme . tabBorder
}
Rectangle {
anchors.top: parent . top
anchors.bottom: parent . bottom
anchors.right: parent . right
2023-05-23 02:13:42 +00:00
width: appSettingsButton . checked
2023-05-21 19:28:23 +00:00
color: theme . tabBorder
}
2023-04-25 17:00:28 +00:00
}
2023-04-25 14:57:40 +00:00
Accessible.role: Accessible . Button
Accessible.name: qsTr ( "Application settings" )
Accessible.description: qsTr ( "Settings related to general behavior of the application" )
2023-04-23 10:58:07 +00:00
}
2023-05-21 19:28:41 +00:00
TabButton {
id: localDocsButton
contentItem: IconLabel {
color: theme . textColor
font.bold: localDocsButton . checked
2023-05-23 18:51:14 +00:00
text: qsTr ( "LocalDocs Plugin (BETA)" )
2023-05-21 19:28:41 +00:00
}
background: Rectangle {
color: localDocsButton . checked ? theme.backgroundDarkest : theme . backgroundLight
Rectangle {
anchors.top: parent . top
anchors.left: parent . left
anchors.right: parent . right
2023-05-23 02:13:42 +00:00
height: localDocsButton . checked
color: theme . tabBorder
}
Rectangle {
anchors.bottom: parent . bottom
anchors.left: parent . left
anchors.right: parent . right
height: ! localDocsButton . checked
2023-05-21 19:28:41 +00:00
color: theme . tabBorder
}
Rectangle {
anchors.top: parent . top
anchors.bottom: parent . bottom
anchors.left: parent . left
2023-05-23 02:13:42 +00:00
width: localDocsButton . checked
2023-05-21 19:28:41 +00:00
color: theme . tabBorder
}
Rectangle {
anchors.top: parent . top
anchors.bottom: parent . bottom
anchors.right: parent . right
2023-05-23 02:13:42 +00:00
width: localDocsButton . checked
2023-05-21 19:28:41 +00:00
color: theme . tabBorder
}
}
Accessible.role: Accessible . Button
Accessible.name: qsTr ( "LocalDocs settings" )
Accessible.description: qsTr ( "Settings related to localdocs plugin" )
}
2023-04-25 14:57:40 +00:00
}
StackLayout {
anchors.top: settingsTabBar . bottom
2023-05-23 02:13:42 +00:00
anchors.topMargin: - 1
2023-04-25 14:57:40 +00:00
width: parent . width
2023-04-25 17:00:28 +00:00
height: availableHeight
2023-04-25 14:57:40 +00:00
currentIndex: settingsTabBar . currentIndex
2023-04-25 17:00:28 +00:00
2023-04-25 14:57:40 +00:00
Item {
id: generationSettingsTab
2023-04-25 17:00:28 +00:00
ScrollView {
background: Rectangle {
color: 'transparent'
border.color: theme . tabBorder
border.width: 1
radius: 2
2023-04-23 10:58:07 +00:00
}
2023-04-25 20:20:19 +00:00
padding: 10
2023-04-25 17:00:28 +00:00
width: parent . width
height: parent . height - 30
contentWidth: availableWidth - 20
contentHeight: generationSettingsTabInner . implicitHeight + 40
ScrollBar.vertical.policy: ScrollBar . AlwaysOn
GridLayout {
id: generationSettingsTabInner
anchors.margins: 10
columns: 2
rowSpacing: 10
columnSpacing: 10
anchors.fill: parent
Label {
id: tempLabel
text: qsTr ( "Temperature:" )
color: theme . textColor
Layout.row: 0
Layout.column: 0
2023-04-25 14:57:40 +00:00
}
2023-05-22 21:58:37 +00:00
MyTextField {
2023-04-25 17:00:28 +00:00
text: settings . temperature . toString ( )
color: theme . textColor
2023-05-23 18:50:10 +00:00
ToolTip.text: qsTr ( "Temperature increases the chances of choosing less likely tokens.\nNOTE: Higher temperature gives more creative but less predictable outputs." )
2023-04-25 17:00:28 +00:00
ToolTip.visible: hovered
Layout.row: 0
Layout.column: 1
2023-04-28 15:36:24 +00:00
validator: DoubleValidator {
locale: "C"
}
2023-04-25 17:00:28 +00:00
onEditingFinished: {
var val = parseFloat ( text )
if ( ! isNaN ( val ) ) {
settings . temperature = val
settings . sync ( )
focus = false
} else {
text = settings . temperature . toString ( )
}
2023-04-25 14:57:40 +00:00
}
2023-04-25 17:00:28 +00:00
Accessible.role: Accessible . EditableText
Accessible.name: tempLabel . text
Accessible.description: ToolTip . text
2023-04-25 14:57:40 +00:00
}
2023-04-25 17:00:28 +00:00
Label {
id: topPLabel
text: qsTr ( "Top P:" )
color: theme . textColor
Layout.row: 1
Layout.column: 0
2023-04-25 14:57:40 +00:00
}
2023-05-22 21:58:37 +00:00
MyTextField {
2023-04-25 17:00:28 +00:00
text: settings . topP . toString ( )
color: theme . textColor
2023-05-23 18:50:10 +00:00
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" )
2023-04-25 17:00:28 +00:00
ToolTip.visible: hovered
Layout.row: 1
Layout.column: 1
2023-04-28 15:36:24 +00:00
validator: DoubleValidator {
locale: "C"
}
2023-04-25 17:00:28 +00:00
onEditingFinished: {
var val = parseFloat ( text )
if ( ! isNaN ( val ) ) {
settings . topP = val
settings . sync ( )
focus = false
} else {
text = settings . topP . toString ( )
}
2023-04-25 14:57:40 +00:00
}
2023-04-25 17:00:28 +00:00
Accessible.role: Accessible . EditableText
Accessible.name: topPLabel . text
Accessible.description: ToolTip . text
}
Label {
id: topKLabel
text: qsTr ( "Top K:" )
color: theme . textColor
Layout.row: 2
Layout.column: 0
}
2023-05-22 21:58:37 +00:00
MyTextField {
2023-04-25 17:00:28 +00:00
text: settings . topK . toString ( )
color: theme . textColor
ToolTip.text: qsTr ( "Only the top K most likely tokens will be chosen from" )
ToolTip.visible: hovered
Layout.row: 2
Layout.column: 1
validator: IntValidator {
bottom: 1
}
onEditingFinished: {
var val = parseInt ( text )
if ( ! isNaN ( val ) ) {
settings . topK = val
settings . sync ( )
focus = false
} else {
text = settings . topK . toString ( )
}
}
Accessible.role: Accessible . EditableText
Accessible.name: topKLabel . text
Accessible.description: ToolTip . text
}
Label {
id: maxLengthLabel
text: qsTr ( "Max Length:" )
color: theme . textColor
Layout.row: 3
Layout.column: 0
}
2023-05-22 21:58:37 +00:00
MyTextField {
2023-04-25 17:00:28 +00:00
text: settings . maxLength . toString ( )
color: theme . textColor
ToolTip.text: qsTr ( "Maximum length of response in tokens" )
ToolTip.visible: hovered
Layout.row: 3
Layout.column: 1
validator: IntValidator {
bottom: 1
}
onEditingFinished: {
var val = parseInt ( text )
if ( ! isNaN ( val ) ) {
settings . maxLength = val
settings . sync ( )
focus = false
} else {
text = settings . maxLength . toString ( )
}
}
Accessible.role: Accessible . EditableText
Accessible.name: maxLengthLabel . text
Accessible.description: ToolTip . text
2023-04-25 14:57:40 +00:00
}
2023-04-23 10:58:07 +00:00
2023-04-25 17:00:28 +00:00
Label {
id: batchSizeLabel
text: qsTr ( "Prompt Batch Size:" )
color: theme . textColor
Layout.row: 4
Layout.column: 0
}
2023-05-22 21:58:37 +00:00
MyTextField {
2023-04-25 17:00:28 +00:00
text: settings . promptBatchSize . toString ( )
color: theme . textColor
2023-05-23 18:50:10 +00:00
ToolTip.text: qsTr ( "Amount of prompt tokens to process at once.\nNOTE: Higher values can speed up reading prompts but will use more RAM" )
2023-04-25 17:00:28 +00:00
ToolTip.visible: hovered
Layout.row: 4
Layout.column: 1
validator: IntValidator {
bottom: 1
}
onEditingFinished: {
var val = parseInt ( text )
if ( ! isNaN ( val ) ) {
settings . promptBatchSize = val
settings . sync ( )
focus = false
} else {
text = settings . promptBatchSize . toString ( )
}
}
Accessible.role: Accessible . EditableText
Accessible.name: batchSizeLabel . text
Accessible.description: ToolTip . text
}
Label {
id: repeatPenaltyLabel
text: qsTr ( "Repeat Penalty:" )
color: theme . textColor
Layout.row: 5
Layout.column: 0
}
2023-05-22 21:58:37 +00:00
MyTextField {
2023-04-25 17:00:28 +00:00
text: settings . repeatPenalty . toString ( )
color: theme . textColor
2023-04-25 20:33:01 +00:00
ToolTip.text: qsTr ( "Amount to penalize repetitiveness of the output" )
2023-04-25 17:00:28 +00:00
ToolTip.visible: hovered
Layout.row: 5
Layout.column: 1
2023-04-28 15:36:24 +00:00
validator: DoubleValidator {
locale: "C"
}
2023-04-25 17:00:28 +00:00
onEditingFinished: {
var val = parseFloat ( text )
if ( ! isNaN ( val ) ) {
settings . repeatPenalty = val
settings . sync ( )
focus = false
} else {
text = settings . repeatPenalty . toString ( )
}
}
2023-04-25 14:57:40 +00:00
Accessible.role: Accessible . EditableText
2023-04-25 17:00:28 +00:00
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
}
2023-05-22 21:58:37 +00:00
MyTextField {
2023-04-25 17:00:28 +00:00
text: settings . repeatPenaltyTokens . toString ( )
color: theme . textColor
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
}
onEditingFinished: {
var val = parseInt ( text )
if ( ! isNaN ( val ) ) {
settings . repeatPenaltyTokens = val
settings . sync ( )
focus = false
} else {
text = settings . repeatPenaltyTokens . toString ( )
}
}
Accessible.role: Accessible . EditableText
Accessible.name: repeatPenaltyTokensLabel . text
Accessible.description: ToolTip . text
}
2023-04-25 14:57:40 +00:00
2023-06-22 19:44:49 +00:00
ColumnLayout {
2023-04-25 17:00:28 +00:00
Layout.row: 7
Layout.column: 0
2023-06-22 19:44:49 +00:00
Layout.topMargin: 10
Layout.alignment: Qt . AlignTop
spacing: 20
Label {
id: promptTemplateLabel
text: qsTr ( "Prompt Template:" )
color: theme . textColor
}
2023-04-25 17:00:28 +00:00
Label {
id: promptTemplateLabelHelp
2023-06-22 19:44:49 +00:00
Layout.maximumWidth: promptTemplateLabel . width
2023-04-25 17:00:28 +00:00
visible: settings . promptTemplate . indexOf (
"%1" ) === - 1
color: theme . textErrorColor
2023-06-22 19:44:49 +00:00
text: qsTr ( "Must contain the string \"%1\" to be replaced with the user's input." )
2023-04-25 17:00:28 +00:00
wrapMode: TextArea . Wrap
Accessible.role: Accessible . EditableText
Accessible.name: text
}
2023-06-22 19:44:49 +00:00
}
Rectangle {
Layout.row: 7
Layout.column: 1
Layout.fillWidth: true
height: 200
color: "transparent"
clip: true
2023-04-25 17:00:28 +00:00
ScrollView {
id: templateScrollView
anchors.fill: parent
TextArea {
text: settings . promptTemplate
color: theme . textColor
background: Rectangle {
implicitWidth: 150
color: theme . backgroundLighter
radius: 10
}
padding: 10
wrapMode: TextArea . Wrap
onTextChanged: {
settings . promptTemplate = text
settings . sync ( )
}
bottomPadding: 10
Accessible.role: Accessible . EditableText
Accessible.name: promptTemplateLabel . text
Accessible.description: promptTemplateLabelHelp . text
2023-05-23 18:50:10 +00:00
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." )
ToolTip.visible: hovered
2023-04-25 17:00:28 +00:00
}
}
}
2023-05-22 13:01:46 +00:00
MyButton {
2023-04-25 17:00:28 +00:00
Layout.row: 8
Layout.column: 1
Layout.fillWidth: true
2023-05-22 13:01:46 +00:00
text: qsTr ( "Restore Defaults" )
Accessible.description: qsTr ( "Restores the settings dialog to a default state" )
2023-04-25 17:00:28 +00:00
onClicked: {
settingsDialog . restoreGenerationDefaults ( )
}
}
}
2023-04-25 14:57:40 +00:00
}
}
Item {
2023-04-25 17:00:28 +00:00
id: applicationSettingsTab
ScrollView {
background: Rectangle {
color: 'transparent'
border.color: theme . tabBorder
border.width: 1
radius: 2
}
2023-04-25 20:20:19 +00:00
padding: 10
2023-04-25 14:57:40 +00:00
width: parent . width
2023-04-25 17:00:28 +00:00
height: parent . height - 30
contentWidth: availableWidth - 20
ScrollBar.vertical.policy: ScrollBar . AlwaysOn
GridLayout {
anchors.margins: 10
columns: 3
rowSpacing: 10
columnSpacing: 10
anchors.fill: parent
2023-05-09 21:10:47 +00:00
Label {
id: defaultModelLabel
text: qsTr ( "Default model:" )
color: theme . textColor
Layout.row: 1
Layout.column: 0
}
2023-05-22 13:01:46 +00:00
MyComboBox {
2023-05-09 21:10:47 +00:00
id: comboBox
Layout.row: 1
Layout.column: 1
Layout.minimumWidth: 350
2023-06-22 19:44:49 +00:00
model: ModelList . userDefaultModelList
2023-05-09 21:10:47 +00:00
Accessible.role: Accessible . ComboBox
Accessible.name: qsTr ( "ComboBox for displaying/picking the default model" )
Accessible.description: qsTr ( "Use this for picking the default model to use; the first item is the current default model" )
2023-06-22 19:44:49 +00:00
function updateModel ( ) {
2023-05-09 21:10:47 +00:00
settings . sync ( ) ;
comboBox . currentIndex = comboBox . indexOfValue ( settingsDialog . userDefaultModel ) ;
}
Component.onCompleted: {
2023-06-22 19:44:49 +00:00
comboBox . updateModel ( )
2023-05-09 21:10:47 +00:00
}
Connections {
target: settings
function onUserDefaultModelChanged ( ) {
2023-06-22 19:44:49 +00:00
comboBox . updateModel ( )
2023-05-09 21:10:47 +00:00
}
}
onActivated: {
settingsDialog . userDefaultModel = comboBox . currentText
settings . sync ( )
}
}
2023-04-25 17:00:28 +00:00
FolderDialog {
id: modelPathDialog
title: "Please choose a directory"
2023-06-22 19:44:49 +00:00
currentFolder: "file://" + ModelList . localModelsPath
2023-04-25 17:00:28 +00:00
onAccepted: {
2023-06-03 02:52:55 +00:00
modelPathDisplayField . text = selectedFolder
2023-06-22 19:44:49 +00:00
ModelList . localModelsPath = modelPathDisplayField . text
settings . modelPath = ModelList . localModelsPath
2023-04-25 17:00:28 +00:00
settings . sync ( )
}
2023-04-25 14:57:40 +00:00
}
2023-04-25 17:00:28 +00:00
Label {
id: modelPathLabel
2023-04-27 20:27:53 +00:00
text: qsTr ( "Download path:" )
2023-04-25 17:00:28 +00:00
color: theme . textColor
2023-05-09 21:10:47 +00:00
Layout.row: 2
2023-04-25 17:00:28 +00:00
Layout.column: 0
2023-04-25 14:57:40 +00:00
}
2023-06-03 02:52:55 +00:00
MyDirectoryField {
id: modelPathDisplayField
2023-06-22 19:44:49 +00:00
text: ModelList . localModelsPath
2023-04-25 17:00:28 +00:00
implicitWidth: 300
2023-05-09 21:10:47 +00:00
Layout.row: 2
2023-04-25 17:00:28 +00:00
Layout.column: 1
2023-04-27 20:27:53 +00:00
Layout.fillWidth: true
2023-04-25 17:00:28 +00:00
ToolTip.text: qsTr ( "Path where model files will be downloaded to" )
ToolTip.visible: hovered
Accessible.role: Accessible . ToolTip
2023-06-03 02:52:55 +00:00
Accessible.name: modelPathDisplayField . text
2023-04-25 17:00:28 +00:00
Accessible.description: ToolTip . text
2023-06-03 02:52:55 +00:00
onEditingFinished: {
if ( isValid ) {
2023-06-22 19:44:49 +00:00
ModelList . localModelsPath = modelPathDisplayField . text
settings . modelPath = ModelList . localModelsPath
2023-06-03 02:52:55 +00:00
settings . sync ( )
} else {
2023-06-22 19:44:49 +00:00
text = ModelList . localModelsPath
2023-06-03 02:52:55 +00:00
}
2023-04-29 02:07:37 +00:00
}
2023-04-25 17:00:28 +00:00
}
2023-05-22 13:01:46 +00:00
MyButton {
2023-05-09 21:10:47 +00:00
Layout.row: 2
2023-04-25 17:00:28 +00:00
Layout.column: 2
text: qsTr ( "Browse" )
2023-05-22 13:01:46 +00:00
Accessible.description: qsTr ( "Opens a folder picker dialog to choose where to save model files" )
2023-04-25 17:00:28 +00:00
onClicked: modelPathDialog . open ( )
2023-04-25 14:57:40 +00:00
}
2023-04-25 17:00:28 +00:00
Label {
id: nThreadsLabel
text: qsTr ( "CPU Threads:" )
2023-04-25 14:57:40 +00:00
color: theme . textColor
2023-05-09 21:10:47 +00:00
Layout.row: 3
2023-04-25 17:00:28 +00:00
Layout.column: 0
2023-04-25 14:57:40 +00:00
}
2023-05-22 21:58:37 +00:00
MyTextField {
2023-04-25 17:00:28 +00:00
text: settingsDialog . threadCount . toString ( )
color: theme . textColor
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
2023-05-09 21:10:47 +00:00
Layout.row: 3
2023-04-25 17:00:28 +00:00
Layout.column: 1
validator: IntValidator {
bottom: 1
}
onEditingFinished: {
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
2023-04-25 14:57:40 +00:00
}
2023-05-05 16:30:11 +00:00
Label {
id: saveChatsLabel
text: qsTr ( "Save chats to disk:" )
color: theme . textColor
2023-05-09 21:10:47 +00:00
Layout.row: 4
2023-05-05 16:30:11 +00:00
Layout.column: 0
}
2023-05-22 21:58:37 +00:00
MyCheckBox {
2023-05-05 16:30:11 +00:00
id: saveChatsBox
2023-05-09 21:10:47 +00:00
Layout.row: 4
2023-05-05 16:30:11 +00:00
Layout.column: 1
checked: settingsDialog . saveChats
onClicked: {
Network . sendSaveChatsToggled ( saveChatsBox . checked ) ;
settingsDialog . saveChats = saveChatsBox . checked
2023-06-22 19:44:49 +00:00
ChatListModel . shouldSaveChats = saveChatsBox . checked
2023-05-05 16:30:11 +00:00
settings . sync ( )
}
ToolTip.text: qsTr ( "WARNING: Saving chats to disk can be ~2GB per chat" )
ToolTip.visible: hovered
}
2023-05-15 22:36:41 +00:00
Label {
id: saveChatGPTChatsLabel
text: qsTr ( "Save ChatGPT chats to disk:" )
color: theme . textColor
Layout.row: 5
Layout.column: 0
}
2023-05-22 21:58:37 +00:00
MyCheckBox {
2023-05-15 22:36:41 +00:00
id: saveChatGPTChatsBox
Layout.row: 5
Layout.column: 1
checked: settingsDialog . saveChatGPTChats
onClicked: {
settingsDialog . saveChatGPTChats = saveChatGPTChatsBox . checked
2023-06-22 19:44:49 +00:00
ChatListModel . shouldSaveChatGPTChats = saveChatGPTChatsBox . checked
2023-05-15 22:36:41 +00:00
settings . sync ( )
}
}
2023-05-11 20:46:25 +00:00
Label {
id: serverChatLabel
2023-06-23 20:28:52 +00:00
text: qsTr ( "Enable API server:" )
2023-05-11 20:46:25 +00:00
color: theme . textColor
2023-05-15 22:36:41 +00:00
Layout.row: 6
2023-05-11 20:46:25 +00:00
Layout.column: 0
}
2023-05-22 21:58:37 +00:00
MyCheckBox {
2023-05-11 20:46:25 +00:00
id: serverChatBox
2023-05-15 22:36:41 +00:00
Layout.row: 6
2023-05-11 20:46:25 +00:00
Layout.column: 1
checked: settings . serverChat
onClicked: {
settingsDialog . serverChat = serverChatBox . checked
LLM . serverEnabled = serverChatBox . checked
settings . sync ( )
}
2023-06-23 20:28:52 +00:00
ToolTip.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" )
2023-05-11 20:46:25 +00:00
ToolTip.visible: hovered
}
2023-06-26 17:37:18 +00:00
Rectangle {
2023-05-15 22:36:41 +00:00
Layout.row: 7
2023-06-26 17:37:18 +00:00
Layout.column: 0
Layout.columnSpan: 3
Layout.fillWidth: true
height: 1
color: theme . dialogBorder
}
Rectangle {
Layout.row: 9
Layout.column: 0
Layout.fillWidth: true
Layout.columnSpan: 3
height: 1
color: theme . dialogBorder
}
Label {
id: gpuOverrideLabel
2023-06-26 18:10:00 +00:00
text: qsTr ( "Force Metal (macOS+arm):" )
2023-06-26 17:37:18 +00:00
color: theme . textColor
Layout.row: 8
Layout.column: 0
}
RowLayout {
Layout.row: 8
Layout.column: 1
Layout.columnSpan: 2
MyCheckBox {
id: gpuOverrideBox
checked: false
onClicked: {
// fixme
}
}
Label {
id: warningLabel
Layout.maximumWidth: 730
Layout.alignment: Qt . AlignTop
color: theme . textErrorColor
wrapMode: Text . WordWrap
text: qsTr ( "WARNING: This setting forces usage of the GPU if it is detected. Can cause a crash if the model requires more RAM than the OS + GPU supports." )
}
}
MyButton {
Layout.row: 10
2023-04-25 17:00:28 +00:00
Layout.column: 1
2023-06-26 17:37:18 +00:00
Layout.columnSpan: 2
2023-04-25 17:00:28 +00:00
Layout.fillWidth: true
2023-05-22 13:01:46 +00:00
text: qsTr ( "Restore Defaults" )
Accessible.description: qsTr ( "Restores the settings dialog to a default state" )
2023-04-25 17:00:28 +00:00
onClicked: {
settingsDialog . restoreApplicationDefaults ( )
}
2023-04-25 14:57:40 +00:00
}
}
}
}
2023-05-21 19:28:41 +00:00
Item {
id: localDocsTab
ScrollView {
background: Rectangle {
color: 'transparent'
border.color: theme . tabBorder
border.width: 1
radius: 2
}
padding: 10
width: parent . width
height: parent . height - 30
contentWidth: availableWidth - 20
ScrollBar.vertical.policy: ScrollBar . AlwaysOn
2023-05-22 13:03:06 +00:00
LocalDocs {
2023-05-21 19:28:41 +00:00
anchors.margins: 10
anchors.fill: parent
}
}
}
2023-04-23 10:58:07 +00:00
}
}