2023-06-28 23:46:03 -04: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 11:34:21 -04:00
import network
2024-06-24 18:49:23 -04:00
import llm
2023-06-28 23:46:03 -04:00
MySettingsTab {
2023-07-01 11:34:21 -04:00
onRestoreDefaultsClicked: {
MySettings . restoreApplicationDefaults ( ) ;
}
2023-06-28 23:46:03 -04:00
title: qsTr ( "Application" )
2024-06-24 18:49:23 -04: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-28 23:46:03 -04:00
contentItem: GridLayout {
id: applicationSettingsTabInner
columns: 3
2024-06-24 18:49:23 -04:00
rowSpacing: 30
2023-06-28 23:46:03 -04:00
columnSpacing: 10
2024-06-24 18:49:23 -04:00
2024-06-28 12:57:57 -04:00
Label {
2024-06-24 18:49:23 -04:00
Layout.row: 0
Layout.column: 0
2024-06-28 12:57:57 -04: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 18:49:23 -04:00
Layout.columnSpan: 3
Layout.fillWidth: true
spacing: 10
Label {
color: theme . styledTextColor
font.pixelSize: theme . fontSizeLarge
font.bold: true
2024-06-28 12:57:57 -04:00
text: qsTr ( "General" )
2024-06-24 18:49:23 -04:00
}
Rectangle {
Layout.fillWidth: true
2024-06-27 07:16:11 -04:00
height: 1
2024-06-24 18:49:23 -04:00
color: theme . settingsDivider
}
}
2024-01-22 14:41:47 -05:00
MySettingsLabel {
2023-07-26 15:42:07 -04:00
id: themeLabel
2024-01-22 14:41:47 -05:00
text: qsTr ( "Theme" )
2024-06-28 12:57:57 -04:00
helpText: qsTr ( "The application color scheme." )
Layout.row: 2
2023-07-26 15:42:07 -04:00
Layout.column: 0
}
MyComboBox {
id: themeBox
2024-06-28 12:57:57 -04:00
Layout.row: 2
2024-06-24 18:49:23 -04:00
Layout.column: 2
2024-01-29 11:12:12 -05:00
Layout.minimumWidth: 200
2024-06-24 18:49:23 -04:00
Layout.maximumWidth: 200
2023-07-26 15:42:07 -04:00
Layout.fillWidth: false
2024-06-24 18:49:23 -04:00
Layout.alignment: Qt . AlignRight
2024-07-16 16:12:44 -04:00
// NOTE: indices match values of ChatTheme enum, keep them in sync
model: [ qsTr ( "Light" ) , qsTr ( "Dark" ) , qsTr ( "LegacyDark" ) ]
2024-06-28 12:57:57 -04:00
Accessible.name: themeLabel . text
Accessible.description: themeLabel . helpText
2023-07-26 15:42:07 -04:00
function updateModel ( ) {
2024-07-16 16:12:44 -04:00
themeBox . currentIndex = MySettings . chatTheme ;
2023-07-26 15:42:07 -04:00
}
Component.onCompleted: {
themeBox . updateModel ( )
}
Connections {
target: MySettings
function onChatThemeChanged ( ) {
themeBox . updateModel ( )
}
}
onActivated: {
2024-07-16 16:12:44 -04:00
MySettings . chatTheme = themeBox . currentIndex
2023-07-26 15:42:07 -04:00
}
}
2024-01-22 14:41:47 -05:00
MySettingsLabel {
2023-08-07 13:54:13 -04:00
id: fontLabel
2024-01-22 14:41:47 -05:00
text: qsTr ( "Font Size" )
2024-06-28 12:57:57 -04:00
helpText: qsTr ( "The size of text in the application." )
Layout.row: 3
2023-08-07 13:54:13 -04:00
Layout.column: 0
}
MyComboBox {
id: fontBox
2024-06-28 12:57:57 -04:00
Layout.row: 3
2024-06-24 18:49:23 -04:00
Layout.column: 2
Layout.minimumWidth: 200
Layout.maximumWidth: 200
2023-08-07 13:54:13 -04:00
Layout.fillWidth: false
2024-06-24 18:49:23 -04:00
Layout.alignment: Qt . AlignRight
2024-07-16 16:12:44 -04:00
// NOTE: indices match values of FontSize enum, keep them in sync
model: [ qsTr ( "Small" ) , qsTr ( "Medium" ) , qsTr ( "Large" ) ]
2024-06-28 12:57:57 -04:00
Accessible.name: fontLabel . text
Accessible.description: fontLabel . helpText
2023-08-07 13:54:13 -04:00
function updateModel ( ) {
2024-07-16 16:12:44 -04:00
fontBox . currentIndex = MySettings . fontSize ;
2023-08-07 13:54:13 -04:00
}
Component.onCompleted: {
fontBox . updateModel ( )
}
Connections {
target: MySettings
function onFontSizeChanged ( ) {
fontBox . updateModel ( )
}
}
onActivated: {
2024-07-16 16:12:44 -04:00
MySettings . fontSize = fontBox . currentIndex
2023-08-07 13:54:13 -04:00
}
}
2024-07-12 16:14:58 -04:00
MySettingsLabel {
id: languageLabel
visible: MySettings . uiLanguages . length > 1
text: qsTr ( "Language and Locale" )
helpText: qsTr ( "The language and locale you wish to use." )
Layout.row: 4
Layout.column: 0
}
MyComboBox {
id: languageBox
visible: MySettings . uiLanguages . length > 1
Layout.row: 4
Layout.column: 2
Layout.minimumWidth: 200
Layout.maximumWidth: 200
Layout.fillWidth: false
Layout.alignment: Qt . AlignRight
model: MySettings . uiLanguages
Accessible.name: fontLabel . text
Accessible.description: fontLabel . helpText
function updateModel ( ) {
languageBox . currentIndex = languageBox . indexOfValue ( MySettings . languageAndLocale ) ;
}
Component.onCompleted: {
languageBox . updateModel ( )
}
onActivated: {
MySettings . languageAndLocale = languageBox . currentText
}
}
2024-01-22 14:41:47 -05:00
MySettingsLabel {
2023-09-13 10:32:08 -04:00
id: deviceLabel
2024-01-22 14:41:47 -05:00
text: qsTr ( "Device" )
2024-06-28 12:57:57 -04:00
helpText: qsTr ( 'The compute device used for text generation. "Auto" uses Vulkan or Metal.' )
2024-07-12 16:14:58 -04:00
Layout.row: 5
2023-09-13 10:32:08 -04:00
Layout.column: 0
}
MyComboBox {
id: deviceBox
2024-07-12 16:14:58 -04:00
Layout.row: 5
2024-06-24 18:49:23 -04:00
Layout.column: 2
Layout.minimumWidth: 400
Layout.maximumWidth: 400
2023-09-13 10:32:08 -04:00
Layout.fillWidth: false
2024-06-24 18:49:23 -04:00
Layout.alignment: Qt . AlignRight
2023-09-13 10:32:08 -04:00
model: MySettings . deviceList
2024-06-28 12:57:57 -04:00
Accessible.name: deviceLabel . text
Accessible.description: deviceLabel . helpText
2023-09-13 10:32:08 -04:00
function updateModel ( ) {
deviceBox . currentIndex = deviceBox . indexOfValue ( MySettings . device ) ;
}
Component.onCompleted: {
2024-06-28 12:57:57 -04:00
deviceBox . updateModel ( ) ;
2023-09-13 10:32:08 -04:00
}
Connections {
target: MySettings
function onDeviceChanged ( ) {
2024-06-28 12:57:57 -04:00
deviceBox . updateModel ( ) ;
2023-09-13 10:32:08 -04:00
}
}
onActivated: {
2024-06-28 12:57:57 -04:00
MySettings . device = deviceBox . currentText ;
2023-09-13 10:32:08 -04:00
}
}
2024-01-22 14:41:47 -05:00
MySettingsLabel {
2023-06-28 23:46:03 -04:00
id: defaultModelLabel
2024-06-28 12:57:57 -04:00
text: qsTr ( "Default Model" )
helpText: qsTr ( "The preferred model for new chats. Also used as the local server fallback." )
2024-07-12 16:14:58 -04:00
Layout.row: 6
2023-06-28 23:46:03 -04:00
Layout.column: 0
}
MyComboBox {
id: comboBox
2024-07-12 16:14:58 -04:00
Layout.row: 6
2024-06-24 18:49:23 -04:00
Layout.column: 2
Layout.minimumWidth: 400
Layout.maximumWidth: 400
Layout.alignment: Qt . AlignRight
2023-06-28 23:46:03 -04:00
model: ModelList . userDefaultModelList
2024-06-28 12:57:57 -04:00
Accessible.name: defaultModelLabel . text
Accessible.description: defaultModelLabel . helpText
2023-06-28 23:46:03 -04: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-07-10 15:45:20 -04:00
MySettingsLabel {
id: suggestionModeLabel
text: qsTr ( "Suggestion Mode" )
helpText: qsTr ( "Generate suggested follow-up questions at the end of responses." )
2024-07-12 16:14:58 -04:00
Layout.row: 7
2024-07-10 15:45:20 -04:00
Layout.column: 0
}
MyComboBox {
id: suggestionModeBox
2024-07-12 16:14:58 -04:00
Layout.row: 7
2024-07-10 15:45:20 -04:00
Layout.column: 2
Layout.minimumWidth: 400
Layout.maximumWidth: 400
Layout.alignment: Qt . AlignRight
2024-07-16 16:12:44 -04:00
// NOTE: indices match values of SuggestionMode enum, keep them in sync
2024-07-10 15:45:20 -04:00
model: [ qsTr ( "When chatting with LocalDocs" ) , qsTr ( "Whenever possible" ) , qsTr ( "Never" ) ]
Accessible.name: suggestionModeLabel . text
Accessible.description: suggestionModeLabel . helpText
onActivated: {
MySettings . suggestionMode = suggestionModeBox . currentIndex ;
}
Component.onCompleted: {
suggestionModeBox . currentIndex = MySettings . suggestionMode ;
}
}
2024-01-22 14:41:47 -05:00
MySettingsLabel {
2023-06-28 23:46:03 -04:00
id: modelPathLabel
2024-06-28 12:57:57 -04:00
text: qsTr ( "Download Path" )
helpText: qsTr ( "Where to store local models and the LocalDocs database." )
2024-07-12 16:14:58 -04:00
Layout.row: 8
2023-06-28 23:46:03 -04:00
Layout.column: 0
}
2024-06-24 18:49:23 -04:00
RowLayout {
2024-07-12 16:14:58 -04:00
Layout.row: 8
2024-06-24 18:49:23 -04: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 12:57:57 -04:00
Accessible.name: modelPathLabel . text
Accessible.description: modelPathLabel . helpText
2024-06-24 18:49:23 -04: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-28 23:46:03 -04:00
}
}
}
2024-06-24 18:49:23 -04:00
MySettingsLabel {
id: dataLakeLabel
2024-06-28 12:57:57 -04:00
text: qsTr ( "Enable Datalake" )
helpText: qsTr ( "Send chats and feedback to the GPT4All Open-Source Datalake." )
2024-07-12 16:14:58 -04:00
Layout.row: 9
2024-06-24 18:49:23 -04:00
Layout.column: 0
}
MyCheckBox {
id: dataLakeBox
2024-07-12 16:14:58 -04:00
Layout.row: 9
2023-06-28 23:46:03 -04:00
Layout.column: 2
2024-06-24 18:49:23 -04:00
Layout.alignment: Qt . AlignRight
2024-06-28 12:57:57 -04:00
Component.onCompleted: { dataLakeBox . checked = MySettings . networkIsActive ; }
Connections {
target: MySettings
function onNetworkIsActiveChanged ( ) { dataLakeBox . checked = MySettings . networkIsActive ; }
}
2023-07-09 13:05:06 -04:00
onClicked: {
2024-06-28 12:57:57 -04:00
if ( MySettings . networkIsActive )
MySettings . networkIsActive = false ;
else
networkDialog . open ( ) ;
dataLakeBox . checked = MySettings . networkIsActive ;
2023-07-09 13:05:06 -04:00
}
2023-06-28 23:46:03 -04:00
}
2024-06-24 18:49:23 -04:00
ColumnLayout {
2024-07-12 16:14:58 -04:00
Layout.row: 10
2024-06-24 18:49:23 -04: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 12:57:57 -04:00
text: qsTr ( "Advanced" )
2024-06-24 18:49:23 -04:00
}
Rectangle {
Layout.fillWidth: true
2024-06-27 07:16:11 -04:00
height: 1
2024-06-24 18:49:23 -04:00
color: theme . settingsDivider
}
}
2024-01-22 14:41:47 -05:00
MySettingsLabel {
2023-06-28 23:46:03 -04:00
id: nThreadsLabel
2024-01-22 14:41:47 -05:00
text: qsTr ( "CPU Threads" )
2024-06-28 12:57:57 -04:00
helpText: qsTr ( "The number of CPU threads used for inference and embedding." )
2024-07-12 16:14:58 -04:00
Layout.row: 11
2023-06-28 23:46:03 -04:00
Layout.column: 0
}
MyTextField {
text: MySettings . threadCount
color: theme . textColor
2023-08-07 13:54:13 -04:00
font.pixelSize: theme . fontSizeLarge
2024-06-24 18:49:23 -04:00
Layout.alignment: Qt . AlignRight
2024-07-12 16:14:58 -04:00
Layout.row: 11
2024-06-24 18:49:23 -04:00
Layout.column: 2
Layout.minimumWidth: 200
Layout.maximumWidth: 200
2023-06-28 23:46:03 -04: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 14:41:47 -05:00
MySettingsLabel {
2023-10-11 10:23:33 -04:00
id: saveChatsContextLabel
2024-06-28 12:57:57 -04:00
text: qsTr ( "Save Chat Context" )
helpText: qsTr ( "Save the chat model's state to disk for faster loading. WARNING: Uses ~2GB per chat." )
2024-07-12 16:14:58 -04:00
Layout.row: 12
2023-06-28 23:46:03 -04:00
Layout.column: 0
}
MyCheckBox {
2023-10-11 10:23:33 -04:00
id: saveChatsContextBox
2024-07-12 16:14:58 -04:00
Layout.row: 12
2024-06-24 18:49:23 -04:00
Layout.column: 2
Layout.alignment: Qt . AlignRight
2023-10-11 10:23:33 -04:00
checked: MySettings . saveChatsContext
2023-06-28 23:46:03 -04:00
onClicked: {
2023-10-11 10:23:33 -04:00
MySettings . saveChatsContext = ! MySettings . saveChatsContext
2023-06-28 23:46:03 -04:00
}
}
2024-01-22 14:41:47 -05:00
MySettingsLabel {
2023-06-28 23:46:03 -04:00
id: serverChatLabel
2024-06-28 12:57:57 -04:00
text: qsTr ( "Enable Local Server" )
helpText: qsTr ( "Expose an OpenAI-Compatible server to localhost. WARNING: Results in increased resource usage." )
2024-07-12 16:14:58 -04:00
Layout.row: 13
2023-06-28 23:46:03 -04:00
Layout.column: 0
}
MyCheckBox {
id: serverChatBox
2024-07-12 16:14:58 -04:00
Layout.row: 13
2024-06-24 18:49:23 -04:00
Layout.column: 2
Layout.alignment: Qt . AlignRight
2023-06-28 23:46:03 -04:00
checked: MySettings . serverChat
onClicked: {
MySettings . serverChat = ! MySettings . serverChat
}
2024-03-09 10:32:35 -05:00
}
MySettingsLabel {
2023-11-11 13:52:51 -05:00
id: serverPortLabel
2024-06-28 12:57:57 -04:00
text: qsTr ( "API Server Port" )
helpText: qsTr ( "The port to use for the local server. Requires restart." )
2024-07-12 16:14:58 -04:00
Layout.row: 14
2023-11-11 13:52:51 -05:00
Layout.column: 0
2023-06-28 23:46:03 -04:00
}
2023-11-11 13:52:51 -05:00
MyTextField {
2024-03-09 10:32:35 -05:00
id: serverPortField
2023-11-11 13:52:51 -05:00
text: MySettings . networkPort
color: theme . textColor
font.pixelSize: theme . fontSizeLarge
2024-07-12 16:14:58 -04:00
Layout.row: 14
2024-06-24 18:49:23 -04:00
Layout.column: 2
Layout.minimumWidth: 200
Layout.maximumWidth: 200
Layout.alignment: Qt . AlignRight
2023-11-11 13:52:51 -05: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 12:57:57 -04:00
Accessible.name: serverPortLabel . text
Accessible.description: serverPortLabel . helpText
2023-11-11 13:52:51 -05:00
}
2024-06-24 18:49:23 -04:00
2024-06-27 11:08:32 -04:00
/ * M y S e t t i n g s L a b e l {
2023-06-28 23:46:03 -04:00
id: gpuOverrideLabel
2024-01-22 14:41:47 -05:00
text: qsTr ( "Force Metal (macOS+arm)" )
2024-06-24 18:49:23 -04:00
Layout.row: 13
2023-06-28 23:46:03 -04:00
Layout.column: 0
}
2024-06-24 18:49:23 -04:00
MyCheckBox {
id: gpuOverrideBox
Layout.row: 13
Layout.column: 2
Layout.alignment: Qt . AlignRight
checked: MySettings . forceMetal
onClicked: {
MySettings . forceMetal = ! MySettings . forceMetal
2023-06-28 23:46:03 -04:00
}
2024-06-24 18:49:23 -04: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 11:08:32 -04:00
} * /
2023-07-01 11:34:21 -04:00
2024-06-24 18:49:23 -04:00
MySettingsLabel {
id: updatesLabel
2024-06-28 12:57:57 -04:00
text: qsTr ( "Check For Updates" )
helpText: qsTr ( "Manually check for an update to GPT4All." ) ;
2024-07-12 16:14:58 -04:00
Layout.row: 15
2024-06-24 18:49:23 -04:00
Layout.column: 0
}
MySettingsButton {
2024-07-12 16:14:58 -04:00
Layout.row: 15
2024-06-24 18:49:23 -04:00
Layout.column: 2
Layout.alignment: Qt . AlignRight
text: qsTr ( "Updates" ) ;
onClicked: {
if ( ! LLM . checkForUpdates ( ) )
checkForUpdatesError . open ( )
2023-06-28 23:46:03 -04:00
}
}
2024-06-24 18:49:23 -04:00
Rectangle {
2024-07-12 16:14:58 -04:00
Layout.row: 16
2024-06-24 18:49:23 -04:00
Layout.column: 0
Layout.columnSpan: 3
Layout.fillWidth: true
2024-06-27 07:16:11 -04:00
height: 1
2024-06-24 18:49:23 -04:00
color: theme . settingsDivider
}
2023-06-28 23:46:03 -04:00
}
}