Skip to content

Commit ac6f8ca

Browse files
committed
skip loading custom_models if not specified
1 parent 7cbb2d2 commit ac6f8ca

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

tools/server/server-models.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,16 @@ void server_models::load_models() {
163163
}
164164
// 3. custom-path models from presets
165165
common_preset global = {};
166-
common_presets custom_models = ctx_preset.load_from_ini(base_params.models_preset, global);
167-
SRV_INF("Loaded %zu custom model presets from %s\n", custom_models.size(), base_params.models_preset.c_str());
166+
common_presets custom_presets = {};
167+
if (!base_params.models_preset.empty()) {
168+
custom_presets = ctx_preset.load_from_ini(base_params.models_preset, global);
169+
SRV_INF("Loaded %zu custom model presets from %s\n", custom_presets.size(), base_params.models_preset.c_str());
170+
}
168171

169172
// cascade, apply global preset first
170-
cached_models = ctx_preset.cascade(global, cached_models);
171-
local_models = ctx_preset.cascade(global, local_models);
172-
custom_models = ctx_preset.cascade(global, custom_models);
173+
cached_models = ctx_preset.cascade(global, cached_models);
174+
local_models = ctx_preset.cascade(global, local_models);
175+
custom_presets = ctx_preset.cascade(global, custom_presets);
173176

174177
// note: if a model exists in both cached and local, local takes precedence
175178
common_presets final_presets;
@@ -181,7 +184,7 @@ void server_models::load_models() {
181184
}
182185

183186
// process custom presets from INI
184-
for (const auto & [name, custom] : custom_models) {
187+
for (const auto & [name, custom] : custom_presets) {
185188
if (final_presets.find(name) != final_presets.end()) {
186189
// apply custom config if exists
187190
common_preset & target = final_presets[name];
@@ -212,14 +215,16 @@ void server_models::load_models() {
212215
}
213216

214217
// log available models
215-
std::unordered_set<std::string> custom_names;
216-
for (const auto & [name, preset] : custom_models) {
217-
custom_names.insert(name);
218-
}
219-
SRV_INF("Available models (%zu) (*: custom preset)\n", mapping.size());
220-
for (const auto & [name, inst] : mapping) {
221-
bool has_custom = custom_names.find(name) != custom_names.end();
222-
SRV_INF(" %c %s\n", has_custom ? '*' : ' ', name.c_str());
218+
{
219+
std::unordered_set<std::string> custom_names;
220+
for (const auto & [name, preset] : custom_presets) {
221+
custom_names.insert(name);
222+
}
223+
SRV_INF("Available models (%zu) (*: custom preset)\n", mapping.size());
224+
for (const auto & [name, inst] : mapping) {
225+
bool has_custom = custom_names.find(name) != custom_names.end();
226+
SRV_INF(" %c %s\n", has_custom ? '*' : ' ', name.c_str());
227+
}
223228
}
224229
}
225230

0 commit comments

Comments
 (0)