会议模式:修"列表没检查出来还是文本" + 标签页重名 + 长文本收起来
用户:"结果界面一塌糊涂,列表没检查出来还是文本",并给了 hy.json(两豆包辩论)。
【真凶:边的 kind 会过期,节点的出口类型不会】
那张图里 p1 / p2 是**列表**变量,读变量(p1) 的出口类型也是列表;
但 `readvar(p1) → 最终输出` 那条边的 kind 写的是 **'str'**
(连线是变量还是 str 类型时接的,后来变量改成了列表)。
我原来按**边上的 kind** 判最终输出的类型 → 判成文本 →
一份 JSON 数组被当一大坨文字铺在界面上。这就是用户看到的"还是文本"。
改成:**优先看来源节点的实际出口类型**(readvar 的出口 = 变量登记表里的类型),
拿不到才退回边上的 kind,再拿不到就看内容像不像 JSON 数组。
两份引擎都改了。
实测(用户那张图,22/22 条边):
[list ] 最终输出 = '["..."]' ← p1
[list ] 最终输出 = '["..."]' ← p2
[str ] 最终输出 = '...' ← cp
【标签页重名】
图上有 3 个 end 节点、标题都叫「最终输出」(默认名),
原样显示就是一排一模一样的标签,点哪个都不知道。
现在重名的补序号:「最终输出 1 / 2 / 3」。
【同一个 end 跑多次只留最后一次】
"最终输出"顾名思义是最后的结果。循环里连了 end 的话,每轮都记一条,
结果界面就会堆出一排标题相同的标签页。现在按 nodeId 去重、只留最新。
【长文本默认收起来】
辩论这种场景一段输出好几千字,全铺开的话下面的内容得翻半天才看得到 ——
用户说的"一塌糊涂"有一半是这个。现在超过 240 字的默认只显示 6 行,
下面给「展开全文(共 N 字)」。
【顺带发现 Node 侧缺一大块】
对拍暴露出 Node 的 end 分支**根本没做 results 收集**(之前那次镜像没落上),
所以它连"多个最终输出"都不支持。补全:results 数组、类型判定、
去重、meeting_done 带回 results、aborted 分支也带回。
(这正是对拍的价值:不跑它就一直以为两边一样。)
【验证】
- 引擎回归 40/40,Node 与 Python **16/16 逐用例一致**
- 会议 HTTP 13/13 ×2、语音 41/41、Markdown 19/19
- 用用户给的 hy.json 实测:22/22 条边保留,三个最终输出的类型判定全部正确
This commit is contained in:
@@ -603,6 +603,8 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF
|
||||
const budget = nodes.reduce((sum, n) => sum + (limitOf(n) || 200), 0);
|
||||
const maxSteps = Math.max(20, budget * 2 + nodes.length);
|
||||
let finalOutput = '';
|
||||
// 所有 end 节点的产出(结果界面按标签页展示)
|
||||
const results = [];
|
||||
|
||||
const canRun = (id) => {
|
||||
const node = byId.get(id);
|
||||
@@ -626,7 +628,7 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF
|
||||
while (queue.length && steps < maxSteps) {
|
||||
if (shouldStop && shouldStop()) {
|
||||
emit({ type: 'meeting_done', output: finalOutput, aborted: true });
|
||||
return { output: finalOutput, aborted: true };
|
||||
return { output: finalOutput, results, aborted: true };
|
||||
}
|
||||
|
||||
const nodeId = queue.shift();
|
||||
@@ -800,8 +802,37 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF
|
||||
});
|
||||
}
|
||||
} else if (nodeType === 'end') {
|
||||
outputs[nodeId] = String(node.text || '').trim() || input;
|
||||
finalOutput = outputs[nodeId];
|
||||
// ★ 最终输出可以有**多个**(结果界面用标签页展示),每个还能是不同类型、
|
||||
// 展示方式不同。所以每个 end 节点都把自己那份结果和类型记下来。
|
||||
let value = String(node.text || '').trim();
|
||||
if (!value) {
|
||||
value = input;
|
||||
// 和"写变量"同样的道理:只连了 exec 线时,用上游的输出。
|
||||
if (dataIn(edges, nodeId).length === 0) {
|
||||
const ups = execIn(edges, nodeId)
|
||||
.map((e) => outputs[e.from])
|
||||
.filter((t) => t);
|
||||
if (ups.length) value = ups[ups.length - 1];
|
||||
}
|
||||
}
|
||||
outputs[nodeId] = value;
|
||||
finalOutput = value;
|
||||
|
||||
// 类型:**优先看来源节点的实际出口类型**,不要信边上的 kind ——
|
||||
// 边的 kind 会过期(连线时变量还是 str,后来改成了列表),
|
||||
// 节点的出口类型不会。不这样判的话,一份 JSON 数组会被当文本显示。
|
||||
const insList = dataIn(edges, nodeId);
|
||||
let rtype = insList.length ? (dataOutType(byId.get(insList[0].from)) || '') : '';
|
||||
if (!rtype && insList.length) rtype = kindOf(insList[0]);
|
||||
if (!PIN_TYPES.includes(rtype)) {
|
||||
const v = String(value).trim();
|
||||
rtype = (v.startsWith('[') && v.endsWith(']')) ? 'list' : 'str';
|
||||
}
|
||||
// 同一个 end 节点跑过多次只留最后一次("最终输出"就是最后的结果)
|
||||
for (let i = results.length - 1; i >= 0; i -= 1) {
|
||||
if (results[i].nodeId === nodeId) results.splice(i, 1);
|
||||
}
|
||||
results.push({ nodeId, title: node.title || '最终输出', type: rtype, value });
|
||||
emit({ type: 'node_done',
|
||||
nodeId,
|
||||
nodeType, output: finalOutput, run: runIndex });
|
||||
@@ -829,6 +860,6 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF
|
||||
}
|
||||
}
|
||||
|
||||
emit({ type: 'meeting_done', output: finalOutput });
|
||||
return { output: finalOutput };
|
||||
emit({ type: 'meeting_done', output: finalOutput, results });
|
||||
return { output: finalOutput, results };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user