2023-06-29 03:46:03 +00:00
import QtCore
import QtQuick
import QtQuick . Controls
import QtQuick . Controls . Basic
import QtQuick . Layouts
import QtQuick . Dialogs
import modellist
import mysettings
2023-07-01 15:34:21 +00:00
import network
2024-06-24 22:49:23 +00:00
import llm
2023-06-29 03:46:03 +00:00
MySettingsTab {
2023-07-01 15:34:21 +00:00
onRestoreDefaultsClicked: {
MySettings . restoreApplicationDefaults ( ) ;
}
2023-06-29 03:46:03 +00:00
title: qsTr ( "Application" )
2024-06-24 22:49:23 +00:00
NetworkDialog {
id: networkDialog
anchors.centerIn: parent
width: Math . min ( 1024 , window . width - ( window . width * . 2 ) )
height: Math . min ( 600 , window . height - ( window . height * . 2 ) )
Item {
Accessible.role: Accessible . Dialog
Accessible.name: qsTr ( "Network dialog" )
Accessible.description: qsTr ( "opt-in to share feedback/conversations" )
}
}
Dialog {
id: checkForUpdatesError
anchors.centerIn: parent
modal: false
padding: 20
Text {
horizontalAlignment: Text . AlignJustify
text: qsTr ( " ERROR: Update system could not find the MaintenanceTool used < br >
to check for updates ! < br > < br >
Did you install this application using the online installer ? If so , < br >
the MaintenanceTool executable should be located one directory < br >
above where this application resides on your filesystem . < br > < br >
If you can 't start it manually, then I' m afraid you ' ll have to < br >
reinstall . " )
color: theme . textErrorColor
font.pixelSize: theme . fontSizeLarge
Accessible.role: Accessible . Dialog
Accessible.name: text
Accessible.description: qsTr ( "Error dialog" )
}
background: Rectangle {
anchors.fill: parent
color: theme . containerBackground
border.width: 1
border.color: theme . dialogBorder
radius: 10
}
}
2023-06-29 03:46:03 +00:00
contentItem: GridLayout {
id: applicationSettingsTabInner
columns: 3
2024-06-24 22:49:23 +00:00
rowSpacing: 30
2023-06-29 03:46:03 +00:00
columnSpacing: 10
2024-06-24 22:49:23 +00:00
2024-06-28 16:57:57 +00:00
Label {
2024-06-24 22:49:23 +00:00
Layout.row: 0
Layout.column: 0
2024-06-28 16:57:57 +00:00
Layout.bottomMargin: 10
color: theme . settingsTitleTextColor
font.pixelSize: theme . fontSizeBannerSmall
font.bold: true
text: qsTr ( "Application Settings" )
}
ColumnLayout {
Layout.row: 1
Layout.column: 0
2024-06-24 22:49:23 +00:00
Layout.columnSpan: 3
Layout.fillWidth: true
spacing: 10
Label {
color: theme . styledTextColor
font.pixelSize: theme . fontSizeLarge
font.bold: true
2024-06-28 16:57:57 +00:00
text: qsTr ( "General" )
2024-06-24 22:49:23 +00:00
}
Rectangle {
Layout.fillWidth: true
2024-06-27 11:16:11 +00:00
height: 1
2024-06-24 22:49:23 +00:00
color: theme . settingsDivider
}
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-07-26 19:42:07 +00:00
id: themeLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "Theme" )
2024-06-28 16:57:57 +00:00
helpText: qsTr ( "The application color scheme." )
Layout.row: 2
2023-07-26 19:42:07 +00:00
Layout.column: 0
}
MyComboBox {
id: themeBox
2024-06-28 16:57:57 +00:00
Layout.row: 2
2024-06-24 22:49:23 +00:00
Layout.column: 2
2024-01-29 16:12:12 +00:00
Layout.minimumWidth: 200
2024-06-24 22:49:23 +00:00
Layout.maximumWidth: 200
2023-07-26 19:42:07 +00:00
Layout.fillWidth: false
2024-06-24 22:49:23 +00:00
Layout.alignment: Qt . AlignRight
model: [ qsTr ( "Dark" ) , qsTr ( "Light" ) , qsTr ( "LegacyDark" ) ]
2024-06-28 16:57:57 +00:00
Accessible.name: themeLabel . text
Accessible.description: themeLabel . helpText
2023-07-26 19:42:07 +00:00
function updateModel ( ) {
themeBox . currentIndex = themeBox . indexOfValue ( MySettings . chatTheme ) ;
}
Component.onCompleted: {
themeBox . updateModel ( )
}
Connections {
target: MySettings
function onChatThemeChanged ( ) {
themeBox . updateModel ( )
}
}
onActivated: {
MySettings . chatTheme = themeBox . currentText
}
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-08-07 17:54:13 +00:00
id: fontLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "Font Size" )
2024-06-28 16:57:57 +00:00
helpText: qsTr ( "The size of text in the application." )
Layout.row: 3
2023-08-07 17:54:13 +00:00
Layout.column: 0
}
MyComboBox {
id: fontBox
2024-06-28 16:57:57 +00:00
Layout.row: 3
2024-06-24 22:49:23 +00:00
Layout.column: 2
Layout.minimumWidth: 200
Layout.maximumWidth: 200
2023-08-07 17:54:13 +00:00
Layout.fillWidth: false
2024-06-24 22:49:23 +00:00
Layout.alignment: Qt . AlignRight
2023-08-07 17:54:13 +00:00
model: [ "Small" , "Medium" , "Large" ]
2024-06-28 16:57:57 +00:00
Accessible.name: fontLabel . text
Accessible.description: fontLabel . helpText
2023-08-07 17:54:13 +00:00
function updateModel ( ) {
fontBox . currentIndex = fontBox . indexOfValue ( MySettings . fontSize ) ;
}
Component.onCompleted: {
fontBox . updateModel ( )
}
Connections {
target: MySettings
function onFontSizeChanged ( ) {
fontBox . updateModel ( )
}
}
onActivated: {
MySettings . fontSize = fontBox . currentText
}
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-09-13 14:32:08 +00:00
id: deviceLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "Device" )
2024-06-28 16:57:57 +00:00
helpText: qsTr ( 'The compute device used for text generation. "Auto" uses Vulkan or Metal.' )
Layout.row: 4
2023-09-13 14:32:08 +00:00
Layout.column: 0
}
MyComboBox {
id: deviceBox
2024-06-28 16:57:57 +00:00
Layout.row: 4
2024-06-24 22:49:23 +00:00
Layout.column: 2
Layout.minimumWidth: 400
Layout.maximumWidth: 400
2023-09-13 14:32:08 +00:00
Layout.fillWidth: false
2024-06-24 22:49:23 +00:00
Layout.alignment: Qt . AlignRight
2023-09-13 14:32:08 +00:00
model: MySettings . deviceList
2024-06-28 16:57:57 +00:00
Accessible.name: deviceLabel . text
Accessible.description: deviceLabel . helpText
2023-09-13 14:32:08 +00:00
function updateModel ( ) {
deviceBox . currentIndex = deviceBox . indexOfValue ( MySettings . device ) ;
}
Component.onCompleted: {
2024-06-28 16:57:57 +00:00
deviceBox . updateModel ( ) ;
2023-09-13 14:32:08 +00:00
}
Connections {
target: MySettings
function onDeviceChanged ( ) {
2024-06-28 16:57:57 +00:00
deviceBox . updateModel ( ) ;
2023-09-13 14:32:08 +00:00
}
}
onActivated: {
2024-06-28 16:57:57 +00:00
MySettings . device = deviceBox . currentText ;
2023-09-13 14:32:08 +00:00
}
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-06-29 03:46:03 +00:00
id: defaultModelLabel
2024-06-28 16:57:57 +00:00
text: qsTr ( "Default Model" )
helpText: qsTr ( "The preferred model for new chats. Also used as the local server fallback." )
Layout.row: 5
2023-06-29 03:46:03 +00:00
Layout.column: 0
}
MyComboBox {
id: comboBox
2024-06-28 16:57:57 +00:00
Layout.row: 5
2024-06-24 22:49:23 +00:00
Layout.column: 2
Layout.minimumWidth: 400
Layout.maximumWidth: 400
Layout.alignment: Qt . AlignRight
2023-06-29 03:46:03 +00:00
model: ModelList . userDefaultModelList
2024-06-28 16:57:57 +00:00
Accessible.name: defaultModelLabel . text
Accessible.description: defaultModelLabel . helpText
2023-06-29 03:46:03 +00:00
function updateModel ( ) {
comboBox . currentIndex = comboBox . indexOfValue ( MySettings . userDefaultModel ) ;
}
Component.onCompleted: {
comboBox . updateModel ( )
}
Connections {
target: MySettings
function onUserDefaultModelChanged ( ) {
comboBox . updateModel ( )
}
}
onActivated: {
MySettings . userDefaultModel = comboBox . currentText
}
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-06-29 03:46:03 +00:00
id: modelPathLabel
2024-06-28 16:57:57 +00:00
text: qsTr ( "Download Path" )
helpText: qsTr ( "Where to store local models and the LocalDocs database." )
Layout.row: 6
2023-06-29 03:46:03 +00:00
Layout.column: 0
}
2024-06-24 22:49:23 +00:00
RowLayout {
2024-06-28 16:57:57 +00:00
Layout.row: 6
2024-06-24 22:49:23 +00:00
Layout.column: 2
Layout.alignment: Qt . AlignRight
Layout.minimumWidth: 400
Layout.maximumWidth: 400
spacing: 10
MyDirectoryField {
id: modelPathDisplayField
text: MySettings . modelPath
font.pixelSize: theme . fontSizeLarge
implicitWidth: 300
Layout.fillWidth: true
2024-06-28 16:57:57 +00:00
Accessible.name: modelPathLabel . text
Accessible.description: modelPathLabel . helpText
2024-06-24 22:49:23 +00:00
onEditingFinished: {
if ( isValid ) {
MySettings . modelPath = modelPathDisplayField . text
} else {
text = MySettings . modelPath
}
}
}
MySettingsButton {
text: qsTr ( "Browse" )
Accessible.description: qsTr ( "Choose where to save model files" )
onClicked: {
openFolderDialog ( "file://" + MySettings . modelPath , function ( selectedFolder ) {
MySettings . modelPath = selectedFolder
} )
2023-06-29 03:46:03 +00:00
}
}
}
2024-06-24 22:49:23 +00:00
MySettingsLabel {
id: dataLakeLabel
2024-06-28 16:57:57 +00:00
text: qsTr ( "Enable Datalake" )
helpText: qsTr ( "Send chats and feedback to the GPT4All Open-Source Datalake." )
Layout.row: 7
2024-06-24 22:49:23 +00:00
Layout.column: 0
}
MyCheckBox {
id: dataLakeBox
2024-06-28 16:57:57 +00:00
Layout.row: 7
2023-06-29 03:46:03 +00:00
Layout.column: 2
2024-06-24 22:49:23 +00:00
Layout.alignment: Qt . AlignRight
2024-06-28 16:57:57 +00:00
Component.onCompleted: { dataLakeBox . checked = MySettings . networkIsActive ; }
Connections {
target: MySettings
function onNetworkIsActiveChanged ( ) { dataLakeBox . checked = MySettings . networkIsActive ; }
}
2023-07-09 17:05:06 +00:00
onClicked: {
2024-06-28 16:57:57 +00:00
if ( MySettings . networkIsActive )
MySettings . networkIsActive = false ;
else
networkDialog . open ( ) ;
dataLakeBox . checked = MySettings . networkIsActive ;
2023-07-09 17:05:06 +00:00
}
2023-06-29 03:46:03 +00:00
}
2024-06-24 22:49:23 +00:00
ColumnLayout {
2024-06-28 16:57:57 +00:00
Layout.row: 8
2024-06-24 22:49:23 +00:00
Layout.column: 0
Layout.columnSpan: 3
Layout.fillWidth: true
spacing: 10
Label {
color: theme . styledTextColor
font.pixelSize: theme . fontSizeLarge
font.bold: true
2024-06-28 16:57:57 +00:00
text: qsTr ( "Advanced" )
2024-06-24 22:49:23 +00:00
}
Rectangle {
Layout.fillWidth: true
2024-06-27 11:16:11 +00:00
height: 1
2024-06-24 22:49:23 +00:00
color: theme . settingsDivider
}
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-06-29 03:46:03 +00:00
id: nThreadsLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "CPU Threads" )
2024-06-28 16:57:57 +00:00
helpText: qsTr ( "The number of CPU threads used for inference and embedding." )
Layout.row: 9
2023-06-29 03:46:03 +00:00
Layout.column: 0
}
MyTextField {
text: MySettings . threadCount
color: theme . textColor
2023-08-07 17:54:13 +00:00
font.pixelSize: theme . fontSizeLarge
2024-06-24 22:49:23 +00:00
Layout.alignment: Qt . AlignRight
2024-06-28 16:57:57 +00:00
Layout.row: 9
2024-06-24 22:49:23 +00:00
Layout.column: 2
Layout.minimumWidth: 200
Layout.maximumWidth: 200
2023-06-29 03:46:03 +00:00
validator: IntValidator {
bottom: 1
}
onEditingFinished: {
var val = parseInt ( text )
if ( ! isNaN ( val ) ) {
MySettings . threadCount = val
focus = false
} else {
text = MySettings . threadCount
}
}
Accessible.role: Accessible . EditableText
Accessible.name: nThreadsLabel . text
Accessible.description: ToolTip . text
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-10-11 14:23:33 +00:00
id: saveChatsContextLabel
2024-06-28 16:57:57 +00:00
text: qsTr ( "Save Chat Context" )
helpText: qsTr ( "Save the chat model's state to disk for faster loading. WARNING: Uses ~2GB per chat." )
Layout.row: 10
2023-06-29 03:46:03 +00:00
Layout.column: 0
}
MyCheckBox {
2023-10-11 14:23:33 +00:00
id: saveChatsContextBox
2024-06-28 16:57:57 +00:00
Layout.row: 10
2024-06-24 22:49:23 +00:00
Layout.column: 2
Layout.alignment: Qt . AlignRight
2023-10-11 14:23:33 +00:00
checked: MySettings . saveChatsContext
2023-06-29 03:46:03 +00:00
onClicked: {
2023-10-11 14:23:33 +00:00
MySettings . saveChatsContext = ! MySettings . saveChatsContext
2023-06-29 03:46:03 +00:00
}
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-06-29 03:46:03 +00:00
id: serverChatLabel
2024-06-28 16:57:57 +00:00
text: qsTr ( "Enable Local Server" )
helpText: qsTr ( "Expose an OpenAI-Compatible server to localhost. WARNING: Results in increased resource usage." )
Layout.row: 11
2023-06-29 03:46:03 +00:00
Layout.column: 0
}
MyCheckBox {
id: serverChatBox
2024-06-28 16:57:57 +00:00
Layout.row: 11
2024-06-24 22:49:23 +00:00
Layout.column: 2
Layout.alignment: Qt . AlignRight
2023-06-29 03:46:03 +00:00
checked: MySettings . serverChat
onClicked: {
MySettings . serverChat = ! MySettings . serverChat
}
2024-03-09 15:32:35 +00:00
}
MySettingsLabel {
2023-11-11 18:52:51 +00:00
id: serverPortLabel
2024-06-28 16:57:57 +00:00
text: qsTr ( "API Server Port" )
helpText: qsTr ( "The port to use for the local server. Requires restart." )
Layout.row: 12
2023-11-11 18:52:51 +00:00
Layout.column: 0
2023-06-29 03:46:03 +00:00
}
2023-11-11 18:52:51 +00:00
MyTextField {
2024-03-09 15:32:35 +00:00
id: serverPortField
2023-11-11 18:52:51 +00:00
text: MySettings . networkPort
color: theme . textColor
font.pixelSize: theme . fontSizeLarge
2024-06-28 16:57:57 +00:00
Layout.row: 12
2024-06-24 22:49:23 +00:00
Layout.column: 2
Layout.minimumWidth: 200
Layout.maximumWidth: 200
Layout.alignment: Qt . AlignRight
2023-11-11 18:52:51 +00:00
validator: IntValidator {
bottom: 1
}
onEditingFinished: {
var val = parseInt ( text )
if ( ! isNaN ( val ) ) {
MySettings . networkPort = val
focus = false
} else {
text = MySettings . networkPort
}
}
Accessible.role: Accessible . EditableText
2024-06-28 16:57:57 +00:00
Accessible.name: serverPortLabel . text
Accessible.description: serverPortLabel . helpText
2023-11-11 18:52:51 +00:00
}
2024-06-24 22:49:23 +00:00
2024-06-27 15:08:32 +00:00
/ * M y S e t t i n g s L a b e l {
2023-06-29 03:46:03 +00:00
id: gpuOverrideLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "Force Metal (macOS+arm)" )
2024-06-24 22:49:23 +00:00
Layout.row: 13
2023-06-29 03:46:03 +00:00
Layout.column: 0
}
2024-06-24 22:49:23 +00:00
MyCheckBox {
id: gpuOverrideBox
Layout.row: 13
Layout.column: 2
Layout.alignment: Qt . AlignRight
checked: MySettings . forceMetal
onClicked: {
MySettings . forceMetal = ! MySettings . forceMetal
2023-06-29 03:46:03 +00:00
}
2024-06-24 22:49:23 +00:00
ToolTip.text: qsTr ( "WARNING: On macOS with arm (M1+) this setting forces usage of the GPU. Can cause crashes if the model requires more RAM than the system supports. Because of crash possibility the setting will not persist across restarts of the application. This has no effect on non-macs or intel." )
ToolTip.visible: hovered
2024-06-27 15:08:32 +00:00
} * /
2023-07-01 15:34:21 +00:00
2024-06-24 22:49:23 +00:00
MySettingsLabel {
id: updatesLabel
2024-06-28 16:57:57 +00:00
text: qsTr ( "Check For Updates" )
helpText: qsTr ( "Manually check for an update to GPT4All." ) ;
2024-06-24 22:49:23 +00:00
Layout.row: 14
Layout.column: 0
}
MySettingsButton {
Layout.row: 14
Layout.column: 2
Layout.alignment: Qt . AlignRight
text: qsTr ( "Updates" ) ;
onClicked: {
if ( ! LLM . checkForUpdates ( ) )
checkForUpdatesError . open ( )
2023-06-29 03:46:03 +00:00
}
}
2024-06-24 22:49:23 +00:00
Rectangle {
Layout.row: 15
Layout.column: 0
Layout.columnSpan: 3
Layout.fillWidth: true
2024-06-27 11:16:11 +00:00
height: 1
2024-06-24 22:49:23 +00:00
color: theme . settingsDivider
}
2023-06-29 03:46:03 +00:00
}
}