+ {(props.items || []).map((item, index) => {
+ const status = item.status || 'pending';
+ const expanded = isExpanded(item, index);
+ const expandable = props.collapsible && Boolean(item.content);
+ const title = renderTNodeJSX('title', { params: { item, index } }) ?? renderItemNode(item.title);
+ const content = renderTNodeJSX('content', { params: { item, index } }) ?? renderItemNode(item.content);
+ return (
+
+
+ {renderIcon(item, index)}
+ {index < (props.items || []).length - 1 && }
+
+
+
toggleExpand(item, index)}
+ >
+ {title}
+ {expandable && }
+
+ {item.content && expanded &&
{content}
}
+
+
+ );
+ })}
+
+ );
+ },
+});
diff --git a/packages/pro-components/chat/chat-thought-chain/index.ts b/packages/pro-components/chat/chat-thought-chain/index.ts
new file mode 100644
index 0000000000..064c2bdb86
--- /dev/null
+++ b/packages/pro-components/chat/chat-thought-chain/index.ts
@@ -0,0 +1,2 @@
+import _ChatThoughtChain from './chat-thought-chain';
+export default _ChatThoughtChain;
diff --git a/packages/pro-components/chat/index.ts b/packages/pro-components/chat/index.ts
index 7aa47b75c8..84782cf3a3 100644
--- a/packages/pro-components/chat/index.ts
+++ b/packages/pro-components/chat/index.ts
@@ -5,6 +5,7 @@ import _ChatItem from './chat-item';
import _ChatInput from './chat-input';
import _ChatContent from './chat-content';
import _ChatReasoning from './chat-reasoning';
+import _ChatThoughtChain from './chat-thought-chain';
import _ChatLoading from './chat-loading';
import _ChatActionbar from './chat-actionbar';
@@ -28,6 +29,7 @@ import {
TdChatInputProps,
TdChatSenderProps,
TdChatReasoningProps,
+ TdChatThoughtChainProps,
TdChatLoadingProps,
} from './type';
@@ -46,6 +48,7 @@ export type ChatActionProps = TdChatActionProps;
export type ChatInputProps = TdChatInputProps;
export type ChatSenderProps = TdChatSenderProps;
export type ChatReasoningProps = TdChatReasoningProps;
+export type ChatThoughtChainProps = TdChatThoughtChainProps;
export type ChatLoadingProps = TdChatLoadingProps;
export const ChatList = withInstall(_ChatList);
@@ -63,6 +66,8 @@ export const ChatSuggestionContent = withInstall(ChatSuggestionContentComponent,
export const ChatMarkdown = withInstall(_ChatMarkdown, 't-chat-markdown');
+export const ChatThoughtChain = withInstall(_ChatThoughtChain);
+
// TODO:待下线的组件
export const Chat = withInstall(_ChatList); // 兼容历史版本,分别导出ChatList,Chat
export const ChatAction = withInstall(_ChatActionbar); // 兼容历史版本,分别导出ChatActionbar,ChatAction
@@ -93,6 +98,7 @@ export default {
app.use(ChatInput, config);
app.use(ChatItem, config);
app.use(ChatReasoning, config);
+ app.use(ChatThoughtChain, config);
app.component('TChat', Chat);
app.component('TChatAction', ChatAction);
},
diff --git a/packages/pro-components/chat/type.ts b/packages/pro-components/chat/type.ts
index ccd54a84b2..37276ce8c0 100644
--- a/packages/pro-components/chat/type.ts
+++ b/packages/pro-components/chat/type.ts
@@ -487,6 +487,71 @@ export interface UploadActionConfig {
action: (params: { files: File[]; name: UploadActionType; e?: Event }) => void;
}
+export type ThoughtChainItemStatus = 'pending' | 'processing' | 'success' | 'error';
+
+export interface TdThoughtChainItem {
+ /**
+ * 节点唯一标识,缺省时使用节点索引
+ */
+ key?: string | number;
+ /**
+ * 节点标题
+ */
+ title?: string | TNode;
+ /**
+ * 节点描述内容,为空时该节点不可展开
+ */
+ content?: string | TNode;
+ /**
+ * 节点状态,可选项:pending/processing/success/error
+ * @default pending
+ */
+ status?: ThoughtChainItemStatus;
+ /**
+ * 自定义节点图标,优先级高于 status 对应的默认图标
+ */
+ icon?: TNode;
+}
+
+export interface TdChatThoughtChainProps {
+ /**
+ * 是否支持折叠每个思考节点的内容
+ * @default true
+ */
+ collapsible?: boolean;
+ /**
+ * 思维链节点列表
+ */
+ items?: TdThoughtChainItem[];
+ /**
+ * 展开的节点。支持语法糖 v-model:expandedValue
+ */
+ expandedValue?: Array