You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

对话树JSON结构转换需求:节点边模型转会话分组模型

Markdown格式规范
  • 标题使用井号(#)标记,层级越多井号数量越多
  • 列表项以短横线(-)开头
  • 强调文本用一对星号(*)包裹
  • 代码或命令用一对反引号(`)包裹,多行代码用三个反引号开头结尾并指定语言
  • 引用文本使用大于号(>)标记
  • 链接格式:[显示文本](目标URL)
  • 图片格式:[替代文本](图片URL)

对话树结构转换需求

输入对话树模型(JSON)

{"nodes": [{"text": "Third message, which is a question","id": "A","from": "bot"},{"text": "A possible answer from the player","id": "B","from": "player"},{"text": "Another possible answer from the player","id": "C","from": "player"},{"text": "Let's continue here","id": "D","from": "bot"},{"text": "Or let's continue there","id": "E","from": "bot"},{"text": "Final message","id": "F","from": "bot"},{"text": "Second message","id": "G","from": "bot"},{"text": "First message","id": "H","from": "bot"}],"edges": [{"id": "986c8f1fa8579f27","fromNode": "G","toNode": "A"},{"id": "94a3c66c65bd23f7","fromNode": "A","toNode": "B"},{"id": "7b6cb44465c55e11","fromNode": "A","toNode": "C"},{"id": "0c6880a58da67e1e","fromNode": "B","toNode": "D"},{"id": "f4451611cc94a7fe","fromNode": "C","toNode": "E"},{"id": "e81c1b1cb31a4659","fromNode": "D","toNode": "F"},{"id": "cda64626f98c3674","fromNode": "E","toNode": "F"},{"id": "f67f1d371ffbb169","fromNode": "H","toNode": "G"}]}

期望输出结构(JSON)

{"chats": {"H": {"messages": ["First message","Second message","Third message, which is a question"],"answer_propositions": {"D": "A possible answer from the player","E": "Another possible answer from the player"}},"D": {"messages": ["Let's continue here","Final message"],"answer_propositions": {}},"E": {"messages": ["Or let's continue there","Final message"],"answer_propositions": {}}}}

转换规则

  • 玩家选择answer_propositions中的消息时,对应键为会话跳转的下一个节点ID
  • 机器人连续发送的多条消息需合并到同一对象的messages数组中,按对话树逻辑排序
  • 会话结束时,answer_propositions为空白对象
  • 不能依赖输入nodes的顺序,必须严格遵循对话树逻辑处理
  • 无需考虑性能优化

内容的提问来源于stack exchange,提问作者Will

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 11:22:12