feat(settings): support gateway source switching
This commit is contained in:
+39
-5
@@ -285,7 +285,13 @@ class ImageStudioGenerateJobsWorker(BaseWorker):
|
||||
self.job_type = str(job_type or "main")
|
||||
self.aspect_ratio = str(aspect_ratio or "1:1")
|
||||
self.db_path = db_path
|
||||
self.config = config
|
||||
self.config = ai.freeze_runtime_config(
|
||||
config,
|
||||
cmhub_config_path=cmhub_config_path,
|
||||
models_path=(config or {}).get("ai_models_path", appconfig.AI_MODELS_PATH),
|
||||
include_cmhub=True,
|
||||
include_direct_models=False,
|
||||
)
|
||||
self.cmhub_config_path = cmhub_config_path
|
||||
self._done = 0
|
||||
self._failed = 0
|
||||
@@ -358,7 +364,13 @@ class ProductSuiteGenerateWorker(BaseWorker):
|
||||
self.generation_round_key = str(generation_round_key or "").strip()
|
||||
self.aspect_ratio = str(aspect_ratio or "1:1")
|
||||
self.db_path = db_path
|
||||
self.config = config
|
||||
self.config = ai.freeze_runtime_config(
|
||||
config,
|
||||
cmhub_config_path=cmhub_config_path,
|
||||
models_path=(config or {}).get("ai_models_path", appconfig.AI_MODELS_PATH),
|
||||
include_cmhub=True,
|
||||
include_direct_models=False,
|
||||
)
|
||||
self.cmhub_config_path = cmhub_config_path
|
||||
self.job_ids = []
|
||||
self._done = 0
|
||||
@@ -366,6 +378,8 @@ class ProductSuiteGenerateWorker(BaseWorker):
|
||||
self._lock = threading.Lock()
|
||||
|
||||
def execute(self):
|
||||
if appconfig.ai_backend(self.config) != "cmhub":
|
||||
raise ValueError("商品套图仅支持默认网关,请到⑤设置切换后再生成")
|
||||
total = len(self.job_specs)
|
||||
if total <= 0:
|
||||
raise ValueError("商品套图生成任务不能为空")
|
||||
@@ -474,12 +488,20 @@ class ProductSuiteAiWriteWorker(BaseWorker):
|
||||
self.instruction = str(instruction or "")
|
||||
self.context = str(context or "")
|
||||
self.image_paths = [str(path or "") for path in list(image_paths or [])]
|
||||
self.config = config
|
||||
self.config = ai.freeze_runtime_config(
|
||||
config,
|
||||
cmhub_config_path=cmhub_config_path,
|
||||
models_path=(config or {}).get("ai_models_path", appconfig.AI_MODELS_PATH),
|
||||
include_cmhub=True,
|
||||
include_direct_models=False,
|
||||
)
|
||||
self.cmhub_config_path = cmhub_config_path
|
||||
|
||||
def execute(self):
|
||||
if self.should_cancel():
|
||||
return {"cancelled": True}
|
||||
if appconfig.ai_backend(self.config) != "cmhub":
|
||||
raise ValueError("商品套图AI帮写仅支持默认网关,请到⑤设置切换后再使用")
|
||||
result = ai.analyze_product_images(
|
||||
self.instruction,
|
||||
self.context,
|
||||
@@ -583,7 +605,13 @@ class ImageStudioResumeJobsWorker(BaseWorker):
|
||||
self.project_id = int(project_id) if project_id is not None else None
|
||||
self.aspect_ratio = str(aspect_ratio or "1:1")
|
||||
self.db_path = db_path
|
||||
self.config = config
|
||||
self.config = ai.freeze_runtime_config(
|
||||
config,
|
||||
cmhub_config_path=cmhub_config_path,
|
||||
models_path=(config or {}).get("ai_models_path", appconfig.AI_MODELS_PATH),
|
||||
include_cmhub=True,
|
||||
include_direct_models=False,
|
||||
)
|
||||
self.cmhub_config_path = cmhub_config_path
|
||||
self._done = 0
|
||||
self._failed = 0
|
||||
@@ -689,7 +717,11 @@ class GenerateWorker(BaseWorker):
|
||||
self.tasks = list(tasks)
|
||||
self.prompt_values = dict(prompt_values or {})
|
||||
self.db_path = db_path
|
||||
self.config = config
|
||||
self.config = ai.freeze_runtime_config(
|
||||
config,
|
||||
cmhub_config_path=(config or {}).get("cmhub_config_path", appconfig.CMHUB_CONFIG_PATH),
|
||||
models_path=(config or {}).get("ai_models_path", appconfig.AI_MODELS_PATH),
|
||||
)
|
||||
self.diagnostic_log_dir = diagnostic_log_dir
|
||||
self.generation_scope = product_status.normalize_scope(generation_scope)
|
||||
self.product_status_counts = {
|
||||
@@ -786,6 +818,8 @@ class GenerateWorker(BaseWorker):
|
||||
),
|
||||
excluded=self.status_scope_excluded,
|
||||
)
|
||||
if appconfig.ai_backend(self.config) == "direct":
|
||||
start_message += ";自定义网关(不计点数,费用由服务商收取)"
|
||||
self._log_run_event(start_message)
|
||||
try:
|
||||
summary = ai.generate_batch(
|
||||
|
||||
Reference in New Issue
Block a user