Commit ba43598f by CalciumIon

fix: streaming timeout

parent 05dc4bfc
...@@ -133,7 +133,7 @@ func OpenaiStreamHandler(c *gin.Context, resp *http.Response, info *relaycommon. ...@@ -133,7 +133,7 @@ func OpenaiStreamHandler(c *gin.Context, resp *http.Response, info *relaycommon.
}() }()
service.SetEventStreamHeaders(c) service.SetEventStreamHeaders(c)
isFirst := true isFirst := true
ticker := time.NewTicker(time.Duration(constant.StreamingTimeout)) ticker := time.NewTicker(time.Duration(constant.StreamingTimeout) * time.Second)
defer ticker.Stop() defer ticker.Stop()
c.Stream(func(w io.Writer) bool { c.Stream(func(w io.Writer) bool {
select { select {
...@@ -145,7 +145,7 @@ func OpenaiStreamHandler(c *gin.Context, resp *http.Response, info *relaycommon. ...@@ -145,7 +145,7 @@ func OpenaiStreamHandler(c *gin.Context, resp *http.Response, info *relaycommon.
isFirst = false isFirst = false
info.FirstResponseTime = time.Now() info.FirstResponseTime = time.Now()
} }
ticker.Reset(time.Duration(constant.StreamingTimeout)) ticker.Reset(time.Duration(constant.StreamingTimeout) * time.Second)
if strings.HasPrefix(data, "data: [DONE]") { if strings.HasPrefix(data, "data: [DONE]") {
data = data[:12] data = data[:12]
} }
......
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