feat: 更新配置文档
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
@@ -50,6 +51,7 @@ type AIConfig struct {
|
||||
type STTConfig struct {
|
||||
Provider string `mapstructure:"provider"`
|
||||
APIKey string `mapstructure:"api_key"`
|
||||
Model string `mapstructure:"model"`
|
||||
Endpoint string `mapstructure:"endpoint"`
|
||||
}
|
||||
|
||||
@@ -64,6 +66,7 @@ type LLMConfig struct {
|
||||
type TTSConfig struct {
|
||||
Provider string `mapstructure:"provider"`
|
||||
APIKey string `mapstructure:"api_key"`
|
||||
Model string `mapstructure:"model"`
|
||||
Voice string `mapstructure:"voice"`
|
||||
Speed float64 `mapstructure:"speed"`
|
||||
Endpoint string `mapstructure:"endpoint"`
|
||||
@@ -98,12 +101,14 @@ func Load() (*Config, error) {
|
||||
v.SetDefault("redis.addr", "localhost:6379")
|
||||
v.SetDefault("redis.db", 0)
|
||||
v.SetDefault("ai.stt.provider", "deepgram")
|
||||
v.SetDefault("ai.stt.model", "nova-2")
|
||||
v.SetDefault("ai.stt.endpoint", "wss://api.deepgram.com/v1/listen")
|
||||
v.SetDefault("ai.llm.provider", "openai")
|
||||
v.SetDefault("ai.llm.model", "gpt-4o")
|
||||
v.SetDefault("ai.llm.endpoint", "https://api.openai.com/v1")
|
||||
v.SetDefault("ai.llm.timeout", 10)
|
||||
v.SetDefault("ai.tts.provider", "openai")
|
||||
v.SetDefault("ai.tts.model", "tts-1")
|
||||
v.SetDefault("ai.tts.voice", "alloy")
|
||||
v.SetDefault("ai.tts.speed", 1.0)
|
||||
v.SetDefault("ai.tts.endpoint", "https://api.openai.com/v1")
|
||||
@@ -125,6 +130,11 @@ func Load() (*Config, error) {
|
||||
_ = v.MergeInConfig()
|
||||
}
|
||||
|
||||
// 加载 .env 文件(不覆盖已有环境变量)
|
||||
// 按优先级尝试:当前目录、上级目录(兼容从 backend/ 或项目根目录启动)
|
||||
_ = godotenv.Load()
|
||||
_ = godotenv.Load("../.env")
|
||||
|
||||
// 环境变量覆盖
|
||||
v.SetEnvPrefix("CAMTALK")
|
||||
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||
|
||||
Reference in New Issue
Block a user