@zero-library/chat-copilot 1.0.2 → 1.0.4
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 +3582 -3542
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +178 -103
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +64 -15
- package/dist/index.d.ts +64 -15
- package/dist/index.esm.js +3530 -3489
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import react__default from 'react';
|
|
2
|
+
import react__default, { ReactNode } from 'react';
|
|
3
|
+
import { BubbleProps } from '@ant-design/x-v2';
|
|
3
4
|
import { ButtonProps, ThemeConfig } from 'antd';
|
|
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';
|
|
7
6
|
|
|
8
7
|
type ConversationMemberEnum = 'user' | 'agent';
|
|
9
8
|
declare enum AgentTypeEnum {
|
|
@@ -135,7 +134,7 @@ interface SenderProps {
|
|
|
135
134
|
/** 文件上传配置 */
|
|
136
135
|
fileUpload?: FileUpload;
|
|
137
136
|
}
|
|
138
|
-
declare const _default$
|
|
137
|
+
declare const _default$2: react.ForwardRefExoticComponent<SenderProps & react.RefAttributes<ChatSenderHandle>>;
|
|
139
138
|
|
|
140
139
|
interface UserInputType {
|
|
141
140
|
inputs: Variable[];
|
|
@@ -349,11 +348,48 @@ interface InputFile {
|
|
|
349
348
|
* 定义通过URL访问的文件信息
|
|
350
349
|
*/
|
|
351
350
|
interface FileUrlType {
|
|
351
|
+
/** 文件后缀名 */
|
|
352
|
+
suffix: string;
|
|
353
|
+
/** 文件访问URL */
|
|
354
|
+
fileUrl: string;
|
|
355
|
+
/** 文件名 */
|
|
356
|
+
fileName: string;
|
|
357
|
+
}
|
|
358
|
+
interface FirstMessageRenderCtx {
|
|
359
|
+
index: number;
|
|
360
|
+
member: 1 | 2;
|
|
361
|
+
}
|
|
362
|
+
interface FirstMessage extends Omit<BubbleProps, 'content' | 'contentRender' | 'role' | 'placement'> {
|
|
363
|
+
/** 会话成员类型 */
|
|
364
|
+
member?: 1 | 2;
|
|
365
|
+
/** 直接传入要展示的节点 */
|
|
366
|
+
content?: ReactNode;
|
|
367
|
+
/** 动态生成要展示的节点 */
|
|
368
|
+
contentRender?: (ctx: FirstMessageRenderCtx) => ReactNode;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* 文件文本类型接口
|
|
372
|
+
* 定义包含文本内容的文件信息
|
|
373
|
+
*/
|
|
374
|
+
interface FileTextType {
|
|
375
|
+
/** 文件内容 */
|
|
376
|
+
content: string;
|
|
377
|
+
/** 文件后缀名 */
|
|
378
|
+
suffix: string;
|
|
379
|
+
/** 文件名 */
|
|
380
|
+
fileName: string;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* 文件文本类型接口
|
|
384
|
+
* 定义包含文本内容的文件信息
|
|
385
|
+
*/
|
|
386
|
+
interface FileTextType {
|
|
387
|
+
/** 文件内容 */
|
|
388
|
+
content: string;
|
|
389
|
+
/** 文件后缀名 */
|
|
390
|
+
suffix: string;
|
|
352
391
|
/** 文件名 */
|
|
353
392
|
fileName: string;
|
|
354
|
-
path: string;
|
|
355
|
-
fileUrl?: string;
|
|
356
|
-
ext?: string;
|
|
357
393
|
}
|
|
358
394
|
/**
|
|
359
395
|
* 消息引用类型
|
|
@@ -364,8 +400,6 @@ interface MessageQuoteMsg {
|
|
|
364
400
|
id?: string;
|
|
365
401
|
/** 被引用的消息内容 */
|
|
366
402
|
msgContent?: string;
|
|
367
|
-
/** 被引用消息的附件文件列表 */
|
|
368
|
-
msgFiles?: InputFile[];
|
|
369
403
|
}
|
|
370
404
|
/**
|
|
371
405
|
* 引用内容接口
|
|
@@ -634,6 +668,21 @@ interface ChatHandle {
|
|
|
634
668
|
* chatRef.current?.switchConversation(item)
|
|
635
669
|
*/
|
|
636
670
|
switchConversation: (id: ConversationType['id']) => Promise<void>;
|
|
671
|
+
/**
|
|
672
|
+
* 切换智能体会话
|
|
673
|
+
* 切换到指定的智能体并创建或获取会话
|
|
674
|
+
*
|
|
675
|
+
* @param agentId - 目标智能体ID
|
|
676
|
+
* @param strategy - 会话策略,1-使用最近会话,2-创建新会话
|
|
677
|
+
*
|
|
678
|
+
* @example
|
|
679
|
+
* // 切换到指定智能体并创建新会话
|
|
680
|
+
* chatRef.current?.switchAgentConversation('agent-001')
|
|
681
|
+
*
|
|
682
|
+
* @example
|
|
683
|
+
* // 切换到指定智能体并使用最近会话
|
|
684
|
+
* chatRef.current?.switchAgentConversation('agent-001', 1)
|
|
685
|
+
*/
|
|
637
686
|
/**
|
|
638
687
|
* 基于当前接收者创建新的会话
|
|
639
688
|
*
|
|
@@ -665,6 +714,7 @@ interface ChatHandle {
|
|
|
665
714
|
* // 清除引用
|
|
666
715
|
* chatRef.current?.setReferences()
|
|
667
716
|
*/
|
|
717
|
+
setReferences: (references?: ReferencesType) => void;
|
|
668
718
|
/**
|
|
669
719
|
* 直接设置输入框中的文本内容
|
|
670
720
|
*
|
|
@@ -1155,14 +1205,14 @@ interface ChatHooks {
|
|
|
1155
1205
|
* @param file - 被预览的文件对象, 如果不存在则表示正在关闭预览
|
|
1156
1206
|
* @param isBuiltIn - 是否为内嵌布局
|
|
1157
1207
|
*/
|
|
1158
|
-
onBeforeFilePreview?: (file?: FileUrlType, isBuiltIn?: boolean) => boolean | Promise<boolean> | void;
|
|
1208
|
+
onBeforeFilePreview?: (file?: FileUrlType | FileTextType, isBuiltIn?: boolean) => boolean | Promise<boolean> | void;
|
|
1159
1209
|
/**
|
|
1160
1210
|
* 文件预览后的回调函数
|
|
1161
1211
|
* 在文件预览打开或关闭之后执行,可以用于控制布局等
|
|
1162
1212
|
* @param file - 预览的文件对象, 如果不存在则表示已经关闭预览
|
|
1163
1213
|
* @param isBuiltIn - 是否为内嵌布局
|
|
1164
1214
|
*/
|
|
1165
|
-
onAfterFilePreview?: (file?: FileUrlType, isBuiltIn?: boolean) => void;
|
|
1215
|
+
onAfterFilePreview?: (file?: FileUrlType | FileTextType, isBuiltIn?: boolean) => void;
|
|
1166
1216
|
/**
|
|
1167
1217
|
* 设置引用消息前回调
|
|
1168
1218
|
* 在设置引用消息前调用,返回false可阻止设置
|
|
@@ -1326,7 +1376,7 @@ interface ChatLayoutWelcomeMessage {
|
|
|
1326
1376
|
*/
|
|
1327
1377
|
interface ChatLayoutMessageList {
|
|
1328
1378
|
/** 首条消息配置 */
|
|
1329
|
-
firstMessages?:
|
|
1379
|
+
firstMessages?: FirstMessage[];
|
|
1330
1380
|
/** 头像显示控制:可以是全局布尔值或按成员类型分别控制 */
|
|
1331
1381
|
avatar?: boolean | Partial<Record<ConversationMemberEnum, boolean>>;
|
|
1332
1382
|
/** 智能体消息操作区渲染控制 */
|
|
@@ -1438,7 +1488,7 @@ interface AttachmentsProps {
|
|
|
1438
1488
|
* 附件上传组件
|
|
1439
1489
|
* 支持多文件上传、文件类型验证、文件大小限制等功能
|
|
1440
1490
|
*/
|
|
1441
|
-
declare const _default$
|
|
1491
|
+
declare const _default$1: react.ForwardRefExoticComponent<AttachmentsProps & react.RefAttributes<unknown>>;
|
|
1442
1492
|
|
|
1443
1493
|
interface RoleContent {
|
|
1444
1494
|
role: number;
|
|
@@ -1457,8 +1507,7 @@ interface MessageRenderProps {
|
|
|
1457
1507
|
/** message自定义标记渲染组件 */
|
|
1458
1508
|
customComponents?: ChatLayoutMessageList['customComponents'];
|
|
1459
1509
|
}
|
|
1460
|
-
declare const _default$1: react__default.MemoExoticComponent<({ role, message, messageIndex, loading, containerRef, customComponents }: MessageRenderProps) => react_jsx_runtime.JSX.Element>;
|
|
1461
1510
|
|
|
1462
1511
|
declare const _default: react.ForwardRefExoticComponent<ChatProps & react.RefAttributes<ChatHandle>>;
|
|
1463
1512
|
|
|
1464
|
-
export { type AgentConfig, type AgentInfo, type AgentSpec, _default$
|
|
1513
|
+
export { type AgentConfig, type AgentInfo, type AgentSpec, _default$1 as Attachments, type AttachmentsProps, type ChatConfig, _default as ChatCopilot, type ChatHandle, type ChatHooks, type ChatLayout, type ChatParams, type ChatProps, _default$2 as ChatSender, type ChatServices, type ConversationMessage, type ConversationStrategy, type FileUploadConfig, type InputFile, type MessageRenderProps, type ReferencesType, type RequestInstance, type SenderProps };
|