(file string, opts ...ConfigLoaderOption)
| 175 | } |
| 176 | |
| 177 | func (bcl *ModelConfigLoader) ReadModelConfig(file string, opts ...ConfigLoaderOption) error { |
| 178 | bcl.Lock() |
| 179 | defer bcl.Unlock() |
| 180 | configs, err := readModelConfigsFromFile(file, opts...) |
| 181 | if err != nil { |
| 182 | return fmt.Errorf("ReadModelConfig cannot read config file %q: %w", file, err) |
| 183 | } |
| 184 | if len(configs) == 0 { |
| 185 | return fmt.Errorf("ReadModelConfig: no configs found in file %q", file) |
| 186 | } |
| 187 | if len(configs) > 1 { |
| 188 | xlog.Warn("ReadModelConig: read more than one config from file, only using first", "file", file, "configs", len(configs)) |
| 189 | } |
| 190 | |
| 191 | c := configs[0] |
| 192 | if valid, err := c.Validate(); valid { |
| 193 | bcl.configs[c.Name] = *c |
| 194 | } else { |
| 195 | if err != nil { |
| 196 | return fmt.Errorf("model config %q is not valid: %w. Ensure the YAML file has a valid 'name' field and correct syntax. See https://localai.io/docs/getting-started/customize-model/ for config reference", file, err) |
| 197 | } |
| 198 | return fmt.Errorf("model config %q is not valid. Ensure the YAML file has a valid 'name' field and correct syntax. See https://localai.io/docs/getting-started/customize-model/ for config reference", file) |
| 199 | } |
| 200 | |
| 201 | return nil |
| 202 | } |
| 203 | |
| 204 | func (bcl *ModelConfigLoader) GetModelConfig(m string) (ModelConfig, bool) { |
| 205 | bcl.Lock() |
no test coverage detected