@zero-library/chat-agent 2.2.15 → 2.2.16
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 +6 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +32 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.esm.js +6 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -930,6 +930,37 @@ interface ChatHooks {
|
|
|
930
930
|
* @param isBuiltIn - 是否为内嵌布局
|
|
931
931
|
*/
|
|
932
932
|
onAfterFilePreview?: (file?: FileUrlType | FileTextType, isBuiltIn?: boolean) => void;
|
|
933
|
+
/**
|
|
934
|
+
* 设置引用消息前回调
|
|
935
|
+
* 在设置引用消息前调用,返回false可阻止设置
|
|
936
|
+
*
|
|
937
|
+
* @param references - 要设置的引用消息, 空则表示正在清除引用消息
|
|
938
|
+
* @returns boolean | Promise<boolean> | void - 返回false阻止设置
|
|
939
|
+
*
|
|
940
|
+
* @example
|
|
941
|
+
* onBeforeSetReferences: (references) => {
|
|
942
|
+
* // 验证引用消息内容
|
|
943
|
+
* if (!references || !references.content) {
|
|
944
|
+
* message.error('引用消息内容不能为空')
|
|
945
|
+
* return false
|
|
946
|
+
* }
|
|
947
|
+
* return true
|
|
948
|
+
* }
|
|
949
|
+
*/
|
|
950
|
+
onBeforeSetReferences?: (references?: ReferencesType) => boolean | Promise<boolean> | void;
|
|
951
|
+
/**
|
|
952
|
+
* 设置引用消息后回调
|
|
953
|
+
* 在设置引用消息完成后调用
|
|
954
|
+
*
|
|
955
|
+
* @param references - 已设置的引用消息, 空则表示已清除引用消息
|
|
956
|
+
*
|
|
957
|
+
* @example
|
|
958
|
+
* onAfterSetReferences: (references) => {
|
|
959
|
+
* console.log('引用消息已设置:', references)
|
|
960
|
+
* // 可以在这里更新界面状态或其他相关操作
|
|
961
|
+
* }
|
|
962
|
+
*/
|
|
963
|
+
onAfterSetReferences?: (references?: ReferencesType) => void;
|
|
933
964
|
}
|
|
934
965
|
/**
|
|
935
966
|
* 聊天参数接口
|
|
@@ -1387,7 +1418,7 @@ interface ChatHandle {
|
|
|
1387
1418
|
* 设置引用消息
|
|
1388
1419
|
* 在输入框中设置引用内容,将在下次发送消息时包含引用信息
|
|
1389
1420
|
*
|
|
1390
|
-
* @param references -
|
|
1421
|
+
* @param references - 引用内容对象, 空则表示清除引用消息
|
|
1391
1422
|
*
|
|
1392
1423
|
* @example
|
|
1393
1424
|
* // 设置Markdown引用
|
package/dist/index.d.ts
CHANGED
|
@@ -930,6 +930,37 @@ interface ChatHooks {
|
|
|
930
930
|
* @param isBuiltIn - 是否为内嵌布局
|
|
931
931
|
*/
|
|
932
932
|
onAfterFilePreview?: (file?: FileUrlType | FileTextType, isBuiltIn?: boolean) => void;
|
|
933
|
+
/**
|
|
934
|
+
* 设置引用消息前回调
|
|
935
|
+
* 在设置引用消息前调用,返回false可阻止设置
|
|
936
|
+
*
|
|
937
|
+
* @param references - 要设置的引用消息, 空则表示正在清除引用消息
|
|
938
|
+
* @returns boolean | Promise<boolean> | void - 返回false阻止设置
|
|
939
|
+
*
|
|
940
|
+
* @example
|
|
941
|
+
* onBeforeSetReferences: (references) => {
|
|
942
|
+
* // 验证引用消息内容
|
|
943
|
+
* if (!references || !references.content) {
|
|
944
|
+
* message.error('引用消息内容不能为空')
|
|
945
|
+
* return false
|
|
946
|
+
* }
|
|
947
|
+
* return true
|
|
948
|
+
* }
|
|
949
|
+
*/
|
|
950
|
+
onBeforeSetReferences?: (references?: ReferencesType) => boolean | Promise<boolean> | void;
|
|
951
|
+
/**
|
|
952
|
+
* 设置引用消息后回调
|
|
953
|
+
* 在设置引用消息完成后调用
|
|
954
|
+
*
|
|
955
|
+
* @param references - 已设置的引用消息, 空则表示已清除引用消息
|
|
956
|
+
*
|
|
957
|
+
* @example
|
|
958
|
+
* onAfterSetReferences: (references) => {
|
|
959
|
+
* console.log('引用消息已设置:', references)
|
|
960
|
+
* // 可以在这里更新界面状态或其他相关操作
|
|
961
|
+
* }
|
|
962
|
+
*/
|
|
963
|
+
onAfterSetReferences?: (references?: ReferencesType) => void;
|
|
933
964
|
}
|
|
934
965
|
/**
|
|
935
966
|
* 聊天参数接口
|
|
@@ -1387,7 +1418,7 @@ interface ChatHandle {
|
|
|
1387
1418
|
* 设置引用消息
|
|
1388
1419
|
* 在输入框中设置引用内容,将在下次发送消息时包含引用信息
|
|
1389
1420
|
*
|
|
1390
|
-
* @param references -
|
|
1421
|
+
* @param references - 引用内容对象, 空则表示清除引用消息
|
|
1391
1422
|
*
|
|
1392
1423
|
* @example
|
|
1393
1424
|
* // 设置Markdown引用
|
package/dist/index.esm.js
CHANGED
|
@@ -681,8 +681,13 @@ function createChatStore() {
|
|
|
681
681
|
const setSpeakHuman = (speakHuman) => {
|
|
682
682
|
conversation.messages[conversation.active.id].speakHuman = speakHuman;
|
|
683
683
|
};
|
|
684
|
-
const setReferences = (references) => {
|
|
684
|
+
const setReferences = async (references) => {
|
|
685
|
+
const canProceed = await config.hooks?.onBeforeSetReferences?.(references);
|
|
686
|
+
if (canProceed === false) {
|
|
687
|
+
throw new Error("\u64CD\u4F5C\u88AB\u963B\u6B62");
|
|
688
|
+
}
|
|
685
689
|
conversation.messages[conversation.active.id].references = references;
|
|
690
|
+
config.hooks?.onAfterSetReferences?.(references);
|
|
686
691
|
};
|
|
687
692
|
const setContent = (content) => {
|
|
688
693
|
conversation.messages[conversation.active.id].content = content;
|