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:
@@ -178,6 +178,34 @@ class TestAiOutfitPanelDefaults(unittest.TestCase):
|
||||
self.assertIsNone(config)
|
||||
self.assertTrue(error)
|
||||
|
||||
def test_find_title_model_image_model_rejected_upfront(self):
|
||||
"""§19.21: title_model 命中图片模型(images_edits)→ 开跑前报错。"""
|
||||
panel = self._panel()
|
||||
panel._models = [
|
||||
{"name": "GPT-5.5 文本", "url": "https://r/v1/images/edits",
|
||||
"model": "gpt-image", "api_key": "sk-x", "api_type": "images_edits"},
|
||||
]
|
||||
panel._title_model_name = "GPT-5.5 文本"
|
||||
|
||||
config, error = panel._find_title_model()
|
||||
|
||||
self.assertIsNone(config)
|
||||
self.assertIn("图片模型", error)
|
||||
|
||||
def test_find_title_model_image_model_by_url_autodetect_rejected(self):
|
||||
"""api_type=auto 但 URL 是 images 端点 → 仍按图片模型拦截。"""
|
||||
panel = self._panel()
|
||||
panel._models = [
|
||||
{"name": "标题模型", "url": "https://r/v1/images/generations",
|
||||
"model": "x", "api_key": "sk-x", "api_type": "auto"},
|
||||
]
|
||||
panel._title_model_name = "标题模型"
|
||||
|
||||
config, error = panel._find_title_model()
|
||||
|
||||
self.assertIsNone(config)
|
||||
self.assertIn("图片模型", error)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user