2.0.0
Skip to content

ThoughtChain 思维链 ​

思维链组件用于可视化和追踪 Agent 对 Actions 和 Tools 的调用链。

何时使用 ​

  • 调试和跟踪复杂 Agent System 中的调用链
  • 类似的链式场景中使用

代码演示 ​

基本 ​

1
Knowledge Query
Query knowledge base
2
Web Search Tool Invoked
Tool invocation
3
Model Invocation Complete
Invoke model for response
4
Task completed
基本

基础用法。

ThoughtChain.Item ​

loading status:
Tool Calling
Tool Calling
Tool Calling
success status:
Tool Call Finished
Tool Call Finished
Tool Call Finished
error status:
Tool Call Error
Tool Call Error
Tool Call Error
abort status:
Agent Response Aborted
Agent Response Aborted
Agent Response Aborted
custom icon:
Task Completed
Task Completed
Task Completed
description & click:
Opening Webpage
https://x.ant.design/docs/playground/copilot
Creating
todo.md
Searching
Route Information
blink:
ThoughtChain.Item

ThoughtChain.Item 是一个独立的紧凑型组件,支持 solid、outlined、text 三种变体,以及 loading、success、error、abort 四种状态。

节点状态 ​

Thought Chain Item - 1
status: success
Thought Chain Item - 2
status: error
节点状态

思维链节点支持配置 status 属性来明显的表明当前节点的执行状态。

可折叠的 ​

Create Task: Write New Component
Execute files needed for creating new component
Creating folder for new component
Executing command
mkdir -p component
Creating files needed for new component
Creating file
component/index.tsx
Creating Chinese description file for new component
Creating file
component/index.zh-CN.md
Creating English description file for new component
Creating file
component/index.en-US.md
Checking Task Execution Steps
Verify overall task execution logic and feasibility
Folder created
component
File created
component/index.tsx
File created
component/index.zh-CN.md
File created
component/index.en-US.md
可折叠的

配置 item 的 collapsible 和 defaultExpandedKeys 可开启对思维链节点内容区域的折叠功能。

受控模式 ​

Create Task: Develop New Component
Execute files needed for new component creation
Creating folder for new component
Executing command
mkdir -p component
Creating files needed for new component
Creating file
component/index.tsx
Creating Chinese documentation fileCreating English description file for new component
Continue creating file
component/index.en-US.md
Check Task Execution Steps Completion
Verify the overall task execution logic and feasibility
Using the New Component
Using the generated component to complete the task
File created
component
受控模式

通过 expandedKeys 和 onExpand 实现受控模式。

客制化 ​

Create Task
description
Thinking Process
1. Analyze task, understand task workflow 2. Task creation, files needed for task 3. Task execution, using new component
Creating folder for new component
Executing command
mkdir -p component
Creating files needed for new component
Creating file
component/index.tsx
Creating Chinese documentation file for new component
Continue creating file
component/index.zh-CN.md
Creating English description file for new component
Continue creating file
component/index.en-US.md
Check Task Execution Steps Completion
Verify the overall task execution logic and feasibility
Checking Task Execution Steps
Verify the overall task execution logic and feasibility
Folder creation completed
component
File creation completed
component/index.tsx
File creation completed
component/index.zh-CN.md
File creation completed
component/index.en-US.md
客制化

items 属性支持灵活的客制化配置,包括自定义图标、脚注、Think 组件嵌套等。支持 line="dashed" 虚线样式。

嵌套使用 ​

1
1 - Thought Chain Item
description
1
1-1 Thought Chain Item
description
2
1-2 Thought Chain Item
description
2
2 - Thought Chain Item
description
1
2-1 Thought Chain Item
description
2
2-2 Thought Chain Item
description
3
2-3 Thought Chain Item
description
嵌套使用

ThoughtChain 组件支持嵌套使用。

单行折叠 ​

Create Task: Write New Component
Creating folder for new component
Executing command
mkdir -p component
Creating files needed for new component
Creating file
component/index.tsx
Creating Chinese description file for new component
Creating file
component/index.zh-CN.md
Creating English description file for new component
Creating file
component/index.en-US.md
单行折叠

通过 icon: false 隐藏图标,配合自定义 styles.itemContent 实现单行折叠效果。

API ​

ThoughtChainProps ​

属性说明类型默认值版本
items思维节点集合ThoughtChainItemType[]--
defaultExpandedKeys初始化展开的节点string[]--
expandedKeys当前展开的节点string[]--
onExpand展开节点变化回调(expandedKeys: string[]) => void--
line线条样式boolean | 'solid' | 'dashed' | 'dotted'true-
classNames语义化结构的类名Record<SemanticType, string>--
styles语义化结构的样式Record<SemanticType, CSSProperties>--
prefixCls自定义前缀string--
rootClassName自定义根类名string--

ThoughtChainItemType ​

属性说明类型默认值版本
key思维节点唯一标识符string--
icon思维节点图标,设为 false 可隐藏VNode | string | number | falseindex+1-
title思维节点标题VNode | string--
description思维节点描述VNode | string--
content思维节点内容VNode | string--
footer思维节点脚注VNode | string--
status思维节点状态'loading' | 'success' | 'error' | 'abort'--
collapsible是否可折叠boolean--
blink闪烁动画boolean--

ThoughtChain.Item Props ​

属性说明类型默认值版本
variant变体'solid' | 'outlined' | 'text''solid'-
icon图标VNode | string--
title标题VNode | string--
description描述VNode | string--
status状态'loading' | 'success' | 'error' | 'abort'--
blink闪烁动画boolean--
onClick点击事件() => void--
classNames语义化结构类名Record<'root' | 'icon' | 'title' | 'description', string>--
styles语义化结构样式Record<'root' | 'icon' | 'title' | 'description', CSSProperties>--

SemanticType ​

名称说明
root根节点
item节点项
itemHeader节点头部
itemIcon节点图标
itemContent节点内容
itemFooter节点脚注

Semantic DOM ​

预览依次展示 ThoughtChain 与 ThoughtChain.Item 的语义结构。

Thought Chain Item Title
description
Thought Chain Item Content
  • root
    根节点
  • item
    思维链节点
  • itemIcon
    思维链图标
  • itemHeader
    思维链节点头部
  • itemContent
    思维链节点内容
  • itemFooter
    思维链节点页脚
Opening Webpage
https://x.ant.design/docs/playground/copilot
  • root
    根节点
  • icon
    思维链图标
  • title
    思维链标题
  • description
    思维链节点描述

主题变量(Design Token) ​

属性说明类型默认值
itemSolidBgThoughtChain.Item solid 背景色stringcolorFillTertiary
itemSolidHoverBgThoughtChain.Item solid 悬浮态背景色stringcolorBgTextHover
itemOutlinedBgThoughtChain.Item outlined 背景色stringcolorBgContainer
itemOutlinedHoverBgThoughtChain.Item outlined 悬浮态背景色stringcolorBgTextHover
itemBorderRadiusThoughtChain.Item 圆角numberborderRadius
iconSize图标容器尺寸numberfontSize
colorTextBlinkDefault默认打字动画颜色stringcolorTextDescription
colorTextBlink打字动画颜色stringcolorTextBase
itemMotionDescription动效描述文本颜色(半透明)stringrgba(colorTextDescription, 0.25)