feat(gate): invoke_model完备性门禁接入能力降级换算——i2i/r2v模型无媒体输入时按t2i/t2v契约校验(否则i2i承接文生图被缺输入图误拦)(2026-09-08)
This commit is contained in:
parent
d8bd88ced7
commit
5bb22fe7df
@ -91,6 +91,32 @@ def _biz_media(biz, key):
|
||||
return bool(str(v or "").strip())
|
||||
|
||||
|
||||
def _degrade_gate_cap(cap, biz):
|
||||
"""能力降级门禁换算(2026-09-08,i2i→t2i / r2v→t2v)。
|
||||
|
||||
选中模型能力是降级源(i2i/r2v)但调用没带该能力必需的媒体输入时,
|
||||
说明任务实际是请求能力(t2i/t2v)形态——门禁按请求能力契约校验
|
||||
(只要 task 描述),否则 i2i 模型承接文生图任务会被「缺输入图」误拦。
|
||||
带了媒体输入 = 真 i2i/r2v 用法,契约不变。
|
||||
"""
|
||||
try:
|
||||
from pipeline_llm.selection import CAP_DEGRADE_SOURCE
|
||||
except ImportError:
|
||||
return cap
|
||||
src = CAP_DEGRADE_SOURCE.get((cap or "").strip().lower())
|
||||
if not src:
|
||||
return cap
|
||||
for req in _CAP_REQUIRED.get(cap, ()):
|
||||
if req == "task":
|
||||
continue
|
||||
if req == "any_media":
|
||||
if not any(_biz_media(biz or {}, k) for k in _MEDIA_KEYS):
|
||||
return src
|
||||
elif not _biz_media(biz or {}, req):
|
||||
return src
|
||||
return cap
|
||||
|
||||
|
||||
def _check_completeness_code(capability, task, biz):
|
||||
"""能力契约代码表校验(**兜底层**,2026-09-08 用户定夺后降级)。
|
||||
|
||||
@ -356,6 +382,8 @@ async def tool_invoke_model(params, org_id, user_id=""):
|
||||
desc = ""
|
||||
cap2, desc = await _resolve_capability(model, org_id)
|
||||
cap = cap or cap2
|
||||
# 能力降级门禁换算:i2i/r2v 模型无媒体输入时按 t2i/t2v 契约校验
|
||||
cap = _degrade_gate_cap(cap, biz)
|
||||
gap = await judge_completeness(model, cap, task, biz,
|
||||
description=desc, org_id=org_id or "0",
|
||||
user_id=user_id or "")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user