feat(ui): paginate model gallery (#4886)

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto 2025-02-22 21:38:00 +01:00 committed by GitHub
parent 5b59b5e0c1
commit e9971b168a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 117 additions and 3 deletions

View file

@ -62,3 +62,15 @@ func (gm GalleryModels) FindByName(name string) *GalleryModel {
}
return nil
}
func (gm GalleryModels) Paginate(pageNum int, itemsNum int) GalleryModels {
start := (pageNum - 1) * itemsNum
end := start + itemsNum
if start > len(gm) {
start = len(gm)
}
if end > len(gm) {
end = len(gm)
}
return gm[start:end]
}