mirror of
https://github.com/mudler/LocalAI.git
synced 2025-01-31 00:24:54 +00:00
fix(chat): re-generated uuid, created, and text on each request (#3359)
This was noticed by models returning content besides function calls. Sadly we can't test that easily in the CI so it got unnoticed. Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
7d030b56b2
commit
fbaae8528d
@ -25,9 +25,8 @@ import (
|
|||||||
// @Success 200 {object} schema.OpenAIResponse "Response"
|
// @Success 200 {object} schema.OpenAIResponse "Response"
|
||||||
// @Router /v1/chat/completions [post]
|
// @Router /v1/chat/completions [post]
|
||||||
func ChatEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, startupOptions *config.ApplicationConfig) func(c *fiber.Ctx) error {
|
func ChatEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, startupOptions *config.ApplicationConfig) func(c *fiber.Ctx) error {
|
||||||
textContentToReturn := ""
|
var id, textContentToReturn string
|
||||||
id := uuid.New().String()
|
var created int
|
||||||
created := int(time.Now().Unix())
|
|
||||||
|
|
||||||
process := func(s string, req *schema.OpenAIRequest, config *config.BackendConfig, loader *model.ModelLoader, responses chan schema.OpenAIResponse) {
|
process := func(s string, req *schema.OpenAIRequest, config *config.BackendConfig, loader *model.ModelLoader, responses chan schema.OpenAIResponse) {
|
||||||
initialMessage := schema.OpenAIResponse{
|
initialMessage := schema.OpenAIResponse{
|
||||||
@ -159,6 +158,10 @@ func ChatEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, startup
|
|||||||
}
|
}
|
||||||
|
|
||||||
return func(c *fiber.Ctx) error {
|
return func(c *fiber.Ctx) error {
|
||||||
|
textContentToReturn = ""
|
||||||
|
id = uuid.New().String()
|
||||||
|
created = int(time.Now().Unix())
|
||||||
|
|
||||||
modelFile, input, err := readRequest(c, cl, ml, startupOptions, true)
|
modelFile, input, err := readRequest(c, cl, ml, startupOptions, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed reading parameters from request:%w", err)
|
return fmt.Errorf("failed reading parameters from request:%w", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user