会议模式:修"列表没检查出来还是文本" + 标签页重名 + 长文本收起来
用户:"结果界面一塌糊涂,列表没检查出来还是文本",并给了 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:
@@ -2052,12 +2052,34 @@ private fun ResultValueView(r: MeetingResult) {
|
||||
)
|
||||
}
|
||||
}
|
||||
else -> Text(
|
||||
r.value.ifBlank { "(没有输出)" },
|
||||
fontSize = 13.sp,
|
||||
color = doubaoText(),
|
||||
lineHeight = 19.sp,
|
||||
)
|
||||
else -> {
|
||||
// ★ 长文本默认**收起来**。
|
||||
// 辩论这种场景一段输出能有好几千字,全铺开的话下面的内容
|
||||
// 得翻半天才看得到,结果界面就"一塌糊涂"了(用户的原话)。
|
||||
// 默认只显示开头几行,想看全文点"展开"。
|
||||
var open by remember(r.value) { mutableStateOf(false) }
|
||||
val long = r.value.length > 240
|
||||
Text(
|
||||
r.value.ifBlank { "(没有输出)" },
|
||||
fontSize = 13.sp,
|
||||
color = doubaoText(),
|
||||
lineHeight = 19.sp,
|
||||
maxLines = if (open || !long) Int.MAX_VALUE else 6,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
if (long) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Text(
|
||||
if (open) "收起" else "展开全文(共 ${r.value.length} 字)",
|
||||
fontSize = 11.sp,
|
||||
color = Doubao.Blue,
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(6.dp))
|
||||
.clickable { open = !open }
|
||||
.padding(horizontal = 6.dp, vertical = 3.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2073,6 +2095,16 @@ private fun ResultsPanel(results: List<MeetingResult>) {
|
||||
var tab by remember(results) { mutableStateOf(0) }
|
||||
val idx = tab.coerceIn(0, results.size - 1)
|
||||
|
||||
// ★ 标签页**重名要区分开**。
|
||||
// 图上多个 end 节点的标题都叫"最终输出"是常态(默认名),
|
||||
// 原样展示就是一排一模一样的标签,点哪个都不知道。
|
||||
// 重名的补上序号,至少能分辨"这是第几个最终输出"。
|
||||
val dupTitles = results.groupingBy { it.title.ifBlank { "最终输出" } }.eachCount()
|
||||
fun tabLabel(i: Int): String {
|
||||
val base = results[i].title.ifBlank { "最终输出" }
|
||||
return if ((dupTitles[base] ?: 0) > 1) "$base ${i + 1}" else base
|
||||
}
|
||||
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
if (results.size > 1) {
|
||||
// 多个输出才需要标签页;只有一个就直接展示,省一行
|
||||
@@ -2081,10 +2113,10 @@ private fun ResultsPanel(results: List<MeetingResult>) {
|
||||
.fillMaxWidth()
|
||||
.horizontalScroll(rememberScrollState()),
|
||||
) {
|
||||
results.forEachIndexed { i, r ->
|
||||
results.forEachIndexed { i, _ ->
|
||||
val on = i == idx
|
||||
Text(
|
||||
r.title.ifBlank { "输出 ${i + 1}" },
|
||||
tabLabel(i),
|
||||
fontSize = 13.sp,
|
||||
color = if (on) Color.White else doubaoTextSecondary(),
|
||||
fontWeight = if (on) FontWeight.Medium else FontWeight.Normal,
|
||||
@@ -2107,7 +2139,7 @@ private fun ResultsPanel(results: List<MeetingResult>) {
|
||||
) {
|
||||
Column(Modifier.padding(12.dp)) {
|
||||
Text(
|
||||
cur.title.ifBlank { "最终输出" } + "(${typeLabel(cur.type)})",
|
||||
tabLabel(idx) + "(${typeLabel(cur.type)})",
|
||||
fontSize = 11.sp,
|
||||
color = Doubao.Blue,
|
||||
)
|
||||
|
||||
@@ -1484,12 +1484,46 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
|
||||
elif node_type == 'end':
|
||||
# ★ 最终输出可以有**多个**(结果界面用标签页展示),每个还能是不同类型、
|
||||
# 展示方式不同。所以每个 end 节点都把自己那份结果和类型记下来。
|
||||
value = (node.get('text') or '').strip() or incoming
|
||||
value = (node.get('text') or '').strip()
|
||||
if not value:
|
||||
value = incoming
|
||||
# 和"写变量"同样的道理:只连了 exec 线时,用上游的输出。
|
||||
# 用户的心智模型是"这根线连过来了,所以把刚才产生的东西显示出来",
|
||||
# 逼他必须再拉一根数据线,只会让他看到一片空白还不知道为什么。
|
||||
if not _data_in(edges, node_id):
|
||||
ups = [outputs.get(e.get('from'))
|
||||
for e in _exec_in(edges, node_id)]
|
||||
ups = [t for t in ups if t]
|
||||
if ups:
|
||||
value = ups[-1]
|
||||
outputs[node_id] = value
|
||||
# 类型取数据入线的类型;没有数据线就按文本
|
||||
kinds = [_kind(e) for e in _data_in(edges, node_id)]
|
||||
rtype = kinds[0] if kinds else 'str'
|
||||
# 类型:**优先看来源节点的实际出口类型**,不要信边上的 kind。
|
||||
#
|
||||
# 踩过的坑:读变量(p1) 的出口类型是"列表",但那条边的 kind
|
||||
# 写的是 'str'(连线是在变量还是 str 类型的时候接的、后来变量
|
||||
# 改成了列表)。结果最终输出把一份 JSON 数组当文本显示,
|
||||
# 界面上就是一大坨 —— 用户的原话"列表没检查出来还是文本"。
|
||||
#
|
||||
# 边的 kind 会过期,节点的出口类型不会。
|
||||
ins = _data_in(edges, node_id)
|
||||
rtype = ''
|
||||
if ins:
|
||||
rtype = _data_out_type(ins[0].get('from')) or ''
|
||||
if not rtype:
|
||||
rtype = _kind(ins[0]) if ins else ''
|
||||
if rtype not in PIN_TYPES:
|
||||
# 还是没有就**看内容像什么**:JSON 数组当列表
|
||||
v = value.strip()
|
||||
rtype = 'list' if (v.startswith('[') and v.endswith(']')) else 'str'
|
||||
if rtype == 'str' and not ins:
|
||||
v = value.strip()
|
||||
if v.startswith('[') and v.endswith(']'):
|
||||
rtype = 'list'
|
||||
final_output = value
|
||||
# ★ 同一个 end 节点跑过多次时**只留最后一次** ——
|
||||
# "最终输出"顾名思义是最后的结果。循环里连了 end 的话,
|
||||
# 每轮都 append 会在结果界面堆出一排标题一模一样的标签页。
|
||||
results[:] = [r for r in results if r.get('nodeId') != node_id]
|
||||
results.append({
|
||||
'nodeId': node_id,
|
||||
'title': node.get('title') or '最终输出',
|
||||
|
||||
Reference in New Issue
Block a user