|
4 | 4 | * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC |
5 | 5 | * */ |
6 | 6 | import { TdChatLoadingProps } from '../chat-loading/type'; |
7 | | -import { TdChatAttachmentsProps } from '../attachments/type'; |
| 7 | +import { TdChatAttachmentsProps, FileItem } from '../attachments/type'; |
8 | 8 |
|
9 | | -export type ChatContentType = 'text' | 'markdown' | 'search' | 'thinking' | 'suggestion' | 'attachment'; |
| 9 | +export type ChatContentType = |
| 10 | + | 'text' |
| 11 | + | 'markdown' |
| 12 | + | 'thinking' |
| 13 | + | 'attachment' |
10 | 14 |
|
11 | | -// todo: 下个版本 |
12 | | -// export interface TdChatMarkdownContentProps { |
13 | | -// content: string; |
14 | | -// [key: string]: any; |
15 | | -// } |
| 15 | +export type ChatMessageStatus = 'pending' | 'streaming' | 'complete' | 'stop' | 'error'; |
16 | 16 |
|
17 | | -// export interface TdChatContentSearchProps { |
18 | | -// query: string; |
19 | | -// results: any[]; |
20 | | -// [key: string]: any; |
21 | | -// } |
| 17 | +/** |
| 18 | + * 基础内容结构,所有内容类型都遵循此结构 |
| 19 | + */ |
| 20 | +export interface ChatBaseContent<T extends ChatContentType, TData> { |
| 21 | + type: T; |
| 22 | + data: TData; |
| 23 | +} |
| 24 | + |
| 25 | +/** |
| 26 | + * 思考内容数据结构 |
| 27 | + */ |
| 28 | +export interface ThinkingContentData { |
| 29 | + /** |
| 30 | + * 思考标题 |
| 31 | + */ |
| 32 | + title?: string; |
| 33 | + /** |
| 34 | + * 思考内容文本 |
| 35 | + */ |
| 36 | + text: string; |
| 37 | +} |
| 38 | + |
| 39 | +/** |
| 40 | + * 文本内容类型 |
| 41 | + */ |
| 42 | +export type TextContent = ChatBaseContent<'text', string>; |
| 43 | + |
| 44 | +/** |
| 45 | + * Markdown内容类型 |
| 46 | + */ |
| 47 | +export type MarkdownContent = ChatBaseContent<'markdown', string>; |
| 48 | + |
| 49 | +/** |
| 50 | + * 思考内容类型 |
| 51 | + */ |
| 52 | +export type ThinkingContent = ChatBaseContent<'thinking', ThinkingContentData>; |
| 53 | + |
| 54 | +/** |
| 55 | + * 附件内容类型 |
| 56 | + */ |
| 57 | +export type AttachmentContent = ChatBaseContent<'attachment', FileItem[]>; |
| 58 | + |
| 59 | +/** |
| 60 | + * 消息内容联合类型 |
| 61 | + */ |
| 62 | +export type MessageContent = TextContent | MarkdownContent | ThinkingContent | AttachmentContent; |
22 | 63 |
|
23 | 64 | export type TdChatContentThinkProps = { |
24 | 65 | maxHeight?: number; |
25 | 66 | animation?: TdChatLoadingProps['animation']; |
26 | 67 | collapsed?: boolean; |
27 | 68 | layout?: 'block' | 'border'; |
| 69 | + status?: 'pending' | 'complete' ; |
28 | 70 | }; |
29 | 71 |
|
30 | 72 | export type TdChatContentProps = { |
@@ -73,12 +115,14 @@ export interface TdChatMessageProps { |
73 | 115 | value?: 'base' | 'outline' | 'text'; |
74 | 116 | }; |
75 | 117 | /** |
76 | | - * 消息内容对象 todo: 需要完善 |
77 | | - * @default {} |
| 118 | + * 消息内容对象,支持多种内容类型的数组 |
| 119 | + * - 用户消息:TextContent | AttachmentContent |
| 120 | + * - AI消息:TextContent | MarkdownContent | ThinkingContent | AttachmentContent |
| 121 | + * @default [] |
78 | 122 | */ |
79 | 123 | content?: { |
80 | 124 | type: ArrayConstructor; |
81 | | - value?: Array<any>; |
| 125 | + value?: MessageContent[]; |
82 | 126 | }; |
83 | 127 | role?: { |
84 | 128 | type: StringConstructor; |
|
0 commit comments