增加ai配置

This commit is contained in:
2025-12-02 13:38:49 +08:00
parent c2c6577064
commit 70e8627a96
3 changed files with 26 additions and 0 deletions

View File

@@ -125,3 +125,10 @@ alarm_notification:
dpanic: 1
panic: 1
fatal: 1
# AI 服务配置
ai:
gemini:
api_key: "YOUR_GEMINI_API_KEY" # 替换为你的 Gemini API Key
model_name: "gemini-2.5-flash" # Gemini 模型名称,例如 "gemini-pro"
timeout: 30 # AI 请求超时时间 (秒)

View File

@@ -103,3 +103,10 @@ alarm_notification:
dpanic: 1
panic: 1
fatal: 1
# AI 服务配置
ai:
gemini:
api_key: "AIzaSyAJdXUmoN07LIswDac6YxPeRnvXlR73OO8" # 替换为你的 Gemini API Key
model_name: "gemini-2.5-flash" # Gemini 模型名称,例如 "gemini-pro"
timeout: 30 # AI 请求超时时间 (秒)

View File

@@ -50,6 +50,9 @@ type Config struct {
// AlarmNotification 告警通知配置
AlarmNotification AlarmNotificationConfig `yaml:"alarm_notification"`
// AI AI服务配置
AI AIConfig `yaml:"ai"`
}
// AppConfig 代表应用基础配置
@@ -231,6 +234,15 @@ type AlarmNotificationConfig struct {
NotificationIntervals NotificationIntervalsConfig `yaml:"notification_intervals"`
}
// AIConfig AI 服务配置
type AIConfig struct {
Gemini struct {
APIKey string `yaml:"api_key"` // Gemini API Key
ModelName string `yaml:"model_name"` // Gemini 模型名称,例如 "gemini-pro"
Timeout int `yaml:"timeout"` // AI 请求超时时间 (秒)
} `yaml:"gemini"`
}
// NewConfig 创建并返回一个新的配置实例
func NewConfig() *Config {
// 默认值可以在这里设置,但我们优先使用配置文件中的值