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

Method ValidateAliasTarget

core/config/model_config_loader.go:318–333  ·  view source on GitHub ↗

ValidateAliasTarget checks an alias config's target at create/swap time: the target must exist, must not be an alias, and must not be disabled. Returns nil for non-alias configs.

(cfg *ModelConfig)

Source from the content-addressed store, hash-verified

316// the target must exist, must not be an alias, and must not be disabled.
317// Returns nil for non-alias configs.
318func (bcl *ModelConfigLoader) ValidateAliasTarget(cfg *ModelConfig) error {
319 if cfg == nil || !cfg.IsAlias() {
320 return nil
321 }
322 target, exists := bcl.GetModelConfig(cfg.Alias)
323 if !exists {
324 return fmt.Errorf("alias target %q does not exist", cfg.Alias)
325 }
326 if target.IsAlias() {
327 return fmt.Errorf("alias target %q is itself an alias (chains are not allowed)", cfg.Alias)
328 }
329 if target.IsDisabled() {
330 return fmt.Errorf("alias target %q is disabled", cfg.Alias)
331 }
332 return nil
333}
334
335// Preload prepare models if they are not local but url or huggingface repositories
336func (bcl *ModelConfigLoader) Preload(modelPath string) error {

Callers 5

ImportModelEndpointFunction · 0.80
PatchConfigMethod · 0.80
EditYAMLMethod · 0.80
createAliasMethod · 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 3

GetModelConfigMethod · 0.95
IsAliasMethod · 0.80
IsDisabledMethod · 0.80

Tested by

no test coverage detected