feat(ai-outfit): 标题模型命中图片模型时开跑前拦截 (§19.21)
补齐缺口③:title_model 名字命中了、但那条是纯图片接口
(api_type=images/images_edits,如误指 GPT Image 2)时,过去会开跑后
逐行失败;现在 _find_title_model 在 api_config_errors 后用 detect_api_type
判类型,命中图片接口即返回错误「『{名字}』是图片模型({api_type}),不能
生成文字标题,请改选 chat/gemini 文本模型」→ _resolve_title_model_config
弹窗 + _start_title 中止,体验对齐①没配模型/②名字找不到。
边界:api_type=chat 但实际返图的模型(如 Nano Banana)类型上判不出,仍
运行时由「未找到文字标题」逐行暴露,固有限制。
测试:_find_title_model 命中 images_edits / URL 自动判图片 两例报错;
既有命中(chat)/缺失用例保持绿。离屏冒烟:title_model 指向图片模型 →
点「生成标题」前即弹窗中止、线程不启动。全套 py37 通过
(test_config_service 的 ai_models.json 顺序失败属并行 §19.13,与本改动无关)。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -903,10 +903,18 @@ class AiOutfitPanel(QWidget):
|
||||
return None, ("未找到标题模型「{}」。请在 ai_models.json 添加可生成文字的"
|
||||
"模型(chat/gemini),并把 app_config 的 title_model 设为它的 "
|
||||
"name。".format(name or "(未配置)"))
|
||||
from services.ai_image_service import AiModelConfig, api_config_errors
|
||||
from services.ai_image_service import (
|
||||
API_IMAGES, API_IMAGES_EDITS, AiModelConfig, api_config_errors,
|
||||
detect_api_type,
|
||||
)
|
||||
errors = api_config_errors(data)
|
||||
if errors:
|
||||
return None, "标题模型「{}」配置有误:{}".format(name, ";".join(errors))
|
||||
# 命中的若是纯图片接口,开跑前拦截(§19.21)——否则会逐行失败。
|
||||
api_type = detect_api_type(data.get("url", ""), data.get("api_type", "auto"))
|
||||
if api_type in (API_IMAGES, API_IMAGES_EDITS):
|
||||
return None, ("「{}」是图片模型({}),不能生成文字标题,"
|
||||
"请改选 chat/gemini 文本模型。".format(name, api_type))
|
||||
return AiModelConfig.from_dict(data), None
|
||||
|
||||
def _resolve_title_model_config(self):
|
||||
|
||||
Reference in New Issue
Block a user