mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-06-25 15:02:03 +00:00
modellist: fix cloning of chat template and system message (#3262)
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
parent
f67b370f5a
commit
b7df4ebbcb
@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|||||||
- Fix API server ignoring assistant messages in history after v3.5.0 ([#3256](https://github.com/nomic-ai/gpt4all/pull/3256))
|
- Fix API server ignoring assistant messages in history after v3.5.0 ([#3256](https://github.com/nomic-ai/gpt4all/pull/3256))
|
||||||
- Fix API server replying with incorrect token counts and stop reason after v3.5.0 ([#3256](https://github.com/nomic-ai/gpt4all/pull/3256))
|
- Fix API server replying with incorrect token counts and stop reason after v3.5.0 ([#3256](https://github.com/nomic-ai/gpt4all/pull/3256))
|
||||||
- Fix API server remembering previous, unrelated conversations after v3.5.0 ([#3256](https://github.com/nomic-ai/gpt4all/pull/3256))
|
- Fix API server remembering previous, unrelated conversations after v3.5.0 ([#3256](https://github.com/nomic-ai/gpt4all/pull/3256))
|
||||||
|
- Fix mishandling of default chat template and system message of cloned models in v3.5.0 ([#3262](https://github.com/nomic-ai/gpt4all/pull/3262))
|
||||||
|
|
||||||
## [3.5.1] - 2024-12-10
|
## [3.5.1] - 2024-12-10
|
||||||
|
|
||||||
|
@ -1141,18 +1141,20 @@ bool ModelList::isUniqueName(const QString &name) const
|
|||||||
|
|
||||||
QString ModelList::clone(const ModelInfo &model)
|
QString ModelList::clone(const ModelInfo &model)
|
||||||
{
|
{
|
||||||
|
auto *mySettings = MySettings::globalInstance();
|
||||||
|
|
||||||
const QString id = Network::globalInstance()->generateUniqueId();
|
const QString id = Network::globalInstance()->generateUniqueId();
|
||||||
addModel(id);
|
addModel(id);
|
||||||
|
|
||||||
QString chatTemplate, systemMessage;
|
QString tmplSetting, sysmsgSetting;
|
||||||
if (auto tmpl = model.chatTemplate().asModern()) {
|
if (auto tmpl = model.chatTemplate().asModern()) {
|
||||||
chatTemplate = *tmpl;
|
tmplSetting = *tmpl;
|
||||||
} else {
|
} else {
|
||||||
qWarning("ModelList Warning: attempted to clone model with legacy chat template");
|
qWarning("ModelList Warning: attempted to clone model with legacy chat template");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (auto msg = model.systemMessage().asModern()) {
|
if (auto msg = model.systemMessage().asModern()) {
|
||||||
systemMessage = *msg;
|
sysmsgSetting = *msg;
|
||||||
} else {
|
} else {
|
||||||
qWarning("ModelList Warning: attempted to clone model with legacy system message");
|
qWarning("ModelList Warning: attempted to clone model with legacy system message");
|
||||||
return {};
|
return {};
|
||||||
@ -1177,12 +1179,22 @@ QString ModelList::clone(const ModelInfo &model)
|
|||||||
{ ModelList::GpuLayersRole, model.gpuLayers() },
|
{ ModelList::GpuLayersRole, model.gpuLayers() },
|
||||||
{ ModelList::RepeatPenaltyRole, model.repeatPenalty() },
|
{ ModelList::RepeatPenaltyRole, model.repeatPenalty() },
|
||||||
{ ModelList::RepeatPenaltyTokensRole, model.repeatPenaltyTokens() },
|
{ ModelList::RepeatPenaltyTokensRole, model.repeatPenaltyTokens() },
|
||||||
{ ModelList::ChatTemplateRole, chatTemplate },
|
{ ModelList::SystemMessageRole, model.m_systemMessage },
|
||||||
{ ModelList::SystemMessageRole, systemMessage },
|
|
||||||
{ ModelList::ChatNamePromptRole, model.chatNamePrompt() },
|
{ ModelList::ChatNamePromptRole, model.chatNamePrompt() },
|
||||||
{ ModelList::SuggestedFollowUpPromptRole, model.suggestedFollowUpPrompt() },
|
{ ModelList::SuggestedFollowUpPromptRole, model.suggestedFollowUpPrompt() },
|
||||||
};
|
};
|
||||||
|
if (auto tmpl = model.m_chatTemplate)
|
||||||
|
data.emplace_back(ModelList::ChatTemplateRole, *tmpl); // copy default chat template, if known
|
||||||
updateData(id, data);
|
updateData(id, data);
|
||||||
|
|
||||||
|
// Ensure setting overrides are copied in case the base model overrides change.
|
||||||
|
// This is necessary because setting these roles on ModelInfo above does not write to settings.
|
||||||
|
auto cloneInfo = modelInfo(id);
|
||||||
|
if (mySettings->isModelChatTemplateSet (model))
|
||||||
|
mySettings->setModelChatTemplate (cloneInfo, tmplSetting );
|
||||||
|
if (mySettings->isModelSystemMessageSet(model))
|
||||||
|
mySettings->setModelSystemMessage(cloneInfo, sysmsgSetting);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user