@@ -20,7 +20,7 @@ func New(opts ...config.AppOption) (*Application, error) {
2020 options := config .NewApplicationConfig (opts ... )
2121 application := newApplication (options )
2222
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 )
2424 log .Info ().Msgf ("LocalAI version: %s" , internal .PrintableVersion ())
2525 caps , err := xsysinfo .CPUCapabilities ()
2626 if err == nil {
@@ -35,10 +35,11 @@ func New(opts ...config.AppOption) (*Application, error) {
3535 }
3636
3737 // 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" )
4040 }
41- err = os .MkdirAll (options .ModelPath , 0750 )
41+
42+ err = os .MkdirAll (options .SystemState .Model .ModelsPath , 0750 )
4243 if err != nil {
4344 return nil , fmt .Errorf ("unable to create ModelPath: %q" , err )
4445 }
@@ -55,50 +56,50 @@ func New(opts ...config.AppOption) (*Application, error) {
5556 }
5657 }
5758
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 {
5960 log .Error ().Err (err ).Msg ("error installing models" )
6061 }
6162
6263 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 {
6465 log .Error ().Err (err ).Msg ("error installing external backend" )
6566 }
6667 }
6768
6869 configLoaderOpts := options .ToConfigLoaderOptions ()
6970
70- if err := application .BackendLoader ().LoadBackendConfigsFromPath (options .ModelPath , configLoaderOpts ... ); err != nil {
71+ if err := application .BackendLoader ().LoadModelConfigsFromPath (options .SystemState . Model . ModelsPath , configLoaderOpts ... ); err != nil {
7172 log .Error ().Err (err ).Msg ("error loading config files" )
7273 }
7374
74- if err := gallery .RegisterBackends (options .BackendsPath , application .ModelLoader ()); err != nil {
75+ if err := gallery .RegisterBackends (options .SystemState , application .ModelLoader ()); err != nil {
7576 log .Error ().Err (err ).Msg ("error registering external backends" )
7677 }
7778
7879 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 {
8081 log .Error ().Err (err ).Msg ("error loading config file" )
8182 }
8283 }
8384
84- if err := application .BackendLoader ().Preload (options .ModelPath ); err != nil {
85+ if err := application .BackendLoader ().Preload (options .SystemState . Model . ModelsPath ); err != nil {
8586 log .Error ().Err (err ).Msg ("error downloading models" )
8687 }
8788
8889 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 {
9091 return nil , err
9192 }
9293 }
9394
9495 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 {
9697 return nil , err
9798 }
9899 }
99100
100101 if options .Debug {
101- for _ , v := range application .BackendLoader ().GetAllBackendConfigs () {
102+ for _ , v := range application .BackendLoader ().GetAllModelsConfigs () {
102103 log .Debug ().Msgf ("Model: %s (config: %+v)" , v .Name , v )
103104 }
104105 }
@@ -131,7 +132,7 @@ func New(opts ...config.AppOption) (*Application, error) {
131132
132133 if options .LoadToMemory != nil && ! options .SingleBackend {
133134 for _ , m := range options .LoadToMemory {
134- cfg , err := application .BackendLoader ().LoadBackendConfigFileByNameDefaultOptions (m , options )
135+ cfg , err := application .BackendLoader ().LoadModelConfigFileByNameDefaultOptions (m , options )
135136 if err != nil {
136137 return nil , err
137138 }
0 commit comments