fix: fix finish_reason fileld not fully compatible with OpenAI (close #372, #373)

* optimize:unify finish_reason field

* refactor: use a global stop finish reason

---------

Co-authored-by: JustSong <songquanpeng@foxmail.com>
This commit is contained in:
igophper
2023-08-12 11:04:53 +08:00
committed by GitHub
parent c58f710227
commit 476a46ad7e
8 changed files with 19 additions and 7 deletions

View File

@@ -138,6 +138,9 @@ func streamResponseXunfei2OpenAI(xunfeiResponse *XunfeiChatResponse) *ChatComple
}
var choice ChatCompletionsStreamResponseChoice
choice.Delta.Content = xunfeiResponse.Payload.Choices.Text[0].Content
if xunfeiResponse.Payload.Choices.Status == 2 {
choice.FinishReason = &stopFinishReason
}
response := ChatCompletionsStreamResponse{
Object: "chat.completion.chunk",
Created: common.GetTimestamp(),