@zero-library/chat-agent 2.1.18 → 2.1.20
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/dist/index.cjs.js +130 -157
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +0 -24
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +295 -197
- package/dist/index.d.ts +295 -197
- package/dist/index.esm.js +131 -158
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,55 @@
|
|
|
1
|
-
import { createRequest, RenderControl
|
|
1
|
+
import { createRequest, RenderControl } from '@zero-library/common';
|
|
2
2
|
import { ButtonProps, ThemeConfig } from 'antd';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { Conversation, BubbleProps } from '@ant-design/x';
|
|
5
5
|
export * from '@ant-design/x';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* 聊天服务模块
|
|
10
|
+
* 提供聊天相关的 API 接口定义和类型声明
|
|
11
|
+
* 包含会话管理、消息处理、智能体操作等功能
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* 用户信息接口
|
|
15
|
+
* 定义用户的基本信息和权限配置
|
|
16
|
+
*/
|
|
17
|
+
interface UserInfo {
|
|
18
|
+
/** 用户ID */
|
|
19
|
+
id: number;
|
|
20
|
+
/** 机构名称 */
|
|
21
|
+
orgName?: string;
|
|
22
|
+
/** 用户姓名 */
|
|
23
|
+
name: string;
|
|
24
|
+
/** 用户名 */
|
|
25
|
+
username?: string;
|
|
26
|
+
/** 手机号 */
|
|
27
|
+
mobile?: string;
|
|
28
|
+
/** 头像地址 */
|
|
29
|
+
avatar: string;
|
|
30
|
+
/** 我的邀请码 */
|
|
31
|
+
myInviteCode?: string;
|
|
32
|
+
/** 邮箱地址 */
|
|
33
|
+
email?: string;
|
|
34
|
+
/** 备注信息 */
|
|
35
|
+
remark?: string;
|
|
36
|
+
/** 角色ID列表 */
|
|
37
|
+
roles?: number[];
|
|
38
|
+
/** 权限代码列表 */
|
|
39
|
+
permissions?: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 会话列表查询参数接口
|
|
43
|
+
* 用于获取用户的会话列表
|
|
44
|
+
*/
|
|
8
45
|
interface ConversationsQuery extends PageReq {
|
|
46
|
+
/** 业务数据唯一ID,非必填 */
|
|
9
47
|
businessId?: string;
|
|
48
|
+
/** 业务类型,非必填 */
|
|
10
49
|
businessType?: number;
|
|
50
|
+
/** 目标ID(如智能体ID、专家ID等) */
|
|
11
51
|
targetId: string;
|
|
52
|
+
/** 目标类型:1-用户 2-专家 3-Agent 4-税协 */
|
|
12
53
|
targetType: number;
|
|
13
54
|
}
|
|
14
55
|
/**
|
|
@@ -148,299 +189,218 @@ interface ConversationRecentQuery {
|
|
|
148
189
|
*/
|
|
149
190
|
receiverType: number;
|
|
150
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* 会话消息查询参数接口
|
|
194
|
+
* 用于获取指定会话的消息列表
|
|
195
|
+
*/
|
|
151
196
|
interface conversationMessagesQuery extends PageReq {
|
|
197
|
+
/** 会话ID */
|
|
152
198
|
conversationId: string;
|
|
153
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* 输入文件接口
|
|
202
|
+
* 定义聊天中上传文件的属性
|
|
203
|
+
*/
|
|
154
204
|
interface InputFile {
|
|
155
|
-
/**
|
|
156
|
-
* Content,文件内容
|
|
157
|
-
*/
|
|
205
|
+
/** 文件内容(base64编码或URL) */
|
|
158
206
|
content: string;
|
|
159
|
-
/**
|
|
160
|
-
* 文件模式 remote_url local_file
|
|
161
|
-
*/
|
|
207
|
+
/** 文件模式:remote_url(远程URL)| local_file(本地文件) */
|
|
162
208
|
mode: string;
|
|
163
|
-
/**
|
|
164
|
-
* Type,文件类型
|
|
165
|
-
*/
|
|
209
|
+
/** 文件类型(MIME类型) */
|
|
166
210
|
type: string;
|
|
167
|
-
/**
|
|
168
|
-
* 文件扩展名
|
|
169
|
-
*/
|
|
211
|
+
/** 文件扩展名 */
|
|
170
212
|
extension: string;
|
|
171
|
-
/**
|
|
172
|
-
* 文件名
|
|
173
|
-
*/
|
|
213
|
+
/** 文件名 */
|
|
174
214
|
name: string;
|
|
175
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* 消息引用类型
|
|
218
|
+
* 用于消息回复时的引用信息
|
|
219
|
+
*/
|
|
176
220
|
interface MessageQuoteMsg {
|
|
177
|
-
/**
|
|
178
|
-
* Id,消息ID
|
|
179
|
-
*/
|
|
221
|
+
/** 被引用的消息ID */
|
|
180
222
|
id?: string;
|
|
181
|
-
/**
|
|
182
|
-
* Msgcontent,消息内容
|
|
183
|
-
*/
|
|
223
|
+
/** 被引用的消息内容 */
|
|
184
224
|
msgContent?: string;
|
|
185
|
-
/**
|
|
186
|
-
* Msgfiles,附件文件列表
|
|
187
|
-
*/
|
|
225
|
+
/** 被引用消息的附件文件列表 */
|
|
188
226
|
msgFiles?: InputFile[];
|
|
189
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* 消息发送者接口
|
|
230
|
+
* 定义消息发送者的身份信息
|
|
231
|
+
*/
|
|
190
232
|
interface MessageSender {
|
|
191
|
-
/**
|
|
192
|
-
* Curruser,是否为当前用户
|
|
193
|
-
*/
|
|
233
|
+
/** 是否为当前用户 */
|
|
194
234
|
currUser?: boolean;
|
|
195
|
-
/**
|
|
196
|
-
* Id,发送者ID
|
|
197
|
-
*/
|
|
235
|
+
/** 发送者ID */
|
|
198
236
|
id: string;
|
|
199
|
-
/**
|
|
200
|
-
* Type,1-用户 2-专家 3-Agent 4-税协
|
|
201
|
-
*/
|
|
237
|
+
/** 发送者类型:1-用户 2-专家 3-Agent 4-税协 */
|
|
202
238
|
type: number;
|
|
203
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* 会话消息接口
|
|
242
|
+
* 定义聊天消息的完整信息
|
|
243
|
+
*/
|
|
204
244
|
interface ConversationMessage {
|
|
205
|
-
/**
|
|
206
|
-
* Conversationid,会话ID
|
|
207
|
-
*/
|
|
245
|
+
/** 会话ID */
|
|
208
246
|
conversationId: string;
|
|
247
|
+
/** 会话标题(WebSocket返回时可能包含) */
|
|
209
248
|
conversationTitle?: string;
|
|
249
|
+
/** 消息类型:WebSocket流式消息类型 */
|
|
210
250
|
type?: 'TEXT_MESSAGE_START' | 'STEP_STARTED' | 'TEXT_MESSAGE_CONTENT' | 'TEXT_MESSAGE_END' | 'RUN_ERROR';
|
|
211
|
-
/**
|
|
212
|
-
* Id,消息ID
|
|
213
|
-
*/
|
|
251
|
+
/** 消息ID */
|
|
214
252
|
id: string;
|
|
215
|
-
/**
|
|
216
|
-
* Msgcontent,消息内容
|
|
217
|
-
*/
|
|
253
|
+
/** 消息内容 */
|
|
218
254
|
msgContent: string;
|
|
219
|
-
/**
|
|
220
|
-
* Msgfeedback,消息反馈
|
|
221
|
-
*/
|
|
255
|
+
/** 消息反馈:1-赞 2-踩 */
|
|
222
256
|
msgFeedback?: number;
|
|
223
|
-
/**
|
|
224
|
-
* Msgfiles,附件文件列表
|
|
225
|
-
*/
|
|
257
|
+
/** 附件文件列表 */
|
|
226
258
|
msgFiles?: InputFile[];
|
|
227
|
-
/**
|
|
228
|
-
* 引消息
|
|
229
|
-
*/
|
|
259
|
+
/** 引用的消息信息 */
|
|
230
260
|
quoteMsg?: MessageQuoteMsg;
|
|
231
|
-
/**
|
|
232
|
-
* 发送者信息
|
|
233
|
-
*/
|
|
261
|
+
/** 发送者信息 */
|
|
234
262
|
sender?: MessageSender;
|
|
235
|
-
/**
|
|
236
|
-
* Sendtime,发送时间
|
|
237
|
-
*/
|
|
263
|
+
/** 发送时间戳 */
|
|
238
264
|
sendTime: number;
|
|
239
|
-
/**
|
|
240
|
-
* Stopflag,是否打断
|
|
241
|
-
*/
|
|
265
|
+
/** 是否被打断标志 */
|
|
242
266
|
stopFlag?: boolean;
|
|
243
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* 消息反馈更新接口
|
|
270
|
+
* 用于用户对消息进行赞/踩评价
|
|
271
|
+
*/
|
|
244
272
|
interface FeedbackUpdate {
|
|
245
|
-
/**
|
|
246
|
-
* Conversationid,会话ID
|
|
247
|
-
*/
|
|
273
|
+
/** 会话ID */
|
|
248
274
|
conversationId: string;
|
|
249
|
-
/**
|
|
250
|
-
* Id,消息ID
|
|
251
|
-
*/
|
|
275
|
+
/** 消息ID */
|
|
252
276
|
id: string;
|
|
253
|
-
/**
|
|
254
|
-
* Msgfeedback,反馈类型:1-赞,2-踩
|
|
255
|
-
*/
|
|
277
|
+
/** 反馈类型:1-赞 2-踩 */
|
|
256
278
|
msgFeedback: number;
|
|
257
|
-
/**
|
|
258
|
-
* Msgfeedbackcontent,消息反馈内容
|
|
259
|
-
*/
|
|
279
|
+
/** 反馈内容描述,非必填 */
|
|
260
280
|
msgFeedbackContent?: string;
|
|
261
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* 消息发送参数接口
|
|
284
|
+
* 定义发送消息时所需的全部参数
|
|
285
|
+
*/
|
|
262
286
|
interface ConversationMessageSend {
|
|
263
|
-
/**
|
|
264
|
-
* Conversationid,会话 ID
|
|
265
|
-
*/
|
|
287
|
+
/** 会话ID */
|
|
266
288
|
conversationId: string;
|
|
267
|
-
/**
|
|
268
|
-
* Msgcontent,消息内容
|
|
269
|
-
*/
|
|
289
|
+
/** 消息内容 */
|
|
270
290
|
msgContent: string;
|
|
271
|
-
/**
|
|
272
|
-
* Msgfiles,附件文件列表
|
|
273
|
-
*/
|
|
291
|
+
/** 附件文件列表 */
|
|
274
292
|
msgFiles?: InputFile[];
|
|
275
|
-
/**
|
|
276
|
-
* Params,业务参数,透传到智能体
|
|
277
|
-
*/
|
|
293
|
+
/** 业务参数,透传到智能体的JSON字符串 */
|
|
278
294
|
params?: string;
|
|
279
|
-
/**
|
|
280
|
-
* Quotemsgid,引用的消息 ID,大于 0 的整数
|
|
281
|
-
*/
|
|
295
|
+
/** 引用的消息ID,大于0的整数 */
|
|
282
296
|
quoteMsgId?: number;
|
|
283
|
-
/**
|
|
284
|
-
* Receiverid,接收者 ID。当 receiverType ≠ 3(非 agent)时,后端需填充此字段
|
|
285
|
-
*/
|
|
297
|
+
/** 接收者ID,当receiverType≠3时由后端填充 */
|
|
286
298
|
receiverId: string;
|
|
287
|
-
/**
|
|
288
|
-
* Receivertype,接收者身份,必填:1-用户;2-专家;3-agent 4-税协
|
|
289
|
-
*/
|
|
299
|
+
/** 接收者类型:1-用户 2-专家 3-agent 4-税协 */
|
|
290
300
|
receiverType: number;
|
|
291
|
-
/**
|
|
292
|
-
* Returntype,返回方式:1-http;2-ws(WebSocket)
|
|
293
|
-
*/
|
|
301
|
+
/** 返回方式:1-http 2-WebSocket */
|
|
294
302
|
returnType: number;
|
|
295
|
-
/**
|
|
296
|
-
* Senderid,发送者 ID
|
|
297
|
-
*/
|
|
303
|
+
/** 发送者ID */
|
|
298
304
|
senderId: string;
|
|
299
|
-
/**
|
|
300
|
-
* Sendertype,发送者身份,必填:1-用户;2-专家;3-agent 4-税协
|
|
301
|
-
*/
|
|
305
|
+
/** 发送者类型:1-用户 2-专家 3-agent 4-税协 */
|
|
302
306
|
senderType: number;
|
|
303
|
-
/**
|
|
304
|
-
* Source,会话来源: 1-罗拉-APP; 2-罗拉-pc端; 3-合作伙伴端 4-税协 5-罗拉-cube 6-api
|
|
305
|
-
*/
|
|
307
|
+
/** 会话来源:1-罗拉-APP 2-罗拉-pc端 3-合作伙伴端 4-税协 5-罗拉-cube 6-api */
|
|
306
308
|
source: number;
|
|
307
|
-
/**
|
|
308
|
-
* Stream,是否启用流式返回响应结果
|
|
309
|
-
*/
|
|
309
|
+
/** 是否启用流式返回 */
|
|
310
310
|
stream: boolean;
|
|
311
311
|
}
|
|
312
312
|
/**
|
|
313
|
-
*
|
|
313
|
+
* 文件上传配置接口
|
|
314
|
+
* 定义智能体的文件上传规则
|
|
314
315
|
*/
|
|
315
316
|
interface FileUploadConfig {
|
|
316
|
-
/**
|
|
317
|
-
* Allowedfiletypes,允许的文件类型
|
|
318
|
-
*/
|
|
317
|
+
/** 允许的文件类型列表(MIME类型或扩展名) */
|
|
319
318
|
allowedFileTypes: string[];
|
|
320
|
-
/**
|
|
321
|
-
* Enabled,是否启用文件上传
|
|
322
|
-
*/
|
|
319
|
+
/** 是否启用文件上传功能 */
|
|
323
320
|
enabled: boolean;
|
|
324
|
-
/**
|
|
325
|
-
* Maxfilecount,最大文件数量
|
|
326
|
-
*/
|
|
321
|
+
/** 单次上传最大文件数量 */
|
|
327
322
|
maxFileCount: number;
|
|
328
|
-
/**
|
|
329
|
-
* Maxfilesize,最大文件大小
|
|
330
|
-
*/
|
|
323
|
+
/** 单个文件最大大小(字节) */
|
|
331
324
|
maxFileSize?: number;
|
|
332
325
|
}
|
|
333
326
|
/**
|
|
334
|
-
*
|
|
327
|
+
* 推荐问题接口
|
|
328
|
+
* 定义单个推荐问题的结构
|
|
335
329
|
*/
|
|
336
330
|
interface RecommendQuestion {
|
|
337
|
-
/**
|
|
338
|
-
* Id,问题 ID
|
|
339
|
-
*/
|
|
331
|
+
/** 问题ID */
|
|
340
332
|
id: number;
|
|
341
|
-
/**
|
|
342
|
-
* Question,问题内容
|
|
343
|
-
*/
|
|
333
|
+
/** 问题内容 */
|
|
344
334
|
question: string;
|
|
345
335
|
}
|
|
346
336
|
/**
|
|
347
|
-
*
|
|
337
|
+
* 热门问题标签接口
|
|
338
|
+
* 定义热门问题的分类标签
|
|
348
339
|
*/
|
|
349
340
|
interface HotQuestionList {
|
|
350
|
-
/**
|
|
351
|
-
* Id,标签 ID
|
|
352
|
-
*/
|
|
341
|
+
/** 标签ID */
|
|
353
342
|
id: number;
|
|
354
|
-
/**
|
|
355
|
-
* Items,标签下的问题列表
|
|
356
|
-
*/
|
|
343
|
+
/** 标签下的问题列表 */
|
|
357
344
|
items: RecommendQuestion[];
|
|
358
|
-
/**
|
|
359
|
-
* Name,标签名称
|
|
360
|
-
*/
|
|
345
|
+
/** 标签名称 */
|
|
361
346
|
name: string;
|
|
362
347
|
}
|
|
348
|
+
/**
|
|
349
|
+
* 智能体配置接口
|
|
350
|
+
* 定义智能体的功能配置信息
|
|
351
|
+
*/
|
|
363
352
|
interface AgentConfig {
|
|
364
|
-
/**
|
|
365
|
-
* 文件上传配置
|
|
366
|
-
*/
|
|
353
|
+
/** 文件上传配置列表 */
|
|
367
354
|
fileUpload?: FileUploadConfig[];
|
|
368
|
-
/**
|
|
369
|
-
* Labels,热门问题标签列表
|
|
370
|
-
*/
|
|
355
|
+
/** 热门问题标签列表 */
|
|
371
356
|
labels?: HotQuestionList[];
|
|
372
|
-
/**
|
|
373
|
-
* Recommendquestions,推荐问题列表
|
|
374
|
-
*/
|
|
357
|
+
/** 推荐问题列表 */
|
|
375
358
|
recommendQuestions?: RecommendQuestion[];
|
|
376
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* 智能体信息接口
|
|
362
|
+
* 定义智能体的基本信息和配置
|
|
363
|
+
*/
|
|
377
364
|
interface AgentInfo {
|
|
378
|
-
/**
|
|
379
|
-
* Agentname,名称
|
|
380
|
-
*/
|
|
365
|
+
/** 智能体名称 */
|
|
381
366
|
agentName: string;
|
|
382
|
-
/**
|
|
383
|
-
* Agenttype,智能体类型
|
|
384
|
-
*/
|
|
367
|
+
/** 智能体类型 */
|
|
385
368
|
agentType: number;
|
|
386
|
-
/**
|
|
387
|
-
* 智能体的附带信息
|
|
388
|
-
*/
|
|
369
|
+
/** 智能体的配置信息 */
|
|
389
370
|
config: AgentConfig;
|
|
390
|
-
/**
|
|
391
|
-
* Description,描述
|
|
392
|
-
*/
|
|
371
|
+
/** 智能体描述 */
|
|
393
372
|
description?: string;
|
|
394
|
-
/**
|
|
395
|
-
* Id,主键
|
|
396
|
-
*/
|
|
373
|
+
/** 智能体ID */
|
|
397
374
|
id: string;
|
|
398
|
-
/**
|
|
399
|
-
* Isavailable,是否可用
|
|
400
|
-
*/
|
|
375
|
+
/** 智能体是否可用 */
|
|
401
376
|
isAvailable?: boolean;
|
|
402
|
-
/**
|
|
403
|
-
* Logo,logo
|
|
404
|
-
*/
|
|
377
|
+
/** 智能体Logo地址 */
|
|
405
378
|
logo: string;
|
|
379
|
+
/** 智能体特性配置,JSON字符串格式 */
|
|
406
380
|
feature?: string;
|
|
407
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* 智能体性格接口
|
|
384
|
+
* 定义智能体的性格特征配置
|
|
385
|
+
*/
|
|
408
386
|
interface AgentCharacter {
|
|
409
|
-
/**
|
|
410
|
-
* Agentid,智能体ID
|
|
411
|
-
*/
|
|
387
|
+
/** 智能体ID */
|
|
412
388
|
agentId: number;
|
|
413
|
-
/**
|
|
414
|
-
* Charactername,性格名称
|
|
415
|
-
*/
|
|
389
|
+
/** 性格名称 */
|
|
416
390
|
characterName: string;
|
|
417
|
-
/**
|
|
418
|
-
* Detaillevel,详细程度:1-10
|
|
419
|
-
*/
|
|
391
|
+
/** 详细程度评级:1-10 */
|
|
420
392
|
detailLevel: number;
|
|
421
|
-
/**
|
|
422
|
-
* Humorlevel,幽默程度:1-10
|
|
423
|
-
*/
|
|
393
|
+
/** 幽默程度评级:1-10 */
|
|
424
394
|
humorLevel: number;
|
|
425
|
-
/**
|
|
426
|
-
* Id,id
|
|
427
|
-
*/
|
|
395
|
+
/** 性格配置ID */
|
|
428
396
|
id: number;
|
|
429
|
-
/**
|
|
430
|
-
* Logo,头像,存储图片路径
|
|
431
|
-
*/
|
|
397
|
+
/** 性格头像图片路径 */
|
|
432
398
|
logo: string;
|
|
433
|
-
/**
|
|
434
|
-
* Professionallevel,专业程度:1-10
|
|
435
|
-
*/
|
|
399
|
+
/** 专业程度评级:1-10 */
|
|
436
400
|
professionalLevel: number;
|
|
437
|
-
/**
|
|
438
|
-
* Selected,是否已选择
|
|
439
|
-
*/
|
|
401
|
+
/** 是否为当前选择的性格 */
|
|
440
402
|
selected: boolean;
|
|
441
|
-
/**
|
|
442
|
-
* Sex,性别:1-男,2-女
|
|
443
|
-
*/
|
|
403
|
+
/** 性别设置:1-男 2-女 */
|
|
444
404
|
sex: number;
|
|
445
405
|
}
|
|
446
406
|
/**
|
|
@@ -505,77 +465,177 @@ declare const createFileService: (request: ReturnType<typeof createRequest>) =>
|
|
|
505
465
|
fileCreate: (fileContent: string, fileName?: string, targetFormat?: string) => Promise<void>;
|
|
506
466
|
};
|
|
507
467
|
|
|
468
|
+
/**
|
|
469
|
+
* 会话策略类型
|
|
470
|
+
* 1-最近会话:获取用户最近的会话继续对话
|
|
471
|
+
* 2-新会话:创建全新的会话开始对话
|
|
472
|
+
*/
|
|
508
473
|
type ConversationStrategy = 1 | 2;
|
|
474
|
+
/**
|
|
475
|
+
* 引用内容接口
|
|
476
|
+
* 扩展消息引用信息,支持更多引用格式
|
|
477
|
+
*/
|
|
509
478
|
interface ReferencesContent extends MessageQuoteMsg {
|
|
479
|
+
/** 引用名称 */
|
|
510
480
|
name?: string;
|
|
481
|
+
/** Markdown格式的引用内容 */
|
|
511
482
|
markdown?: string;
|
|
483
|
+
/** 其他扩展属性 */
|
|
512
484
|
[key: string]: any;
|
|
513
485
|
}
|
|
486
|
+
/**
|
|
487
|
+
* 引用类型接口
|
|
488
|
+
* 定义消息引用的各种类型和参数
|
|
489
|
+
*/
|
|
514
490
|
interface ReferencesType {
|
|
491
|
+
/** 引用类型:1-markdown引用(拼正文发) 2-文案引用(不发正文) 3-消息引用 */
|
|
515
492
|
type: number;
|
|
493
|
+
/** 引用内容 */
|
|
516
494
|
content: ReferencesContent;
|
|
495
|
+
/** 引用参数 */
|
|
517
496
|
params?: ObjectType<any>;
|
|
518
497
|
}
|
|
498
|
+
/**
|
|
499
|
+
* 聊天组件生命周期钩子接口
|
|
500
|
+
* 定义聊天组件在各种事件发生时的回调函数
|
|
501
|
+
*/
|
|
519
502
|
interface ChatHooks {
|
|
503
|
+
/** 初始化前回调 */
|
|
520
504
|
onBeforeInit?: () => void;
|
|
505
|
+
/** 初始化后回调 */
|
|
521
506
|
onAfterInit?: () => void;
|
|
507
|
+
/** 输入框聚焦回调 */
|
|
522
508
|
onSenderFocus?: () => void;
|
|
509
|
+
/** 头部关闭回调 */
|
|
523
510
|
onHeaderClose?: () => void;
|
|
511
|
+
/** 发送消息前回调,可阻止发送 */
|
|
524
512
|
onBeforeSend?: (message: ConversationMessageSend['msgContent'], files: InputFile[]) => boolean | Promise<boolean> | void;
|
|
513
|
+
/** 发送消息后回调 */
|
|
525
514
|
onAfterSend?: () => void;
|
|
515
|
+
/** 切换智能体前回调,可阻止切换 */
|
|
526
516
|
onBeforeSwitchAgent?: (agentId: string) => boolean | Promise<boolean> | void;
|
|
517
|
+
/** 切换智能体后回调 */
|
|
527
518
|
onAfterSwitchAgent?: (agent: AgentInfo) => void;
|
|
519
|
+
/** 切换会话前回调,可阻止切换 */
|
|
528
520
|
onBeforeSwitchConversation?: (conversationId: string) => boolean | Promise<boolean> | void;
|
|
521
|
+
/** 切换会话后回调 */
|
|
529
522
|
onAfterSwitchConversation?: (conversationId: string) => void;
|
|
523
|
+
/** 初始化消息前回调,可阻止初始化 */
|
|
530
524
|
onBeforeInitMessages?: (conversationId: string) => boolean | Promise<boolean> | void;
|
|
525
|
+
/** 初始化消息后回调 */
|
|
531
526
|
onAfterInitMessages?: (messages: ConversationMessage[]) => void;
|
|
527
|
+
/** 删除会话前回调,可阻止删除 */
|
|
532
528
|
onBeforeDelConversation?: (conversationId: string) => boolean | Promise<boolean> | void;
|
|
529
|
+
/** 删除会话后回调 */
|
|
533
530
|
onAfterDelConversation?: (conversationId: string, isCurrentConversation: boolean) => void;
|
|
534
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* 聊天参数接口
|
|
534
|
+
* 定义聊天组件的运行时参数
|
|
535
|
+
*/
|
|
535
536
|
interface ChatParams {
|
|
537
|
+
/** 会话来源 */
|
|
536
538
|
source?: number;
|
|
539
|
+
/** 业务扩展数据,JSON字符串格式 */
|
|
537
540
|
businessData?: string;
|
|
541
|
+
/** 业务数据唯一ID */
|
|
538
542
|
businessId?: string;
|
|
543
|
+
/** 业务类型 */
|
|
539
544
|
businessType?: number;
|
|
545
|
+
/** 扩展参数对象 */
|
|
540
546
|
params?: ObjectType<any>;
|
|
541
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* 聊天布局头部配置接口
|
|
550
|
+
* 控制聊天头部区域的显示和功能
|
|
551
|
+
* 默认 title = true, closeBtn = false, newConversationBtn = true, conversationListBtn = true
|
|
552
|
+
*/
|
|
542
553
|
interface ChatLayoutHeader {
|
|
554
|
+
/** 头部标题渲染控制 */
|
|
543
555
|
title?: RenderControl<void, void>;
|
|
556
|
+
/** 是否显示关闭按钮 */
|
|
544
557
|
closeBtn?: boolean;
|
|
558
|
+
/** 新建会话按钮渲染控制 */
|
|
545
559
|
newConversationBtn?: RenderControl<void, void>;
|
|
560
|
+
/** 是否显示智能体性格选择 */
|
|
546
561
|
agentCharacter?: boolean;
|
|
562
|
+
/** 是否显示会话列表按钮 */
|
|
547
563
|
conversationListBtn?: boolean;
|
|
548
564
|
}
|
|
565
|
+
/**
|
|
566
|
+
* 聊天布局会话列表配置接口
|
|
567
|
+
* 控制会话列表区域的显示和功能
|
|
568
|
+
* 默认 header = true
|
|
569
|
+
*/
|
|
549
570
|
interface ChatLayoutConversationList {
|
|
571
|
+
/** 会话列表头部渲染控制 */
|
|
550
572
|
header?: RenderControl<void, void>;
|
|
551
573
|
}
|
|
574
|
+
/**
|
|
575
|
+
* 聊天布局输入框配置接口
|
|
576
|
+
* 控制输入框区域的功能和样式
|
|
577
|
+
* 默认 placeholder, extraBtn = false, referencesBtn = false
|
|
578
|
+
*/
|
|
552
579
|
interface ChatLayoutSender {
|
|
580
|
+
/** 输入框占位符文本 */
|
|
553
581
|
placeholder?: string;
|
|
582
|
+
/** 额外按钮渲染控制 */
|
|
554
583
|
extraBtn?: RenderControl<void, void>;
|
|
584
|
+
/** 引用按钮渲染控制 */
|
|
555
585
|
referencesBtn?: RenderControl<void, void>;
|
|
586
|
+
/** 底部额外内容渲染控制 */
|
|
556
587
|
footerBelow?: RenderControl<void, void>;
|
|
588
|
+
/** 发送按钮属性配置函数 */
|
|
557
589
|
sendBtnProps?: () => ButtonProps;
|
|
590
|
+
/** 是否显示推荐问题 */
|
|
558
591
|
prompts?: boolean;
|
|
559
592
|
}
|
|
593
|
+
/**
|
|
594
|
+
* 聊天布局消息列表配置接口
|
|
595
|
+
* 控制消息列表区域的显示和功能
|
|
596
|
+
*/
|
|
560
597
|
interface ChatLayoutMessageList {
|
|
598
|
+
/** 头像显示控制:可以是全局布尔值或按成员类型分别控制 */
|
|
561
599
|
avatar?: boolean | Partial<Record<ConversationMemberEnum, boolean>>;
|
|
600
|
+
/** 首条消息渲染控制 */
|
|
562
601
|
firstMessage?: RenderControl<void, void>;
|
|
563
602
|
}
|
|
603
|
+
/**
|
|
604
|
+
* 聊天布局配置接口
|
|
605
|
+
* 控制聊天组件整体布局的显示和功能
|
|
606
|
+
*/
|
|
564
607
|
interface ChatLayout {
|
|
608
|
+
/** 左侧面板渲染控制 */
|
|
565
609
|
leftPanel?: RenderControl<void, void>;
|
|
610
|
+
/** 会话列表面板渲染控制 */
|
|
566
611
|
conversationList?: RenderControl<void, ChatLayoutConversationList>;
|
|
612
|
+
/** 是否允许预览功能 */
|
|
567
613
|
preview?: boolean;
|
|
614
|
+
/** 消息列表渲染控制 */
|
|
568
615
|
messageList?: RenderControl<void, ChatLayoutMessageList>;
|
|
616
|
+
/** 输入框头部渲染控制 */
|
|
569
617
|
senderHeader?: RenderControl<void, void>;
|
|
618
|
+
/** 输入框渲染控制 */
|
|
570
619
|
sender?: RenderControl<void, ChatLayoutSender>;
|
|
620
|
+
/** 输入框底部渲染控制 */
|
|
571
621
|
senderFooter?: RenderControl<void, void>;
|
|
622
|
+
/** 全局头部渲染控制 */
|
|
572
623
|
globalHeader?: RenderControl<void, ChatLayoutHeader>;
|
|
624
|
+
/** 聊天区域头部渲染控制 */
|
|
573
625
|
chatHeader?: RenderControl<void, ChatLayoutHeader>;
|
|
626
|
+
/** 免责声明渲染控制 */
|
|
574
627
|
disclaimerNotice?: RenderControl<void, void>;
|
|
575
628
|
}
|
|
629
|
+
/**
|
|
630
|
+
* 聊天服务接口
|
|
631
|
+
* 定义聊天组件所需的服务配置
|
|
632
|
+
*/
|
|
576
633
|
interface ChatServices {
|
|
634
|
+
/** WebSocket连接基础URL列表,支持多地址容错 */
|
|
577
635
|
websocketBaseUrls?: string[];
|
|
636
|
+
/** API基础URL */
|
|
578
637
|
baseUrl?: string;
|
|
638
|
+
/** 聊天服务和文件服务的合并请求对象 */
|
|
579
639
|
request?: ReturnType<typeof createChatService> & ReturnType<typeof createFileService>;
|
|
580
640
|
}
|
|
581
641
|
|
|
@@ -659,33 +719,71 @@ interface SenderProps {
|
|
|
659
719
|
}
|
|
660
720
|
declare const _default$2: react.ForwardRefExoticComponent<SenderProps & react.RefAttributes<ChatSenderHandle>>;
|
|
661
721
|
|
|
722
|
+
/**
|
|
723
|
+
* 聊天组件配置接口
|
|
724
|
+
* 定义聊天组件的初始化配置选项
|
|
725
|
+
*/
|
|
662
726
|
interface ChatConfig {
|
|
727
|
+
/** 接收者类型:1-用户 2-专家 3-Agent */
|
|
663
728
|
receiverType?: number;
|
|
729
|
+
/** 接收者ID:专家或智能体ID */
|
|
664
730
|
receiverId?: string;
|
|
731
|
+
/** 会话ID:已存在的会话ID */
|
|
665
732
|
conversationId?: string;
|
|
733
|
+
/** 会话策略:1-最近会话 2-新会话 */
|
|
666
734
|
conversationStrategy?: ConversationStrategy;
|
|
667
735
|
}
|
|
736
|
+
/**
|
|
737
|
+
* 聊天组件操作句柄接口
|
|
738
|
+
* 提供外部操作聊天组件的方法
|
|
739
|
+
*/
|
|
668
740
|
interface ChatHandle {
|
|
741
|
+
/** 发送消息 */
|
|
669
742
|
sendMessage: (message?: string, files?: InputFile[]) => void;
|
|
743
|
+
/** 切换智能体会话 */
|
|
670
744
|
switchAgentConversation: (agentId: AgentInfo['id'], strategy?: ConversationStrategy) => Promise<void>;
|
|
745
|
+
/** 切换会话 */
|
|
671
746
|
switchConversation: (id?: Conversation['id']) => Promise<void>;
|
|
747
|
+
/** 创建新会话 */
|
|
672
748
|
createConversation: () => Promise<void>;
|
|
749
|
+
/** 设置引用消息 */
|
|
673
750
|
setReferences: (references?: ReferencesType) => void;
|
|
751
|
+
/** 设置输入框消息内容 */
|
|
674
752
|
setMessage: (message?: string) => void;
|
|
753
|
+
/** 设置上传文件列表 */
|
|
675
754
|
setFiles: (files?: InputFile[]) => void;
|
|
755
|
+
/** 设置聊天参数 */
|
|
676
756
|
setParams: (params?: ChatParams) => void;
|
|
757
|
+
/** 设置服务配置 */
|
|
677
758
|
setServices: (services?: ChatServices) => void;
|
|
759
|
+
/** 输入框聚焦 */
|
|
678
760
|
senderFocus: ChatSenderHandle['focus'];
|
|
679
761
|
}
|
|
762
|
+
/**
|
|
763
|
+
* 聊天组件属性接口
|
|
764
|
+
* 定义聊天组件的输入属性
|
|
765
|
+
*/
|
|
680
766
|
interface ChatProps {
|
|
767
|
+
/** 主题配置 */
|
|
681
768
|
theme?: ThemeConfig;
|
|
769
|
+
/** 聊天配置 */
|
|
682
770
|
config?: ChatConfig;
|
|
771
|
+
/** 聊天参数 */
|
|
683
772
|
params?: ChatParams;
|
|
773
|
+
/** 生命周期钩子 */
|
|
684
774
|
hooks?: ChatHooks;
|
|
775
|
+
/** 布局配置 */
|
|
685
776
|
layout?: ChatLayout;
|
|
777
|
+
/** 用户信息 */
|
|
686
778
|
userInfo?: UserInfo;
|
|
779
|
+
/** 服务配置 */
|
|
687
780
|
services?: ChatServices;
|
|
688
781
|
}
|
|
782
|
+
/**
|
|
783
|
+
* 聊天组件
|
|
784
|
+
* 使用 React.forwardRef 实现的聊天界面组件
|
|
785
|
+
* 集成了消息收发、会话管理、文件预览等功能
|
|
786
|
+
*/
|
|
689
787
|
declare const _default$1: react.ForwardRefExoticComponent<ChatProps & react.RefAttributes<ChatHandle>>;
|
|
690
788
|
|
|
691
789
|
/**
|
|
@@ -703,4 +801,4 @@ interface MessageRenderProps {
|
|
|
703
801
|
*/
|
|
704
802
|
declare const _default: ({ message, placement }: MessageRenderProps) => react_jsx_runtime.JSX.Element;
|
|
705
803
|
|
|
706
|
-
export { type AgentInfo, _default$3 as Attachments, type AttachmentsProps, type ChatConfig, _default$1 as ChatCopilot, type ChatHandle, type ChatHooks, type ChatLayout, type ChatParams, type ChatProps, _default$2 as ChatSender, type ConversationStrategy, type InputFile, _default as MessageRender, type MessageRenderProps, type ReferencesType, type SenderProps };
|
|
804
|
+
export { type AgentInfo, _default$3 as Attachments, type AttachmentsProps, type ChatConfig, _default$1 as ChatCopilot, type ChatHandle, type ChatHooks, type ChatLayout, type ChatParams, type ChatProps, _default$2 as ChatSender, type ChatServices, type ConversationStrategy, type InputFile, _default as MessageRender, type MessageRenderProps, type ReferencesType, type SenderProps, type UserInfo };
|