- agent_handler.go: 新增agent管理接口 - agent_service.go: 扩展agent服务逻辑 - skill_handler.go: 更新skill接口 - chat_service.go: 更新chat服务 - model相关: 新增model仓库和服务 - main.go: 更新路由配置 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
113 lines
4.3 KiB
Go
113 lines
4.3 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// SecurityLevel 安全等级
|
|
type SecurityLevel string
|
|
|
|
const (
|
|
SecurityLevelSafe SecurityLevel = "safe"
|
|
SecurityLevelReview SecurityLevel = "review"
|
|
SecurityLevelDanger SecurityLevel = "danger"
|
|
)
|
|
|
|
// 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"`
|
|
|
|
// 技能列表(JSON数组)
|
|
Skills []string `json:"skills" gorm:"type:text;serializer:json"`
|
|
|
|
// 角色描述和模型配置
|
|
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"`
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
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"`
|
|
Message string `json:"message" binding:"required"`
|
|
SessionID string `json:"session_id"`
|
|
ModelID string `json:"model_id"`
|
|
Context map[string]interface{} `json:"context"`
|
|
}
|
|
|
|
// AgentResponse 聊天响应
|
|
type AgentResponse struct {
|
|
Reply string `json:"reply"`
|
|
SessionID string `json:"session_id"`
|
|
ToolsUsed []string `json:"tools_used"`
|
|
Metadata map[string]interface{} `json:"metadata"`
|
|
}
|