From 14b85318a6390b42cb28798682e569cd1905c17b Mon Sep 17 00:00:00 2001 From: JustSong Date: Tue, 20 Jun 2023 20:56:35 +0800 Subject: [PATCH 1/2] fix: fix crash when Redis is enabled --- model/cache.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/model/cache.go b/model/cache.go index 4ca60496..cf7cf4f7 100644 --- a/model/cache.go +++ b/model/cache.go @@ -33,6 +33,7 @@ func CacheGetTokenByKey(key string) (*Token, error) { if err != nil { common.SysError("Redis set token error: " + err.Error()) } + return &token, nil } err = json.Unmarshal([]byte(tokenObjectString), &token) return &token, err @@ -94,6 +95,7 @@ func CacheGetRandomSatisfiedChannel(group string, model string) (*Channel, error if !common.RedisEnabled { return GetRandomSatisfiedChannel(group, model) } + return GetRandomSatisfiedChannel(group, model) // TODO: implement this return nil, nil } From ced9f060c7d1f1f4544f5535f4a1e61eabeba5ff Mon Sep 17 00:00:00 2001 From: JustSong Date: Tue, 20 Jun 2023 21:05:07 +0800 Subject: [PATCH 2/2] fix: fix used amount not correct --- controller/billing.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controller/billing.go b/controller/billing.go index 18a34dc9..8197bc88 100644 --- a/controller/billing.go +++ b/controller/billing.go @@ -48,6 +48,9 @@ func GetUsage(c *gin.Context) { return } amount := float64(quota) + if common.DisplayInCurrencyEnabled { + amount /= common.QuotaPerUnit + } usage := OpenAIUsageResponse{ Object: "list", TotalUsage: amount,