Commit c144bc7f by Calcium-Ion Committed by GitHub

Merge pull request #1524 from feitianbubu/pr/fix-last-resp

fix: ensure last message is sent successfully
parents bd421f47 e434c0c9
......@@ -3,6 +3,7 @@ package openai
import (
"encoding/json"
"errors"
"github.com/samber/lo"
"net/http"
"one-api/common"
"one-api/dto"
......@@ -186,7 +187,9 @@ func handleLastResponse(lastStreamData string, responseId *string, createAt *int
*containStreamUsage = true
*usage = lastStreamResponse.Usage
if !info.ShouldIncludeUsage {
*shouldSendLastResp = false
*shouldSendLastResp = lo.SomeBy(lastStreamResponse.Choices, func(choice dto.ChatCompletionsStreamResponseChoice) bool {
return choice.Delta.GetContentString() != "" || choice.Delta.GetReasoningContent() != ""
})
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment