fix: filter title model from outfit picker

This commit is contained in:
2026-06-24 08:58:40 +08:00
parent e4b691b22a
commit 0230d4774f
3 changed files with 102 additions and 15 deletions
+23 -11
View File
@@ -698,15 +698,26 @@ class AiOutfitPanel(QWidget):
self._last_model = self._model_combo.currentText() if self._models else ""
def _fill_model_combo(self, combo, selected_name):
"""Fill a model dropdown from self._models (shared by 图片/标题 model, §17.3)."""
"""Fill the image model dropdown, excluding the configured title model."""
combo.clear()
if not self._models:
combo.addItem("(未配置模型,请在 ai_models.json 添加)")
combo.setEnabled(False)
return
title_model_name = (self._title_model_name or "").strip()
image_models = [
m for m in self._models
if (m.get("name") or m.get("model")) != title_model_name
]
if not image_models:
combo.addItem("(未配置可用图片模型,请在 ai_models.json 添加)")
combo.setEnabled(False)
return
combo.setEnabled(True)
for m in self._models:
combo.addItem(m.get("name") or m.get("model") or "(未命名)")
for m in image_models:
combo.addItem(m.get("name") or m.get("model") or "(未命名)", m)
self._set_combo(combo, selected_name)
def _set_combo(self, combo, value):
@@ -718,7 +729,8 @@ class AiOutfitPanel(QWidget):
self.config_changed.emit({
"outfit_excel": self._excel_edit.text(),
"outfit_output_dir": self._output_edit.text(),
"outfit_model": self._model_combo.currentText() if self._models else "",
"outfit_model": self._model_combo.currentText()
if self._model_combo.currentData() else "",
"outfit_concurrency": self._concurrency.value(),
"outfit_request_interval": self._interval.value(),
"outfit_task_cooldown": self._cooldown.value(),
@@ -1073,9 +1085,9 @@ class AiOutfitPanel(QWidget):
return
self._last_model = name
api_type = "auto"
idx = self._model_combo.currentIndex()
if self._models and 0 <= idx < len(self._models):
api_type = self._models[idx].get("api_type", "auto") or "auto"
data = self._model_combo.currentData()
if isinstance(data, dict):
api_type = data.get("api_type", "auto") or "auto"
QMessageBox.information(
self, "AI 模型已切换",
"已切换模型到 {}。\n\n"
@@ -1158,12 +1170,12 @@ class AiOutfitPanel(QWidget):
self._stop_btn.setText("停止中…")
def _selected_model_config(self):
if not self._models:
data = self._model_combo.currentData()
if not isinstance(data, dict):
QMessageBox.warning(
self, "未配置模型",
"尚未配置 AI 模型。请在 ~/.cmbot/config/ai_models.json 添加后重试。")
"尚未配置可用图片 AI 模型。请在 ~/.cmbot/config/ai_models.json 添加后重试。")
return None
data = self._models[self._model_combo.currentIndex()]
from services.ai_image_service import AiModelConfig, api_config_errors
errors = api_config_errors(data)
if errors:
@@ -1176,7 +1188,7 @@ class AiOutfitPanel(QWidget):
self._stop_btn.setEnabled(running)
self._stop_btn.setText("停止生成") # reset 「停止中…」 (§19.24)
self._excel_edit.setEnabled(not running)
self._model_combo.setEnabled(not running and bool(self._models))
self._model_combo.setEnabled(not running and bool(self._model_combo.currentData()))
self._title_btn.setEnabled(not running) # mutually exclusive with 生成标题
# -- worker callbacks (UI thread) -----------------------------------