ThoughtChain 思维链
思维链组件用于可视化和追踪 Agent 对 Actions 和 Tools 的调用链。
何时使用
- 调试和跟踪复杂 Agent System 中的调用链
- 类似的链式场景中使用
代码演示
基本
Knowledge Query
Query knowledge base
Web Search Tool Invoked
Tool invocation
Model Invocation Complete
Invoke model for response
Response Complete
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:
Task Completed
Task Completed
Task Completed
Route Information
节点状态
Thought Chain Item - 1
status: success
Thought Chain Item - 2
status: error
可折叠的
Create Task: Write New Component
Execute files needed for creating new component
Creating folder for new componentCreating files needed for new componentCreating Chinese description file for new componentCreating English description file for new component
Executing command
mkdir -p component
Creating file
component/index.tsx
Creating file
component/index.zh-CN.md
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
受控模式
Create Task: Develop New Component
Execute files needed for new component creation
Creating folder for new componentCreating files needed for new componentCreating Chinese documentation fileCreating English description file for new component
Executing command
mkdir -p component
Creating file
component/index.tsx
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
客制化
Create Task
description
Thinking Process
1. Analyze task, understand task workflow
2. Task creation, files needed for task
3. Task execution, using new component
Executing command
mkdir -p component
Creating file
component/index.tsx
Continue creating file
component/index.zh-CN.md
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
嵌套使用
1 - Thought Chain Item
description
1-1 Thought Chain Item
description
1-2 Thought Chain Item
description
2 - Thought Chain Item
description
2-1 Thought Chain Item
description
2-2 Thought Chain Item
description
2-3 Thought Chain Item
description
单行折叠
Create Task: Write New Component
Creating folder for new componentCreating files needed for new componentCreating Chinese description file for new componentCreating English description file for new component
Executing command
mkdir -p component
Creating file
component/index.tsx
Creating file
component/index.zh-CN.md
Creating file
component/index.en-US.md
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 | false | index+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)
| 属性 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| itemSolidBg | ThoughtChain.Item solid 背景色 | string | colorFillTertiary |
| itemSolidHoverBg | ThoughtChain.Item solid 悬浮态背景色 | string | colorBgTextHover |
| itemOutlinedBg | ThoughtChain.Item outlined 背景色 | string | colorBgContainer |
| itemOutlinedHoverBg | ThoughtChain.Item outlined 悬浮态背景色 | string | colorBgTextHover |
| itemBorderRadius | ThoughtChain.Item 圆角 | number | borderRadius |
| iconSize | 图标容器尺寸 | number | fontSize |
| colorTextBlinkDefault | 默认打字动画颜色 | string | colorTextDescription |
| colorTextBlink | 打字动画颜色 | string | colorTextBase |
| itemMotionDescription | 动效描述文本颜色(半透明) | string | rgba(colorTextDescription, 0.25) |