From 0facecce69ed5de71b3d00a5771d220210726379 Mon Sep 17 00:00:00 2001 From: quzard <1191890118@qq.com> Date: Wed, 21 Jun 2023 17:17:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=9D=E5=BA=A6=E6=B1=87?= =?UTF-8?q?=E7=8E=87=E7=9A=84=E5=B1=95=E7=8E=B0=E5=BD=A2=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/constants.go | 2 +- common/logger.go | 2 +- controller/billing.go | 4 ++-- web/src/helpers/render.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/constants.go b/common/constants.go index 88ef15df..643c2b34 100644 --- a/common/constants.go +++ b/common/constants.go @@ -15,7 +15,7 @@ var Footer = "" var Logo = "" var TopUpLink = "" var ChatLink = "" -var QuotaPerUnit = 0.002 // $0.002 / 1K tokens +var QuotaPerUnit = 500 * 1000.0 // $0.002 / 1K tokens var DisplayInCurrencyEnabled = false var UsingSQLite = false diff --git a/common/logger.go b/common/logger.go index 56c9de74..3658dbdb 100644 --- a/common/logger.go +++ b/common/logger.go @@ -45,7 +45,7 @@ func FatalLog(v ...any) { func LogQuota(quota int) string { if DisplayInCurrencyEnabled { - return fmt.Sprintf("$%.6f 额度", float64(quota)/1000*QuotaPerUnit) + return fmt.Sprintf("$%.6f 额度", float64(quota)/QuotaPerUnit) } else { return fmt.Sprintf("%d 点额度", quota) } diff --git a/controller/billing.go b/controller/billing.go index ef72a62a..8197bc88 100644 --- a/controller/billing.go +++ b/controller/billing.go @@ -21,7 +21,7 @@ func GetSubscription(c *gin.Context) { } amount := float64(quota) if common.DisplayInCurrencyEnabled { - amount = amount / 1000 * common.QuotaPerUnit + amount /= common.QuotaPerUnit } subscription := OpenAISubscriptionResponse{ Object: "billing_subscription", @@ -49,7 +49,7 @@ func GetUsage(c *gin.Context) { } amount := float64(quota) if common.DisplayInCurrencyEnabled { - amount = amount / 1000 * common.QuotaPerUnit + amount /= common.QuotaPerUnit } usage := OpenAIUsageResponse{ Object: "list", diff --git a/web/src/helpers/render.js b/web/src/helpers/render.js index 276cb45d..a9c81cc1 100644 --- a/web/src/helpers/render.js +++ b/web/src/helpers/render.js @@ -43,7 +43,7 @@ export function renderQuota(quota, digits = 2) { quotaPerUnit = parseFloat(quotaPerUnit); displayInCurrency = displayInCurrency === 'true'; if (displayInCurrency) { - return '$' + (quota / 1000 * quotaPerUnit).toFixed(digits); + return '$' + (quota / quotaPerUnit).toFixed(digits); } return renderNumber(quota); }