添加会话授权支持

This commit is contained in:
RockYang
2023-03-21 18:12:24 +08:00
parent 3bb6814493
commit 005d219a8c
16 changed files with 403 additions and 73 deletions

View File

@@ -10,10 +10,12 @@ import (
)
type Config struct {
Listen string
Session Session
ProxyURL string
Chat Chat
Listen string
Session Session
ProxyURL string
Chat Chat
EnableAuth bool // 是否开启鉴权
Tokens []string // 授权的白名单列表 TODO: 后期要存储到 LevelDB 或者 Mysql 数据库
}
// Chat configs struct
@@ -60,6 +62,7 @@ func NewDefaultConfig() *Config {
Temperature: 1.0,
EnableContext: true,
},
EnableAuth: true,
}
}

View File

@@ -31,5 +31,9 @@ const (
InvalidParams = BizCode(101) // 非法参数
NotAuthorized = BizCode(400) // 未授权
OkMsg = "Success"
OkMsg = "Success"
ErrorMsg = "系统开小差了"
)
const TokenName = "ChatGPT-Token"
const SessionKey = "WEB_SSH_SESSION"