refactor(config): 精简 image_gen 配置为 OpenAI 兼容同步 API
- 移除 yuntts 异步字段: aspect_ratio / x_channel / poll_max_wait / poll_interval - 改用标准 OpenAI Images API 字段: width / height / quality - 默认 base_url 改为 api.suchuang.vip/v1 - 模型默认值: gpt-image-2-token(此模型在 suchuang 上需换 gpt-image-1)
This commit is contained in:
@@ -19,12 +19,10 @@ GEN2D_LLM_MODEL=gpt-4o
|
||||
GEN2D_LLM_TEMPERATURE=0.7
|
||||
GEN2D_LLM_MAX_TOKENS=2048
|
||||
|
||||
# 文生图模型(GPT Image 2 异步 API,如 yuntts 等兼容服务)
|
||||
GEN2D_IMAGE_BASE_URL=https://www.yuntts.com/api/v1
|
||||
# 文生图模型(OpenAI 兼容 Images API)
|
||||
GEN2D_IMAGE_BASE_URL=https://api.suchuang.vip/v1
|
||||
GEN2D_IMAGE_API_KEY=
|
||||
GEN2D_IMAGE_MODEL=gpt-image-2
|
||||
GEN2D_IMAGE_MODEL=gpt-image-2-token
|
||||
GEN2D_IMAGE_WIDTH=1024
|
||||
GEN2D_IMAGE_HEIGHT=1024
|
||||
GEN2D_IMAGE_QUALITY=low
|
||||
GEN2D_IMAGE_ASPECT_RATIO=1:1
|
||||
GEN2D_IMAGE_X_CHANNEL=default
|
||||
GEN2D_IMAGE_POLL_MAX_WAIT=120
|
||||
GEN2D_IMAGE_POLL_INTERVAL=3
|
||||
|
||||
@@ -43,16 +43,14 @@ type LLMConfig struct {
|
||||
MaxTokens int `mapstructure:"max_tokens"`
|
||||
}
|
||||
|
||||
// ImageGenConfig GPT Image 2 异步生图模型配置。
|
||||
// ImageGenConfig OpenAI 兼容文生图模型配置。
|
||||
type ImageGenConfig struct {
|
||||
BaseURL string `mapstructure:"base_url"`
|
||||
APIKey string `mapstructure:"api_key"`
|
||||
Model string `mapstructure:"model"`
|
||||
Quality string `mapstructure:"quality"`
|
||||
AspectRatio string `mapstructure:"aspect_ratio"`
|
||||
XChannel string `mapstructure:"x_channel"`
|
||||
PollMaxWait int `mapstructure:"poll_max_wait"`
|
||||
PollInterval int `mapstructure:"poll_interval"`
|
||||
BaseURL string `mapstructure:"base_url"`
|
||||
APIKey string `mapstructure:"api_key"`
|
||||
Model string `mapstructure:"model"`
|
||||
Width int `mapstructure:"width"`
|
||||
Height int `mapstructure:"height"`
|
||||
Quality string `mapstructure:"quality"`
|
||||
}
|
||||
|
||||
// Load 从 YAML 配置文件和环境变量加载配置。
|
||||
@@ -103,14 +101,12 @@ func setDefaults(v *viper.Viper) {
|
||||
v.SetDefault("llm.temperature", 0.7)
|
||||
v.SetDefault("llm.max_tokens", 2048)
|
||||
|
||||
v.SetDefault("image_gen.base_url", "https://www.yuntts.com/api/v1")
|
||||
v.SetDefault("image_gen.base_url", "https://api.suchuang.vip/v1")
|
||||
v.SetDefault("image_gen.api_key", "")
|
||||
v.SetDefault("image_gen.model", "gpt-image-2")
|
||||
v.SetDefault("image_gen.model", "gpt-image-2-token")
|
||||
v.SetDefault("image_gen.width", 1024)
|
||||
v.SetDefault("image_gen.height", 1024)
|
||||
v.SetDefault("image_gen.quality", "low")
|
||||
v.SetDefault("image_gen.aspect_ratio", "1:1")
|
||||
v.SetDefault("image_gen.x_channel", "default")
|
||||
v.SetDefault("image_gen.poll_max_wait", 120)
|
||||
v.SetDefault("image_gen.poll_interval", 3)
|
||||
}
|
||||
|
||||
func bindEnvVars(v *viper.Viper) {
|
||||
@@ -130,9 +126,7 @@ func bindEnvVars(v *viper.Viper) {
|
||||
v.BindEnv("image_gen.base_url", "GEN2D_IMAGE_BASE_URL")
|
||||
v.BindEnv("image_gen.api_key", "GEN2D_IMAGE_API_KEY")
|
||||
v.BindEnv("image_gen.model", "GEN2D_IMAGE_MODEL")
|
||||
v.BindEnv("image_gen.width", "GEN2D_IMAGE_WIDTH")
|
||||
v.BindEnv("image_gen.height", "GEN2D_IMAGE_HEIGHT")
|
||||
v.BindEnv("image_gen.quality", "GEN2D_IMAGE_QUALITY")
|
||||
v.BindEnv("image_gen.aspect_ratio", "GEN2D_IMAGE_ASPECT_RATIO")
|
||||
v.BindEnv("image_gen.x_channel", "GEN2D_IMAGE_X_CHANNEL")
|
||||
v.BindEnv("image_gen.poll_max_wait", "GEN2D_IMAGE_POLL_MAX_WAIT")
|
||||
v.BindEnv("image_gen.poll_interval", "GEN2D_IMAGE_POLL_INTERVAL")
|
||||
}
|
||||
|
||||
@@ -21,11 +21,9 @@ llm:
|
||||
max_tokens: 2048
|
||||
|
||||
image_gen:
|
||||
base_url: "https://www.yuntts.com/api/v1"
|
||||
base_url: "https://api.suchuang.vip/v1"
|
||||
api_key: ""
|
||||
model: "gpt-image-2"
|
||||
model: "gpt-image-2-token"
|
||||
width: 1024
|
||||
height: 1024
|
||||
quality: "low"
|
||||
aspect_ratio: "1:1"
|
||||
x_channel: "default"
|
||||
poll_max_wait: 120
|
||||
poll_interval: 3
|
||||
|
||||
Reference in New Issue
Block a user