@zero-library/chat-copilot 1.0.0 → 1.0.2
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 +440 -469
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +39 -64
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +111 -64
- package/dist/index.d.ts +111 -64
- package/dist/index.esm.js +440 -469
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import react__default from 'react';
|
|
|
3
3
|
import { ButtonProps, ThemeConfig } from 'antd';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import { createRequest, RequestConfig, RenderControl } from '@zero-library/common';
|
|
6
|
+
import { BubbleProps } from '@ant-design/x-v2';
|
|
6
7
|
|
|
7
8
|
type ConversationMemberEnum = 'user' | 'agent';
|
|
8
9
|
declare enum AgentTypeEnum {
|
|
@@ -66,10 +67,10 @@ interface AgentConfig {
|
|
|
66
67
|
}
|
|
67
68
|
interface AgentInfo {
|
|
68
69
|
id: string;
|
|
69
|
-
name
|
|
70
|
-
description
|
|
71
|
-
iconUrl
|
|
72
|
-
agentType
|
|
70
|
+
name?: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
iconUrl?: string;
|
|
73
|
+
agentType?: AgentTypeEnum;
|
|
73
74
|
updatedAt?: string;
|
|
74
75
|
tagIds?: string[];
|
|
75
76
|
spec?: AgentSpec;
|
|
@@ -77,6 +78,65 @@ interface AgentInfo {
|
|
|
77
78
|
userInput?: Variable[];
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
/**
|
|
82
|
+
* ChatSender 组件暴露的方法接口
|
|
83
|
+
*/
|
|
84
|
+
interface ChatSenderHandle {
|
|
85
|
+
/** 聚焦输入框 */
|
|
86
|
+
focus: (options?: {
|
|
87
|
+
cursor?: 'start' | 'end';
|
|
88
|
+
}) => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 文件上传配置接口
|
|
92
|
+
*/
|
|
93
|
+
interface FileUpload {
|
|
94
|
+
/** 上传时的额外参数 */
|
|
95
|
+
params?: ObjectType<any>;
|
|
96
|
+
/** 文件上传配置列表 */
|
|
97
|
+
config: FileUploadConfig;
|
|
98
|
+
/** 文件上传请求函数 */
|
|
99
|
+
request: AttachmentsProps['fileUpload'];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* ChatSender 组件属性接口
|
|
103
|
+
*/
|
|
104
|
+
interface SenderProps {
|
|
105
|
+
/** 输入框占位符 */
|
|
106
|
+
placeholder?: string;
|
|
107
|
+
/** 输入框内容 */
|
|
108
|
+
content?: string;
|
|
109
|
+
/** 文件列表 */
|
|
110
|
+
fileList?: InputFile[];
|
|
111
|
+
/** 是否打开文件选择头部 */
|
|
112
|
+
headerOpen?: boolean;
|
|
113
|
+
/** 是否正在发送消息 */
|
|
114
|
+
loading?: boolean;
|
|
115
|
+
/** 内容变化回调 */
|
|
116
|
+
onContentChange: (value: string) => void;
|
|
117
|
+
/** 文件列表变化回调 */
|
|
118
|
+
onFileListChange: (files: InputFile[]) => void;
|
|
119
|
+
/** 头部打开状态变化回调 */
|
|
120
|
+
onHeaderOpenChange: (open: boolean) => void;
|
|
121
|
+
/** 发送消息回调 */
|
|
122
|
+
onSend: () => void;
|
|
123
|
+
/** 取消发送回调 */
|
|
124
|
+
onCancel?: () => void;
|
|
125
|
+
/** 输入框聚焦回调 */
|
|
126
|
+
onFocus?: () => void;
|
|
127
|
+
/** 头部额外内容 */
|
|
128
|
+
extraHeader?: React.ReactNode;
|
|
129
|
+
/** 底部额外内容 */
|
|
130
|
+
extraFooter?: React.ReactNode;
|
|
131
|
+
/** 底部下方额外内容 */
|
|
132
|
+
extraFooterBelow?: React.ReactNode;
|
|
133
|
+
/** 发送按钮属性 */
|
|
134
|
+
sendBtnProps?: ButtonProps;
|
|
135
|
+
/** 文件上传配置 */
|
|
136
|
+
fileUpload?: FileUpload;
|
|
137
|
+
}
|
|
138
|
+
declare const _default$3: react.ForwardRefExoticComponent<SenderProps & react.RefAttributes<ChatSenderHandle>>;
|
|
139
|
+
|
|
80
140
|
interface UserInputType {
|
|
81
141
|
inputs: Variable[];
|
|
82
142
|
outputs: Variable[];
|
|
@@ -87,6 +147,7 @@ interface UserInputType {
|
|
|
87
147
|
* @returns 聊天服务对象
|
|
88
148
|
*/
|
|
89
149
|
declare const createChatService: (request: ReturnType<typeof createRequest>, config?: RequestConfig) => {
|
|
150
|
+
fetchModelList: () => Promise<R<ProviderModel[]>>;
|
|
90
151
|
fetchAgentInfo: (agentId: string) => Promise<R<AgentInfo>>;
|
|
91
152
|
createConversationId: (params: ConversationCreate) => Promise<R<string>>;
|
|
92
153
|
fetchConversations: (params: ConversationsQuery) => Promise<R<ConversationType[]>>;
|
|
@@ -237,9 +298,13 @@ interface ConvMeta {
|
|
|
237
298
|
* 1 正常 2 debug
|
|
238
299
|
*/
|
|
239
300
|
mode?: number;
|
|
301
|
+
/** 项目或知识库ID */
|
|
240
302
|
libraryId?: string;
|
|
303
|
+
/** 会话来源 */
|
|
241
304
|
source?: number;
|
|
305
|
+
/** 项目或知识库类型 */
|
|
242
306
|
libraryType?: LibraryTypeEnum;
|
|
307
|
+
/** 技能会话ID */
|
|
243
308
|
skillConversationId?: string;
|
|
244
309
|
}
|
|
245
310
|
|
|
@@ -482,11 +547,17 @@ type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent
|
|
|
482
547
|
* 定义智能体和用户之间的消息结构
|
|
483
548
|
*/
|
|
484
549
|
interface ConversationMessage {
|
|
550
|
+
/** 消息ID */
|
|
485
551
|
messageId: string;
|
|
552
|
+
/** 会话ID */
|
|
486
553
|
conversationId: string;
|
|
554
|
+
/** 执行ID */
|
|
487
555
|
executionId: string;
|
|
556
|
+
/** 角色:1-智能体 2-用户 */
|
|
488
557
|
role: number;
|
|
558
|
+
/** 消息内容 */
|
|
489
559
|
content: MessageEvent[];
|
|
560
|
+
/** 上传文件内容 */
|
|
490
561
|
files?: InputFile[];
|
|
491
562
|
/** 消息反馈:1-赞 2-踩 */
|
|
492
563
|
feedback?: number;
|
|
@@ -494,6 +565,7 @@ interface ConversationMessage {
|
|
|
494
565
|
params?: string;
|
|
495
566
|
/** 引用的消息信息 */
|
|
496
567
|
quoteMsg?: MessageQuoteMsg;
|
|
568
|
+
/** 创建时间 */
|
|
497
569
|
createdAt: string;
|
|
498
570
|
/** 是否被打断标志 */
|
|
499
571
|
stopFlag?: boolean;
|
|
@@ -1077,6 +1149,12 @@ interface ChatHooks {
|
|
|
1077
1149
|
* }
|
|
1078
1150
|
*/
|
|
1079
1151
|
onAppRightVerify?: (appKey: string) => boolean | Promise<boolean> | void;
|
|
1152
|
+
/**
|
|
1153
|
+
* 文件预览前回调函数
|
|
1154
|
+
* 在文件预览打开前调用,返回false可阻止预览
|
|
1155
|
+
* @param file - 被预览的文件对象, 如果不存在则表示正在关闭预览
|
|
1156
|
+
* @param isBuiltIn - 是否为内嵌布局
|
|
1157
|
+
*/
|
|
1080
1158
|
onBeforeFilePreview?: (file?: FileUrlType, isBuiltIn?: boolean) => boolean | Promise<boolean> | void;
|
|
1081
1159
|
/**
|
|
1082
1160
|
* 文件预览后的回调函数
|
|
@@ -1323,6 +1401,23 @@ interface ChatProps {
|
|
|
1323
1401
|
layout?: ChatLayout;
|
|
1324
1402
|
services?: ChatServices;
|
|
1325
1403
|
}
|
|
1404
|
+
interface Model {
|
|
1405
|
+
modelName: string;
|
|
1406
|
+
modelLabel: string;
|
|
1407
|
+
desc: string | null;
|
|
1408
|
+
tags: readonly string[] | null;
|
|
1409
|
+
providerId: string;
|
|
1410
|
+
providerName: string;
|
|
1411
|
+
providerLabel?: string;
|
|
1412
|
+
icon: string;
|
|
1413
|
+
}
|
|
1414
|
+
interface ProviderModel {
|
|
1415
|
+
providerName: string;
|
|
1416
|
+
providerLabel: string;
|
|
1417
|
+
iconUrl: string;
|
|
1418
|
+
icon?: string;
|
|
1419
|
+
models: Model[];
|
|
1420
|
+
}
|
|
1326
1421
|
|
|
1327
1422
|
/**
|
|
1328
1423
|
* 附件组件属性接口
|
|
@@ -1339,67 +1434,21 @@ interface AttachmentsProps {
|
|
|
1339
1434
|
/** 文件列表变化回调函数 */
|
|
1340
1435
|
onChange: (fileList: InputFile[]) => void;
|
|
1341
1436
|
}
|
|
1342
|
-
|
|
1343
1437
|
/**
|
|
1344
|
-
*
|
|
1438
|
+
* 附件上传组件
|
|
1439
|
+
* 支持多文件上传、文件类型验证、文件大小限制等功能
|
|
1345
1440
|
*/
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
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;
|
|
1441
|
+
declare const _default$2: react.ForwardRefExoticComponent<AttachmentsProps & react.RefAttributes<unknown>>;
|
|
1442
|
+
|
|
1443
|
+
interface RoleContent {
|
|
1444
|
+
role: number;
|
|
1445
|
+
user: ConversationMemberEnum;
|
|
1446
|
+
placement: BubbleProps['placement'];
|
|
1447
|
+
avatar?: any;
|
|
1399
1448
|
}
|
|
1400
|
-
declare const _default$3: react.ForwardRefExoticComponent<SenderProps & react.RefAttributes<ChatSenderHandle>>;
|
|
1401
1449
|
|
|
1402
1450
|
interface MessageRenderProps {
|
|
1451
|
+
role: RoleContent;
|
|
1403
1452
|
message: ConversationMessage;
|
|
1404
1453
|
messageIndex?: number;
|
|
1405
1454
|
loading?: boolean;
|
|
@@ -1408,10 +1457,8 @@ interface MessageRenderProps {
|
|
|
1408
1457
|
/** message自定义标记渲染组件 */
|
|
1409
1458
|
customComponents?: ChatLayoutMessageList['customComponents'];
|
|
1410
1459
|
}
|
|
1411
|
-
declare const _default$
|
|
1412
|
-
|
|
1413
|
-
declare const _default$1: ({ firstMessages, welcomeMessage, avatar, agentActions, customComponents }: ChatLayoutMessageList) => react_jsx_runtime.JSX.Element;
|
|
1460
|
+
declare const _default$1: react__default.MemoExoticComponent<({ role, message, messageIndex, loading, containerRef, customComponents }: MessageRenderProps) => react_jsx_runtime.JSX.Element>;
|
|
1414
1461
|
|
|
1415
1462
|
declare const _default: react.ForwardRefExoticComponent<ChatProps & react.RefAttributes<ChatHandle>>;
|
|
1416
1463
|
|
|
1417
|
-
export { type AgentConfig, type AgentInfo, type AgentSpec, _default$
|
|
1464
|
+
export { type AgentConfig, type AgentInfo, type AgentSpec, _default$2 as Attachments, type AttachmentsProps, type ChatConfig, _default as ChatCopilot, type ChatHandle, type ChatHooks, type ChatLayout, type ChatParams, type ChatProps, _default$3 as ChatSender, type ChatServices, type ConversationMessage, type ConversationStrategy, type FileUploadConfig, type InputFile, _default$1 as MessageRender, type MessageRenderProps, type ReferencesType, type RequestInstance, type SenderProps };
|