77 "path/filepath"
88
99 "github.com/mudler/LocalAI/core/config"
10+ "github.com/mudler/LocalAI/core/services"
1011 . "github.com/mudler/LocalAI/core/startup"
1112 "github.com/mudler/LocalAI/pkg/model"
1213 "github.com/mudler/LocalAI/pkg/system"
@@ -19,8 +20,11 @@ var _ = Describe("Preload test", func() {
1920 var tmpdir string
2021 var systemState * system.SystemState
2122 var ml * model.ModelLoader
23+ var ctx context.Context
24+ var cancel context.CancelFunc
2225
2326 BeforeEach (func () {
27+ ctx , cancel = context .WithCancel (context .Background ())
2428 var err error
2529 tmpdir , err = os .MkdirTemp ("" , "" )
2630 Expect (err ).ToNot (HaveOccurred ())
@@ -29,13 +33,22 @@ var _ = Describe("Preload test", func() {
2933 ml = model .NewModelLoader (systemState , true )
3034 })
3135
36+ AfterEach (func () {
37+ cancel ()
38+ })
39+
3240 Context ("Preloading from strings" , func () {
3341 It ("loads from embedded full-urls" , func () {
3442 url := "https://raw.githubusercontent.com/mudler/LocalAI-examples/main/configurations/phi-2.yaml"
3543 fileName := fmt .Sprintf ("%s.yaml" , "phi-2" )
3644
37- InstallModels (context .TODO (), nil , []config.Gallery {}, []config.Gallery {}, systemState , ml , true , true , nil , url )
45+ galleryService := services .NewGalleryService (& config.ApplicationConfig {}, ml )
46+ galleryService .Start (ctx , config .NewModelConfigLoader (tmpdir ), systemState )
3847
48+ err := InstallModels (ctx , galleryService , []config.Gallery {}, []config.Gallery {}, systemState , ml , true , true , func (s1 , s2 , s3 string , f float64 ) {
49+ fmt .Println (s1 , s2 , s3 , f )
50+ }, url )
51+ Expect (err ).ToNot (HaveOccurred ())
3952 resultFile := filepath .Join (tmpdir , fileName )
4053
4154 content , err := os .ReadFile (resultFile )
@@ -47,7 +60,11 @@ var _ = Describe("Preload test", func() {
4760 url := "huggingface://TheBloke/TinyLlama-1.1B-Chat-v0.3-GGUF/tinyllama-1.1b-chat-v0.3.Q2_K.gguf"
4861 fileName := fmt .Sprintf ("%s.gguf" , "tinyllama-1.1b-chat-v0.3.Q2_K" )
4962
50- err := InstallModels (context .TODO (), nil , []config.Gallery {}, []config.Gallery {}, systemState , ml , true , true , nil , url )
63+ galleryService := services .NewGalleryService (& config.ApplicationConfig {}, ml )
64+
65+ err := InstallModels (ctx , galleryService , []config.Gallery {}, []config.Gallery {}, systemState , ml , true , true , func (s1 , s2 , s3 string , f float64 ) {
66+ fmt .Println (s1 , s2 , s3 , f )
67+ }, url )
5168 Expect (err ).ToNot (HaveOccurred ())
5269
5370 resultFile := filepath .Join (tmpdir , fileName )
0 commit comments