fix: wait data out

This commit is contained in:
Xiangyuan Liu 2023-11-30 10:12:14 +08:00 committed by Xyfacai
parent 69a1dccf5f
commit 90bfe70a58

View File

@ -10,6 +10,7 @@ import (
"one-api/common" "one-api/common"
"strings" "strings"
"sync" "sync"
"time"
) )
func openaiStreamHandler(c *gin.Context, resp *http.Response, relayMode int) (*OpenAIErrorWithStatusCode, string) { func openaiStreamHandler(c *gin.Context, resp *http.Response, relayMode int) (*OpenAIErrorWithStatusCode, string) {
@ -78,6 +79,10 @@ func openaiStreamHandler(c *gin.Context, resp *http.Response, relayMode int) (*O
} }
} }
} }
if len(dataChan) > 0 {
// wait data out
time.Sleep(2 * time.Second)
}
stopChan <- true stopChan <- true
}() }()
setEventStreamHeaders(c) setEventStreamHeaders(c)