fix: make first stream message to send empty content (#751)

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
renovate/github.com-ggerganov-whisper.cpp-bindings-go-digest
Ettore Di Giacinto 1 year ago committed by GitHub
parent 3c3a9b765a
commit 17294ae5e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      api/openai/chat.go

@ -19,9 +19,10 @@ import (
func ChatEndpoint(cm *config.ConfigLoader, o *options.Option) func(c *fiber.Ctx) error {
process := func(s string, req *OpenAIRequest, config *config.Config, loader *model.ModelLoader, responses chan OpenAIResponse) {
emptyMessage := ""
initialMessage := OpenAIResponse{
Model: req.Model, // we have to return what the user sent here, due to OpenAI spec.
Choices: []Choice{{Delta: &Message{Role: "assistant"}}},
Choices: []Choice{{Delta: &Message{Role: "assistant", Content: &emptyMessage}}},
Object: "chat.completion.chunk",
}
responses <- initialMessage

Loading…
Cancel
Save