Documentation
¶
Index ¶
- type ChatLogService
- func (s *ChatLogService) CreateAIMessage(username, source, content string, parentID uint) (*model.ChatLog, error)
- func (s *ChatLogService) CreateAIMessageWithConversation(username, source, content string, parentID, conversationID uint) (*model.ChatLog, error)
- func (s *ChatLogService) CreateChatLog(log *model.ChatLog) error
- func (s *ChatLogService) CreateUserMessage(username, source, content string) (*model.ChatLog, error)
- func (s *ChatLogService) CreateUserMessageWithConversation(username, source, content string, conversationID uint) (*model.ChatLog, error)
- func (s *ChatLogService) DeleteChatLog(id uint) error
- func (s *ChatLogService) GetChatLogByID(id uint) (*model.ChatLog, error)
- func (s *ChatLogService) GetConversationContext(messageID uint) ([]model.ChatLog, error)
- func (s *ChatLogService) GetDB() *gorm.DB
- func (s *ChatLogService) ListChatLogs(username, source string, chatType int, limit, offset int) ([]model.ChatLog, int64, error)
- type ConfigService
- func (s *ConfigService) CreateLLMConfig(config *model.LLMConfig) error
- func (s *ConfigService) CreateMCPServer(server *model.MCPServer) error
- func (s *ConfigService) CreateMCPTool(tool *model.MCPTool) error
- func (s *ConfigService) CreateProviderAccount(account *model.ProviderAccount) error
- func (s *ConfigService) DeleteIMConfig(id uint) error
- func (s *ConfigService) DeleteLLMConfig(id uint) error
- func (s *ConfigService) DeleteMCPServer(id uint) error
- func (s *ConfigService) DeleteMCPToolsByServerID(serverID uint) error
- func (s *ConfigService) DeleteProviderAccount(id uint) error
- func (s *ConfigService) ExportMCPServersToJSON(outputPath string) error
- func (s *ConfigService) GetCICDConfig(platform string) (*model.CICDConfig, error)
- func (s *ConfigService) GetDB() *gorm.DB
- func (s *ConfigService) GetDefaultLLMConfig() (*model.LLMConfig, error)
- func (s *ConfigService) GetEnabledLLMConfigs() ([]model.LLMConfig, error)
- func (s *ConfigService) GetIMConfig(platform string) (*model.IMConfig, error)
- func (s *ConfigService) GetIMConfigByID(id uint) (*model.IMConfig, error)
- func (s *ConfigService) GetLLMConfig(id uint) (*model.LLMConfig, error)
- func (s *ConfigService) GetLLMConfigByName(name string) (*model.LLMConfig, error)
- func (s *ConfigService) GetMCPServer(id uint) (*model.MCPServer, error)
- func (s *ConfigService) GetMCPServerByName(name string) (*model.MCPServer, error)
- func (s *ConfigService) GetMCPToolsByServerID(serverID uint) ([]model.MCPTool, error)
- func (s *ConfigService) GetProviderAccount(id uint) (*model.ProviderAccount, error)
- func (s *ConfigService) GetProviderAccountByName(provider, name string) (*model.ProviderAccount, error)
- func (s *ConfigService) GetSystemConfig(key string) (*model.SystemConfig, error)
- func (s *ConfigService) ListCICDConfigs() ([]model.CICDConfig, error)
- func (s *ConfigService) ListIMConfigs() ([]model.IMConfig, error)
- func (s *ConfigService) ListLLMConfigs() ([]model.LLMConfig, error)
- func (s *ConfigService) ListMCPServers() ([]model.MCPServer, error)
- func (s *ConfigService) ListProviderAccounts(provider string) ([]model.ProviderAccount, error)
- func (s *ConfigService) ListSystemConfigs() ([]model.SystemConfig, error)
- func (s *ConfigService) LoadCICDConfigsFromDB(cfg *config.Config) error
- func (s *ConfigService) LoadConfigFromDB() (*config.Config, error)
- func (s *ConfigService) LoadIMConfigsFromDB(cfg *config.Config) error
- func (s *ConfigService) LoadMCPServersFromDB() (map[string]interface{}, error)
- func (s *ConfigService) LoadProvidersFromDB() (config.ProvidersConfig, error)
- func (s *ConfigService) LoadSystemConfigsFromDB(cfg *config.Config) error
- func (s *ConfigService) MigrateFromYAML(cfg *config.Config) error
- func (s *ConfigService) MigrateMCPServersFromJSON(mcpConfigPath string) error
- func (s *ConfigService) SaveCICDConfig(config *model.CICDConfig) error
- func (s *ConfigService) SaveIMConfig(config *model.IMConfig) error
- func (s *ConfigService) SetSystemConfig(key, value, description string) error
- func (s *ConfigService) UpdateLLMConfig(config *model.LLMConfig) error
- func (s *ConfigService) UpdateMCPServer(server *model.MCPServer) error
- func (s *ConfigService) UpdateMCPTool(tool *model.MCPTool) error
- func (s *ConfigService) UpdateProviderAccount(account *model.ProviderAccount) error
- func (s *ConfigService) UpsertMCPTool(tool *model.MCPTool) error
- type ConversationService
- func (s *ConversationService) CreateConversation(username, title string) (*model.Conversation, error)
- func (s *ConversationService) DeleteConversation(id uint) error
- func (s *ConversationService) GetConversation(id uint) (*model.Conversation, error)
- func (s *ConversationService) GetConversationMessages(conversationID uint) ([]model.ChatLog, error)
- func (s *ConversationService) ListConversations(username string) ([]model.Conversation, error)
- func (s *ConversationService) ShouldGenerateTitle(conversationID uint) (bool, error)
- func (s *ConversationService) UpdateConversation(id uint, title string) error
- func (s *ConversationService) UpdateLastMessageAt(id uint) error
- type MCPLogParams
- type MCPLogService
- func (s *MCPLogService) CreateMCPLog(params *MCPLogParams) (*model.MCPLog, error)
- func (s *MCPLogService) DeleteMCPLog(id uint) error
- func (s *MCPLogService) GetMCPLogByID(id uint) (*model.MCPLog, error)
- func (s *MCPLogService) GetMCPLogStats() (map[string]interface{}, error)
- func (s *MCPLogService) ListMCPLogs(serverName, toolName, status string, limit, offset int) ([]model.MCPLog, int64, error)
- type MCPServerDef
- type MCPServersConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatLogService ¶
type ChatLogService struct {
// contains filtered or unexported fields
}
ChatLogService 对话日志服务
func (*ChatLogService) CreateAIMessage ¶
func (s *ChatLogService) CreateAIMessage(username, source, content string, parentID uint) (*model.ChatLog, error)
CreateAIMessage 创建AI回复日志
func (*ChatLogService) CreateAIMessageWithConversation ¶
func (s *ChatLogService) CreateAIMessageWithConversation(username, source, content string, parentID, conversationID uint) (*model.ChatLog, error)
CreateAIMessageWithConversation 创建AI回复日志(带会话ID)
func (*ChatLogService) CreateChatLog ¶
func (s *ChatLogService) CreateChatLog(log *model.ChatLog) error
CreateChatLog 创建对话日志
func (*ChatLogService) CreateUserMessage ¶
func (s *ChatLogService) CreateUserMessage(username, source, content string) (*model.ChatLog, error)
CreateUserMessage 创建用户消息日志
func (*ChatLogService) CreateUserMessageWithConversation ¶
func (s *ChatLogService) CreateUserMessageWithConversation(username, source, content string, conversationID uint) (*model.ChatLog, error)
CreateUserMessageWithConversation 创建用户消息日志(带会话ID)
func (*ChatLogService) DeleteChatLog ¶
func (s *ChatLogService) DeleteChatLog(id uint) error
DeleteChatLog 删除对话日志(软删除)
func (*ChatLogService) GetChatLogByID ¶
func (s *ChatLogService) GetChatLogByID(id uint) (*model.ChatLog, error)
GetChatLogByID 根据ID获取对话日志
func (*ChatLogService) GetConversationContext ¶
func (s *ChatLogService) GetConversationContext(messageID uint) ([]model.ChatLog, error)
GetConversationContext 获取对话上下文(包括父消息)
func (*ChatLogService) ListChatLogs ¶
func (s *ChatLogService) ListChatLogs(username, source string, chatType int, limit, offset int) ([]model.ChatLog, int64, error)
ListChatLogs 列出对话日志
type ConfigService ¶
type ConfigService struct {
// contains filtered or unexported fields
}
ConfigService 配置服务
func (*ConfigService) CreateLLMConfig ¶
func (s *ConfigService) CreateLLMConfig(config *model.LLMConfig) error
CreateLLMConfig 创建LLM配置
func (*ConfigService) CreateMCPServer ¶
func (s *ConfigService) CreateMCPServer(server *model.MCPServer) error
CreateMCPServer 创建MCP服务器
func (*ConfigService) CreateMCPTool ¶
func (s *ConfigService) CreateMCPTool(tool *model.MCPTool) error
CreateMCPTool 创建MCP工具
func (*ConfigService) CreateProviderAccount ¶
func (s *ConfigService) CreateProviderAccount(account *model.ProviderAccount) error
CreateProviderAccount 创建云厂商账号
func (*ConfigService) DeleteIMConfig ¶
func (s *ConfigService) DeleteIMConfig(id uint) error
DeleteIMConfig 删除IM配置
func (*ConfigService) DeleteLLMConfig ¶
func (s *ConfigService) DeleteLLMConfig(id uint) error
DeleteLLMConfig 删除LLM配置
func (*ConfigService) DeleteMCPServer ¶
func (s *ConfigService) DeleteMCPServer(id uint) error
DeleteMCPServer 删除MCP服务器
func (*ConfigService) DeleteMCPToolsByServerID ¶
func (s *ConfigService) DeleteMCPToolsByServerID(serverID uint) error
DeleteMCPToolsByServerID 删除指定服务器的所有工具
func (*ConfigService) DeleteProviderAccount ¶
func (s *ConfigService) DeleteProviderAccount(id uint) error
DeleteProviderAccount 删除云厂商账号
func (*ConfigService) ExportMCPServersToJSON ¶
func (s *ConfigService) ExportMCPServersToJSON(outputPath string) error
ExportMCPServersToJSON 导出 MCP Servers 配置到 JSON 文件
func (*ConfigService) GetCICDConfig ¶
func (s *ConfigService) GetCICDConfig(platform string) (*model.CICDConfig, error)
GetCICDConfig 获取CICD配置
func (*ConfigService) GetDefaultLLMConfig ¶
func (s *ConfigService) GetDefaultLLMConfig() (*model.LLMConfig, error)
GetDefaultLLMConfig 获取默认LLM配置(第一个启用的配置)
func (*ConfigService) GetEnabledLLMConfigs ¶
func (s *ConfigService) GetEnabledLLMConfigs() ([]model.LLMConfig, error)
GetEnabledLLMConfigs 获取所有启用的LLM配置
func (*ConfigService) GetIMConfig ¶
func (s *ConfigService) GetIMConfig(platform string) (*model.IMConfig, error)
GetIMConfig 获取IM配置
func (*ConfigService) GetIMConfigByID ¶
func (s *ConfigService) GetIMConfigByID(id uint) (*model.IMConfig, error)
GetIMConfigByID 根据ID获取IM配置
func (*ConfigService) GetLLMConfig ¶
func (s *ConfigService) GetLLMConfig(id uint) (*model.LLMConfig, error)
GetLLMConfig 获取指定ID的LLM配置
func (*ConfigService) GetLLMConfigByName ¶
func (s *ConfigService) GetLLMConfigByName(name string) (*model.LLMConfig, error)
GetLLMConfigByName 根据名称获取LLM配置
func (*ConfigService) GetMCPServer ¶
func (s *ConfigService) GetMCPServer(id uint) (*model.MCPServer, error)
GetMCPServer 获取指定MCP服务器
func (*ConfigService) GetMCPServerByName ¶
func (s *ConfigService) GetMCPServerByName(name string) (*model.MCPServer, error)
GetMCPServerByName 根据名称获取MCP服务器
func (*ConfigService) GetMCPToolsByServerID ¶
func (s *ConfigService) GetMCPToolsByServerID(serverID uint) ([]model.MCPTool, error)
GetMCPToolsByServerID 获取指定服务器的所有工具
func (*ConfigService) GetProviderAccount ¶
func (s *ConfigService) GetProviderAccount(id uint) (*model.ProviderAccount, error)
GetProviderAccount 获取指定云厂商账号
func (*ConfigService) GetProviderAccountByName ¶
func (s *ConfigService) GetProviderAccountByName(provider, name string) (*model.ProviderAccount, error)
GetProviderAccountByName 根据provider和name获取账号
func (*ConfigService) GetSystemConfig ¶
func (s *ConfigService) GetSystemConfig(key string) (*model.SystemConfig, error)
GetSystemConfig 获取系统配置
func (*ConfigService) ListCICDConfigs ¶
func (s *ConfigService) ListCICDConfigs() ([]model.CICDConfig, error)
ListCICDConfigs 列出所有CICD配置
func (*ConfigService) ListIMConfigs ¶
func (s *ConfigService) ListIMConfigs() ([]model.IMConfig, error)
ListIMConfigs 列出所有IM配置
func (*ConfigService) ListLLMConfigs ¶
func (s *ConfigService) ListLLMConfigs() ([]model.LLMConfig, error)
ListLLMConfigs 列出所有LLM配置
func (*ConfigService) ListMCPServers ¶
func (s *ConfigService) ListMCPServers() ([]model.MCPServer, error)
ListMCPServers 列出MCP服务器
func (*ConfigService) ListProviderAccounts ¶
func (s *ConfigService) ListProviderAccounts(provider string) ([]model.ProviderAccount, error)
ListProviderAccounts 列出云厂商账号
func (*ConfigService) ListSystemConfigs ¶
func (s *ConfigService) ListSystemConfigs() ([]model.SystemConfig, error)
ListSystemConfigs 列出所有系统配置
func (*ConfigService) LoadCICDConfigsFromDB ¶
func (s *ConfigService) LoadCICDConfigsFromDB(cfg *config.Config) error
LoadCICDConfigsFromDB 从数据库加载CICD配置
func (*ConfigService) LoadConfigFromDB ¶
func (s *ConfigService) LoadConfigFromDB() (*config.Config, error)
LoadConfigFromDB 从数据库加载配置到内存结构
func (*ConfigService) LoadIMConfigsFromDB ¶
func (s *ConfigService) LoadIMConfigsFromDB(cfg *config.Config) error
LoadIMConfigsFromDB 从数据库加载IM配置
func (*ConfigService) LoadMCPServersFromDB ¶
func (s *ConfigService) LoadMCPServersFromDB() (map[string]interface{}, error)
LoadMCPServersFromDB 从数据库加载活动的 MCP Servers 配置
func (*ConfigService) LoadProvidersFromDB ¶
func (s *ConfigService) LoadProvidersFromDB() (config.ProvidersConfig, error)
LoadProvidersFromDB 从数据库加载云厂商配置
func (*ConfigService) LoadSystemConfigsFromDB ¶
func (s *ConfigService) LoadSystemConfigsFromDB(cfg *config.Config) error
LoadSystemConfigsFromDB 从数据库加载系统配置
func (*ConfigService) MigrateFromYAML ¶
func (s *ConfigService) MigrateFromYAML(cfg *config.Config) error
MigrateFromYAML 从YAML配置迁移到数据库
func (*ConfigService) MigrateMCPServersFromJSON ¶
func (s *ConfigService) MigrateMCPServersFromJSON(mcpConfigPath string) error
MigrateMCPServersFromJSON 从 JSON 文件迁移 MCP Servers 配置
func (*ConfigService) SaveCICDConfig ¶
func (s *ConfigService) SaveCICDConfig(config *model.CICDConfig) error
SaveCICDConfig 保存CICD配置
func (*ConfigService) SaveIMConfig ¶
func (s *ConfigService) SaveIMConfig(config *model.IMConfig) error
SaveIMConfig 保存IM配置
func (*ConfigService) SetSystemConfig ¶
func (s *ConfigService) SetSystemConfig(key, value, description string) error
SetSystemConfig 设置系统配置
func (*ConfigService) UpdateLLMConfig ¶
func (s *ConfigService) UpdateLLMConfig(config *model.LLMConfig) error
UpdateLLMConfig 更新LLM配置
func (*ConfigService) UpdateMCPServer ¶
func (s *ConfigService) UpdateMCPServer(server *model.MCPServer) error
UpdateMCPServer 更新MCP服务器
func (*ConfigService) UpdateMCPTool ¶
func (s *ConfigService) UpdateMCPTool(tool *model.MCPTool) error
UpdateMCPTool 更新MCP工具
func (*ConfigService) UpdateProviderAccount ¶
func (s *ConfigService) UpdateProviderAccount(account *model.ProviderAccount) error
UpdateProviderAccount 更新云厂商账号
func (*ConfigService) UpsertMCPTool ¶
func (s *ConfigService) UpsertMCPTool(tool *model.MCPTool) error
UpsertMCPTool 创建或更新MCP工具(基于server_id + name唯一性)
type ConversationService ¶
type ConversationService struct {
// contains filtered or unexported fields
}
ConversationService 会话服务
func NewConversationService ¶
func NewConversationService() *ConversationService
NewConversationService 创建会话服务实例
func (*ConversationService) CreateConversation ¶
func (s *ConversationService) CreateConversation(username, title string) (*model.Conversation, error)
CreateConversation 创建会话
func (*ConversationService) DeleteConversation ¶
func (s *ConversationService) DeleteConversation(id uint) error
DeleteConversation 删除会话(软删除)
func (*ConversationService) GetConversation ¶
func (s *ConversationService) GetConversation(id uint) (*model.Conversation, error)
GetConversation 获取会话
func (*ConversationService) GetConversationMessages ¶
func (s *ConversationService) GetConversationMessages(conversationID uint) ([]model.ChatLog, error)
GetConversationMessages 获取会话的所有消息
func (*ConversationService) ListConversations ¶
func (s *ConversationService) ListConversations(username string) ([]model.Conversation, error)
ListConversations 列出用户的会话列表
func (*ConversationService) ShouldGenerateTitle ¶
func (s *ConversationService) ShouldGenerateTitle(conversationID uint) (bool, error)
ShouldGenerateTitle 检查是否需要生成标题(标题为默认值且有消息)
func (*ConversationService) UpdateConversation ¶
func (s *ConversationService) UpdateConversation(id uint, title string) error
UpdateConversation 更新会话
func (*ConversationService) UpdateLastMessageAt ¶
func (s *ConversationService) UpdateLastMessageAt(id uint) error
UpdateLastMessageAt 更新会话最后消息时间
type MCPLogParams ¶
type MCPLogParams struct {
ServerName string
ToolName string
Username string
Source string // "admin_test", "dingtalk", "feishu", "wecom", "llm"
ChatLogID uint // 关联的对话记录ID(可选)
Request map[string]interface{}
Response interface{}
ErrorMessage string
Latency int64 // 毫秒
Success bool
}
MCPLogParams MCP 日志参数
type MCPLogService ¶
type MCPLogService struct {
// contains filtered or unexported fields
}
MCPLogService MCP 日志服务
func (*MCPLogService) CreateMCPLog ¶
func (s *MCPLogService) CreateMCPLog(params *MCPLogParams) (*model.MCPLog, error)
CreateMCPLog 创建 MCP 调用日志
func (*MCPLogService) DeleteMCPLog ¶
func (s *MCPLogService) DeleteMCPLog(id uint) error
DeleteMCPLog 删除日志
func (*MCPLogService) GetMCPLogByID ¶
func (s *MCPLogService) GetMCPLogByID(id uint) (*model.MCPLog, error)
GetMCPLogByID 根据ID获取日志
func (*MCPLogService) GetMCPLogStats ¶
func (s *MCPLogService) GetMCPLogStats() (map[string]interface{}, error)
GetMCPLogStats 获取统计信息
func (*MCPLogService) ListMCPLogs ¶
func (s *MCPLogService) ListMCPLogs(serverName, toolName, status string, limit, offset int) ([]model.MCPLog, int64, error)
ListMCPLogs 查询 MCP 日志列表
type MCPServerDef ¶
type MCPServerDef struct {
IsActive bool `json:"isActive"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
BaseURL string `json:"baseUrl"`
URL string `json:"url"` // sse 类型使用
Command string `json:"command"`
Args []string `json:"args"`
Env map[string]string `json:"env"`
Headers map[string]string `json:"headers"`
LongRunning bool `json:"longRunning"`
Timeout int `json:"timeout"`
InstallSource string `json:"installSource"`
ToolPrefix string `json:"toolPrefix"`
AutoRegister bool `json:"autoRegister"`
Provider string `json:"provider"`
ProviderURL string `json:"providerUrl"`
LogoURL string `json:"logoUrl"`
Tags []string `json:"tags"`
}
MCPServerDef MCP Server 定义
type MCPServersConfig ¶
type MCPServersConfig struct {
MCPServers map[string]MCPServerDef `json:"mcpServers"`
}
MCPServersConfig MCP Servers 配置文件结构(兼容 Claude Desktop 格式)