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

Method ReadModelConfig

core/config/model_config_loader.go:177–202  ·  view source on GitHub ↗
(file string, opts ...ConfigLoaderOption)

Source from the content-addressed store, hash-verified

175}
176
177func (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
204func (bcl *ModelConfigLoader) GetModelConfig(m string) (ModelConfig, bool) {
205 bcl.Lock()

Callers 6

RunMethod · 0.95
request_test.goFile · 0.80
models_test.goFile · 0.80
pii_test.goFile · 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 4

readModelConfigsFromFileFunction · 0.85
LockMethod · 0.65
UnlockMethod · 0.65
ValidateMethod · 0.45

Tested by

no test coverage detected