mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-06-24 06:27:22 +00:00
Provide a user default model setting and honor it.
This commit is contained in:
parent
069c243f1a
commit
2206fa7f8c
@ -65,7 +65,12 @@ bool ChatLLM::loadDefaultModel()
|
|||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.sync();
|
settings.sync();
|
||||||
QString defaultModel = settings.value("defaultModel", "gpt4all-j-v1.3-groovy").toString();
|
// The user default model can be set by the user in the settings dialog. The "default" user
|
||||||
|
// default model is "Application default" which signals we should use the default model that was
|
||||||
|
// specified by the models.json file.
|
||||||
|
QString defaultModel = settings.value("userDefaultModel").toString();
|
||||||
|
if (defaultModel.isEmpty() || !models.contains(defaultModel) || defaultModel == "Application default")
|
||||||
|
defaultModel = settings.value("defaultModel").toString();
|
||||||
if (defaultModel.isEmpty() || !models.contains(defaultModel))
|
if (defaultModel.isEmpty() || !models.contains(defaultModel))
|
||||||
defaultModel = models.first();
|
defaultModel = models.first();
|
||||||
return loadModel(defaultModel);
|
return loadModel(defaultModel);
|
||||||
|
@ -25,6 +25,8 @@ Dialog {
|
|||||||
Network.sendSettingsDialog();
|
Network.sendSettingsDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property var currentChat: LLM.chatListModel.currentChat
|
||||||
|
|
||||||
Theme {
|
Theme {
|
||||||
id: theme
|
id: theme
|
||||||
}
|
}
|
||||||
@ -42,6 +44,7 @@ Dialog {
|
|||||||
%1
|
%1
|
||||||
### Assistant:\n"
|
### Assistant:\n"
|
||||||
property string defaultModelPath: Download.defaultLocalModelsPath()
|
property string defaultModelPath: Download.defaultLocalModelsPath()
|
||||||
|
property string defaultUserDefaultModel: "Application default"
|
||||||
|
|
||||||
property alias temperature: settings.temperature
|
property alias temperature: settings.temperature
|
||||||
property alias topP: settings.topP
|
property alias topP: settings.topP
|
||||||
@ -54,6 +57,7 @@ Dialog {
|
|||||||
property alias threadCount: settings.threadCount
|
property alias threadCount: settings.threadCount
|
||||||
property alias saveChats: settings.saveChats
|
property alias saveChats: settings.saveChats
|
||||||
property alias modelPath: settings.modelPath
|
property alias modelPath: settings.modelPath
|
||||||
|
property alias userDefaultModel: settings.userDefaultModel
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
id: settings
|
id: settings
|
||||||
@ -68,6 +72,7 @@ Dialog {
|
|||||||
property int repeatPenaltyTokens: settingsDialog.defaultRepeatPenaltyTokens
|
property int repeatPenaltyTokens: settingsDialog.defaultRepeatPenaltyTokens
|
||||||
property string promptTemplate: settingsDialog.defaultPromptTemplate
|
property string promptTemplate: settingsDialog.defaultPromptTemplate
|
||||||
property string modelPath: settingsDialog.defaultModelPath
|
property string modelPath: settingsDialog.defaultModelPath
|
||||||
|
property string userDefaultModel: settingsDialog.defaultUserDefaultModel
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreGenerationDefaults() {
|
function restoreGenerationDefaults() {
|
||||||
@ -86,6 +91,7 @@ Dialog {
|
|||||||
settings.modelPath = settingsDialog.defaultModelPath
|
settings.modelPath = settingsDialog.defaultModelPath
|
||||||
settings.threadCount = defaultThreadCount
|
settings.threadCount = defaultThreadCount
|
||||||
settings.saveChats = defaultSaveChats
|
settings.saveChats = defaultSaveChats
|
||||||
|
settings.userDefaultModel = defaultUserDefaultModel
|
||||||
Download.downloadLocalModelsPath = settings.modelPath
|
Download.downloadLocalModelsPath = settings.modelPath
|
||||||
LLM.threadCount = settings.threadCount
|
LLM.threadCount = settings.threadCount
|
||||||
LLM.chatListModel.shouldSaveChats = settings.saveChats
|
LLM.chatListModel.shouldSaveChats = settings.saveChats
|
||||||
@ -498,7 +504,7 @@ Dialog {
|
|||||||
Layout.row: 8
|
Layout.row: 8
|
||||||
Layout.column: 1
|
Layout.column: 1
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
padding: 15
|
padding: 10
|
||||||
contentItem: Text {
|
contentItem: Text {
|
||||||
text: qsTr("Restore Defaults")
|
text: qsTr("Restore Defaults")
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
@ -543,6 +549,104 @@ Dialog {
|
|||||||
rowSpacing: 10
|
rowSpacing: 10
|
||||||
columnSpacing: 10
|
columnSpacing: 10
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
Label {
|
||||||
|
id: defaultModelLabel
|
||||||
|
text: qsTr("Default model:")
|
||||||
|
color: theme.textColor
|
||||||
|
Layout.row: 1
|
||||||
|
Layout.column: 0
|
||||||
|
}
|
||||||
|
ComboBox {
|
||||||
|
id: comboBox
|
||||||
|
Layout.row: 1
|
||||||
|
Layout.column: 1
|
||||||
|
Layout.minimumWidth: 350
|
||||||
|
font.pixelSize: theme.fontSizeLarge
|
||||||
|
spacing: 0
|
||||||
|
padding: 10
|
||||||
|
model: modelList
|
||||||
|
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")
|
||||||
|
function updateModel(newModelList) {
|
||||||
|
var newArray = Array.from(newModelList);
|
||||||
|
newArray.unshift('Application default');
|
||||||
|
comboBox.model = newArray;
|
||||||
|
settings.sync();
|
||||||
|
comboBox.currentIndex = comboBox.indexOfValue(settingsDialog.userDefaultModel);
|
||||||
|
|
||||||
|
}
|
||||||
|
Component.onCompleted: {
|
||||||
|
comboBox.updateModel(currentChat.modelList)
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: settings
|
||||||
|
function onUserDefaultModelChanged() {
|
||||||
|
comboBox.updateModel(currentChat.modelList)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: currentChat
|
||||||
|
function onModelListChanged() {
|
||||||
|
comboBox.updateModel(currentChat.modelList)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contentItem: Text {
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
leftPadding: 10
|
||||||
|
rightPadding: 10
|
||||||
|
text: comboBox.displayText
|
||||||
|
font: comboBox.font
|
||||||
|
color: theme.textColor
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
delegate: ItemDelegate {
|
||||||
|
width: comboBox.width
|
||||||
|
contentItem: Text {
|
||||||
|
text: modelData
|
||||||
|
color: theme.textColor
|
||||||
|
font: comboBox.font
|
||||||
|
elide: Text.ElideRight
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
background: Rectangle {
|
||||||
|
color: highlighted ? theme.backgroundLight : theme.backgroundDark
|
||||||
|
}
|
||||||
|
highlighted: comboBox.highlightedIndex === index
|
||||||
|
}
|
||||||
|
popup: Popup {
|
||||||
|
y: comboBox.height - 1
|
||||||
|
width: comboBox.width
|
||||||
|
implicitHeight: contentItem.implicitHeight
|
||||||
|
padding: 0
|
||||||
|
|
||||||
|
contentItem: ListView {
|
||||||
|
clip: true
|
||||||
|
implicitHeight: contentHeight
|
||||||
|
model: comboBox.popup.visible ? comboBox.delegateModel : null
|
||||||
|
currentIndex: comboBox.highlightedIndex
|
||||||
|
ScrollIndicator.vertical: ScrollIndicator { }
|
||||||
|
}
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: theme.backgroundDark
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: theme.backgroundDark
|
||||||
|
border.width: 1
|
||||||
|
border.color: theme.backgroundLightest
|
||||||
|
radius: 10
|
||||||
|
}
|
||||||
|
|
||||||
|
onActivated: {
|
||||||
|
settingsDialog.userDefaultModel = comboBox.currentText
|
||||||
|
settings.sync()
|
||||||
|
}
|
||||||
|
}
|
||||||
FolderDialog {
|
FolderDialog {
|
||||||
id: modelPathDialog
|
id: modelPathDialog
|
||||||
title: "Please choose a directory"
|
title: "Please choose a directory"
|
||||||
@ -557,7 +661,7 @@ Dialog {
|
|||||||
id: modelPathLabel
|
id: modelPathLabel
|
||||||
text: qsTr("Download path:")
|
text: qsTr("Download path:")
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
Layout.row: 1
|
Layout.row: 2
|
||||||
Layout.column: 0
|
Layout.column: 0
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
@ -566,7 +670,8 @@ Dialog {
|
|||||||
readOnly: true
|
readOnly: true
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
implicitWidth: 300
|
implicitWidth: 300
|
||||||
Layout.row: 1
|
padding: 10
|
||||||
|
Layout.row: 2
|
||||||
Layout.column: 1
|
Layout.column: 1
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
ToolTip.text: qsTr("Path where model files will be downloaded to")
|
ToolTip.text: qsTr("Path where model files will be downloaded to")
|
||||||
@ -580,7 +685,7 @@ Dialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
Layout.row: 1
|
Layout.row: 2
|
||||||
Layout.column: 2
|
Layout.column: 2
|
||||||
text: qsTr("Browse")
|
text: qsTr("Browse")
|
||||||
contentItem: Text {
|
contentItem: Text {
|
||||||
@ -604,7 +709,7 @@ Dialog {
|
|||||||
id: nThreadsLabel
|
id: nThreadsLabel
|
||||||
text: qsTr("CPU Threads:")
|
text: qsTr("CPU Threads:")
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
Layout.row: 2
|
Layout.row: 3
|
||||||
Layout.column: 0
|
Layout.column: 0
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
@ -618,7 +723,7 @@ Dialog {
|
|||||||
padding: 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 of processing threads to use, a setting of 0 will use the lesser of 4 or your number of CPU threads")
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
Layout.row: 2
|
Layout.row: 3
|
||||||
Layout.column: 1
|
Layout.column: 1
|
||||||
validator: IntValidator {
|
validator: IntValidator {
|
||||||
bottom: 1
|
bottom: 1
|
||||||
@ -642,12 +747,12 @@ Dialog {
|
|||||||
id: saveChatsLabel
|
id: saveChatsLabel
|
||||||
text: qsTr("Save chats to disk:")
|
text: qsTr("Save chats to disk:")
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
Layout.row: 3
|
Layout.row: 4
|
||||||
Layout.column: 0
|
Layout.column: 0
|
||||||
}
|
}
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: saveChatsBox
|
id: saveChatsBox
|
||||||
Layout.row: 3
|
Layout.row: 4
|
||||||
Layout.column: 1
|
Layout.column: 1
|
||||||
checked: settingsDialog.saveChats
|
checked: settingsDialog.saveChats
|
||||||
onClicked: {
|
onClicked: {
|
||||||
@ -692,10 +797,10 @@ Dialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
Layout.row: 4
|
Layout.row: 5
|
||||||
Layout.column: 1
|
Layout.column: 1
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
padding: 15
|
padding: 10
|
||||||
contentItem: Text {
|
contentItem: Text {
|
||||||
text: qsTr("Restore Defaults")
|
text: qsTr("Restore Defaults")
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
Loading…
Reference in New Issue
Block a user