feat(realtime): Initial Realtime API implementation

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto 2024-10-02 11:16:11 +02:00 committed by Richard Palethorpe
parent 456b4982ef
commit ae6069a0a0
13 changed files with 1453 additions and 1135 deletions

View file

@ -9,6 +9,7 @@ import (
"path/filepath"
"github.com/dave-gray101/v2keyauth"
"github.com/gofiber/websocket/v2"
"github.com/mudler/LocalAI/pkg/utils"
"github.com/mudler/LocalAI/core/http/endpoints/localai"
@ -91,6 +92,7 @@ func API(application *application.Application) (*fiber.App, error) {
router.Use(middleware.StripPathPrefix())
<<<<<<< HEAD
if application.ApplicationConfig().MachineTag != "" {
router.Use(func(c *fiber.Ctx) error {
c.Response().Header.Set("Machine-Tag", application.ApplicationConfig().MachineTag)
@ -98,6 +100,16 @@ func API(application *application.Application) (*fiber.App, error) {
return c.Next()
})
}
=======
router.Use("/v1/realtime", func(c *fiber.Ctx) error {
if websocket.IsWebSocketUpgrade(c) {
// Returns true if the client requested upgrade to the WebSocket protocol
return c.Next()
}
return nil
})
>>>>>>> 43463868 (feat(realtime): Initial Realtime API implementation)
router.Hooks().OnListen(func(listenData fiber.ListenData) error {
scheme := "http"