🐛 fix: missing toolcalls parameter in stream response (#95)

This commit is contained in:
Buer 2024-03-10 02:37:47 +08:00 committed by GitHub
parent 6329db1a49
commit fa89a3d60b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -131,6 +131,24 @@ func (h *mistralStreamHandler) handlerStream(rawLine *[]byte, dataChan chan stri
*h.Usage = *mistralResponse.Usage *h.Usage = *mistralResponse.Usage
} }
stop := false
for _, choice := range mistralResponse.ChatCompletionStreamResponse.Choices {
if choice.Delta.ToolCalls != nil {
choices := choice.ConvertOpenaiStream()
for _, newChoice := range choices {
chatCompletionCopy := mistralResponse
chatCompletionCopy.Choices = []types.ChatCompletionStreamChoice{newChoice}
responseBody, _ := json.Marshal(chatCompletionCopy.ChatCompletionStreamResponse)
dataChan <- string(responseBody)
}
stop = true
}
}
if stop {
return
}
responseBody, _ := json.Marshal(mistralResponse.ChatCompletionStreamResponse) responseBody, _ := json.Marshal(mistralResponse.ChatCompletionStreamResponse)
dataChan <- string(responseBody) dataChan <- string(responseBody)