Skip to content

Commit ee625fc

Browse files
authored
fix(backends gallery): pass-by backend galleries to the model service (#5906)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 693aa0b commit ee625fc

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

‎core/http/endpoints/localai/gallery.go‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@ import (
1515
)
1616

1717
type ModelGalleryEndpointService struct {
18-
galleries []config.Gallery
19-
modelPath string
20-
galleryApplier *services.GalleryService
18+
galleries []config.Gallery
19+
backendGalleries []config.Gallery
20+
modelPath string
21+
galleryApplier *services.GalleryService
2122
}
2223

2324
type GalleryModel struct {
2425
ID string `json:"id"`
2526
gallery.GalleryModel
2627
}
2728

28-
func CreateModelGalleryEndpointService(galleries []config.Gallery, modelPath string, galleryApplier *services.GalleryService) ModelGalleryEndpointService {
29+
func CreateModelGalleryEndpointService(galleries []config.Gallery, backendGalleries []config.Gallery, modelPath string, galleryApplier *services.GalleryService) ModelGalleryEndpointService {
2930
return ModelGalleryEndpointService{
30-
galleries: galleries,
31-
modelPath: modelPath,
32-
galleryApplier: galleryApplier,
31+
galleries: galleries,
32+
backendGalleries: backendGalleries,
33+
modelPath: modelPath,
34+
galleryApplier: galleryApplier,
3335
}
3436
}
3537

@@ -79,6 +81,7 @@ func (mgs *ModelGalleryEndpointService) ApplyModelGalleryEndpoint() func(c *fibe
7981
ID: uuid.String(),
8082
GalleryElementName: input.ID,
8183
Galleries: mgs.galleries,
84+
BackendGalleries: mgs.backendGalleries,
8285
}
8386

8487
return c.JSON(schema.GalleryResponse{ID: uuid.String(), StatusURL: fmt.Sprintf("%smodels/jobs/%s", utils.BaseURL(c), uuid.String())})

‎core/http/routes/localai.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func RegisterLocalAIRoutes(router *fiber.App,
2323

2424
// LocalAI API endpoints
2525
if !appConfig.DisableGalleryEndpoint {
26-
modelGalleryEndpointService := localai.CreateModelGalleryEndpointService(appConfig.Galleries, appConfig.ModelPath, galleryService)
26+
modelGalleryEndpointService := localai.CreateModelGalleryEndpointService(appConfig.Galleries, appConfig.BackendGalleries, appConfig.ModelPath, galleryService)
2727
router.Post("/models/apply", modelGalleryEndpointService.ApplyModelGalleryEndpoint())
2828
router.Post("/models/delete/:name", modelGalleryEndpointService.DeleteModelGalleryEndpoint())
2929

‎core/http/routes/ui_gallery.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ func registerGalleryRoutes(app *fiber.App, cl *config.BackendConfigLoader, appCo
180180
ID: uid,
181181
GalleryElementName: galleryID,
182182
Galleries: appConfig.Galleries,
183+
BackendGalleries: appConfig.BackendGalleries,
183184
}
184185
go func() {
185186
galleryService.ModelGalleryChannel <- op
@@ -219,6 +220,7 @@ func registerGalleryRoutes(app *fiber.App, cl *config.BackendConfigLoader, appCo
219220
Delete: true,
220221
GalleryElementName: galleryName,
221222
Galleries: appConfig.Galleries,
223+
BackendGalleries: appConfig.BackendGalleries,
222224
}
223225
go func() {
224226
galleryService.ModelGalleryChannel <- op

0 commit comments

Comments
 (0)