Browse Source

修复tts异常时仍然扣费的问题

CaIon 2 years ago
parent
commit
9ddafba7b8
2 changed files with 10 additions and 0 deletions
  1. 5 0
      controller/relay-audio.go
  2. 5 0
      controller/relay-image.go

+ 5 - 0
controller/relay-audio.go

@@ -129,6 +129,11 @@ func relayAudioHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
 	if err != nil {
 		return errorWrapper(err, "close_request_body_failed", http.StatusInternalServerError)
 	}
+
+	if resp.StatusCode != http.StatusOK {
+		return relayErrorHandler(resp)
+	}
+
 	var audioResponse AudioResponse
 
 	defer func(ctx context.Context) {

+ 5 - 0
controller/relay-image.go

@@ -147,6 +147,11 @@ func relayImageHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
 	if err != nil {
 		return errorWrapper(err, "close_request_body_failed", http.StatusInternalServerError)
 	}
+
+	if resp.StatusCode != http.StatusOK {
+		return relayErrorHandler(resp)
+	}
+
 	var textResponse ImageResponse
 	defer func(ctx context.Context) {
 		if consumeQuota {