@@ -20,7 +20,7 @@ func New(opts ...config.AppOption) (*Application, error) {
20
20
options := config .NewApplicationConfig (opts ... )
21
21
application := newApplication (options )
22
22
23
- log .Info ().Msgf ("Starting LocalAI using %d threads, with models path: %s" , options .Threads , options .ModelPath )
23
+ log .Info ().Msgf ("Starting LocalAI using %d threads, with models path: %s" , options .Threads , options .SystemState . Model . ModelsPath )
24
24
log .Info ().Msgf ("LocalAI version: %s" , internal .PrintableVersion ())
25
25
caps , err := xsysinfo .CPUCapabilities ()
26
26
if err == nil {
@@ -35,10 +35,11 @@ func New(opts ...config.AppOption) (*Application, error) {
35
35
}
36
36
37
37
// Make sure directories exists
38
- if options .ModelPath == "" {
39
- return nil , fmt .Errorf ("options.ModelPath cannot be empty" )
38
+ if options .SystemState . Model . ModelsPath == "" {
39
+ return nil , fmt .Errorf ("models path cannot be empty" )
40
40
}
41
- err = os .MkdirAll (options .ModelPath , 0750 )
41
+
42
+ err = os .MkdirAll (options .SystemState .Model .ModelsPath , 0750 )
42
43
if err != nil {
43
44
return nil , fmt .Errorf ("unable to create ModelPath: %q" , err )
44
45
}
@@ -55,50 +56,50 @@ func New(opts ...config.AppOption) (*Application, error) {
55
56
}
56
57
}
57
58
58
- if err := coreStartup .InstallModels (options .Galleries , options .BackendGalleries , options .ModelPath , options . BackendsPath , options .EnforcePredownloadScans , options .AutoloadBackendGalleries , nil , options .ModelsURL ... ); err != nil {
59
+ if err := coreStartup .InstallModels (options .Galleries , options .BackendGalleries , options .SystemState , options .EnforcePredownloadScans , options .AutoloadBackendGalleries , nil , options .ModelsURL ... ); err != nil {
59
60
log .Error ().Err (err ).Msg ("error installing models" )
60
61
}
61
62
62
63
for _ , backend := range options .ExternalBackends {
63
- if err := coreStartup .InstallExternalBackends (options .BackendGalleries , options .BackendsPath , nil , backend , "" , "" ); err != nil {
64
+ if err := coreStartup .InstallExternalBackends (options .BackendGalleries , options .SystemState , nil , backend , "" , "" ); err != nil {
64
65
log .Error ().Err (err ).Msg ("error installing external backend" )
65
66
}
66
67
}
67
68
68
69
configLoaderOpts := options .ToConfigLoaderOptions ()
69
70
70
- if err := application .BackendLoader ().LoadBackendConfigsFromPath (options .ModelPath , configLoaderOpts ... ); err != nil {
71
+ if err := application .BackendLoader ().LoadModelConfigsFromPath (options .SystemState . Model . ModelsPath , configLoaderOpts ... ); err != nil {
71
72
log .Error ().Err (err ).Msg ("error loading config files" )
72
73
}
73
74
74
- if err := gallery .RegisterBackends (options .BackendsPath , application .ModelLoader ()); err != nil {
75
+ if err := gallery .RegisterBackends (options .SystemState , application .ModelLoader ()); err != nil {
75
76
log .Error ().Err (err ).Msg ("error registering external backends" )
76
77
}
77
78
78
79
if options .ConfigFile != "" {
79
- if err := application .BackendLoader ().LoadMultipleBackendConfigsSingleFile (options .ConfigFile , configLoaderOpts ... ); err != nil {
80
+ if err := application .BackendLoader ().LoadMultipleModelConfigsSingleFile (options .ConfigFile , configLoaderOpts ... ); err != nil {
80
81
log .Error ().Err (err ).Msg ("error loading config file" )
81
82
}
82
83
}
83
84
84
- if err := application .BackendLoader ().Preload (options .ModelPath ); err != nil {
85
+ if err := application .BackendLoader ().Preload (options .SystemState . Model . ModelsPath ); err != nil {
85
86
log .Error ().Err (err ).Msg ("error downloading models" )
86
87
}
87
88
88
89
if options .PreloadJSONModels != "" {
89
- if err := services .ApplyGalleryFromString (options .ModelPath , options . BackendsPath , options .EnforcePredownloadScans , options .AutoloadBackendGalleries , options .Galleries , options .BackendGalleries , options .PreloadJSONModels ); err != nil {
90
+ if err := services .ApplyGalleryFromString (options .SystemState , options .EnforcePredownloadScans , options .AutoloadBackendGalleries , options .Galleries , options .BackendGalleries , options .PreloadJSONModels ); err != nil {
90
91
return nil , err
91
92
}
92
93
}
93
94
94
95
if options .PreloadModelsFromPath != "" {
95
- if err := services .ApplyGalleryFromFile (options .ModelPath , options . BackendsPath , options .EnforcePredownloadScans , options .AutoloadBackendGalleries , options .Galleries , options .BackendGalleries , options .PreloadModelsFromPath ); err != nil {
96
+ if err := services .ApplyGalleryFromFile (options .SystemState , options .EnforcePredownloadScans , options .AutoloadBackendGalleries , options .Galleries , options .BackendGalleries , options .PreloadModelsFromPath ); err != nil {
96
97
return nil , err
97
98
}
98
99
}
99
100
100
101
if options .Debug {
101
- for _ , v := range application .BackendLoader ().GetAllBackendConfigs () {
102
+ for _ , v := range application .BackendLoader ().GetAllModelsConfigs () {
102
103
log .Debug ().Msgf ("Model: %s (config: %+v)" , v .Name , v )
103
104
}
104
105
}
@@ -131,7 +132,7 @@ func New(opts ...config.AppOption) (*Application, error) {
131
132
132
133
if options .LoadToMemory != nil && ! options .SingleBackend {
133
134
for _ , m := range options .LoadToMemory {
134
- cfg , err := application .BackendLoader ().LoadBackendConfigFileByNameDefaultOptions (m , options )
135
+ cfg , err := application .BackendLoader ().LoadModelConfigFileByNameDefaultOptions (m , options )
135
136
if err != nil {
136
137
return nil , err
137
138
}
0 commit comments