From e9d4226e7dd158e729b57dae471cfe6ae7428408 Mon Sep 17 00:00:00 2001 From: jinjianmingming <17610798380@163.com> Date: Wed, 17 Jul 2024 16:25:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BD=99=E9=A2=9D=E4=B8=8D=E8=B6=B3?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=B8=AD=E6=96=87=E5=A2=9E=E5=BC=BA=E5=BC=95?= =?UTF-8?q?=E5=AF=BC=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- relay/controller/audio.go | 4 ++-- relay/controller/helper.go | 4 +++- relay/controller/image.go | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/relay/controller/audio.go b/relay/controller/audio.go index 83040662eb..ae1044596a 100644 --- a/relay/controller/audio.go +++ b/relay/controller/audio.go @@ -71,9 +71,9 @@ func RelayAudioHelper(c *gin.Context, relayMode int) *relaymodel.ErrorWithStatus return openai.ErrorWrapper(err, "get_user_quota_failed", http.StatusInternalServerError) } - // Check if user quota is enough + // Check if user quota is enough Message prompts the user to use Chinese if userQuota-preConsumedQuota < 0 { - return openai.ErrorWrapper(errors.New("user quota is not enough"), "insufficient_user_quota", http.StatusForbidden) + return openai.ErrorWrapper(errors.New("请移步充值页面进行充值,可在日志中查阅使用明细"), "insufficient_user_quota", http.StatusForbidden) } err = model.CacheDecreaseUserQuota(userId, preConsumedQuota) if err != nil { diff --git a/relay/controller/helper.go b/relay/controller/helper.go index 87d22f13f6..18a86ca3d9 100644 --- a/relay/controller/helper.go +++ b/relay/controller/helper.go @@ -68,8 +68,10 @@ func preConsumeQuota(ctx context.Context, textRequest *relaymodel.GeneralOpenAIR if err != nil { return preConsumedQuota, openai.ErrorWrapper(err, "get_user_quota_failed", http.StatusInternalServerError) } + // Check if user quota is enough Message prompts the user to use Chinese if userQuota-preConsumedQuota < 0 { - return preConsumedQuota, openai.ErrorWrapper(errors.New("user quota is not enough"), "insufficient_user_quota", http.StatusForbidden) + return preConsumedQuota, openai.ErrorWrapper(errors.New("请移步充值页面进行充值,可在日志中查阅使用明细"), "insufficient_user_quota", http.StatusForbidden) + } err = model.CacheDecreaseUserQuota(meta.UserId, preConsumedQuota) if err != nil { diff --git a/relay/controller/image.go b/relay/controller/image.go index 1e06e858ef..ca197e7bfa 100644 --- a/relay/controller/image.go +++ b/relay/controller/image.go @@ -173,9 +173,9 @@ func RelayImageHelper(c *gin.Context, relayMode int) *relaymodel.ErrorWithStatus userQuota, err := model.CacheGetUserQuota(ctx, meta.UserId) quota := int64(ratio*imageCostRatio*1000) * int64(imageRequest.N) - + // Check if user quota is enough Message prompts the user to use Chinese if userQuota-quota < 0 { - return openai.ErrorWrapper(errors.New("user quota is not enough"), "insufficient_user_quota", http.StatusForbidden) + return openai.ErrorWrapper(errors.New("请移步充值页面进行充值,可在日志中查阅使用明细"), "insufficient_user_quota", http.StatusForbidden) } // do request