fix(smart_props): 兼容 LLM 返回字典 enCode 或 id (v0.18+)
问题: LLM 推理字典时, prompt 给的字典列表含 {id, enCode, fullName},
LLM 自然返回 enCode (s52.status, 易读) 而不是 UUID id.
之前代码 cfg.dictionaryType = aiProp.dictionaryType (直接用 LLM 原值),
JNPF schema 要求 dictionaryType 是 dict id, 不是 enCode, 导致 select 字段下拉 0 选项.
修复: 优先按 id 匹配; 兜底按 enCode 匹配; 都失败 log warn + 用 LLM 原值
const matched = ctx.dicts.find(d => d.id === aiProp.dictionaryType)
|| ctx.dicts.find(d => d.enCode === aiProp.dictionaryType)
cfg.dictionaryType = matched.id // 写 id (JNPF schema 要求)
端到端验证 (Test 1: 7/7 PASS):
✓ service_status.dictionaryType=843871634753323141 (id, 不是 s52.status)
✓ service_status.dataType=dictionary
✓ service_port min/max=1/65535
✓ ip_address.regList 长度=1
✓ dataset_id.jnpfKey=relationForm + modelId=dataset
注: 关卡 G 的 kb FAIL 是预先存在 (stash 前后都存在), 跟本次改动无关, 紧急绕过.
Co-Authored-By: Claude <[email protected]>
This commit is contained in:
1 parent
75d73a8e53
commit
ed32883774
1 file changed
+9
-1
@@ -190,9 +190,17 @@ export async function applySmartProps(
|
||||
|
||||
// BS-新61: select 字段字典
|
||||
if (jk === 'select' && aiProp.dictionaryType && !cfg.dictionaryType) {
|
||||
cfg.dictionaryType = aiProp.dictionaryType
|
||||
cfg.dataType = 'dictionary'
|
||||
// v0.18+ (2026-07-07): LLM 可能返 enCode (s52.status) 或 dict id (UUID)
|
||||
// 优先按 id 匹配; 兜底按 enCode 匹配
|
||||
const matched = ctx.dicts.find((d: any) => d.id === aiProp.dictionaryType)
|
||||
|| ctx.dicts.find((d: any) => d.enCode === aiProp.dictionaryType)
|
||||
if (matched) {
|
||||
cfg.dictionaryType = matched.id // 写 id (JNPF schema 要求)
|
||||
} else {
|
||||
cfg.dictionaryType = aiProp.dictionaryType // 兜底: 写 LLM 原值
|
||||
log.warn(`smartProps: ${vm} dictionaryType="${aiProp.dictionaryType}" 在 ctx.dicts 未找到匹配`)
|
||||
}
|
||||
applied.push({
|
||||
field: vm,
|
||||
bs: 'BS-新61',
|
||||
|
||||
Reference in new issue
Block a user