support stream usage

This commit is contained in:
ybyang 2024-11-28 18:05:38 +08:00 committed by linux
parent e916af9c56
commit 59a835ede7

View File

@ -121,11 +121,12 @@ func streamResponseXunfei2OpenAI(xunfeiResponse *ChatResponse) *openai.ChatCompl
choice.FinishReason = &constant.StopFinishReason choice.FinishReason = &constant.StopFinishReason
} }
response := openai.ChatCompletionsStreamResponse{ response := openai.ChatCompletionsStreamResponse{
Id: fmt.Sprintf("chatcmpl-%s", random.GetUUID()), Id: xunfeiResponse.Header.Sid,
Object: "chat.completion.chunk", Object: "chat.completion.chunk",
Created: helper.GetTimestamp(), Created: helper.GetTimestamp(),
Model: "SparkDesk", Model: "SparkDesk",
Choices: []openai.ChatCompletionsStreamResponseChoice{choice}, Choices: []openai.ChatCompletionsStreamResponseChoice{choice},
Usage: &xunfeiResponse.Payload.Usage.Text,
} }
return &response return &response
} }