feat: 添加成功时自动启用通道功能, close #27

This commit is contained in:
CaIon
2024-02-01 18:52:39 +08:00
parent affe5111cc
commit 5c8f8b4901
6 changed files with 48 additions and 9 deletions

View File

@@ -258,6 +258,19 @@ func shouldDisableChannel(err *OpenAIError, statusCode int) bool {
return false
}
func shouldEnableChannel(err error, openAIErr *OpenAIError) bool {
if !common.AutomaticEnableChannelEnabled {
return false
}
if err != nil {
return false
}
if openAIErr != nil {
return false
}
return true
}
func setEventStreamHeaders(c *gin.Context) {
c.Writer.Header().Set("Content-Type", "text/event-stream")
c.Writer.Header().Set("Cache-Control", "no-cache")