This commit is contained in:
1iaan
2026-04-10 12:00:03 +08:00
parent 94bdba930e
commit 5ce2a5f1a3
150 changed files with 215 additions and 20694 deletions

View File

@@ -2,6 +2,7 @@ package config
import (
"log"
"os"
"github.com/spf13/viper"
)
@@ -113,6 +114,7 @@ func InitConfig(filePath string, typ ...string) {
log.Fatal(err)
}
normalizeConfig(conf)
applySecretEnvOverrides(conf)
}
@@ -167,3 +169,15 @@ func normalizeConfig(conf *Config) {
conf.Embedding.Timeout = 10
}
}
func applySecretEnvOverrides(conf *Config) {
if v := os.Getenv("MOONSHOT_API_KEY"); v != "" {
conf.Chat.ApiKey = v
}
if v := os.Getenv("AI_CHAT_EMBEDDING_API_KEY"); v != "" {
conf.Embedding.ApiKey = v
}
if v := os.Getenv("REDIS_PASSWORD"); v != "" {
conf.Redis.Pwd = v
}
}