Merge pull request #1524 from feitianbubu/pr/fix-last-resp
fix: ensure last message is sent successfully
This commit is contained in:
@@ -3,6 +3,7 @@ package openai
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/samber/lo"
|
||||||
"net/http"
|
"net/http"
|
||||||
"one-api/common"
|
"one-api/common"
|
||||||
"one-api/dto"
|
"one-api/dto"
|
||||||
@@ -186,7 +187,9 @@ func handleLastResponse(lastStreamData string, responseId *string, createAt *int
|
|||||||
*containStreamUsage = true
|
*containStreamUsage = true
|
||||||
*usage = lastStreamResponse.Usage
|
*usage = lastStreamResponse.Usage
|
||||||
if !info.ShouldIncludeUsage {
|
if !info.ShouldIncludeUsage {
|
||||||
*shouldSendLastResp = false
|
*shouldSendLastResp = lo.SomeBy(lastStreamResponse.Choices, func(choice dto.ChatCompletionsStreamResponseChoice) bool {
|
||||||
|
return choice.Delta.GetContentString() != "" || choice.Delta.GetReasoningContent() != ""
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user