定期清理用户聊天会话上下文 ChatContext

This commit is contained in:
RockYang
2023-03-28 18:13:17 +08:00
parent 4e575d01db
commit cb2b01127b
6 changed files with 60 additions and 21 deletions

View File

@@ -48,6 +48,12 @@ type ChatSession struct {
Username string `json:"user"` // 当前登录的 user
}
// ChatContext 聊天上下文
type ChatContext struct {
Messages []Message
LastAccessTime int64 // 最后一次访问上下文时间
}
func GetDefaultChatRole() map[string]ChatRole {
return map[string]ChatRole{
"gpt": {

View File

@@ -22,12 +22,13 @@ type User struct {
// Chat configs struct
type Chat struct {
ApiURL string
ApiKeys []string
Model string
Temperature float32
MaxTokens int
EnableContext bool // 是否保持聊天上下文
ApiURL string
ApiKeys []string
Model string
Temperature float32
MaxTokens int
EnableContext bool // 是否保持聊天上下文
ChatContextExpireTime int // 聊天上下文过期时间,单位:秒
}
// Session configs struct