@zero-library/chat-copilot 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/index.cjs.js +4868 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.css +503 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +1417 -0
- package/dist/index.d.ts +1417 -0
- package/dist/index.esm.js +4854 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/logo-BX4TAWHK.png +0 -0
- package/package.json +65 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1417 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default from 'react';
|
|
3
|
+
import { ButtonProps, ThemeConfig } from 'antd';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { createRequest, RequestConfig, RenderControl } from '@zero-library/common';
|
|
6
|
+
|
|
7
|
+
type ConversationMemberEnum = 'user' | 'agent';
|
|
8
|
+
declare enum AgentTypeEnum {
|
|
9
|
+
DEFAULT = 0,
|
|
10
|
+
FLOW = 1
|
|
11
|
+
}
|
|
12
|
+
declare enum LibraryTypeEnum {
|
|
13
|
+
DEFAULT = 0
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface VariableRule {
|
|
17
|
+
type: 'required' | 'email' | 'pattern' | 'max' | 'min' | 'length' | 'size' | 'enum';
|
|
18
|
+
value?: string | number | boolean;
|
|
19
|
+
message?: string;
|
|
20
|
+
}
|
|
21
|
+
interface Variable {
|
|
22
|
+
name: string;
|
|
23
|
+
type: 'STRING' | 'LONG' | 'NUMBER' | 'BOOLEAN' | 'FILE' | 'ARRAY_FILE' | 'OBJECT' | 'ARRAY' | 'ARRAY_STRING' | 'ARRAY_NUMBER' | 'ARRAY_DECIMAL' | 'ARRAY_BOOLEAN' | 'ARRAY_OBJECT';
|
|
24
|
+
value?: any;
|
|
25
|
+
enableEdit?: boolean;
|
|
26
|
+
rules?: VariableRule[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface ModelConfig {
|
|
30
|
+
providerName: string;
|
|
31
|
+
modelName: string;
|
|
32
|
+
reasoning: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface FileUploadConfig {
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
allowedTypes: string[];
|
|
37
|
+
maxSize: number;
|
|
38
|
+
maxCount: number;
|
|
39
|
+
}
|
|
40
|
+
interface AgentSpec {
|
|
41
|
+
model: ModelConfig;
|
|
42
|
+
knowledge: {
|
|
43
|
+
mode: number;
|
|
44
|
+
items: {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
}[];
|
|
48
|
+
};
|
|
49
|
+
skills: {
|
|
50
|
+
mode: number;
|
|
51
|
+
items: {
|
|
52
|
+
id: string;
|
|
53
|
+
}[];
|
|
54
|
+
};
|
|
55
|
+
systemPrompt: string;
|
|
56
|
+
userPrompt: string;
|
|
57
|
+
}
|
|
58
|
+
interface AgentConfig {
|
|
59
|
+
onboarding: {
|
|
60
|
+
greeting: string | null;
|
|
61
|
+
guiding: string[];
|
|
62
|
+
};
|
|
63
|
+
options: {
|
|
64
|
+
fileUpload?: FileUploadConfig;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
interface AgentInfo {
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
description: string;
|
|
71
|
+
iconUrl: string;
|
|
72
|
+
agentType: AgentTypeEnum;
|
|
73
|
+
updatedAt?: string;
|
|
74
|
+
tagIds?: string[];
|
|
75
|
+
spec?: AgentSpec;
|
|
76
|
+
config?: AgentConfig;
|
|
77
|
+
userInput?: Variable[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface UserInputType {
|
|
81
|
+
inputs: Variable[];
|
|
82
|
+
outputs: Variable[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 创建聊天服务
|
|
86
|
+
* @param request - 请求函数实例
|
|
87
|
+
* @returns 聊天服务对象
|
|
88
|
+
*/
|
|
89
|
+
declare const createChatService: (request: ReturnType<typeof createRequest>, config?: RequestConfig) => {
|
|
90
|
+
fetchAgentInfo: (agentId: string) => Promise<R<AgentInfo>>;
|
|
91
|
+
createConversationId: (params: ConversationCreate) => Promise<R<string>>;
|
|
92
|
+
fetchConversations: (params: ConversationsQuery) => Promise<R<ConversationType[]>>;
|
|
93
|
+
deleteConversation: (id: string) => Promise<R<string>>;
|
|
94
|
+
fetchMessages: (params: ConversationMessagesQuery) => Promise<R<ConversationMessage[]>>;
|
|
95
|
+
sendMessageStream: (params: ConversationMessageSend, agentId: string) => Promise<R<ConversationMessage[]>>;
|
|
96
|
+
cancelMessage: (executionId: string) => Promise<R<string>>;
|
|
97
|
+
getRecommendQuestions: (params: {
|
|
98
|
+
conversationId: string;
|
|
99
|
+
messageId: string;
|
|
100
|
+
}) => Promise<R<string[]>>;
|
|
101
|
+
getAgentUserInput: (agentId: string) => Promise<R<UserInputType>>;
|
|
102
|
+
feedbackUpdate: (params: FeedbackUpdate) => Promise<R<null>>;
|
|
103
|
+
chatUpload: (agentId: string, data: FormData, conversationId: string, signal?: AbortSignal) => Promise<R<InputFile[]>>;
|
|
104
|
+
getPreviewUrl: (agentId: string, conversationId: string, path: string) => string;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
type RequestInstance = ReturnType<typeof createChatService>;
|
|
108
|
+
/**
|
|
109
|
+
* 聊天HTTP服务配置接口
|
|
110
|
+
* 定义聊天组件所需的HTTP服务配置,用于API请求
|
|
111
|
+
*/
|
|
112
|
+
interface ChatHttpServices {
|
|
113
|
+
/**
|
|
114
|
+
* 基于axios扩展的配置参数
|
|
115
|
+
* 支持所有axios配置选项,如baseURL、timeout、headers等
|
|
116
|
+
* @see {@link RequestConfig}
|
|
117
|
+
*/
|
|
118
|
+
config?: RequestConfig;
|
|
119
|
+
/**
|
|
120
|
+
* 聊天服务和文件服务的合并请求对象(没有测试,暂时不使用)
|
|
121
|
+
* 可以提供自定义的请求实例,用于替代默认创建的实例
|
|
122
|
+
*/
|
|
123
|
+
request?: RequestInstance;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 聊天WebSocket服务配置接口
|
|
127
|
+
* 定义聊天组件所需的WebSocket服务配置,用于实时消息通信
|
|
128
|
+
*/
|
|
129
|
+
interface ChatWebsocketServices {
|
|
130
|
+
/**
|
|
131
|
+
* WebSocket连接基础URL列表,支持多地址容错(目前只支持两个地址)
|
|
132
|
+
*
|
|
133
|
+
* 使用方式:
|
|
134
|
+
* - undefined: 继承http.config.baseURL的值
|
|
135
|
+
* - []: 空数组表示关闭WebSocket功能
|
|
136
|
+
* - [url]: 单个URL用于WebSocket连接
|
|
137
|
+
* - [url1, url2]: 两个URL用于WebSocket连接,支持多端容错
|
|
138
|
+
*/
|
|
139
|
+
baseURLs?: (string | undefined)[];
|
|
140
|
+
/**
|
|
141
|
+
* WebSocket连接参数
|
|
142
|
+
* - undefined: 继承http.config.headers的值
|
|
143
|
+
* 附加到WebSocket URL上的查询参数
|
|
144
|
+
*/
|
|
145
|
+
params?: Record<string, string | number>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 聊天服务配置接口
|
|
149
|
+
* 定义聊天组件所需的所有服务配置,包括HTTP和WebSocket
|
|
150
|
+
* * @example
|
|
151
|
+
* // 基本配置,使用默认继承
|
|
152
|
+
* const services: ChatServices = {
|
|
153
|
+
* http: {
|
|
154
|
+
* config: {
|
|
155
|
+
* baseURL: '/api',
|
|
156
|
+
* timeout: 10000,
|
|
157
|
+
* headers: { 'NS-TOKEN': '123456' }
|
|
158
|
+
* }
|
|
159
|
+
* },
|
|
160
|
+
* websocket: {} // 继承http的baseURL和headers参数
|
|
161
|
+
* }
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* // 自定义WebSocket配置
|
|
165
|
+
* const services: ChatServices = {
|
|
166
|
+
* http: {
|
|
167
|
+
* config: { baseURL: '/api' }
|
|
168
|
+
* },
|
|
169
|
+
* websocket: {
|
|
170
|
+
* baseURLs: ['/api', '/api/saas'],
|
|
171
|
+
* params: { token: 'abc123' }
|
|
172
|
+
* }
|
|
173
|
+
* }
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* // 关闭WebSocket功能
|
|
177
|
+
* const services: ChatServices = {
|
|
178
|
+
* http: {
|
|
179
|
+
* config: { baseURL: '/api' }
|
|
180
|
+
* },
|
|
181
|
+
* websocket: {
|
|
182
|
+
* baseURLs: [] // 空数组表示关闭WebSocket
|
|
183
|
+
* }
|
|
184
|
+
* }
|
|
185
|
+
*/
|
|
186
|
+
interface ChatServices {
|
|
187
|
+
/** HTTP服务配置 */
|
|
188
|
+
http?: ChatHttpServices;
|
|
189
|
+
/** WebSocket服务配置 */
|
|
190
|
+
websocket?: ChatWebsocketServices;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* 会话策略类型
|
|
195
|
+
* 定义创建或获取会话的策略
|
|
196
|
+
*
|
|
197
|
+
* 取值说明:
|
|
198
|
+
* - 1: 最近会话策略 - 获取用户最近的会话继续对话
|
|
199
|
+
* - 2: 新会话策略 - 创建全新的会话开始对话
|
|
200
|
+
*/
|
|
201
|
+
type ConversationStrategy = 1 | 2;
|
|
202
|
+
/**
|
|
203
|
+
* 会话类型接口
|
|
204
|
+
*/
|
|
205
|
+
interface ConversationType {
|
|
206
|
+
agentId?: string;
|
|
207
|
+
agentVersionId?: string;
|
|
208
|
+
spec?: AgentSpec;
|
|
209
|
+
id: string;
|
|
210
|
+
title?: string;
|
|
211
|
+
updatedAt?: string;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* 创建会话类型接口
|
|
215
|
+
*/
|
|
216
|
+
interface ConversationCreate {
|
|
217
|
+
agentId: string;
|
|
218
|
+
convMeta: ConvMeta;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* 会话列表查询参数接口
|
|
222
|
+
*/
|
|
223
|
+
interface ConversationsQuery {
|
|
224
|
+
agentId: string;
|
|
225
|
+
convMeta?: ConvMeta;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* 会话消息查询参数接口
|
|
229
|
+
* 用于获取指定会话的消息列表
|
|
230
|
+
*/
|
|
231
|
+
interface ConversationMessagesQuery {
|
|
232
|
+
/** 会话ID */
|
|
233
|
+
conversationId: string;
|
|
234
|
+
}
|
|
235
|
+
interface ConvMeta {
|
|
236
|
+
/**
|
|
237
|
+
* 1 正常 2 debug
|
|
238
|
+
*/
|
|
239
|
+
mode?: number;
|
|
240
|
+
libraryId?: string;
|
|
241
|
+
source?: number;
|
|
242
|
+
libraryType?: LibraryTypeEnum;
|
|
243
|
+
skillConversationId?: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* 发送消息类型接口
|
|
248
|
+
* 定义发送到智能体的消息内容和可选文件
|
|
249
|
+
*/
|
|
250
|
+
interface ConversationMessageSend {
|
|
251
|
+
/** 会话ID */
|
|
252
|
+
conversationId?: string;
|
|
253
|
+
/** 消息内容 */
|
|
254
|
+
message: string;
|
|
255
|
+
convMeta?: ConvMeta;
|
|
256
|
+
/** 附件文件列表 */
|
|
257
|
+
files?: InputFile[];
|
|
258
|
+
/** 业务参数,透传到智能体的JSON字符串 */
|
|
259
|
+
params?: ObjectType<any>;
|
|
260
|
+
spec?: AgentSpec;
|
|
261
|
+
stream: boolean;
|
|
262
|
+
responseMode: number;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* 输入文件接口
|
|
266
|
+
* 定义聊天中上传文件的属性
|
|
267
|
+
*/
|
|
268
|
+
interface InputFile {
|
|
269
|
+
/** 文件id */
|
|
270
|
+
id: string;
|
|
271
|
+
/** 文件扩展名 */
|
|
272
|
+
ext: string;
|
|
273
|
+
/** 文件名 */
|
|
274
|
+
name: string;
|
|
275
|
+
/** 文件路径 */
|
|
276
|
+
path?: string;
|
|
277
|
+
/** 会话ID */
|
|
278
|
+
conversationId?: string;
|
|
279
|
+
/** 文件预览URL */
|
|
280
|
+
url?: string;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* 文件URL类型接口
|
|
284
|
+
* 定义通过URL访问的文件信息
|
|
285
|
+
*/
|
|
286
|
+
interface FileUrlType {
|
|
287
|
+
/** 文件名 */
|
|
288
|
+
fileName: string;
|
|
289
|
+
path: string;
|
|
290
|
+
fileUrl?: string;
|
|
291
|
+
ext?: string;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* 消息引用类型
|
|
295
|
+
* 用于消息回复时的引用信息
|
|
296
|
+
*/
|
|
297
|
+
interface MessageQuoteMsg {
|
|
298
|
+
/** 被引用的消息ID */
|
|
299
|
+
id?: string;
|
|
300
|
+
/** 被引用的消息内容 */
|
|
301
|
+
msgContent?: string;
|
|
302
|
+
/** 被引用消息的附件文件列表 */
|
|
303
|
+
msgFiles?: InputFile[];
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* 引用内容接口
|
|
307
|
+
* 扩展消息引用信息,支持更多引用格式
|
|
308
|
+
* @remarks
|
|
309
|
+
* 包含引用名称、引用内容、引用参数;
|
|
310
|
+
* SenderHeader显示顺序:name > msgContent > msgFiles
|
|
311
|
+
* MessageQuoteMsg显示顺序:quoteMsg > params.citation
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* // 引用文档片段
|
|
315
|
+
* const quote: ReferencesContent = {
|
|
316
|
+
* name: '法规条款',
|
|
317
|
+
* msgContent: '> 根据《企业所得税法》第XX条规定...',
|
|
318
|
+
* }
|
|
319
|
+
*/
|
|
320
|
+
interface ReferencesContent extends MessageQuoteMsg {
|
|
321
|
+
/** 引用名称 */
|
|
322
|
+
name?: string;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* 引用类型接口
|
|
326
|
+
* 定义消息引用的各种类型和参数
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* // Markdown引用(拼接到正文发送)
|
|
330
|
+
* const markdownRef: ReferencesType = {
|
|
331
|
+
* type: 1,
|
|
332
|
+
* content: {
|
|
333
|
+
* name: '法规摘要',
|
|
334
|
+
* msgContent: '> 根据相关规定...'
|
|
335
|
+
* },
|
|
336
|
+
* params: {
|
|
337
|
+
* source: 'law-001'
|
|
338
|
+
* }
|
|
339
|
+
* }
|
|
340
|
+
*
|
|
341
|
+
* // 文案引用(不发送正文)
|
|
342
|
+
* const textRef: ReferencesType = {
|
|
343
|
+
* type: 2,
|
|
344
|
+
* content: {
|
|
345
|
+
* name: '参考答案',
|
|
346
|
+
* },
|
|
347
|
+
* params: {
|
|
348
|
+
* citation: '建议按以下方式处理...'
|
|
349
|
+
* }
|
|
350
|
+
* }
|
|
351
|
+
*
|
|
352
|
+
* // 消息引用
|
|
353
|
+
* const messageRef: ReferencesType = {
|
|
354
|
+
* type: 3,
|
|
355
|
+
* content: {
|
|
356
|
+
* id: 'msg-001',
|
|
357
|
+
* msgContent: '之前的回答内容'
|
|
358
|
+
* }
|
|
359
|
+
* }
|
|
360
|
+
*/
|
|
361
|
+
interface ReferencesType {
|
|
362
|
+
/** 引用类型:1-Markdown引用(拼正文发) 2-文案引用(不发正文) 3-消息引用 */
|
|
363
|
+
type: number;
|
|
364
|
+
/** 引用内容 */
|
|
365
|
+
content: ReferencesContent;
|
|
366
|
+
/** 引用参数,最终透传大模型 */
|
|
367
|
+
params?: ObjectType<any>;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* 消息反馈更新接口
|
|
371
|
+
* 用于用户对消息进行赞/踩评价
|
|
372
|
+
*/
|
|
373
|
+
interface FeedbackUpdate {
|
|
374
|
+
/** 执行ID */
|
|
375
|
+
executionId: string;
|
|
376
|
+
/** 反馈类型:1-赞 2-踩 */
|
|
377
|
+
feedback: number;
|
|
378
|
+
/** 反馈内容描述,非必填 */
|
|
379
|
+
feedbackContent?: string;
|
|
380
|
+
}
|
|
381
|
+
interface RunStartedEvent {
|
|
382
|
+
type: 'runStarted';
|
|
383
|
+
title?: string;
|
|
384
|
+
show?: boolean;
|
|
385
|
+
}
|
|
386
|
+
interface TextEvent {
|
|
387
|
+
type: 'text';
|
|
388
|
+
text?: string;
|
|
389
|
+
messageContent?: string;
|
|
390
|
+
reasoningContent?: string;
|
|
391
|
+
}
|
|
392
|
+
interface FilesEvent {
|
|
393
|
+
type: 'files';
|
|
394
|
+
files: {
|
|
395
|
+
id: string;
|
|
396
|
+
name: string;
|
|
397
|
+
ext: string;
|
|
398
|
+
}[];
|
|
399
|
+
}
|
|
400
|
+
interface StepStartedEvent {
|
|
401
|
+
type: 'stepStarted';
|
|
402
|
+
stepId: string;
|
|
403
|
+
title: string;
|
|
404
|
+
}
|
|
405
|
+
interface StepFinishedEvent {
|
|
406
|
+
type: 'stepFinished';
|
|
407
|
+
title: string;
|
|
408
|
+
stepId?: string;
|
|
409
|
+
}
|
|
410
|
+
interface StepErrorEvent {
|
|
411
|
+
type: 'stepError';
|
|
412
|
+
stepId?: string;
|
|
413
|
+
title?: string;
|
|
414
|
+
errorMessage?: string;
|
|
415
|
+
}
|
|
416
|
+
interface RunFailedEvent {
|
|
417
|
+
type: 'runFailed';
|
|
418
|
+
errorMessage?: string;
|
|
419
|
+
}
|
|
420
|
+
interface RunFinishedEvent {
|
|
421
|
+
type: 'runFinished';
|
|
422
|
+
}
|
|
423
|
+
interface RunStoppedEvent {
|
|
424
|
+
type: 'runStopped';
|
|
425
|
+
}
|
|
426
|
+
interface ConversationNewTitleEvent {
|
|
427
|
+
type: 'conversationNewTitle';
|
|
428
|
+
title: string;
|
|
429
|
+
}
|
|
430
|
+
interface ToolCallEvent {
|
|
431
|
+
type: 'toolCall';
|
|
432
|
+
toolCallId?: string;
|
|
433
|
+
toolName?: string;
|
|
434
|
+
/** 工具图标 */
|
|
435
|
+
toolIcon?: string;
|
|
436
|
+
/** 工具调用标题 */
|
|
437
|
+
title?: string;
|
|
438
|
+
/** 工具执行内容 */
|
|
439
|
+
content?: string;
|
|
440
|
+
/** 工具调用参数 */
|
|
441
|
+
arguments?: any;
|
|
442
|
+
/** 执行状态 */
|
|
443
|
+
status?: 'pending' | 'running' | 'success' | 'error';
|
|
444
|
+
}
|
|
445
|
+
interface ToolResultEvent {
|
|
446
|
+
type: 'toolResult';
|
|
447
|
+
toolCallId?: string;
|
|
448
|
+
toolName?: string;
|
|
449
|
+
/** 工具图标 */
|
|
450
|
+
toolIcon?: string;
|
|
451
|
+
/** 工具调用标题 */
|
|
452
|
+
title?: string;
|
|
453
|
+
/** 工具执行内容 */
|
|
454
|
+
content?: string;
|
|
455
|
+
/** 工具执行结果 */
|
|
456
|
+
result?: any;
|
|
457
|
+
/** 执行状态 */
|
|
458
|
+
status?: 'pending' | 'running' | 'success' | 'error';
|
|
459
|
+
errorMessage?: string;
|
|
460
|
+
/** 耗时(ms) */
|
|
461
|
+
duration?: number;
|
|
462
|
+
}
|
|
463
|
+
interface A2uiCommandEvent {
|
|
464
|
+
type: 'a2uiCommand';
|
|
465
|
+
/** A2UI 协议命令体 */
|
|
466
|
+
command: Record<string, any>;
|
|
467
|
+
}
|
|
468
|
+
interface A2uiSchemaEvent {
|
|
469
|
+
type: 'a2uiSchema';
|
|
470
|
+
/** A2UI Schema 协议体(如 wizard_schema.v1) */
|
|
471
|
+
schema: Record<string, any>;
|
|
472
|
+
}
|
|
473
|
+
interface PlanEvent {
|
|
474
|
+
type: 'plan';
|
|
475
|
+
title?: string;
|
|
476
|
+
content?: string;
|
|
477
|
+
plan?: any;
|
|
478
|
+
}
|
|
479
|
+
type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent | StepFinishedEvent | StepErrorEvent | RunFinishedEvent | RunStoppedEvent | ConversationNewTitleEvent | ToolCallEvent | ToolResultEvent | RunFailedEvent | A2uiCommandEvent | A2uiSchemaEvent | PlanEvent;
|
|
480
|
+
/**
|
|
481
|
+
* 消息类型
|
|
482
|
+
* 定义智能体和用户之间的消息结构
|
|
483
|
+
*/
|
|
484
|
+
interface ConversationMessage {
|
|
485
|
+
messageId: string;
|
|
486
|
+
conversationId: string;
|
|
487
|
+
executionId: string;
|
|
488
|
+
role: number;
|
|
489
|
+
content: MessageEvent[];
|
|
490
|
+
files?: InputFile[];
|
|
491
|
+
/** 消息反馈:1-赞 2-踩 */
|
|
492
|
+
feedback?: number;
|
|
493
|
+
/** 透传参数 json字符串 */
|
|
494
|
+
params?: string;
|
|
495
|
+
/** 引用的消息信息 */
|
|
496
|
+
quoteMsg?: MessageQuoteMsg;
|
|
497
|
+
createdAt: string;
|
|
498
|
+
/** 是否被打断标志 */
|
|
499
|
+
stopFlag?: boolean;
|
|
500
|
+
/** 是否正在生成中 */
|
|
501
|
+
generating?: boolean;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* 提供外部操作聊天组件的方法
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* // 使用ref调用组件方法
|
|
509
|
+
* const chatRef = useRef<ChatHandle>(null)
|
|
510
|
+
* // 在组件中使用
|
|
511
|
+
* <Chat ref={chatRef} config={chatConfig} />
|
|
512
|
+
*
|
|
513
|
+
* // 发送消息
|
|
514
|
+
* chatRef.current?.sendMessage('你好,帮我分析一下这份报表')
|
|
515
|
+
*
|
|
516
|
+
* // 切换智能体会话
|
|
517
|
+
* chatRef.current?.switchAgentConversation('agent-002')
|
|
518
|
+
*
|
|
519
|
+
* // 创建新会话
|
|
520
|
+
* chatRef.current?.createConversation()
|
|
521
|
+
*
|
|
522
|
+
* // 设置引用内容
|
|
523
|
+
* chatRef.current?.setReferences({
|
|
524
|
+
* type: 1,
|
|
525
|
+
* content: {
|
|
526
|
+
* name: '法规条款',
|
|
527
|
+
* msgContent: '> 根据《企业所得税法》第XX条规定...'
|
|
528
|
+
* }
|
|
529
|
+
* })
|
|
530
|
+
*
|
|
531
|
+
* // 聚焦输入框
|
|
532
|
+
* chatRef.current?.senderFocus()
|
|
533
|
+
*/
|
|
534
|
+
interface ChatHandle {
|
|
535
|
+
/** 发送消息
|
|
536
|
+
* @param message - 消息内容,如果提供则直接发送该内容,否则使用输入框内容, 且两者必须存在一个
|
|
537
|
+
* @param files - 文件列表,与消息一起发送的文件
|
|
538
|
+
* @param params - 透传给大模型的参数,用于控制模型行为
|
|
539
|
+
*
|
|
540
|
+
* @remarks
|
|
541
|
+
* 1. 传参调用则只会将参数直接传入接口,不会影响当前输入框数据
|
|
542
|
+
* 2. 参数为空则触发默认逻辑,收集输入框数据、引用等内容发送
|
|
543
|
+
* 3. 如果基于1想发送引用等内容,可以调用setMessage(message)-->sendMessage()
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* // 直接发送消息(不影响输入框)
|
|
547
|
+
* chatRef.current?.sendMessage('你好,帮我分析一下这份报表')
|
|
548
|
+
*
|
|
549
|
+
* @example
|
|
550
|
+
* // 触发默认逻辑(收集输入框内容发送)
|
|
551
|
+
* chatRef.current?.sendMessage()
|
|
552
|
+
*/
|
|
553
|
+
sendMessage: (message?: string, files?: InputFile[], params?: ObjectType<any>) => void;
|
|
554
|
+
/**
|
|
555
|
+
* 切换到指定的会话
|
|
556
|
+
*
|
|
557
|
+
* @param item - 目标会话
|
|
558
|
+
* @param strategy - 策略
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* // 切换到指定会话
|
|
562
|
+
* chatRef.current?.switchConversation(item)
|
|
563
|
+
*/
|
|
564
|
+
switchConversation: (id: ConversationType['id']) => Promise<void>;
|
|
565
|
+
/**
|
|
566
|
+
* 基于当前接收者创建新的会话
|
|
567
|
+
*
|
|
568
|
+
* @example
|
|
569
|
+
* // 创建新会话
|
|
570
|
+
* chatRef.current?.createConversation()
|
|
571
|
+
*/
|
|
572
|
+
createConversation: () => Promise<void>;
|
|
573
|
+
/**
|
|
574
|
+
* 设置引用消息
|
|
575
|
+
* 在输入框中设置引用内容,将在下次发送消息时包含引用信息
|
|
576
|
+
*
|
|
577
|
+
* @param references - 引用内容对象, 空则表示清除引用消息
|
|
578
|
+
*
|
|
579
|
+
* @example
|
|
580
|
+
* // 设置Markdown引用
|
|
581
|
+
* chatRef.current?.setReferences({
|
|
582
|
+
* type: 1,
|
|
583
|
+
* content: {
|
|
584
|
+
* name: '法规条款',
|
|
585
|
+
* msgContent: '> 根据《企业所得税法》第XX条规定...'
|
|
586
|
+
* },
|
|
587
|
+
* params: {
|
|
588
|
+
* source: 'law-001'
|
|
589
|
+
* }
|
|
590
|
+
* })
|
|
591
|
+
*
|
|
592
|
+
* @example
|
|
593
|
+
* // 清除引用
|
|
594
|
+
* chatRef.current?.setReferences()
|
|
595
|
+
*/
|
|
596
|
+
/**
|
|
597
|
+
* 直接设置输入框中的文本内容
|
|
598
|
+
*
|
|
599
|
+
* @param message - 要设置的消息内容
|
|
600
|
+
*
|
|
601
|
+
* @example
|
|
602
|
+
* // 设置输入框内容
|
|
603
|
+
* chatRef.current?.setMessage('请帮我分析以下问题...')
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* // 清空输入框
|
|
607
|
+
* chatRef.current?.setMessage('')
|
|
608
|
+
*/
|
|
609
|
+
setMessage: (message?: string) => void;
|
|
610
|
+
/**
|
|
611
|
+
* 设置消息内容参数
|
|
612
|
+
* 用于设置透传给大模型的参数,这些参数将在下一次发送消息时生效,并在发送后自动清空
|
|
613
|
+
*
|
|
614
|
+
* @param params - 消息参数对象,将传递给大模型
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* // 设置消息参数
|
|
618
|
+
* chatRef.current?.setMessageParams({
|
|
619
|
+
* citation: '税务局',
|
|
620
|
+
* customParam: 'customValue'
|
|
621
|
+
* })
|
|
622
|
+
*/
|
|
623
|
+
setMessageParams: (params?: ObjectType<any>) => void;
|
|
624
|
+
/**
|
|
625
|
+
* 设置输入框中要上传的文件列表
|
|
626
|
+
*
|
|
627
|
+
* @param files - 文件列表
|
|
628
|
+
*
|
|
629
|
+
* @example
|
|
630
|
+
* // 设置文件列表
|
|
631
|
+
* chatRef.current?.setFiles([
|
|
632
|
+
* {
|
|
633
|
+
* fileId: 'file-001',
|
|
634
|
+
* fileName: '财务报表.xlsx',
|
|
635
|
+
* fileUrl: '/files/report.xlsx'
|
|
636
|
+
* }
|
|
637
|
+
* ])
|
|
638
|
+
*
|
|
639
|
+
* @example
|
|
640
|
+
* // 清空文件列表
|
|
641
|
+
* chatRef.current?.setFiles([])
|
|
642
|
+
*/
|
|
643
|
+
setFiles: (files?: InputFile[]) => void;
|
|
644
|
+
/**
|
|
645
|
+
* 设置全局参数
|
|
646
|
+
* 更新聊天组件运行时需要的参数
|
|
647
|
+
*
|
|
648
|
+
* @param params - 聊天参数对象
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* // 设置业务参数
|
|
652
|
+
* chatRef.current?.setParams({
|
|
653
|
+
* businessId: 'case-001',
|
|
654
|
+
* businessType: 2,
|
|
655
|
+
* source: 1
|
|
656
|
+
* })
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* // 设置扩展参数, 透传大模型
|
|
660
|
+
* chatRef.current?.setParams({
|
|
661
|
+
* params: {
|
|
662
|
+
* citation: '税务局',
|
|
663
|
+
* }
|
|
664
|
+
* })
|
|
665
|
+
*/
|
|
666
|
+
setParams: (params: ObjectType<any>) => void;
|
|
667
|
+
/**
|
|
668
|
+
* 设置服务配置
|
|
669
|
+
* 动态更新聊天组件的服务配置
|
|
670
|
+
*
|
|
671
|
+
* @param services - 服务配置对象
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* // 更新HTTP配置,WebSocket继承
|
|
675
|
+
* chatRef.current?.setServices({
|
|
676
|
+
* http: {
|
|
677
|
+
* config: {
|
|
678
|
+
* baseURL: '/new-api',
|
|
679
|
+
* headers: {
|
|
680
|
+
* token: 'new-token'
|
|
681
|
+
* }
|
|
682
|
+
* }
|
|
683
|
+
* }
|
|
684
|
+
* })
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* // 更新WebSocket配置,http使用默认
|
|
688
|
+
* chatRef.current?.setServices({
|
|
689
|
+
* websocket: {
|
|
690
|
+
* baseURLs: ['/api', '/api/backup'],
|
|
691
|
+
* params: {
|
|
692
|
+
* token: 'new-token'
|
|
693
|
+
* }
|
|
694
|
+
* }
|
|
695
|
+
* })
|
|
696
|
+
*/
|
|
697
|
+
setServices: (services?: ChatServices) => void;
|
|
698
|
+
/**
|
|
699
|
+
* 输入框聚焦(如果前一步是设置message,最好加个延时)
|
|
700
|
+
* 使聊天输入框获得焦点
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* // 聚焦输入框
|
|
704
|
+
* chatRef.current?.senderFocus()
|
|
705
|
+
*/
|
|
706
|
+
senderFocus: ChatSenderHandle['focus'];
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* 聊天组件生命周期钩子接口
|
|
711
|
+
* 定义聊天组件在各种事件发生时的回调函数
|
|
712
|
+
* @example
|
|
713
|
+
* // 完整的钩子配置示例
|
|
714
|
+
* const hooks: ChatHooks = {
|
|
715
|
+
* onBeforeInit: () => {
|
|
716
|
+
* console.log('聊天组件初始化前')
|
|
717
|
+
* },
|
|
718
|
+
* onAfterInit: () => {
|
|
719
|
+
* console.log('聊天组件初始化后')
|
|
720
|
+
* },
|
|
721
|
+
* onBeforeSend: (message, files) => {
|
|
722
|
+
* // 验证消息内容
|
|
723
|
+
* if (!message?.trim()) {
|
|
724
|
+
* message.error('请输入消息内容')
|
|
725
|
+
* return false // 阻止发送
|
|
726
|
+
* }
|
|
727
|
+
* return true // 允许发送
|
|
728
|
+
* },
|
|
729
|
+
* onAfterSend: () => {
|
|
730
|
+
* console.log('消息发送完成')
|
|
731
|
+
* },
|
|
732
|
+
* onRequestInterceptor: [
|
|
733
|
+
* (config) => {
|
|
734
|
+
* // 添加认证头
|
|
735
|
+
* config.headers.Authorization = `Bearer ${tokenManager.get()}`
|
|
736
|
+
* return config
|
|
737
|
+
* },
|
|
738
|
+
* (error) => {
|
|
739
|
+
* console.error('请求错误:', error)
|
|
740
|
+
* return Promise.reject(error)
|
|
741
|
+
* }
|
|
742
|
+
* ],
|
|
743
|
+
* ...
|
|
744
|
+
* }
|
|
745
|
+
*/
|
|
746
|
+
interface ChatHooks {
|
|
747
|
+
/**
|
|
748
|
+
* 初始化前回调
|
|
749
|
+
* 在聊天组件初始化之前调用
|
|
750
|
+
*
|
|
751
|
+
* @example
|
|
752
|
+
* onBeforeInit: () => {
|
|
753
|
+
* console.log('准备初始化聊天组件')
|
|
754
|
+
* }
|
|
755
|
+
*/
|
|
756
|
+
onBeforeInit?: () => void;
|
|
757
|
+
/**
|
|
758
|
+
* 初始化后回调
|
|
759
|
+
* 在聊天组件初始化完成后调用
|
|
760
|
+
*
|
|
761
|
+
* @example
|
|
762
|
+
* onAfterInit: () => {
|
|
763
|
+
* console.log('聊天组件初始化完成')
|
|
764
|
+
* }
|
|
765
|
+
*/
|
|
766
|
+
onAfterInit?: () => void;
|
|
767
|
+
/**
|
|
768
|
+
* 输入框聚焦回调
|
|
769
|
+
* 当输入框获得焦点时调用
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* onSenderFocus: () => {
|
|
773
|
+
* console.log('输入框获得焦点')
|
|
774
|
+
* }
|
|
775
|
+
*/
|
|
776
|
+
onSenderFocus?: () => void;
|
|
777
|
+
/**
|
|
778
|
+
* 头部关闭回调
|
|
779
|
+
* 当聊天窗口头部关闭按钮被点击时调用
|
|
780
|
+
*
|
|
781
|
+
* @example
|
|
782
|
+
* onHeaderClose: () => {
|
|
783
|
+
* console.log('聊天窗口关闭')
|
|
784
|
+
* // 可以在这里执行清理操作
|
|
785
|
+
* }
|
|
786
|
+
*/
|
|
787
|
+
onHeaderClose?: () => void;
|
|
788
|
+
/**
|
|
789
|
+
* 发送消息前回调
|
|
790
|
+
* 在消息发送前调用,返回false可阻止发送
|
|
791
|
+
*
|
|
792
|
+
* @param message - 要发送的消息内容
|
|
793
|
+
* @param files - 要发送的文件列表
|
|
794
|
+
* @returns boolean | Promise<boolean> | void - 返回false阻止发送
|
|
795
|
+
*
|
|
796
|
+
* @example
|
|
797
|
+
* onBeforeSend: (message, files) => {
|
|
798
|
+
* // 检查消息长度
|
|
799
|
+
* if (message.length > 1000) {
|
|
800
|
+
* message.error('消息内容过长')
|
|
801
|
+
* return false
|
|
802
|
+
* }
|
|
803
|
+
* return true
|
|
804
|
+
* }
|
|
805
|
+
*/
|
|
806
|
+
onBeforeSend?: (message: ConversationMessageSend['message'], files: InputFile[]) => boolean | Promise<boolean> | void;
|
|
807
|
+
/**
|
|
808
|
+
* 发送消息后回调
|
|
809
|
+
* 在消息发送完成后调用
|
|
810
|
+
*
|
|
811
|
+
* @example
|
|
812
|
+
* onAfterSend: () => {
|
|
813
|
+
* console.log('消息发送完成')
|
|
814
|
+
* // 可以在这里执行后续操作,如滚动到底部
|
|
815
|
+
* }
|
|
816
|
+
*/
|
|
817
|
+
onAfterSend?: () => void;
|
|
818
|
+
/**
|
|
819
|
+
* A2UI 组件事件回调
|
|
820
|
+
* 当用户在 A2UI 渲染界面内触发动作(如按钮点击)时触发
|
|
821
|
+
*/
|
|
822
|
+
onA2uiAction?: (payload: {
|
|
823
|
+
name: string;
|
|
824
|
+
surfaceId: string;
|
|
825
|
+
context: Record<string, any>;
|
|
826
|
+
}) => void | Promise<void>;
|
|
827
|
+
/**
|
|
828
|
+
* 切换智能体前回调
|
|
829
|
+
* 在切换智能体前调用,返回false可阻止切换
|
|
830
|
+
*
|
|
831
|
+
* @param agentId - 目标智能体ID
|
|
832
|
+
* @returns boolean | Promise<boolean> | void - 返回false阻止切换
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
* onBeforeSwitchAgent: (agentId) => {
|
|
836
|
+
* // 检查智能体权益
|
|
837
|
+
* }
|
|
838
|
+
*/
|
|
839
|
+
onBeforeSwitchAgent?: (agentId: string) => boolean | Promise<boolean> | void;
|
|
840
|
+
/**
|
|
841
|
+
* 切换智能体后回调
|
|
842
|
+
* 在切换智能体完成后调用
|
|
843
|
+
*
|
|
844
|
+
* @param agent - 新的智能体信息
|
|
845
|
+
*
|
|
846
|
+
* @example
|
|
847
|
+
* onAfterSwitchAgent: (agent) => {
|
|
848
|
+
* console.log(`已切换到智能体: ${agent.agentName}`)
|
|
849
|
+
* // 可以在这里获取最新的智能体
|
|
850
|
+
* }
|
|
851
|
+
*/
|
|
852
|
+
onAfterSwitchAgent?: (agent: AgentInfo) => void;
|
|
853
|
+
/**
|
|
854
|
+
* 切换会话前回调
|
|
855
|
+
* 在切换会话前调用,返回false可阻止切换
|
|
856
|
+
*
|
|
857
|
+
* @param conversationId - 目标会话ID
|
|
858
|
+
* @returns boolean | Promise<boolean> | void - 返回false阻止切换
|
|
859
|
+
*
|
|
860
|
+
* @example
|
|
861
|
+
* onBeforeSwitchConversation: (conversationId) => {
|
|
862
|
+
* // 检查当前会话状态
|
|
863
|
+
* if (isSendingMessage) {
|
|
864
|
+
* message.warning('正在发送消息,请稍后再切换会话')
|
|
865
|
+
* return false
|
|
866
|
+
* }
|
|
867
|
+
* return true
|
|
868
|
+
* }
|
|
869
|
+
*/
|
|
870
|
+
onBeforeSwitchConversation?: (conversationId: string) => boolean | Promise<boolean> | void;
|
|
871
|
+
/**
|
|
872
|
+
* 在切换会话完成后调用
|
|
873
|
+
*
|
|
874
|
+
* @param conversationId - 新的会话ID
|
|
875
|
+
*
|
|
876
|
+
* @example
|
|
877
|
+
* onAfterSwitchConversation: (conversationId) => {
|
|
878
|
+
* console.log(`已切换到会话: ${conversationId}`)
|
|
879
|
+
* // 可以在这里更新界面状态
|
|
880
|
+
* }
|
|
881
|
+
*/
|
|
882
|
+
onAfterSwitchConversation?: (conversationId: string) => void;
|
|
883
|
+
/**
|
|
884
|
+
* 初始化消息前回调
|
|
885
|
+
* 在初始化消息列表前调用,返回false可阻止初始化
|
|
886
|
+
*
|
|
887
|
+
* @param conversationId - 会话ID
|
|
888
|
+
* @returns boolean | Promise<boolean> | void - 返回false阻止初始化
|
|
889
|
+
*
|
|
890
|
+
* @example
|
|
891
|
+
* onBeforeInitMessages: (conversationId) => {
|
|
892
|
+
* // 检查会话权限
|
|
893
|
+
* if (!hasPermission(conversationId)) {
|
|
894
|
+
* message.error('无权访问此会话')
|
|
895
|
+
* return false
|
|
896
|
+
* }
|
|
897
|
+
* return true
|
|
898
|
+
* }
|
|
899
|
+
*/
|
|
900
|
+
onBeforeInitMessages?: (conversationId: string) => boolean | Promise<boolean> | void;
|
|
901
|
+
/**
|
|
902
|
+
* 初始化消息后回调
|
|
903
|
+
* 在初始化消息列表完成后调用
|
|
904
|
+
*
|
|
905
|
+
* @param messages - 初始化的消息列表
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* onAfterInitMessages: (messages) => {
|
|
909
|
+
* console.log(`加载了 ${messages.length} 条消息`)
|
|
910
|
+
* // 可以在这里执行消息分析等操作
|
|
911
|
+
* }
|
|
912
|
+
*/
|
|
913
|
+
onAfterInitMessages?: (messages: ConversationMessage[]) => void;
|
|
914
|
+
/**
|
|
915
|
+
* 删除会话前回调
|
|
916
|
+
* 在删除会话前调用,返回false可阻止删除
|
|
917
|
+
*
|
|
918
|
+
* @param conversationId - 要删除的会话ID
|
|
919
|
+
* @returns boolean | Promise<boolean> | void - 返回false阻止删除
|
|
920
|
+
*
|
|
921
|
+
* @example
|
|
922
|
+
* onBeforeDelConversation: (conversationId) => {
|
|
923
|
+
* window.confirm('确定要删除此会话吗?删除后无法恢复。')
|
|
924
|
+
* return confirm
|
|
925
|
+
* }
|
|
926
|
+
*/
|
|
927
|
+
onBeforeDelConversation?: (conversationId: string) => boolean | Promise<boolean> | void;
|
|
928
|
+
/**
|
|
929
|
+
* 在删除会话完成后调用
|
|
930
|
+
*
|
|
931
|
+
* @param conversationId - 已删除的会话ID
|
|
932
|
+
* @param isCurrentConversation - 是否为当前会话
|
|
933
|
+
*
|
|
934
|
+
* @example
|
|
935
|
+
* onAfterDelConversation: (conversationId, isCurrentConversation) => {
|
|
936
|
+
* console.log(`会话 ${conversationId} 已删除`)
|
|
937
|
+
* if (isCurrentConversation) {
|
|
938
|
+
* // 当前会话被删除,可能需要切换到其他会话
|
|
939
|
+
* }
|
|
940
|
+
* }
|
|
941
|
+
*/
|
|
942
|
+
onAfterDelConversation?: (conversationId: string, isCurrentConversation: boolean) => void;
|
|
943
|
+
/**
|
|
944
|
+
* 接收消息前回调
|
|
945
|
+
* 在接收到WebSocket消息后调用,返回false可阻止渲染
|
|
946
|
+
*
|
|
947
|
+
* @param message - 接收到的消息
|
|
948
|
+
* @returns boolean | Promise<boolean> | void - 返回false阻止渲染
|
|
949
|
+
*
|
|
950
|
+
* @example
|
|
951
|
+
* onBeforeAcceptMessage: (message) => {
|
|
952
|
+
* // 过滤特定类型的消息
|
|
953
|
+
* if (message.type === 'SYSTEM_NOTIFICATION') {
|
|
954
|
+
* handleSystemNotification(message)
|
|
955
|
+
* return false // 不在聊天界面显示
|
|
956
|
+
* }
|
|
957
|
+
* return true
|
|
958
|
+
* }
|
|
959
|
+
*/
|
|
960
|
+
onBeforeAcceptMessage?: (message: ConversationMessage) => boolean | Promise<boolean> | void;
|
|
961
|
+
/**
|
|
962
|
+
* 在接收到WebSocket消息并处理完成后调用
|
|
963
|
+
*
|
|
964
|
+
* @param message - 处理完成的消息
|
|
965
|
+
*
|
|
966
|
+
* @example
|
|
967
|
+
* onAfterAcceptMessage: (message) => {
|
|
968
|
+
* console.log('收到新消息:', message)
|
|
969
|
+
* // 可以在这里执行消息通知等操作
|
|
970
|
+
* }
|
|
971
|
+
*/
|
|
972
|
+
onAfterAcceptMessage?: (message: ConversationMessage) => void;
|
|
973
|
+
/**
|
|
974
|
+
* HTTP 请求拦截器
|
|
975
|
+
* 在每个HTTP请求发送前调用,可用于修改请求配置、添加认证头等
|
|
976
|
+
*
|
|
977
|
+
* 拦截器数组包含两个函数:
|
|
978
|
+
* 1. 第一个函数:处理成功的请求配置
|
|
979
|
+
* - 参数:当前请求配置对象
|
|
980
|
+
* - 返回:修改后的请求配置对象或Promise
|
|
981
|
+
* 2. 第二个函数:处理请求错误
|
|
982
|
+
* - 参数:错误对象
|
|
983
|
+
* - 返回:错误处理结果或Promise
|
|
984
|
+
*
|
|
985
|
+
* @example
|
|
986
|
+
* // 添加认证头和日志
|
|
987
|
+
* onRequestInterceptor: [
|
|
988
|
+
* (config) => {
|
|
989
|
+
* // 添加认证头
|
|
990
|
+
* config.headers.Authorization = `Bearer ${tokenManager.get()}`
|
|
991
|
+
* console.log('发送请求:', config)
|
|
992
|
+
* return config
|
|
993
|
+
* },
|
|
994
|
+
* (error) => {
|
|
995
|
+
* // 处理请求错误
|
|
996
|
+
* console.error('请求错误:', error)
|
|
997
|
+
* return Promise.reject(error)
|
|
998
|
+
* }
|
|
999
|
+
* ]
|
|
1000
|
+
*/
|
|
1001
|
+
onRequestInterceptor?: [(config: RequestConfig) => RequestConfig | Promise<RequestConfig>, (error: any) => any];
|
|
1002
|
+
/**
|
|
1003
|
+
* HTTP 响应拦截器
|
|
1004
|
+
* 在每个HTTP响应返回后调用,可用于处理响应数据或错误
|
|
1005
|
+
*
|
|
1006
|
+
* 拦截器数组包含两个函数:
|
|
1007
|
+
* 1. 第一个函数:处理成功的响应
|
|
1008
|
+
* - 参数:响应对象
|
|
1009
|
+
* - 返回:处理后的响应数据或Promise
|
|
1010
|
+
* 2. 第二个函数:处理响应错误
|
|
1011
|
+
* - 参数:错误对象
|
|
1012
|
+
* - 返回:错误处理结果或Promise
|
|
1013
|
+
*
|
|
1014
|
+
* @example
|
|
1015
|
+
* // 统一处理响应和错误
|
|
1016
|
+
* onResponseInterceptor: [
|
|
1017
|
+
* (response) => {
|
|
1018
|
+
* // 统一处理业务错误
|
|
1019
|
+
* if (response.data.code !== 200) {
|
|
1020
|
+
* message.error(response.data.message)
|
|
1021
|
+
* }
|
|
1022
|
+
* return response.data
|
|
1023
|
+
* },
|
|
1024
|
+
* (error) => {
|
|
1025
|
+
* // 统一处理HTTP错误
|
|
1026
|
+
* if (error?.response?.status === 401) {
|
|
1027
|
+
* // 未授权,跳转登录
|
|
1028
|
+
* onRedirectLogin?.()
|
|
1029
|
+
* }
|
|
1030
|
+
* return Promise.reject(error)
|
|
1031
|
+
* }
|
|
1032
|
+
* ]
|
|
1033
|
+
*/
|
|
1034
|
+
onResponseInterceptor?: [(response: any) => any | Promise<any>, (error: any) => any];
|
|
1035
|
+
/**
|
|
1036
|
+
* 重定向到登录页面回调函数
|
|
1037
|
+
* 当用户未授权或认证失败时调用,用于执行跳转登录逻辑
|
|
1038
|
+
*
|
|
1039
|
+
* 使用场景:
|
|
1040
|
+
* - HTTP 401 未授权响应
|
|
1041
|
+
*
|
|
1042
|
+
* @example
|
|
1043
|
+
* // 自定义登录跳转逻辑
|
|
1044
|
+
* onRedirectLogin: () => {
|
|
1045
|
+
* // 清除认证信息
|
|
1046
|
+
* tokenManager.clear()
|
|
1047
|
+
* userInfoManager.clear()
|
|
1048
|
+
* // 跳转到登录页
|
|
1049
|
+
* window.location.href = '/login'
|
|
1050
|
+
* }
|
|
1051
|
+
*/
|
|
1052
|
+
onRedirectLogin?: () => void;
|
|
1053
|
+
/**
|
|
1054
|
+
* 应用权限验证回调函数
|
|
1055
|
+
* 在访问特定应用前调用,用于验证用户是否有权限使用指定的应用功能
|
|
1056
|
+
*
|
|
1057
|
+
* @param appKey - 应用标识, 特殊场景下会存在与聊天内部,比如AppCard卡片
|
|
1058
|
+
* @returns boolean | Promise<boolean> | void - 返回验证结果或无返回
|
|
1059
|
+
*
|
|
1060
|
+
* @example
|
|
1061
|
+
* // 简单的权限验证
|
|
1062
|
+
* onAppRightVerify: (appKey) => {
|
|
1063
|
+
* const userRights = getUserRights()
|
|
1064
|
+
* return userRights.includes(appKey)
|
|
1065
|
+
* }
|
|
1066
|
+
*
|
|
1067
|
+
* @example
|
|
1068
|
+
* // 异步权限验证
|
|
1069
|
+
* onAppRightVerify: async (appKey) => {
|
|
1070
|
+
* try {
|
|
1071
|
+
* const result = await checkUserRights(appKey)
|
|
1072
|
+
* return result.hasRight
|
|
1073
|
+
* } catch (error) {
|
|
1074
|
+
* console.error('权限验证失败:', error)
|
|
1075
|
+
* return false
|
|
1076
|
+
* }
|
|
1077
|
+
* }
|
|
1078
|
+
*/
|
|
1079
|
+
onAppRightVerify?: (appKey: string) => boolean | Promise<boolean> | void;
|
|
1080
|
+
onBeforeFilePreview?: (file?: FileUrlType, isBuiltIn?: boolean) => boolean | Promise<boolean> | void;
|
|
1081
|
+
/**
|
|
1082
|
+
* 文件预览后的回调函数
|
|
1083
|
+
* 在文件预览打开或关闭之后执行,可以用于控制布局等
|
|
1084
|
+
* @param file - 预览的文件对象, 如果不存在则表示已经关闭预览
|
|
1085
|
+
* @param isBuiltIn - 是否为内嵌布局
|
|
1086
|
+
*/
|
|
1087
|
+
onAfterFilePreview?: (file?: FileUrlType, isBuiltIn?: boolean) => void;
|
|
1088
|
+
/**
|
|
1089
|
+
* 设置引用消息前回调
|
|
1090
|
+
* 在设置引用消息前调用,返回false可阻止设置
|
|
1091
|
+
*
|
|
1092
|
+
* @param references - 要设置的引用消息, 空则表示正在清除引用消息
|
|
1093
|
+
* @returns boolean | Promise<boolean> | void - 返回false阻止设置
|
|
1094
|
+
*
|
|
1095
|
+
* @example
|
|
1096
|
+
* onBeforeSetReferences: (references) => {
|
|
1097
|
+
* // 验证引用消息内容
|
|
1098
|
+
* if (!references || !references.content) {
|
|
1099
|
+
* message.error('引用消息内容不能为空')
|
|
1100
|
+
* return false
|
|
1101
|
+
* }
|
|
1102
|
+
* return true
|
|
1103
|
+
* }
|
|
1104
|
+
*/
|
|
1105
|
+
onBeforeSetReferences?: (references?: ReferencesType) => boolean | Promise<boolean> | void;
|
|
1106
|
+
/**
|
|
1107
|
+
* 设置引用消息后回调
|
|
1108
|
+
* 在设置引用消息完成后调用
|
|
1109
|
+
*
|
|
1110
|
+
* @param references - 已设置的引用消息, 空则表示已清除引用消息
|
|
1111
|
+
*
|
|
1112
|
+
* @example
|
|
1113
|
+
* onAfterSetReferences: (references) => {
|
|
1114
|
+
* console.log('引用消息已设置:', references)
|
|
1115
|
+
* // 可以在这里更新界面状态或其他相关操作
|
|
1116
|
+
* }
|
|
1117
|
+
*/
|
|
1118
|
+
onAfterSetReferences?: (references?: ReferencesType) => void;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* 聊天布局会话列表配置接口
|
|
1123
|
+
* 控制会话列表区域的显示和功能
|
|
1124
|
+
* ConversationList组件默认 header = true
|
|
1125
|
+
* @example
|
|
1126
|
+
* // 自定义会话列表配置
|
|
1127
|
+
* const conversationList: ChatLayoutConversationList = {
|
|
1128
|
+
* header: true // 显示会话列表头部
|
|
1129
|
+
* }
|
|
1130
|
+
*/
|
|
1131
|
+
interface ChatLayoutConversationList {
|
|
1132
|
+
/** 会话列表头部渲染控制 */
|
|
1133
|
+
header?: RenderControl<void, ChatLayoutConversationListHeader>;
|
|
1134
|
+
}
|
|
1135
|
+
/**
|
|
1136
|
+
* 左侧会话列表header渲染控制
|
|
1137
|
+
* 控制会话列表header区域的显示和功能
|
|
1138
|
+
* ChatHeader组件默认 title = true, avatar = true, newConversationBtn = true, conversationListFavoriteBtn = true
|
|
1139
|
+
* @example
|
|
1140
|
+
* // 自定义头部配置
|
|
1141
|
+
* const header: ChatLayoutConversationListHeader = {
|
|
1142
|
+
* title: true, // 显示标题
|
|
1143
|
+
* avatar: true, // 显示头像
|
|
1144
|
+
* newConversationBtn: false, // 隐藏新建会话按钮
|
|
1145
|
+
* conversationListFavoriteBtn: true // 显示会话收藏列表按钮
|
|
1146
|
+
* }
|
|
1147
|
+
*/
|
|
1148
|
+
interface ChatLayoutConversationListHeader {
|
|
1149
|
+
/** 标题渲染控制 */
|
|
1150
|
+
title?: RenderControl<void, void>;
|
|
1151
|
+
/** 头像渲染控制 */
|
|
1152
|
+
avatar?: RenderControl<void, void>;
|
|
1153
|
+
/** 新建会话按钮渲染控制 */
|
|
1154
|
+
newConversationBtn?: RenderControl<void, void>;
|
|
1155
|
+
/** 是否显示会话收藏列表按钮 */
|
|
1156
|
+
conversationListFavoriteBtn?: boolean;
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* 聊天布局头部配置接口
|
|
1160
|
+
* 控制聊天头部区域的显示和功能
|
|
1161
|
+
* ChatHeader组件默认 title = true, avatar = true, closeBtn = false, newConversationBtn = true, conversationListBtn = true
|
|
1162
|
+
* @example
|
|
1163
|
+
* // 自定义头部配置
|
|
1164
|
+
* const header: ChatLayoutHeader = {
|
|
1165
|
+
* title: true, // 显示标题
|
|
1166
|
+
* avatar: true, // 显示头像
|
|
1167
|
+
* }
|
|
1168
|
+
*/
|
|
1169
|
+
interface ChatLayoutHeader {
|
|
1170
|
+
/** 标题渲染控制 */
|
|
1171
|
+
title?: RenderControl<void, void>;
|
|
1172
|
+
/** 头像渲染控制 */
|
|
1173
|
+
avatar?: RenderControl<void, void>;
|
|
1174
|
+
/** 是否显示关闭按钮 */
|
|
1175
|
+
closeBtn?: boolean;
|
|
1176
|
+
/** 新建会话按钮渲染控制 */
|
|
1177
|
+
newConversationBtn?: RenderControl<void, void>;
|
|
1178
|
+
/** 是否显示智能体性格选择 */
|
|
1179
|
+
agentCharacter?: boolean;
|
|
1180
|
+
/** 是否显示会话列表按钮 */
|
|
1181
|
+
conversationListBtn?: boolean;
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* 聊天布局输入框配置接口
|
|
1185
|
+
* 控制输入框区域的功能和样式
|
|
1186
|
+
* ChatSender组件默认 placeholder, extraBtn = false, referencesBtn = false
|
|
1187
|
+
* @example
|
|
1188
|
+
* // 自定义输入框配置
|
|
1189
|
+
* const sender: ChatLayoutSender = {
|
|
1190
|
+
* placeholder: '请输入您的问题...',
|
|
1191
|
+
* extraBtn: true, // 显示额外按钮
|
|
1192
|
+
* referencesBtn: true, // 显示引用按钮
|
|
1193
|
+
* prompts: true, // 显示推荐问题
|
|
1194
|
+
* sendBtnProps: () => ({
|
|
1195
|
+
* type: 'primary',
|
|
1196
|
+
* children: '发送'
|
|
1197
|
+
* })
|
|
1198
|
+
* }
|
|
1199
|
+
*/
|
|
1200
|
+
interface ChatLayoutSender {
|
|
1201
|
+
/** 输入框占位符文本 */
|
|
1202
|
+
placeholder?: string;
|
|
1203
|
+
/** 额外按钮渲染控制 */
|
|
1204
|
+
extraBtn?: RenderControl<void, void>;
|
|
1205
|
+
/** 引用按钮渲染控制 */
|
|
1206
|
+
referencesBtn?: RenderControl<void, void>;
|
|
1207
|
+
/** 底部额外内容渲染控制 */
|
|
1208
|
+
footerBelow?: RenderControl<void, void>;
|
|
1209
|
+
/** 专业技能按钮渲染控制 */
|
|
1210
|
+
skillsBtn?: RenderControl<void, void>;
|
|
1211
|
+
/** 知识库按钮渲染控制 */
|
|
1212
|
+
knowledgeBtn?: RenderControl<void, void>;
|
|
1213
|
+
/** 发送按钮属性配置函数 */
|
|
1214
|
+
sendBtnProps?: () => ButtonProps;
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* 消息列表欢迎信息配置
|
|
1218
|
+
* 控制聊天界面初始欢迎信息的显示内容和自定义渲染
|
|
1219
|
+
* @example
|
|
1220
|
+
* // 自定义欢迎信息
|
|
1221
|
+
* const welcomeMessage: ChatLayoutWelcomeMessage = {
|
|
1222
|
+
* icon: true, // 显示默认图标
|
|
1223
|
+
* title: {render: () => <>欢迎使用AI助手</>}, // 修改标题
|
|
1224
|
+
* description: false, // 不显示详情
|
|
1225
|
+
* prompts: true // 显示推荐问题
|
|
1226
|
+
* }
|
|
1227
|
+
*/
|
|
1228
|
+
interface ChatLayoutWelcomeMessage {
|
|
1229
|
+
icon?: RenderControl<void, void>;
|
|
1230
|
+
title?: RenderControl<void, void>;
|
|
1231
|
+
description?: RenderControl<void, void>;
|
|
1232
|
+
prompts?: RenderControl<void, void>;
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* 聊天布局消息列表配置接口
|
|
1236
|
+
* 控制消息列表区域的显示和功能
|
|
1237
|
+
* @example
|
|
1238
|
+
* // 自定义消息列表配置
|
|
1239
|
+
* const messageList: ChatLayoutMessageList = {
|
|
1240
|
+
* avatar: {
|
|
1241
|
+
* user: true,
|
|
1242
|
+
* agent: true,
|
|
1243
|
+
* other: false
|
|
1244
|
+
* },
|
|
1245
|
+
* firstMessage: false // 不显示首条消息
|
|
1246
|
+
* welcomeMessage: false // 不显示欢迎消息
|
|
1247
|
+
* }
|
|
1248
|
+
*/
|
|
1249
|
+
interface ChatLayoutMessageList {
|
|
1250
|
+
/** 首条消息配置 */
|
|
1251
|
+
firstMessages?: ConversationMessage[];
|
|
1252
|
+
/** 头像显示控制:可以是全局布尔值或按成员类型分别控制 */
|
|
1253
|
+
avatar?: boolean | Partial<Record<ConversationMemberEnum, boolean>>;
|
|
1254
|
+
/** 智能体消息操作区渲染控制 */
|
|
1255
|
+
agentActions?: RenderControl<{
|
|
1256
|
+
message: ConversationMessage;
|
|
1257
|
+
dom?: HTMLElement;
|
|
1258
|
+
}, void>;
|
|
1259
|
+
/** message自定义标记渲染组件 */
|
|
1260
|
+
customComponents?: Record<string, any>;
|
|
1261
|
+
/** 欢迎消息渲染控制, 要渲染时如果列表有内容则不渲染 */
|
|
1262
|
+
welcomeMessage?: RenderControl<void, ChatLayoutWelcomeMessage>;
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* 聊天布局配置接口(专家和智能体各有一套默认布局)
|
|
1266
|
+
* 控制聊天组件整体布局的显示和功能
|
|
1267
|
+
*
|
|
1268
|
+
* @example
|
|
1269
|
+
* const layout: ChatLayout = {
|
|
1270
|
+
* leftPanel: false,
|
|
1271
|
+
* conversationList: false,
|
|
1272
|
+
* preview: false,
|
|
1273
|
+
* messageList: true,
|
|
1274
|
+
* sender: {
|
|
1275
|
+
* props: {
|
|
1276
|
+
* prompts: false
|
|
1277
|
+
* }
|
|
1278
|
+
* },
|
|
1279
|
+
* chatHeader: {
|
|
1280
|
+
* render: (props) => <div>{props.children}</div>:
|
|
1281
|
+
* },
|
|
1282
|
+
* disclaimerNotice: false
|
|
1283
|
+
* }
|
|
1284
|
+
*/
|
|
1285
|
+
interface ChatLayout {
|
|
1286
|
+
/** 左侧面板渲染控制 */
|
|
1287
|
+
leftPanel?: RenderControl<void, void>;
|
|
1288
|
+
/** 会话列表面板渲染控制 */
|
|
1289
|
+
conversationList?: RenderControl<void, ChatLayoutConversationList>;
|
|
1290
|
+
/** 是否允许预览功能 */
|
|
1291
|
+
preview?: boolean;
|
|
1292
|
+
/** 消息列表渲染控制 */
|
|
1293
|
+
messageList?: RenderControl<void, ChatLayoutMessageList>;
|
|
1294
|
+
/** 输入框头部渲染控制 */
|
|
1295
|
+
senderHeader?: RenderControl<void, void>;
|
|
1296
|
+
/** 输入框渲染控制 */
|
|
1297
|
+
sender?: RenderControl<void, ChatLayoutSender>;
|
|
1298
|
+
/** 输入框底部渲染控制 */
|
|
1299
|
+
senderFooter?: RenderControl<void, void>;
|
|
1300
|
+
/** 全局头部渲染控制 */
|
|
1301
|
+
globalHeader?: RenderControl<void, ChatLayoutHeader>;
|
|
1302
|
+
/** 聊天区域头部渲染控制 */
|
|
1303
|
+
chatHeader?: RenderControl<void, ChatLayoutHeader>;
|
|
1304
|
+
/** 免责声明渲染控制 */
|
|
1305
|
+
disclaimerNotice?: RenderControl<void, void>;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
interface ChatConfig {
|
|
1309
|
+
agent: AgentInfo;
|
|
1310
|
+
conversationId?: string;
|
|
1311
|
+
conversationStrategy?: ConversationStrategy;
|
|
1312
|
+
}
|
|
1313
|
+
interface ChatParams {
|
|
1314
|
+
convMeta?: ConvMeta;
|
|
1315
|
+
/** 扩展参数对象 透传大模型 */
|
|
1316
|
+
params?: ObjectType<any>;
|
|
1317
|
+
}
|
|
1318
|
+
interface ChatProps {
|
|
1319
|
+
theme?: ThemeConfig;
|
|
1320
|
+
config?: ChatConfig;
|
|
1321
|
+
params?: ChatParams;
|
|
1322
|
+
hooks?: ChatHooks;
|
|
1323
|
+
layout?: ChatLayout;
|
|
1324
|
+
services?: ChatServices;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* 附件组件属性接口
|
|
1329
|
+
*/
|
|
1330
|
+
interface AttachmentsProps {
|
|
1331
|
+
/** 文件上传函数,接收 FormData 并返回上传结果 */
|
|
1332
|
+
fileUpload: (formData: FormData, signal?: AbortSignal) => Promise<R<InputFile[]>>;
|
|
1333
|
+
/** 文件上传配置列表,定义允许的文件类型和大小限制 */
|
|
1334
|
+
fileUploadConfig?: FileUploadConfig;
|
|
1335
|
+
/** 额外的上传参数,会附加到 FormData 中 */
|
|
1336
|
+
extraParams?: ObjectType<string | undefined>;
|
|
1337
|
+
/** 当前文件列表 */
|
|
1338
|
+
fileList?: InputFile[];
|
|
1339
|
+
/** 文件列表变化回调函数 */
|
|
1340
|
+
onChange: (fileList: InputFile[]) => void;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/**
|
|
1344
|
+
* ChatSender 组件暴露的方法接口
|
|
1345
|
+
*/
|
|
1346
|
+
interface ChatSenderHandle {
|
|
1347
|
+
/** 聚焦输入框 */
|
|
1348
|
+
focus: (options?: {
|
|
1349
|
+
cursor?: 'start' | 'end';
|
|
1350
|
+
}) => void;
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* 文件上传配置接口
|
|
1354
|
+
*/
|
|
1355
|
+
interface FileUpload {
|
|
1356
|
+
/** 上传时的额外参数 */
|
|
1357
|
+
params?: ObjectType<any>;
|
|
1358
|
+
/** 文件上传配置列表 */
|
|
1359
|
+
config: FileUploadConfig;
|
|
1360
|
+
/** 文件上传请求函数 */
|
|
1361
|
+
request: AttachmentsProps['fileUpload'];
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* ChatSender 组件属性接口
|
|
1365
|
+
*/
|
|
1366
|
+
interface SenderProps {
|
|
1367
|
+
/** 输入框占位符 */
|
|
1368
|
+
placeholder?: string;
|
|
1369
|
+
/** 输入框内容 */
|
|
1370
|
+
content?: string;
|
|
1371
|
+
/** 文件列表 */
|
|
1372
|
+
fileList?: InputFile[];
|
|
1373
|
+
/** 是否打开文件选择头部 */
|
|
1374
|
+
headerOpen?: boolean;
|
|
1375
|
+
/** 是否正在发送消息 */
|
|
1376
|
+
loading?: boolean;
|
|
1377
|
+
/** 内容变化回调 */
|
|
1378
|
+
onContentChange: (value: string) => void;
|
|
1379
|
+
/** 文件列表变化回调 */
|
|
1380
|
+
onFileListChange: (files: InputFile[]) => void;
|
|
1381
|
+
/** 头部打开状态变化回调 */
|
|
1382
|
+
onHeaderOpenChange: (open: boolean) => void;
|
|
1383
|
+
/** 发送消息回调 */
|
|
1384
|
+
onSend: () => void;
|
|
1385
|
+
/** 取消发送回调 */
|
|
1386
|
+
onCancel?: () => void;
|
|
1387
|
+
/** 输入框聚焦回调 */
|
|
1388
|
+
onFocus?: () => void;
|
|
1389
|
+
/** 头部额外内容 */
|
|
1390
|
+
extraHeader?: React.ReactNode;
|
|
1391
|
+
/** 底部额外内容 */
|
|
1392
|
+
extraFooter?: React.ReactNode;
|
|
1393
|
+
/** 底部下方额外内容 */
|
|
1394
|
+
extraFooterBelow?: React.ReactNode;
|
|
1395
|
+
/** 发送按钮属性 */
|
|
1396
|
+
sendBtnProps?: ButtonProps;
|
|
1397
|
+
/** 文件上传配置 */
|
|
1398
|
+
fileUpload?: FileUpload;
|
|
1399
|
+
}
|
|
1400
|
+
declare const _default$3: react.ForwardRefExoticComponent<SenderProps & react.RefAttributes<ChatSenderHandle>>;
|
|
1401
|
+
|
|
1402
|
+
interface MessageRenderProps {
|
|
1403
|
+
message: ConversationMessage;
|
|
1404
|
+
messageIndex?: number;
|
|
1405
|
+
loading?: boolean;
|
|
1406
|
+
onFilePreview?: (file: InputFile) => void;
|
|
1407
|
+
containerRef?: react__default.Ref<HTMLDivElement>;
|
|
1408
|
+
/** message自定义标记渲染组件 */
|
|
1409
|
+
customComponents?: ChatLayoutMessageList['customComponents'];
|
|
1410
|
+
}
|
|
1411
|
+
declare const _default$2: react__default.MemoExoticComponent<({ message, messageIndex, loading, containerRef, customComponents }: MessageRenderProps) => react_jsx_runtime.JSX.Element>;
|
|
1412
|
+
|
|
1413
|
+
declare const _default$1: ({ firstMessages, welcomeMessage, avatar, agentActions, customComponents }: ChatLayoutMessageList) => react_jsx_runtime.JSX.Element;
|
|
1414
|
+
|
|
1415
|
+
declare const _default: react.ForwardRefExoticComponent<ChatProps & react.RefAttributes<ChatHandle>>;
|
|
1416
|
+
|
|
1417
|
+
export { type AgentConfig, type AgentInfo, type AgentSpec, _default$1 as BubbleListItems, type ChatConfig, _default as ChatCopilot, type ChatHandle, type ChatProps, _default$3 as ChatSender, type ConversationMessage, type FileUploadConfig, type InputFile, _default$2 as MessageRender };
|