fix: align cmhub image timeout display
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user