fix: align cmhub image timeout display

This commit is contained in:
chengma
2026-07-07 19:13:00 +08:00
parent 95b180e9cf
commit 2928624019
13 changed files with 67 additions and 29 deletions
+2 -9
View File
@@ -38,6 +38,7 @@ class CMHubError(AIError):
CMHUB_IMAGE_MAX_BYTES = 20 * 1024 * 1024
CMHUB_TITLE_READ_TIMEOUT_SECONDS = 600
CMHUB_IMAGE_READ_TIMEOUT_SECONDS = 650
_RESOLUTION_SIZES = {
"512": (512, 512),
@@ -766,15 +767,7 @@ def _normalize_cmhub_resolution(resolution):
def _cmhub_read_timeout(config, resolution):
try:
timeout = int(appconfig.response_timeout(config))
except Exception:
timeout = 600
resolution_key = str(resolution or "").strip().lower()
timeouts = appconfig.ai_config(config).get("resolution_timeouts", {})
if resolution_key in timeouts:
timeout = int(timeouts[resolution_key])
return min(600, max(1, timeout))
return CMHUB_IMAGE_READ_TIMEOUT_SECONDS
def _cmhub_call_with_retry(
+10
View File
@@ -4,6 +4,7 @@ from __future__ import annotations
from contextlib import contextmanager
from ... import ai as ai_module
from ..widgets import *
from ..workers import AIModelTestWorker as _RealAIModelTestWorker
from ..workers import CMHubSettingsWorker as _RealCMHubSettingsWorker
@@ -922,6 +923,15 @@ class SettingsTab(QWidget):
def _update_response_timeout_label(self, index=None):
ai_cfg = appconfig.ai_config(self.config)
if appconfig.ai_backend(self.config) == "cmhub":
self.response_timeout_label.setText(
"标题 %s 秒 / 图片 %s 秒"
% (
ai_module.CMHUB_TITLE_READ_TIMEOUT_SECONDS,
ai_module.CMHUB_IMAGE_READ_TIMEOUT_SECONDS,
)
)
return
resolution = self.resolution_combo.currentData() or ai_cfg.get("resolution", "1k")
timeouts = ai_cfg.get("resolution_timeouts", {})
timeout = timeouts.get(str(resolution))