From ed32883774fc19dbc8b2390c121c7bd28c30c792 Mon Sep 17 00:00:00 2001 From: ssw Date: Tue, 7 Jul 2026 14:38:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(smart=5Fprops):=20=E5=85=BC=E5=AE=B9=20LLM?= =?UTF-8?q?=20=E8=BF=94=E5=9B=9E=E5=AD=97=E5=85=B8=20enCode=20=E6=88=96=20?= =?UTF-8?q?id=20(v0.18+)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: 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 --- src/commands/form/_smart_props.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/commands/form/_smart_props.ts b/src/commands/form/_smart_props.ts index 4fcb0ea..06a7115 100644 --- a/src/commands/form/_smart_props.ts +++ b/src/commands/form/_smart_props.ts @@ -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',