Skip to content

Commit 9d7d084

Browse files
authored
fix: Wrong template replace to first template (#143)
1 parent 1ca1ffc commit 9d7d084

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

ConfigurationManager.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void ConfigurationManager::init()
3636
{
3737
setupConnections();
3838
updateAllTemplateDescriptions();
39+
checkAllTemplate();
3940
}
4041

4142
void ConfigurationManager::updateTemplateDescription(const Utils::StringAspect &templateAspect)
@@ -59,6 +60,26 @@ void ConfigurationManager::updateAllTemplateDescriptions()
5960
updateTemplateDescription(m_generalSettings.caTemplate);
6061
}
6162

63+
void ConfigurationManager::checkTemplate(const Utils::StringAspect &templateAspect)
64+
{
65+
LLMCore::PromptTemplate *templ = m_templateManger.getFimTemplateByName(templateAspect.value());
66+
67+
if (templ->name() == templateAspect.value())
68+
return;
69+
70+
if (&templateAspect == &m_generalSettings.ccTemplate) {
71+
m_generalSettings.ccTemplate.setValue(templ->name());
72+
} else if (&templateAspect == &m_generalSettings.caTemplate) {
73+
m_generalSettings.caTemplate.setValue(templ->name());
74+
}
75+
}
76+
77+
void ConfigurationManager::checkAllTemplate()
78+
{
79+
checkTemplate(m_generalSettings.ccTemplate);
80+
checkTemplate(m_generalSettings.caTemplate);
81+
}
82+
6283
ConfigurationManager::ConfigurationManager(QObject *parent)
6384
: QObject(parent)
6485
, m_generalSettings(Settings::generalSettings())

ConfigurationManager.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class ConfigurationManager : public QObject
3838

3939
void updateTemplateDescription(const Utils::StringAspect &templateAspect);
4040
void updateAllTemplateDescriptions();
41+
void checkTemplate(const Utils::StringAspect &templateAspect);
42+
void checkAllTemplate();
4143

4244
public slots:
4345
void selectProvider();

settings/GeneralSettings.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ GeneralSettings::GeneralSettings()
9494
ccModel.setHistoryCompleter(Constants::CC_MODEL_HISTORY);
9595
ccSelectModel.m_buttonText = TrConstants::SELECT;
9696

97-
initStringAspect(ccTemplate, Constants::CC_TEMPLATE, TrConstants::TEMPLATE, "Ollama Auto FIM");
97+
initStringAspect(ccTemplate, Constants::CC_TEMPLATE, TrConstants::TEMPLATE, "Ollama FIM");
9898
ccTemplate.setReadOnly(true);
9999
ccSelectTemplate.m_buttonText = TrConstants::SELECT;
100100

@@ -140,7 +140,7 @@ GeneralSettings::GeneralSettings()
140140
ccPreset1SelectModel.m_buttonText = TrConstants::SELECT;
141141

142142
initStringAspect(
143-
ccPreset1Template, Constants::CC_PRESET1_TEMPLATE, TrConstants::TEMPLATE, "Ollama Auto FIM");
143+
ccPreset1Template, Constants::CC_PRESET1_TEMPLATE, TrConstants::TEMPLATE, "Ollama FIM");
144144
ccPreset1Template.setReadOnly(true);
145145
ccPreset1SelectTemplate.m_buttonText = TrConstants::SELECT;
146146

@@ -153,7 +153,7 @@ GeneralSettings::GeneralSettings()
153153
caModel.setHistoryCompleter(Constants::CA_MODEL_HISTORY);
154154
caSelectModel.m_buttonText = TrConstants::SELECT;
155155

156-
initStringAspect(caTemplate, Constants::CA_TEMPLATE, TrConstants::TEMPLATE, "Ollama Auto Chat");
156+
initStringAspect(caTemplate, Constants::CA_TEMPLATE, TrConstants::TEMPLATE, "Ollama Chat");
157157
caTemplate.setReadOnly(true);
158158

159159
caSelectTemplate.m_buttonText = TrConstants::SELECT;

0 commit comments

Comments
 (0)