feat: tighten ai concurrency settings
This commit is contained in:
@@ -40,6 +40,10 @@ CMHUB_CONFIG_PATH = os.path.join(default_data_dir(), "config", "cmhub.json")
|
||||
CATEGORIES = {"text", "image"}
|
||||
API_TYPES = {"chat", "images_edits", "auto"}
|
||||
AI_BACKENDS = {"direct", "cmhub"}
|
||||
AI_CONCURRENCY_MIN = 1
|
||||
AI_CONCURRENCY_MAX = 5
|
||||
AI_RETRY_MIN = 0
|
||||
AI_RETRY_MAX = 10
|
||||
RUNTIME_CONFIG_KEYS = {
|
||||
"config_path",
|
||||
"ai_models_path",
|
||||
@@ -350,12 +354,38 @@ def _normalize_config_values(config):
|
||||
return config
|
||||
ai = config.get("ai")
|
||||
if isinstance(ai, dict):
|
||||
ai["title_concurrency"] = _clamp_int(
|
||||
ai.get("title_concurrency"),
|
||||
AI_CONCURRENCY_MIN,
|
||||
AI_CONCURRENCY_MAX,
|
||||
DEFAULT_CONFIG["ai"]["title_concurrency"],
|
||||
)
|
||||
ai["image_concurrency"] = _clamp_int(
|
||||
ai.get("image_concurrency"),
|
||||
AI_CONCURRENCY_MIN,
|
||||
AI_CONCURRENCY_MAX,
|
||||
DEFAULT_CONFIG["ai"]["image_concurrency"],
|
||||
)
|
||||
ai["retry"] = _clamp_int(
|
||||
ai.get("retry"),
|
||||
AI_RETRY_MIN,
|
||||
AI_RETRY_MAX,
|
||||
DEFAULT_CONFIG["ai"]["retry"],
|
||||
)
|
||||
cmhub = ai.get("cmhub")
|
||||
if isinstance(cmhub, dict):
|
||||
cmhub["base_url"] = normalize_cmhub_base_url(cmhub.get("base_url", ""))
|
||||
return config
|
||||
|
||||
|
||||
def _clamp_int(value, minimum, maximum, default):
|
||||
try:
|
||||
number = int(value)
|
||||
except (TypeError, ValueError):
|
||||
number = int(default)
|
||||
return min(int(maximum), max(int(minimum), number))
|
||||
|
||||
|
||||
def _assert_no_secrets(config):
|
||||
def visit(value, path):
|
||||
if isinstance(value, dict):
|
||||
|
||||
@@ -142,13 +142,19 @@ class SettingsTab(QWidget):
|
||||
self.default_image_model_combo.setObjectName("defaultImageModelCombo")
|
||||
self.title_concurrency_spin = QSpinBox()
|
||||
self.title_concurrency_spin.setObjectName("titleConcurrencySpin")
|
||||
self.title_concurrency_spin.setRange(1, 64)
|
||||
self.title_concurrency_spin.setRange(
|
||||
appconfig.AI_CONCURRENCY_MIN,
|
||||
appconfig.AI_CONCURRENCY_MAX,
|
||||
)
|
||||
self.image_concurrency_spin = QSpinBox()
|
||||
self.image_concurrency_spin.setObjectName("imageConcurrencySpin")
|
||||
self.image_concurrency_spin.setRange(1, 64)
|
||||
self.image_concurrency_spin.setRange(
|
||||
appconfig.AI_CONCURRENCY_MIN,
|
||||
appconfig.AI_CONCURRENCY_MAX,
|
||||
)
|
||||
self.retry_spin = QSpinBox()
|
||||
self.retry_spin.setObjectName("retrySpin")
|
||||
self.retry_spin.setRange(0, 20)
|
||||
self.retry_spin.setRange(appconfig.AI_RETRY_MIN, appconfig.AI_RETRY_MAX)
|
||||
self.resolution_combo = QComboBox()
|
||||
self.resolution_combo.setObjectName("resolutionCombo")
|
||||
for resolution in self.RESOLUTION_ITEMS:
|
||||
|
||||
Reference in New Issue
Block a user