Fix crash with chatgpt and gpu layers.

Signed-off-by: Adam Treat <treat.adam@gmail.com>
This commit is contained in:
Adam Treat 2024-02-22 12:51:44 -05:00 committed by AT
parent e7f2ff189f
commit ef518fae3e
2 changed files with 17 additions and 16 deletions

View File

@ -135,6 +135,7 @@ void ModelInfo::setGpuLayers(int l)
int ModelInfo::maxGpuLayers() const int ModelInfo::maxGpuLayers() const
{ {
if (isOnline) return -1;
if (m_maxGpuLayers != -1) return m_maxGpuLayers; if (m_maxGpuLayers != -1) return m_maxGpuLayers;
auto path = (dirpath + filename()).toStdString(); auto path = (dirpath + filename()).toStdString();
int layers = LLModel::Implementation::layerCount(path); int layers = LLModel::Implementation::layerCount(path);

View File

@ -154,7 +154,7 @@ MySettingsTab {
} }
MySettingsLabel { MySettingsLabel {
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: qsTr("System Prompt") text: qsTr("System Prompt")
Layout.row: 6 Layout.row: 6
Layout.column: 0 Layout.column: 0
@ -163,7 +163,7 @@ MySettingsTab {
Rectangle { Rectangle {
id: systemPrompt id: systemPrompt
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
Layout.row: 7 Layout.row: 7
Layout.column: 0 Layout.column: 0
Layout.columnSpan: 2 Layout.columnSpan: 2
@ -317,14 +317,14 @@ MySettingsTab {
MySettingsLabel { MySettingsLabel {
id: contextLengthLabel id: contextLengthLabel
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: qsTr("Context Length") text: qsTr("Context Length")
Layout.row: 0 Layout.row: 0
Layout.column: 0 Layout.column: 0
} }
MyTextField { MyTextField {
id: contextLengthField id: contextLengthField
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: root.currentModelInfo.contextLength text: root.currentModelInfo.contextLength
font.pixelSize: theme.fontSizeLarge font.pixelSize: theme.fontSizeLarge
color: theme.textColor color: theme.textColor
@ -454,14 +454,14 @@ MySettingsTab {
} }
MySettingsLabel { MySettingsLabel {
id: topKLabel id: topKLabel
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: qsTr("Top K") text: qsTr("Top K")
Layout.row: 2 Layout.row: 2
Layout.column: 2 Layout.column: 2
} }
MyTextField { MyTextField {
id: topKField id: topKField
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: root.currentModelInfo.topK text: root.currentModelInfo.topK
color: theme.textColor color: theme.textColor
font.pixelSize: theme.fontSizeLarge font.pixelSize: theme.fontSizeLarge
@ -499,14 +499,14 @@ MySettingsTab {
} }
MySettingsLabel { MySettingsLabel {
id: maxLengthLabel id: maxLengthLabel
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: qsTr("Max Length") text: qsTr("Max Length")
Layout.row: 0 Layout.row: 0
Layout.column: 2 Layout.column: 2
} }
MyTextField { MyTextField {
id: maxLengthField id: maxLengthField
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: root.currentModelInfo.maxLength text: root.currentModelInfo.maxLength
color: theme.textColor color: theme.textColor
font.pixelSize: theme.fontSizeLarge font.pixelSize: theme.fontSizeLarge
@ -545,14 +545,14 @@ MySettingsTab {
MySettingsLabel { MySettingsLabel {
id: batchSizeLabel id: batchSizeLabel
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: qsTr("Prompt Batch Size") text: qsTr("Prompt Batch Size")
Layout.row: 1 Layout.row: 1
Layout.column: 0 Layout.column: 0
} }
MyTextField { MyTextField {
id: batchSizeField id: batchSizeField
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: root.currentModelInfo.promptBatchSize text: root.currentModelInfo.promptBatchSize
color: theme.textColor color: theme.textColor
font.pixelSize: theme.fontSizeLarge font.pixelSize: theme.fontSizeLarge
@ -590,14 +590,14 @@ MySettingsTab {
} }
MySettingsLabel { MySettingsLabel {
id: repeatPenaltyLabel id: repeatPenaltyLabel
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: qsTr("Repeat Penalty") text: qsTr("Repeat Penalty")
Layout.row: 3 Layout.row: 3
Layout.column: 0 Layout.column: 0
} }
MyTextField { MyTextField {
id: repeatPenaltyField id: repeatPenaltyField
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: root.currentModelInfo.repeatPenalty text: root.currentModelInfo.repeatPenalty
color: theme.textColor color: theme.textColor
font.pixelSize: theme.fontSizeLarge font.pixelSize: theme.fontSizeLarge
@ -635,14 +635,14 @@ MySettingsTab {
} }
MySettingsLabel { MySettingsLabel {
id: repeatPenaltyTokensLabel id: repeatPenaltyTokensLabel
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: qsTr("Repeat Penalty Tokens") text: qsTr("Repeat Penalty Tokens")
Layout.row: 3 Layout.row: 3
Layout.column: 2 Layout.column: 2
} }
MyTextField { MyTextField {
id: repeatPenaltyTokenField id: repeatPenaltyTokenField
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: root.currentModelInfo.repeatPenaltyTokens text: root.currentModelInfo.repeatPenaltyTokens
color: theme.textColor color: theme.textColor
font.pixelSize: theme.fontSizeLarge font.pixelSize: theme.fontSizeLarge
@ -681,14 +681,14 @@ MySettingsTab {
MySettingsLabel { MySettingsLabel {
id: gpuLayersLabel id: gpuLayersLabel
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: qsTr("GPU Layers") text: qsTr("GPU Layers")
Layout.row: 4 Layout.row: 4
Layout.column: 0 Layout.column: 0
} }
MyTextField { MyTextField {
id: gpuLayersField id: gpuLayersField
visible: !root.currentModelInfo.isChatGPT visible: !root.currentModelInfo.isOnline
text: root.currentModelInfo.gpuLayers text: root.currentModelInfo.gpuLayers
font.pixelSize: theme.fontSizeLarge font.pixelSize: theme.fontSizeLarge
color: theme.textColor color: theme.textColor