Skip to content

Commit 14f7742

Browse files
richiejplocalai-bot
authored andcommitted
fix(ui): Refresh model list on deletion (mudler#9059)
Signed-off-by: localai-bot <localai-bot@localai.io>
1 parent 14d083b commit 14f7742

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

core/http/endpoints/localai/gallery.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,21 @@ type ModelGalleryEndpointService struct {
2020
backendGalleries []config.Gallery
2121
modelPath string
2222
galleryApplier *services.GalleryService
23+
configLoader *config.ModelConfigLoader
2324
}
2425

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

30-
func CreateModelGalleryEndpointService(galleries []config.Gallery, backendGalleries []config.Gallery, systemState *system.SystemState, galleryApplier *services.GalleryService) ModelGalleryEndpointService {
31+
func CreateModelGalleryEndpointService(galleries []config.Gallery, backendGalleries []config.Gallery, systemState *system.SystemState, galleryApplier *services.GalleryService, configLoader *config.ModelConfigLoader) ModelGalleryEndpointService {
3132
return ModelGalleryEndpointService{
3233
galleries: galleries,
3334
backendGalleries: backendGalleries,
3435
modelPath: systemState.Model.ModelsPath,
3536
galleryApplier: galleryApplier,
37+
configLoader: configLoader,
3638
}
3739
}
3840

@@ -103,6 +105,8 @@ func (mgs *ModelGalleryEndpointService) DeleteModelGalleryEndpoint() echo.Handle
103105
GalleryElementName: modelName,
104106
}
105107

108+
mgs.configLoader.RemoveModelConfig(modelName)
109+
106110
uuid, err := uuid.NewUUID()
107111
if err != nil {
108112
return err

core/http/routes/localai.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func RegisterLocalAIRoutes(router *echo.Echo,
4040

4141
// Edit model page
4242
router.GET("/models/edit/:name", localai.GetEditModelPage(cl, appConfig))
43-
modelGalleryEndpointService := localai.CreateModelGalleryEndpointService(appConfig.Galleries, appConfig.BackendGalleries, appConfig.SystemState, galleryService)
43+
modelGalleryEndpointService := localai.CreateModelGalleryEndpointService(appConfig.Galleries, appConfig.BackendGalleries, appConfig.SystemState, galleryService, cl)
4444
router.POST("/models/apply", modelGalleryEndpointService.ApplyModelGalleryEndpoint())
4545
router.POST("/models/delete/:name", modelGalleryEndpointService.DeleteModelGalleryEndpoint())
4646

0 commit comments

Comments
 (0)