perf: flush response after response handled (close #364)

This commit is contained in:
JustSong
2023-08-12 18:10:15 +08:00
parent 2a527ee436
commit 7bddc73b96
4 changed files with 10 additions and 2 deletions

View File

@@ -5,13 +5,12 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"io"
"net/http"
"one-api/common"
"one-api/model"
"strings"
"github.com/gin-gonic/gin"
)
const (
@@ -308,6 +307,7 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
var textResponse TextResponse
defer func() {
c.Writer.Flush()
if consumeQuota {
quota := 0
completionRatio := 1.0