feat: Add '/version' endpoint and display it in the CLI (#679)

This commit is contained in:
Ettore Di Giacinto 2023-06-26 15:12:43 +02:00 committed by GitHub
parent 2b957df56c
commit d3a486a4f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 2 deletions

View file

@ -3,6 +3,7 @@ package api
import (
"errors"
"github.com/go-skynet/LocalAI/internal"
"github.com/go-skynet/LocalAI/pkg/assets"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
@ -105,6 +106,12 @@ func App(opts ...AppOption) (*fiber.App, error) {
applier := newGalleryApplier(options.loader.ModelPath)
applier.start(options.context, cm)
app.Get("/version", func(c *fiber.Ctx) error {
return c.JSON(struct {
Version string `json:"version"`
}{Version: internal.PrintableVersion()})
})
app.Post("/models/apply", applyModelGallery(options.loader.ModelPath, cm, applier.C, options.galleries))
app.Get("/models/available", listModelFromGallery(options.galleries, options.loader.ModelPath))
app.Get("/models/jobs/:uuid", getOpStatus(applier))