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
ColumnLayout {
Layout.row: 0
Layout.column: 0
Layout.columnSpan: 3
Layout.fillWidth: true
spacing: 10
Label {
color: theme . styledTextColor
font.pixelSize: theme . fontSizeLarge
font.bold: true
text: "General"
}
Rectangle {
Layout.fillWidth: true
height: 2
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-24 18:49:23 -04:00
helpText: qsTr ( "Customize the colors of GPT4All" )
2023-07-26 15:42:07 -04:00
Layout.row: 1
Layout.column: 0
}
MyComboBox {
id: themeBox
Layout.row: 1
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
model: [ qsTr ( "Dark" ) , qsTr ( "Light" ) , qsTr ( "LegacyDark" ) ]
2023-07-26 15:42:07 -04:00
Accessible.role: Accessible . ComboBox
2023-10-21 10:38:46 -04:00
Accessible.name: qsTr ( "Color theme" )
Accessible.description: qsTr ( "Color theme for the chat client to use" )
2023-07-26 15:42:07 -04: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 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-24 18:49:23 -04:00
helpText: qsTr ( "How big your font is displayed" )
2023-08-07 13:54:13 -04:00
Layout.row: 2
Layout.column: 0
}
MyComboBox {
id: fontBox
Layout.row: 2
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
2023-08-07 13:54:13 -04:00
model: [ "Small" , "Medium" , "Large" ]
Accessible.role: Accessible . ComboBox
2023-10-21 10:38:46 -04:00
Accessible.name: qsTr ( "Font size" )
Accessible.description: qsTr ( "Font size of the chat client" )
2023-08-07 13:54:13 -04: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 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-24 18:49:23 -04:00
helpText: qsTr ( "The hardware device used to load the model" )
2023-09-13 10:32:08 -04:00
Layout.row: 3
Layout.column: 0
}
MyComboBox {
id: deviceBox
Layout.row: 3
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
Accessible.role: Accessible . ComboBox
2023-10-21 10:38:46 -04:00
Accessible.name: qsTr ( "Device" )
Accessible.description: qsTr ( "Device of the chat client" )
2023-09-13 10:32:08 -04:00
function updateModel ( ) {
deviceBox . currentIndex = deviceBox . indexOfValue ( MySettings . device ) ;
}
Component.onCompleted: {
deviceBox . updateModel ( )
}
Connections {
target: MySettings
function onDeviceChanged ( ) {
deviceBox . updateModel ( )
}
function onDeviceListChanged ( ) {
deviceBox . updateModel ( )
}
}
onActivated: {
MySettings . device = deviceBox . currentText
}
}
2024-01-22 14:41:47 -05:00
MySettingsLabel {
2023-06-28 23:46:03 -04:00
id: defaultModelLabel
2024-01-22 14:41:47 -05:00
text: qsTr ( "Default model" )
2024-06-24 18:49:23 -04:00
helpText: qsTr ( "The preferred default model" )
2023-09-13 10:32:08 -04:00
Layout.row: 4
2023-06-28 23:46:03 -04:00
Layout.column: 0
}
MyComboBox {
id: comboBox
2023-09-13 10:32:08 -04:00
Layout.row: 4
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
Accessible.role: Accessible . ComboBox
2023-10-21 10:38:46 -04:00
Accessible.name: qsTr ( "Default model" )
Accessible.description: qsTr ( "Default model to use; the first item is the current default model" )
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-01-22 14:41:47 -05:00
MySettingsLabel {
2023-06-28 23:46:03 -04:00
id: modelPathLabel
2024-01-22 14:41:47 -05:00
text: qsTr ( "Download path" )
2024-06-24 18:49:23 -04:00
helpText: qsTr ( "The download folder for models" )
2023-09-13 10:32:08 -04:00
Layout.row: 5
2023-06-28 23:46:03 -04:00
Layout.column: 0
}
2024-06-24 18:49:23 -04:00
RowLayout {
2023-09-13 10:32:08 -04:00
Layout.row: 5
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
ToolTip.text: qsTr ( "Path where model files will be downloaded to" )
ToolTip.visible: hovered
Accessible.role: Accessible . ToolTip
Accessible.name: modelPathDisplayField . text
Accessible.description: ToolTip . text
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
text: qsTr ( "Opensource Datalake" )
helpText: qsTr ( "Send your data to the GPT4All Open Source Datalake." )
Layout.row: 6
Layout.column: 0
}
MyCheckBox {
id: dataLakeBox
Layout.row: 6
2023-06-28 23:46:03 -04:00
Layout.column: 2
2024-06-24 18:49:23 -04:00
Layout.alignment: Qt . AlignRight
checked: MySettings . networkIsActive
2023-07-09 13:05:06 -04:00
onClicked: {
2024-06-24 18:49:23 -04:00
if ( MySettings . networkIsActive ) {
MySettings . networkIsActive = false
} else
networkDialog . open ( )
2023-07-09 13:05:06 -04:00
}
2024-06-24 18:49:23 -04:00
ToolTip.text: qsTr ( "Reveals a dialogue where you can opt-in for sharing data over network" )
ToolTip.visible: hovered
2023-06-28 23:46:03 -04:00
}
2024-06-24 18:49:23 -04:00
ColumnLayout {
Layout.row: 7
Layout.column: 0
Layout.columnSpan: 3
Layout.fillWidth: true
spacing: 10
Label {
color: theme . styledTextColor
font.pixelSize: theme . fontSizeLarge
font.bold: true
text: "Advanced"
}
Rectangle {
Layout.fillWidth: true
height: 2
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-24 18:49:23 -04:00
helpText: qsTr ( "Number of CPU threads for inference and embedding" )
Layout.row: 8
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
2023-07-10 16:52:32 -04:00
ToolTip.text: qsTr ( "Amount of processing threads to use bounded by 1 and number of logical processors" )
2023-06-28 23:46:03 -04:00
ToolTip.visible: hovered
2024-06-24 18:49:23 -04:00
Layout.alignment: Qt . AlignRight
Layout.row: 8
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-24 18:49:23 -04:00
text: qsTr ( "Save chat context" )
helpText: qsTr ( "Save chat context to disk" )
Layout.row: 9
2023-06-28 23:46:03 -04:00
Layout.column: 0
}
MyCheckBox {
2023-10-11 10:23:33 -04:00
id: saveChatsContextBox
2024-06-24 18:49:23 -04:00
Layout.row: 9
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
}
ToolTip.text: qsTr ( "WARNING: Saving chats to disk can be ~2GB per chat" )
ToolTip.visible: hovered
}
2024-01-22 14:41:47 -05:00
MySettingsLabel {
2023-06-28 23:46:03 -04:00
id: serverChatLabel
2024-01-22 14:41:47 -05:00
text: qsTr ( "Enable API server" )
2024-06-24 18:49:23 -04:00
helpText: qsTr ( "A local http server running on local port" )
Layout.row: 10
2023-06-28 23:46:03 -04:00
Layout.column: 0
}
MyCheckBox {
id: serverChatBox
2024-06-24 18:49:23 -04:00
Layout.row: 10
Layout.column: 2
Layout.alignment: Qt . AlignRight
2023-06-28 23:46:03 -04:00
checked: MySettings . serverChat
onClicked: {
MySettings . serverChat = ! MySettings . serverChat
}
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" )
ToolTip.visible: hovered
2024-03-09 10:32:35 -05:00
}
MySettingsLabel {
2023-11-11 13:52:51 -05:00
id: serverPortLabel
2024-06-24 18:49:23 -04:00
text: qsTr ( "API Server Port:" )
helpText: qsTr ( "A local port to run the server (Requires restart" )
Layout.row: 11
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
ToolTip.text: qsTr ( "Api server port. WARNING: You need to restart the application for it to take effect" )
ToolTip.visible: hovered
2024-06-24 18:49:23 -04:00
Layout.row: 11
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-03-09 10:32:35 -05:00
Accessible.name: serverPortField . text
2023-11-11 13:52:51 -05:00
Accessible.description: ToolTip . text
}
2024-06-24 18:49:23 -04:00
2024-01-22 14:41:47 -05:00
MySettingsLabel {
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
}
2023-07-01 11:34:21 -04:00
2024-06-24 18:49:23 -04:00
MySettingsLabel {
id: updatesLabel
text: qsTr ( "Check for updates" )
helpText: qsTr ( "Click to see if an update to the application is available" ) ;
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-28 23:46:03 -04:00
}
}
2024-06-24 18:49:23 -04:00
Rectangle {
Layout.row: 15
Layout.column: 0
Layout.columnSpan: 3
Layout.fillWidth: true
height: 2
color: theme . settingsDivider
}
2023-06-28 23:46:03 -04:00
}
}