fix: empty completion issue caused by bad status code from upstream channel

This commit is contained in:
Benny
2023-08-14 17:32:32 +08:00
committed by GitHub
parent e4bacc45d6
commit d8b5f4e52b

View File

@@ -313,6 +313,11 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
isStream = isStream || strings.HasPrefix(resp.Header.Get("Content-Type"), "text/event-stream")
}
if resp.StatusCode != http.StatusOK {
return errorWrapper(
fmt.Errorf("bad status code: %d", resp.StatusCode), "bad_status_code", resp.StatusCode)
}
var textResponse TextResponse
tokenName := c.GetString("token_name")
channelId := c.GetInt("channel_id")