Skip to content

Commit 6094f59

Browse files
committed
Fixups
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 3a802ad commit 6094f59

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

core/gallery/importers/llama-cpp.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ func (i *LlamaCPPImporter) Import(details Details) (gallery.ModelConfig, error)
7070
return gallery.ModelConfig{}, err
7171
}
7272
preferencesMap := make(map[string]any)
73-
err = json.Unmarshal(preferences, &preferencesMap)
74-
if err != nil {
75-
return gallery.ModelConfig{}, err
73+
if len(preferences) > 0 {
74+
err = json.Unmarshal(preferences, &preferencesMap)
75+
if err != nil {
76+
return gallery.ModelConfig{}, err
77+
}
7678
}
7779

7880
name, ok := preferencesMap["name"].(string)

core/startup/model_preload_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ var _ = Describe("Preload test", func() {
4242
url := "https://raw.githubusercontent.com/mudler/LocalAI-examples/main/configurations/phi-2.yaml"
4343
fileName := fmt.Sprintf("%s.yaml", "phi-2")
4444

45-
galleryService := services.NewGalleryService(&config.ApplicationConfig{}, ml)
45+
galleryService := services.NewGalleryService(&config.ApplicationConfig{
46+
SystemState: systemState,
47+
}, ml)
4648
galleryService.Start(ctx, config.NewModelConfigLoader(tmpdir), systemState)
4749

4850
err := InstallModels(ctx, galleryService, []config.Gallery{}, []config.Gallery{}, systemState, ml, true, true, func(s1, s2, s3 string, f float64) {
@@ -60,17 +62,22 @@ var _ = Describe("Preload test", func() {
6062
url := "huggingface://TheBloke/TinyLlama-1.1B-Chat-v0.3-GGUF/tinyllama-1.1b-chat-v0.3.Q2_K.gguf"
6163
fileName := fmt.Sprintf("%s.gguf", "tinyllama-1.1b-chat-v0.3.Q2_K")
6264

63-
galleryService := services.NewGalleryService(&config.ApplicationConfig{}, ml)
65+
galleryService := services.NewGalleryService(&config.ApplicationConfig{
66+
SystemState: systemState,
67+
}, ml)
68+
galleryService.Start(ctx, config.NewModelConfigLoader(tmpdir), systemState)
6469

6570
err := InstallModels(ctx, galleryService, []config.Gallery{}, []config.Gallery{}, systemState, ml, true, true, func(s1, s2, s3 string, f float64) {
6671
fmt.Println(s1, s2, s3, f)
6772
}, url)
6873
Expect(err).ToNot(HaveOccurred())
6974

7075
resultFile := filepath.Join(tmpdir, fileName)
76+
dirs, err := os.ReadDir(tmpdir)
77+
Expect(err).ToNot(HaveOccurred())
7178

7279
_, err = os.Stat(resultFile)
73-
Expect(err).ToNot(HaveOccurred())
80+
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("%+v", dirs))
7481
})
7582
})
7683
})

0 commit comments

Comments
 (0)