Skip to content

Commit

Permalink
update cache rule
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Oct 25, 2023
1 parent bf56062 commit c248c35
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
Empty file added app/src/dialogs/Invitation.tsx
Empty file.
27 changes: 27 additions & 0 deletions app/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -382,6 +391,15 @@ const resources = {
docs: {
title: "开放文档",
},
invitation: {
title: "邀请码",
"input-placeholder": "请输入邀请码",
"cancel": "取消",
"check": "验证",
"check-success": "兑换成功",
"check-success-description": "兑换成功!您已获得 {{amount}} 点数,开始您的 AI 之旅吧!",
"check-failed": "兑换失败",
}
},
},
ru: {
Expand Down Expand Up @@ -577,6 +595,15 @@ const resources = {
docs: {
title: "Открыть документы",
},
invitation: {
title: "Код приглашения",
"input-placeholder": "Введите код приглашения",
"cancel": "Отмена",
"check": "Проверить",
"check-success": "Успешно",
"check-success-description": "Успешно! Вы получили {{amount}} очков, начните свое путешествие в мир AI!",
"check-failed": "Не удалось",
}
},
},
};
Expand Down
19 changes: 19 additions & 0 deletions globals/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
4 changes: 4 additions & 0 deletions manager/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit c248c35

Please sign in to comment.