compose
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user