Skip to content

ThoughtChain 思考链 ​

AI 对话组件。公开入口:ThoughtChain。

在线演示 ​

本页复用官方 Go gallery 的真实示例。下方可以切换场景、主题和深浅色;长页面支持滚动,复杂布局可以横向滚动或在独立页面打开。

ThoughtChain 思考链 · 在线体验真实 Go 组件
在独立页面打开 ↗

查看此场景的 Go 源码 ↗

示例代码 ​

以下是上方在线演示运行的 Go 源码(来自官方 gallery),点击标题展开。函数接收的 c *ui.Context 由窗口的 UI 循环每帧传入,接入方式见 Go GUI 入门。

ThoughtChain 思考链

gallery 演示 ThoughtChain 的具名 Render 函数,源码 page_chat.go#L203。

加载中…

API ​

签名与说明由 site/tools/compdoc 从 Go 源码和文档注释提取;点击名称跳到 Go API 参考 的对应条目。

入口函数 ​

ui.ThoughtChain ​

go
func ThoughtChain(c *Context, items []ChainItem) *ThoughtChainW

ThoughtChain adds a chain of steps.

ui.ThoughtChain(c, steps).Title("思考过程").Card()

返回 *ThoughtChainW,可链式调用的方法见 ThoughtChainW 方法。

ThoughtChainW 方法 ​

ui.ThoughtChainW:ThoughtChainW is a vertical chain of steps with status icons, durations and collapsible details, optionally under a collapsible title.

方法说明签名
CardCard draws the chain inside a bordered card.Card() *ThoughtChainW
DefaultCollapsedDefaultCollapsed starts with the steps hidden (needs Title).DefaultCollapsed() *ThoughtChainW
ExpandedExpanded reports whether the steps are shown.Expanded() bool
ItemToggledItemToggled returns the key of the step whose detail was opened or closed this frame.ItemToggled() (string, bool)
LayoutLayout applies layout options to the chain.Layout(opts ...layout.Option) *ThoughtChainW
TitleTitle adds a header that collapses the chain and shows its progress.Title(s string) *ThoughtChainW
ToggledToggled reports a click on the title this frame.Toggled() bool

ChainItem 参数类型 ​

ui.ChainItem:ChainItem is one step of a ThoughtChain.

字段说明类型
Keystable key (default: the index)string
Titlestring
Descriptionsecondary line under the titlestring
StatusChainStatus
Durationshown at the end (0: hidden)time.Duration
Starteda running step shows the time elapsed since thentime.Time
Detailcollapsible Markdown detailstring
Contentcollapsible custom detail (instead of Detail)func()

相关链接 ​

本页由完整组件表、实际 gallery 注册信息和 Go 源码(site/tools/compdoc)生成;新增组件未接入演示时,文档构建会报错。场景中的表单、表格、图表和移动端屏幕使用示例数据。

以 MIT 许可发布