diff --git a/core/http/endpoints/localai/gallery.go b/core/http/endpoints/localai/gallery.go index 4c55630fc..5c87e6d05 100644 --- a/core/http/endpoints/localai/gallery.go +++ b/core/http/endpoints/localai/gallery.go @@ -20,6 +20,7 @@ type ModelGalleryEndpointService struct { backendGalleries []config.Gallery modelPath string galleryApplier *services.GalleryService + configLoader *config.ModelConfigLoader } type GalleryModel struct { @@ -27,12 +28,13 @@ type GalleryModel struct { gallery.GalleryModel } -func CreateModelGalleryEndpointService(galleries []config.Gallery, backendGalleries []config.Gallery, systemState *system.SystemState, galleryApplier *services.GalleryService) ModelGalleryEndpointService { +func CreateModelGalleryEndpointService(galleries []config.Gallery, backendGalleries []config.Gallery, systemState *system.SystemState, galleryApplier *services.GalleryService, configLoader *config.ModelConfigLoader) ModelGalleryEndpointService { return ModelGalleryEndpointService{ galleries: galleries, backendGalleries: backendGalleries, modelPath: systemState.Model.ModelsPath, galleryApplier: galleryApplier, + configLoader: configLoader, } } @@ -103,6 +105,8 @@ func (mgs *ModelGalleryEndpointService) DeleteModelGalleryEndpoint() echo.Handle GalleryElementName: modelName, } + mgs.configLoader.RemoveModelConfig(modelName) + uuid, err := uuid.NewUUID() if err != nil { return err diff --git a/core/http/routes/localai.go b/core/http/routes/localai.go index 9c4f7a517..50bd8218e 100644 --- a/core/http/routes/localai.go +++ b/core/http/routes/localai.go @@ -40,7 +40,7 @@ func RegisterLocalAIRoutes(router *echo.Echo, // Edit model page router.GET("/models/edit/:name", localai.GetEditModelPage(cl, appConfig)) - modelGalleryEndpointService := localai.CreateModelGalleryEndpointService(appConfig.Galleries, appConfig.BackendGalleries, appConfig.SystemState, galleryService) + modelGalleryEndpointService := localai.CreateModelGalleryEndpointService(appConfig.Galleries, appConfig.BackendGalleries, appConfig.SystemState, galleryService, cl) router.POST("/models/apply", modelGalleryEndpointService.ApplyModelGalleryEndpoint()) router.POST("/models/delete/:name", modelGalleryEndpointService.DeleteModelGalleryEndpoint())