feat: 新增 Agent、Memory、Skill 模块
- handler: agent_handler, memory_handler, skill_handler - model: agent.go, skill.go - repository: agent_repo, skill_repo - service: agent_service, memory_service, skill_service - 新增 migrations 目录 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,10 +15,10 @@ const (
|
||||
|
||||
// Agent 智能体
|
||||
type Agent struct {
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
Name string `json:"name" gorm:"size:100;not null"`
|
||||
Description string `json:"description" gorm:"type:text"`
|
||||
OwnerID string `json:"owner_id" gorm:"size:50;not null;index"`
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
Name string `json:"name" gorm:"size:100;not null"`
|
||||
Description string `json:"description" gorm:"type:text"`
|
||||
OwnerID string `json:"owner_id" gorm:"size:50;not null;index"`
|
||||
|
||||
// Agent能力配置
|
||||
Capabilities []string `json:"capabilities" gorm:"type:text"` // JSON数组,可用工具列表
|
||||
@@ -29,6 +29,14 @@ type Agent struct {
|
||||
SecurityLevel SecurityLevel `json:"security_level" gorm:"size:20;default:'safe'"`
|
||||
AllowDangerousTools bool `json:"allow_dangerous_tools" gorm:"default:false"`
|
||||
|
||||
// 扩展字段:角色描述和模型配置
|
||||
RoleDescription string `json:"role_description" gorm:"type:text"` // 角色描述 (System Prompt)
|
||||
ModelProvider string `json:"model_provider" gorm:"size:50"` // 模型提供商: openai/anthropic
|
||||
ModelName string `json:"model_name" gorm:"size:100"` // 模型名称
|
||||
|
||||
// 协作模式
|
||||
IsSupervisor bool `json:"is_supervisor" gorm:"default:false"` // 是否为主智能体
|
||||
|
||||
// 状态
|
||||
IsActive bool `json:"is_active" gorm:"default:true"`
|
||||
|
||||
@@ -36,6 +44,62 @@ type Agent struct {
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// AgentSkill 智能体-技能绑定
|
||||
type AgentSkill struct {
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
AgentID string `json:"agent_id" gorm:"size:191;index"`
|
||||
SkillID string `json:"skill_id" gorm:"size:191;index"`
|
||||
SkillConfig string `json:"skill_config" gorm:"type:text"` // JSON 配置
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// AgentKnowledgeBase 智能体-知识库绑定
|
||||
type AgentKnowledgeBase struct {
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
AgentID string `json:"agent_id" gorm:"size:191;index"`
|
||||
KnowledgeBaseID string `json:"knowledge_base_id" gorm:"size:191;index"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// AgentMemory 长期记忆
|
||||
type AgentMemory struct {
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
AgentID string `json:"agent_id" gorm:"size:191;index"`
|
||||
UserID string `json:"user_id" gorm:"size:191;index"`
|
||||
Content string `json:"content" gorm:"type:text"`
|
||||
MemoryType string `json:"memory_type" gorm:"size:20"` // experience/preference/conversation
|
||||
Importance int `json:"importance" gorm:"default:5"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// AgentTeam 多智能体协作配置
|
||||
type AgentTeam struct {
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
SupervisorAgentID string `json:"supervisor_agent_id" gorm:"size:191;index"`
|
||||
MemberAgentID string `json:"member_agent_id" gorm:"size:191;index"`
|
||||
DispatchStrategy string `json:"dispatch_strategy" gorm:"size:20;default:'parallel'"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// AgentTask 任务记录
|
||||
type AgentTask struct {
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
AgentID string `json:"agent_id" gorm:"size:191;index"`
|
||||
UserID string `json:"user_id" gorm:"size:191;index"`
|
||||
UserInput string `json:"user_input" gorm:"type:text"`
|
||||
AgentResponse string `json:"agent_response" gorm:"type:text"`
|
||||
Status string `json:"status" gorm:"size:20"` // pending/running/completed/failed
|
||||
TokensUsed int `json:"tokens_used" gorm:"default:0"`
|
||||
DurationMs int `json:"duration_ms"`
|
||||
SessionID string `json:"session_id" gorm:"size:191;index"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
CompletedAt time.Time `json:"completed_at"`
|
||||
}
|
||||
|
||||
// AgentRequest 聊天请求
|
||||
type AgentRequest struct {
|
||||
AgentID string `json:"agent_id" binding:"required"`
|
||||
|
||||
Reference in New Issue
Block a user