rename Token to User, the chat history function is ready

This commit is contained in:
RockYang
2023-03-28 16:03:41 +08:00
parent 95f9dfa9cb
commit ebc2041e8a
10 changed files with 261 additions and 141 deletions

View File

@@ -14,6 +14,14 @@ type Message struct {
Content string `json:"content"`
}
// HistoryMessage 历史聊天消息
type HistoryMessage struct {
Type string `json:"type"`
Id string `json:"id"`
Icon string `json:"icon"`
Content string `json:"content"`
}
type ApiResponse struct {
Choices []ChoiceItem `json:"choices"`
}
@@ -37,7 +45,7 @@ type ChatRole struct {
type ChatSession struct {
SessionId string `json:"session_id"`
ClientIP string `json:"client_ip"` // 客户端 IP
Token string `json:"token"` // 当前登录的 token
Username string `json:"user"` // 当前登录的 user
}
func GetDefaultChatRole() map[string]ChatRole {

View File

@@ -13,10 +13,11 @@ type Config struct {
Chat Chat
}
type Token struct {
type User struct {
Name string `json:"name"`
MaxCalls int `json:"max_calls"` // 最多调用次数,如果为 0 则表示不限制
RemainingCalls int `json:"remaining_calls"` // 剩余调用次数
EnableHistory bool `json:"enable_history"` // 是否启用聊天记录
}
// Chat configs struct

View File

@@ -6,7 +6,7 @@ type BizVo struct {
Page int `json:"page,omitempty"`
PageSize int `json:"page_size,omitempty"`
Total int `json:"total,omitempty"`
Message string `json:"message"`
Message string `json:"message,omitempty"`
Data interface{} `json:"data,omitempty"`
}
@@ -36,5 +36,5 @@ const (
ErrorMsg = "系统开小差了"
)
const TokenName = "ChatGPT-Token"
const TokenName = "ChatGPT-TOKEN"
const SessionKey = "WEB_SSH_SESSION"