feat: AIOps智能助手接入真实LLM后端(OpenAI兼容代理+配置持久化)
后端: - models/llm.go: LLMConfig模型(单行配置)+请求/响应struct - handlers/llm.go: GetLLMConfig/SaveLLMConfig(脱敏+upsert)/Chat(OpenAI兼容代理)/TestLLMConnection - routes.go: 注册 /aiops/llm-config(GET/PUT/test)+/aiops/chat(POST) - database.go: AutoMigrate LLMConfig - 支持OpenAI/DeepSeek/通义千问/Moonshot/Ollama/自定义6种提供商 - API Key脱敏(仅保留后4位)+回传脱敏值保留原值 - 优雅错误处理(连接超时/401/未配置均返回友好消息) - 120s超时+AIOps运维助手默认系统提示词 前端: - AIOpsAssistant.tsx: 全量重写接入真实后端 · 配置弹窗从后端加载(持久化),提供商切换自动填充endpoint/模型 · 启用开关+测试连接按钮+保存反馈 · 真实对话(发送最近10条上下文),思考中spinner,错误红色气泡 · 状态徽章(未配置/在线+模型名),新对话清空 - api.ts: aiApi替代mock aiAssistantApi(getConfig/saveConfig/testConnection/chat) 验证: tsc零错误+build通过+/health正常+前后端联调通过(配置CRUD+API Key脱敏+masked-key保留+chat错误优雅降级) // Logan.Li
This commit is contained in:
1 parent
2e174fe7eb
commit
b8cab7ed0f
6 files changed
+627
-176
No files matched your search
@@ -413,6 +413,16 @@ func Register(r *gin.Engine, db *gorm.DB, log *zap.Logger, cfg *config.Config) {
|
||||
agentQuery.POST("/alerts/:id/resolve", taskHandler.ResolveAlert)
|
||||
}
|
||||
|
||||
// AI 智能助手 - LLM 配置 + 对话代理(OpenAI 兼容) // Logan.Li
|
||||
llmHandler := handlers.NewLLMHandler(db)
|
||||
aiopsGroup := authorized.Group("/aiops")
|
||||
{
|
||||
aiopsGroup.GET("/llm-config", llmHandler.GetLLMConfig)
|
||||
aiopsGroup.PUT("/llm-config", llmHandler.SaveLLMConfig)
|
||||
aiopsGroup.POST("/llm-config/test", llmHandler.TestLLMConnection)
|
||||
aiopsGroup.POST("/chat", llmHandler.Chat)
|
||||
}
|
||||
|
||||
// 启动告警引擎(每 30 秒检查一次)
|
||||
alertEngine := handlers.NewAlertEngine(db)
|
||||
go func() {
|
||||
|
||||
Reference in new issue
Block a user