91 lines
2.2 KiB
Go
91 lines
2.2 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
type Config struct {
|
|
// 服务配置
|
|
Port string
|
|
UploadDir string
|
|
OutputDir string
|
|
|
|
// 大模型配置
|
|
APIKey string
|
|
BaseURL string
|
|
Model string
|
|
MaxFixAttempts int
|
|
Timeout time.Duration
|
|
|
|
// 限流配置
|
|
MaxFileSize int64
|
|
MaxTasks int
|
|
|
|
//gitea配置
|
|
GiteaUrl string
|
|
GiteaToken string
|
|
OrgName string
|
|
|
|
DB DB `mapstructure:"db"`
|
|
|
|
Redis Redis `mapstructure:"redis"`
|
|
}
|
|
|
|
type DB struct {
|
|
Driver string `mapstructure:"driver"`
|
|
Source string `mapstructure:"source"`
|
|
MaxIdle int32 `mapstructure:"maxIdle"`
|
|
MaxOpen int32 `mapstructure:"maxOpen"`
|
|
MaxLifetime int32 `mapstructure:"maxLifetime"`
|
|
IsDebug bool `mapstructure:"isDebug"`
|
|
}
|
|
|
|
type Redis struct {
|
|
Host string `mapstructure:"host"`
|
|
Type string `mapstructure:"type"`
|
|
Pass string `mapstructure:"pass"`
|
|
Key string `mapstructure:"key"`
|
|
Tls int32 `mapstructure:"tls"`
|
|
Db int32 `mapstructure:"db"`
|
|
MaxIdle int32 `mapstructure:"maxIdle"`
|
|
PoolSize int32 `mapstructure:"poolSize"`
|
|
MaxIdleTime int32 `mapstructure:"maxIdleTime"`
|
|
}
|
|
|
|
func Load() *Config {
|
|
return &Config{
|
|
Port: getEnv("PORT", "5002"),
|
|
UploadDir: getEnv("UPLOAD_DIR", "./uploads"),
|
|
OutputDir: getEnv("OUTPUT_DIR", "./outputs"),
|
|
APIKey: getEnv("DOUBAO_API_KEY", "ark-3f942f9b-7428-4880-b939-026087b99957-062f1"),
|
|
BaseURL: getEnv("DOUBAO_BASE_URL", "https://ark.cn-beijing.volces.com/api/v3"),
|
|
Model: getEnv("DOUBAO_MODEL", "ep-20260717134040-w9qhc"),
|
|
Timeout: 5 * time.Minute,
|
|
MaxFileSize: 10 * 1024 * 1024, // 10MB
|
|
MaxTasks: 100,
|
|
MaxFixAttempts: 3,
|
|
GiteaUrl: "https://gitea.cdlsxd.cn",
|
|
GiteaToken: "406ebea224965f9be4c25e7ff2614588827fd31f",
|
|
OrgName: "ai_sdk",
|
|
DB: DB{
|
|
Driver: "mysql",
|
|
Source: "root:SD###sdf323r343@tcp(121.199.38.107:3306)/sys_ai?charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai",
|
|
},
|
|
Redis: Redis{
|
|
Host: "47.97.27.195:6379",
|
|
Type: "node",
|
|
Pass: "lansexiongdi@666",
|
|
Key: "code_generate",
|
|
Tls: 30,
|
|
},
|
|
}
|
|
}
|
|
|
|
func getEnv(key, defaultVal string) string {
|
|
if val := os.Getenv(key); val != "" {
|
|
return val
|
|
}
|
|
return defaultVal
|
|
}
|