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)
| 316 | // the target must exist, must not be an alias, and must not be disabled. |
| 317 | // Returns nil for non-alias configs. |
| 318 | func (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 |
| 336 | func (bcl *ModelConfigLoader) Preload(modelPath string) error { |
no test coverage detected