From c248c3519fdb2136023776816aa2b2c7ab502dad Mon Sep 17 00:00:00 2001 From: Zhang Minghan Date: Wed, 25 Oct 2023 11:21:45 +0800 Subject: [PATCH] update cache rule --- app/src/dialogs/Invitation.tsx | 0 app/src/i18n.ts | 27 +++++++++++++++++++++++++++ globals/variables.go | 19 +++++++++++++++++++ manager/cache.go | 4 ++++ 4 files changed, 50 insertions(+) create mode 100644 app/src/dialogs/Invitation.tsx diff --git a/app/src/dialogs/Invitation.tsx b/app/src/dialogs/Invitation.tsx new file mode 100644 index 00000000..e69de29b diff --git a/app/src/i18n.ts b/app/src/i18n.ts index 7c8e779b..9ff4918b 100644 --- a/app/src/i18n.ts +++ b/app/src/i18n.ts @@ -198,6 +198,15 @@ const resources = { docs: { title: "Open Docs", }, + invitation: { + title: "Invitation Code", + "input-placeholder": "Please enter the invitation code", + "cancel": "Cancel", + "check": "Check", + "check-success": "Redeem Success", + "check-success-description": "Redeem Success! You have received {{amount}} points, start your AI journey!", + "check-failed": "Redeem Failed", + } }, }, cn: { @@ -382,6 +391,15 @@ const resources = { docs: { title: "开放文档", }, + invitation: { + title: "邀请码", + "input-placeholder": "请输入邀请码", + "cancel": "取消", + "check": "验证", + "check-success": "兑换成功", + "check-success-description": "兑换成功!您已获得 {{amount}} 点数,开始您的 AI 之旅吧!", + "check-failed": "兑换失败", + } }, }, ru: { @@ -577,6 +595,15 @@ const resources = { docs: { title: "Открыть документы", }, + invitation: { + title: "Код приглашения", + "input-placeholder": "Введите код приглашения", + "cancel": "Отмена", + "check": "Проверить", + "check-success": "Успешно", + "check-success-description": "Успешно! Вы получили {{amount}} очков, начните свое путешествие в мир AI!", + "check-failed": "Не удалось", + } }, }, }; diff --git a/globals/variables.go b/globals/variables.go index 509412bd..cd1a56a2 100644 --- a/globals/variables.go +++ b/globals/variables.go @@ -116,6 +116,21 @@ var LongContextModelArray = []string{ Claude2100k, } +var FreeModelArray = []string{ + GPT3Turbo, + GPT3Turbo0613, + GPT3Turbo0301, + GPT3Turbo16k, + GPT3Turbo16k0613, + GPT3Turbo16k0301, + Claude2, + ChatBison001, + BingCreative, + BingBalanced, + BingPrecise, + ZhiPuChatGLMLite, +} + func in(value string, slice []string) bool { for _, item := range slice { if item == value { @@ -172,3 +187,7 @@ func IsZhiPuModel(model string) bool { func IsLongContextModel(model string) bool { return in(model, LongContextModelArray) } + +func IsFreeModel(model string) bool { + return in(model, FreeModelArray) +} diff --git a/manager/cache.go b/manager/cache.go index 3960a603..a3ce539d 100644 --- a/manager/cache.go +++ b/manager/cache.go @@ -29,6 +29,10 @@ func ExtractCacheData(c *gin.Context, props *CacheProps) *CacheData { } func SaveCacheData(c *gin.Context, props *CacheProps, data *CacheData) { + if !globals.IsFreeModel(props.Model) { + return + } + hash := utils.Md5Encrypt(utils.Marshal(props)) utils.GetCacheFromContext(c).Set(c, fmt.Sprintf(":niodata:%s", hash), utils.Marshal(data), time.Hour*12) }