diff --git a/backend/.env.example b/backend/.env.example index 6789aac..0a64dad 100755 --- a/backend/.env.example +++ b/backend/.env.example @@ -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 diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go index be4deb3..a15d38a 100755 --- a/backend/internal/config/config.go +++ b/backend/internal/config/config.go @@ -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") } diff --git a/backend/internal/config/config.yml b/backend/internal/config/config.yml index 82d076b..aa29e74 100755 --- a/backend/internal/config/config.yml +++ b/backend/internal/config/config.yml @@ -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