feat: 支持配置proxy的能力 (#67)

This commit is contained in:
二丫讲梵
2023-03-03 17:18:00 +08:00
committed by GitHub
parent ef774a7037
commit 6d4d1df808
7 changed files with 39 additions and 18 deletions
+6 -4
View File
@@ -19,6 +19,8 @@ type Configuration struct {
SessionTimeout time.Duration `json:"session_timeout"`
// 默认对话模式
DefaultMode string `json:"default_mode"`
// 代理地址
HttpProxy string `json:"http_proxy"`
}
var config *Configuration
@@ -45,10 +47,7 @@ func LoadConfig() *Configuration {
ApiKey := os.Getenv("APIKEY")
SessionTimeout := os.Getenv("SESSION_TIMEOUT")
defaultMode := os.Getenv("DEFAULT_MODE")
// Model := os.Getenv("MODEL")
// MaxTokens := os.Getenv("MAX_TOKENS")
// Temperature := os.Getenv("TEMPREATURE")
// SessionClearToken := os.Getenv("SESSION_CLEAR_TOKEN")
httpProxy := os.Getenv("HTTP_PROXY")
if ApiKey != "" {
config.ApiKey = ApiKey
}
@@ -65,6 +64,9 @@ func LoadConfig() *Configuration {
if defaultMode != "" {
config.DefaultMode = defaultMode
}
if httpProxy != "" {
config.HttpProxy = httpProxy
}
})
if config.DefaultMode == "" {
config.DefaultMode = "单聊"