- 新增chat_session相关模型、仓库和服务 - 新增chat_group相关模型、仓库和服务 - 新增session_handler和chat_group_handler - 实现会话管理和群聊功能 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
68 lines
2.3 KiB
Go
68 lines
2.3 KiB
Go
package model
|
||
|
||
import "time"
|
||
|
||
// ChatGroup 群聊
|
||
type ChatGroup struct {
|
||
ID string `json:"id" gorm:"primaryKey;type:varchar(36)"`
|
||
UserID string `json:"user_id" gorm:"type:varchar(36);index"`
|
||
Name string `json:"name" gorm:"type:varchar(100)"`
|
||
Description string `json:"description" gorm:"type:text"`
|
||
AgentIDs string `json:"agent_ids" gorm:"type:text"` // JSON数组,存储群聊中的Agent ID列表
|
||
Status string `json:"status" gorm:"type:varchar(20);default:'active'"` // active/archived
|
||
CreatedAt time.Time `json:"created_at"`
|
||
UpdatedAt time.Time `json:"updated_at"`
|
||
}
|
||
|
||
func (ChatGroup) TableName() string {
|
||
return "chat_groups"
|
||
}
|
||
|
||
// CreateGroupRequest 创建群聊请求
|
||
type CreateGroupRequest struct {
|
||
UserID string `json:"user_id"`
|
||
Name string `json:"name" binding:"required"`
|
||
Description string `json:"description"`
|
||
AgentIDs string `json:"agent_ids" binding:"required"` // JSON数组格式
|
||
}
|
||
|
||
// UpdateGroupRequest 更新群聊请求
|
||
type UpdateGroupRequest struct {
|
||
Name string `json:"name"`
|
||
Description string `json:"description"`
|
||
AgentIDs string `json:"agent_ids"`
|
||
Status string `json:"status"`
|
||
}
|
||
|
||
// GroupChatRequest 群聊对话请求
|
||
type GroupChatRequest struct {
|
||
Message string `json:"message" binding:"required"`
|
||
AgentIDs string `json:"agent_ids"` // 可选,覆盖群聊中配置的Agent
|
||
SessionID string `json:"session_id"` // 可选,关联的会话ID
|
||
}
|
||
|
||
// GroupChatResponse 群聊对话响应
|
||
type GroupChatResponse struct {
|
||
SessionID string `json:"session_id"`
|
||
Reply string `json:"reply"`
|
||
DurationMs int `json:"duration_ms"`
|
||
TokensUsed int `json:"tokens_used"`
|
||
Strategy string `json:"strategy"`
|
||
SubtaskResults []SubtaskResult `json:"subtask_results"`
|
||
}
|
||
|
||
// SubtaskResult 子任务结果
|
||
type SubtaskResult struct {
|
||
AgentID string `json:"agent_id"`
|
||
AgentName string `json:"agent_name"`
|
||
Reply string `json:"reply"`
|
||
TokensUsed int `json:"tokens_used"`
|
||
DurationMs int `json:"duration_ms"`
|
||
}
|
||
|
||
// GroupListResponse 群聊列表响应
|
||
type GroupListResponse struct {
|
||
List []ChatGroup `json:"list"`
|
||
Total int64 `json:"total"`
|
||
}
|