fix(gate): _gate_plan按(请求能力,模型能力)对规划门禁——显式t2i选中i2i或自动选型落到i2i且无媒体→t2i契约代码表判定;带媒体=真i2i走LLM层;修自动选型路径cap_req空不换算致LLM按i2i契约误拦(2026-09-08实测)
This commit is contained in:
parent
1fce2ceb03
commit
0702640aba
@ -91,30 +91,45 @@ def _biz_media(biz, key):
|
|||||||
return bool(str(v or "").strip())
|
return bool(str(v or "").strip())
|
||||||
|
|
||||||
|
|
||||||
def _degrade_gate_cap(cap, biz):
|
def _gate_plan(cap_req, cap_model, biz):
|
||||||
"""能力降级门禁换算(2026-09-08,i2i→t2i / r2v→t2v)。
|
"""能力降级门禁规划(2026-09-08,i2i→t2i / r2v→t2v)。
|
||||||
|
|
||||||
选中模型能力是降级源(i2i/r2v)但调用没带该能力必需的媒体输入时,
|
cap_req = 调用方显式指定的能力(空 = 自动选型,请求能力未知)。
|
||||||
说明任务实际是请求能力(t2i/t2v)形态——门禁按请求能力契约校验
|
返回 (gate_cap, use_code_table):
|
||||||
(只要 task 描述),否则 i2i 模型承接文生图任务会被「缺输入图」误拦。
|
- 显式请求且 CAP_DEGRADE[cap_req]==cap_model(如 t2i 选中 i2i 模型)且未带
|
||||||
带了媒体输入 = 真 i2i/r2v 用法,契约不变。
|
模型能力必需媒体 → 契约=请求能力、代码表判定(LLM/模型技能层会按模型
|
||||||
|
自身 i2i 契约误判,实测 2026-09-08 拦截合法文生图任务)
|
||||||
|
- 自动选型(cap_req 空)且模型是降级源(i2i/r2v)且未带媒体 → 任务实为
|
||||||
|
t2i/t2v 形态,契约=降级目标能力、代码表判定
|
||||||
|
- 带媒体输入 → 真 i2i/r2v 用法,契约=模型能力,LLM 层
|
||||||
|
- 其余 → 契约=显式请求能力(空则模型能力),LLM 层
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
from pipeline_llm.selection import CAP_DEGRADE_SOURCE
|
from pipeline_llm.selection import CAP_DEGRADE, CAP_DEGRADE_SOURCE
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return cap
|
return (cap_req or cap_model or ''), False
|
||||||
src = CAP_DEGRADE_SOURCE.get((cap or "").strip().lower())
|
cap_req = (cap_req or '').strip().lower()
|
||||||
if not src:
|
cap_model = (cap_model or '').strip().lower()
|
||||||
return cap
|
|
||||||
for req in _CAP_REQUIRED.get(cap, ()):
|
def _no_media():
|
||||||
if req == "task":
|
for req in _CAP_REQUIRED.get(cap_model, ()):
|
||||||
continue
|
if req == 'task':
|
||||||
if req == "any_media":
|
continue
|
||||||
if not any(_biz_media(biz or {}, k) for k in _MEDIA_KEYS):
|
if req == 'any_media':
|
||||||
return src
|
if not any(_biz_media(biz or {}, k) for k in _MEDIA_KEYS):
|
||||||
elif not _biz_media(biz or {}, req):
|
return True
|
||||||
return src
|
elif not _biz_media(biz or {}, req):
|
||||||
return cap
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
if cap_req:
|
||||||
|
if CAP_DEGRADE.get(cap_req) == cap_model and _no_media():
|
||||||
|
return cap_req, True
|
||||||
|
return cap_req, False
|
||||||
|
src = CAP_DEGRADE_SOURCE.get(cap_model)
|
||||||
|
if src and _no_media():
|
||||||
|
return src, True
|
||||||
|
return (cap_model or ''), False
|
||||||
|
|
||||||
|
|
||||||
def _check_completeness_code(capability, task, biz):
|
def _check_completeness_code(capability, task, biz):
|
||||||
@ -381,12 +396,10 @@ async def tool_invoke_model(params, org_id, user_id=""):
|
|||||||
# capability/description 未显式给出时按选中模型反查。
|
# capability/description 未显式给出时按选中模型反查。
|
||||||
desc = ""
|
desc = ""
|
||||||
cap2, desc = await _resolve_capability(model, org_id)
|
cap2, desc = await _resolve_capability(model, org_id)
|
||||||
cap = cap or cap2
|
cap_req = cap or cap2
|
||||||
# 能力降级门禁换算:i2i/r2v 模型无媒体输入时按 t2i/t2v 契约校验
|
# 能力降级门禁规划:(契约能力, 是否代码表判定)
|
||||||
cap_gate = _degrade_gate_cap(cap, biz)
|
cap_gate, use_code = _gate_plan(cap_req, cap2, biz)
|
||||||
if cap_gate != (cap or "").strip().lower():
|
if use_code:
|
||||||
# 降级执行:契约是确定性规则,直接代码表判定——LLM/模型技能层会按
|
|
||||||
# 模型自身能力(i2i 要源图)误判,实测 2026-09-08 拦截了合法文生图任务
|
|
||||||
gap = _check_completeness_code(cap_gate, task, biz)
|
gap = _check_completeness_code(cap_gate, task, biz)
|
||||||
else:
|
else:
|
||||||
gap = await judge_completeness(model, cap_gate, task, biz,
|
gap = await judge_completeness(model, cap_gate, task, biz,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user