Skip to content

Commit fbaae85

Browse files
authored
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 <[email protected]>
1 parent 7d030b5 commit fbaae85

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

core/http/endpoints/openai/chat.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ import (
2525
// @Success 200 {object} schema.OpenAIResponse "Response"
2626
// @Router /v1/chat/completions [post]
2727
func ChatEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, startupOptions *config.ApplicationConfig) func(c *fiber.Ctx) error {
28-
textContentToReturn := ""
29-
id := uuid.New().String()
30-
created := int(time.Now().Unix())
28+
var id, textContentToReturn string
29+
var created int
3130

3231
process := func(s string, req *schema.OpenAIRequest, config *config.BackendConfig, loader *model.ModelLoader, responses chan schema.OpenAIResponse) {
3332
initialMessage := schema.OpenAIResponse{
@@ -159,6 +158,10 @@ func ChatEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, startup
159158
}
160159

161160
return func(c *fiber.Ctx) error {
161+
textContentToReturn = ""
162+
id = uuid.New().String()
163+
created = int(time.Now().Unix())
164+
162165
modelFile, input, err := readRequest(c, cl, ml, startupOptions, true)
163166
if err != nil {
164167
return fmt.Errorf("failed reading parameters from request:%w", err)

0 commit comments

Comments
 (0)