MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / load_models

Method load_models

tools/server/server-models.cpp:245–378  ·  view source on GitHub ↗

TODO: allow refreshing cached model list

Source from the content-addressed store, hash-verified

243
244// TODO: allow refreshing cached model list
245void server_models::load_models() {
246 // loading models from 3 sources:
247 // 1. cached models
248 common_presets cached_models = ctx_preset.load_from_cache();
249 SRV_INF("Loaded %zu cached model presets\n", cached_models.size());
250 // 2. local models from --models-dir
251 common_presets local_models;
252 if (!base_params.models_dir.empty()) {
253 local_models = ctx_preset.load_from_models_dir(base_params.models_dir);
254 SRV_INF("Loaded %zu local model presets from %s\n", local_models.size(), base_params.models_dir.c_str());
255 }
256 // 3. custom-path models from presets
257 common_preset global = {};
258 common_presets custom_presets = {};
259 if (!base_params.models_preset.empty()) {
260 custom_presets = ctx_preset.load_from_ini(base_params.models_preset, global);
261 SRV_INF("Loaded %zu custom model presets from %s\n", custom_presets.size(), base_params.models_preset.c_str());
262 }
263
264 // cascade, apply global preset first
265 cached_models = ctx_preset.cascade(global, cached_models);
266 local_models = ctx_preset.cascade(global, local_models);
267 custom_presets = ctx_preset.cascade(global, custom_presets);
268
269 // note: if a model exists in both cached and local, local takes precedence
270 common_presets final_presets;
271 for (const auto & [name, preset] : cached_models) {
272 final_presets[name] = preset;
273 }
274 for (const auto & [name, preset] : local_models) {
275 final_presets[name] = preset;
276 }
277
278 // process custom presets from INI
279 for (const auto & [name, custom] : custom_presets) {
280 if (final_presets.find(name) != final_presets.end()) {
281 // apply custom config if exists
282 common_preset & target = final_presets[name];
283 target.merge(custom);
284 } else {
285 // otherwise add directly
286 final_presets[name] = custom;
287 }
288 }
289
290 // server base preset from CLI args take highest precedence
291 for (auto & [name, preset] : final_presets) {
292 preset.merge(base_preset);
293 }
294
295 // convert presets to server_model_meta and add to mapping
296 for (const auto & preset : final_presets) {
297 server_model_meta meta{
298 /* preset */ preset.second,
299 /* name */ preset.first,
300 /* aliases */ {},
301 /* tags */ {},
302 /* port */ 0,

Callers

nothing calls this directly

Calls 14

load_from_cacheMethod · 0.80
load_from_models_dirMethod · 0.80
load_from_iniMethod · 0.80
cascadeMethod · 0.80
findMethod · 0.80
endMethod · 0.80
mergeMethod · 0.80
get_optionMethod · 0.80
string_formatFunction · 0.50
loadFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected