Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto 2024-10-16 09:02:14 +02:00
parent dcb13a7e6f
commit 4ca7689f31
3 changed files with 34 additions and 22 deletions

View file

@ -6,7 +6,6 @@ import (
"fmt"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/websocket/v2"
"github.com/google/uuid"
"github.com/mudler/LocalAI/core/config"
fiberContext "github.com/mudler/LocalAI/core/http/ctx"
@ -49,24 +48,24 @@ func readRequest(c *fiber.Ctx, cl *config.BackendConfigLoader, ml *model.ModelLo
return modelFile, input, err
}
func readWSRequest(c *websocket.Conn, cl *config.BackendConfigLoader, ml *model.ModelLoader, o *config.ApplicationConfig, firstModel bool) (string, *schema.OpenAIRequest, error) {
input := new(schema.OpenAIRequest)
// func readWSRequest(c *websocket.Conn, cl *config.BackendConfigLoader, ml *model.ModelLoader, o *config.ApplicationConfig, firstModel bool) (string, *schema.OpenAIRequest, error) {
// input := new(schema.OpenAIRequest)
input.Model = c.Query("name")
// input.Model = c.Query("name")
received, _ := json.Marshal(input)
// received, _ := json.Marshal(input)
ctx, cancel := context.WithCancel(o.Context)
// ctx, cancel := context.WithCancel(o.Context)
input.Context = ctx
input.Cancel = cancel
// input.Context = ctx
// input.Cancel = cancel
log.Debug().Msgf("Request received: %s", string(received))
// log.Debug().Msgf("Request received: %s", string(received))
modelFile, err := fiberContext.ModelFromContext(c, cl, ml, input.Model, firstModel)
// modelFile, err := fiberContext.ModelFromContext(c, cl, ml, input.Model, firstModel)
return modelFile, input, err
}
// return modelFile, input, err
// }
func updateRequestConfig(config *config.BackendConfig, input *schema.OpenAIRequest) {
if input.Echo {