MCPcopy
hub / github.com/mudler/LocalAI / ResolveAlias

Method ResolveAlias

core/config/model_config_loader.go:301–313  ·  view source on GitHub ↗

ResolveAlias follows a one-hop alias to its target config. Returns (resolved, wasAlias, err). Non-alias configs return (cfg, false, nil) unchanged. Strict: the target must exist and must not itself be an alias (chains are rejected). The returned config is a copy of the target.

(cfg *ModelConfig)

Source from the content-addressed store, hash-verified

299// unchanged. Strict: the target must exist and must not itself be an alias
300// (chains are rejected). The returned config is a copy of the target.
301func (bcl *ModelConfigLoader) ResolveAlias(cfg *ModelConfig) (*ModelConfig, bool, error) {
302 if cfg == nil || !cfg.IsAlias() {
303 return cfg, false, nil
304 }
305 target, exists := bcl.GetModelConfig(cfg.Alias)
306 if !exists {
307 return nil, true, fmt.Errorf("alias %q points to unknown model %q", cfg.Name, cfg.Alias)
308 }
309 if target.IsAlias() {
310 return nil, true, fmt.Errorf("alias %q points to another alias %q (chains are not allowed)", cfg.Name, cfg.Alias)
311 }
312 return &target, true, nil
313}
314
315// ValidateAliasTarget checks an alias config's target at create/swap time:
316// the target must exist, must not be an alias, and must not be disabled.

Callers 3

SetModelAndConfigMethod · 0.80
loadPipelineSubModelFunction · 0.80

Implementers 6

stubClientcore/http/endpoints/mcp/localai_assist
mockConfigLoadercore/services/jobs/dispatcher_test.go
ModelConfigLoadercore/config/model_config_loader.go
fakeClientpkg/mcp/localaitools/fakes_test.go
Clientpkg/mcp/localaitools/httpapi/client.go
Clientpkg/mcp/localaitools/inproc/client.go

Calls 2

GetModelConfigMethod · 0.95
IsAliasMethod · 0.80

Tested by

no test coverage detected