使用 leveldb 存储用户 token 和聊天记录

This commit is contained in:
RockYang
2023-03-27 18:27:33 +08:00
parent 6a38de7eaa
commit a6bab7b12d
15 changed files with 370 additions and 175 deletions

View File

@@ -2,6 +2,7 @@ package utils
import (
"math/rand"
"openai/types"
"strconv"
"strings"
"time"
@@ -31,7 +32,7 @@ func IsBlank(value string) bool {
return len(strings.TrimSpace(value)) == 0
}
func ContainsItem(slice []string, item string) bool {
func ContainsStr(slice []string, item string) bool {
for _, e := range slice {
if e == item {
return true
@@ -39,3 +40,12 @@ func ContainsItem(slice []string, item string) bool {
}
return false
}
func ContainToken(slice []types.Token, token string) bool {
for _, e := range slice {
if e.Name == token {
return true
}
}
return false
}