思维链

一个可折叠组件,可视化 AI 推理步骤,支持搜索结果、图片和逐步进度指示器。

ChainOfThought 组件提供了 AI 推理过程的可视化表示,显示逐步思考,支持搜索结果、图片和进度指示器。它帮助用户理解 AI 如何得出结论。

Install using CLI

AI Elements Vue
shadcn-vue CLI
npx ai-elements-vue@latest add chain-of-thought

Install Manually

Copy and paste the following files into the same folder.

ChainOfThought.vue
ChainOfThoughtHeader.vue
ChainOfThoughtStep.vue
ChainOfThoughtSearchResults.vue
ChainOfThoughtSearchResult.vue
ChainOfThoughtContent.vue
ChainOfThoughtImage.vue
context.ts
index.ts
<script setup lang="ts">
import type { HTMLAttributes, Ref } from 'vue'
import { cn } from '@repo/shadcn-vue/lib/utils'
import { useVModel } from '@vueuse/core'
import { provide } from 'vue'
import { ChainOfThoughtContextKey } from './context'

interface ChainOfThoughtProps {
  modelValue?: boolean
  defaultOpen?: boolean
  class?: HTMLAttributes['class']
}

const props = withDefaults(
  defineProps<ChainOfThoughtProps>(),
  {
    defaultOpen: false,
    modelValue: undefined,
  },
)

const emit = defineEmits<{
  (e: 'update:modelValue', value: boolean): void
}>()

const isOpen = useVModel(props, 'modelValue', emit, {
  defaultValue: props.defaultOpen,
  passive: true,
})

provide(ChainOfThoughtContextKey, isOpen as Ref<boolean>)
</script>

<template>
  <div
    :class="cn('not-prose max-w-prose space-y-4', props.class)"
    v-bind="$attrs"
  >
    <slot />
  </div>
</template>

特性

  • 可折叠界面,具有由 Reka UI 驱动的平滑动画
  • AI 推理过程的逐步可视化
  • 支持不同的步骤状态(完成、活动、待处理)
  • 内置搜索结果显示,带有徽章样式
  • 图片支持,带有视觉内容的标题
  • 不同步骤类型的自定义图标
  • 使用 Inject/Provide API 的上下文感知组件
  • 完全使用 TypeScript 类型化
  • 可访问,具有键盘导航支持
  • 响应式设计,适应不同的屏幕尺寸
  • 平滑的淡入淡出和滑动动画,用于内容过渡
  • 可组合架构,用于灵活的自定义

Props

<ChainOfThought />

defaultOpenboolean
思维链是否默认打开。
classstring
''
应用于组件的额外 CSS 类。

<ChainOfThoughtHeader />

classstring
''
应用于组件的额外 CSS 类。

<ChainOfThoughtStep />

labelstring
步骤的主要文本标签。
descriptionstring
在标签下方显示的可选描述文本。
status'complete' | 'active' | 'pending'
'complete'
步骤的可视状态。默认为 "complete"。
classstring
''
应用于组件的额外 CSS 类。

<ChainOfThoughtSearchResults />

classstring
''
应用于组件的额外 CSS 类。

<ChainOfThoughtSearchResult />

classstring
''
应用于组件的额外 CSS 类。

<ChainOfThoughtContent />

classstring
''
应用于组件的额外 CSS 类。

<ChainOfThoughtImage />

captionstring
在图片下方显示的可选标题文本。
classstring
''
应用于组件的额外 CSS 类。