feat: AIOps智能助手对话历史持久化(按用户隔离,刷新后仍可见)
This commit is contained in:
1 parent
6321886b69
commit
32de3709ed
6 files changed
+109
-5
No files matched your search
@@ -50,3 +50,17 @@ type ChatResponse struct {
|
||||
Model string `json:"model"`
|
||||
TokensUsed int `json:"tokens_used"`
|
||||
}
|
||||
|
||||
// ChatHistory 对话历史记录(按用户隔离) // Logan.Li
|
||||
// 仅持久化成功完成的对话(用户消息 + 助手回复成对写入),错误气泡为瞬时 UI 不入库
|
||||
type ChatHistory struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
UserID uint `gorm:"index;not null" json:"user_id"` // 所属用户(JWT 中间件注入)
|
||||
Role string `gorm:"size:16;not null" json:"role"` // user / assistant
|
||||
Content string `gorm:"type:text;not null" json:"content"` // 消息内容
|
||||
Model string `gorm:"size:100" json:"model"` // 生成回复所用模型(仅 assistant 行有意义)
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// TableName 表名 // Logan.Li
|
||||
func (ChatHistory) TableName() string { return "chat_histories" }
|
||||
Reference in new issue
Block a user