This commit is contained in:
Sakurasan
2024-04-17 19:29:52 +08:00
parent c37760c78b
commit 3b609324b8
2 changed files with 38 additions and 11 deletions

View File

@@ -197,8 +197,8 @@ func ChatMessages(c *gin.Context, chatReq *openai.ChatCompletionRequest) {
io.Copy(c.Writer, rsp.Body)
return
}
teeReader := io.TeeReader(rsp.Body, c.Writer)
var buffer bytes.Buffer
teeReader := io.TeeReader(rsp.Body, &buffer)
dataChan := make(chan string)
// stopChan := make(chan bool)
@@ -246,10 +246,6 @@ func ChatMessages(c *gin.Context, chatReq *openai.ChatCompletionRequest) {
if claudeResp.Delta.StopReason != "" {
dataChan <- "\ndata: [DONE]\n"
}
} else {
if !bytes.HasPrefix(line, []byte("event:")) {
dataChan <- string(line) + "\n"
}
}
}
defer close(dataChan)