@zero-library/chat-copilot 1.0.17 → 1.0.19
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 +14 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +55 -15
- package/dist/index.d.ts +55 -15
- package/dist/index.esm.js +14 -12
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -694,20 +694,20 @@ interface ChatHandle {
|
|
|
694
694
|
*/
|
|
695
695
|
switchConversation: (id: ConversationType['id']) => Promise<void>;
|
|
696
696
|
/**
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
697
|
+
* 切换智能体会话
|
|
698
|
+
* 切换到指定的智能体并创建或获取会话
|
|
699
|
+
*
|
|
700
|
+
* @param agentId - 目标智能体ID
|
|
701
|
+
* @param strategy - 会话策略,1-使用最近会话,2-创建新会话
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* // 切换到指定智能体并创建新会话
|
|
705
|
+
* chatRef.current?.switchAgentConversation('agent-001')
|
|
706
|
+
*
|
|
707
|
+
* @example
|
|
708
|
+
* // 切换到指定智能体并使用最近会话
|
|
709
|
+
* chatRef.current?.switchAgentConversation('agent-001', 1)
|
|
710
|
+
*/
|
|
711
711
|
/**
|
|
712
712
|
* 基于当前接收者创建新的会话
|
|
713
713
|
*
|
|
@@ -851,6 +851,29 @@ interface ChatHandle {
|
|
|
851
851
|
* chatRef.current?.senderFocus()
|
|
852
852
|
*/
|
|
853
853
|
senderFocus: ChatSenderHandle['focus'];
|
|
854
|
+
/**
|
|
855
|
+
* 设置会话spec
|
|
856
|
+
*
|
|
857
|
+
* @example
|
|
858
|
+
* // 设置会话spec
|
|
859
|
+
* chatRef.current?.setConversationSpec({
|
|
860
|
+
* model: {
|
|
861
|
+
* providerName: 'openai',
|
|
862
|
+
* modelName: 'gpt-4o',
|
|
863
|
+
* reasoning: true
|
|
864
|
+
* },
|
|
865
|
+
* skills: [{
|
|
866
|
+
* mode:1,
|
|
867
|
+
* items: [
|
|
868
|
+
* {
|
|
869
|
+
* id: 'skill-001',
|
|
870
|
+
* name: '技能1',
|
|
871
|
+
* }
|
|
872
|
+
* ]
|
|
873
|
+
* }]
|
|
874
|
+
* })
|
|
875
|
+
*/
|
|
876
|
+
setConversationSpec: (spec: AgentSpec) => void;
|
|
854
877
|
}
|
|
855
878
|
|
|
856
879
|
/**
|
|
@@ -1269,6 +1292,23 @@ interface ChatHooks {
|
|
|
1269
1292
|
* }
|
|
1270
1293
|
*/
|
|
1271
1294
|
onAfterSetReferences?: (references?: ReferencesType) => void;
|
|
1295
|
+
/**
|
|
1296
|
+
* 处理发送参数前回调
|
|
1297
|
+
* 在发送消息前调用,返回新的发送参数,如果是异步操作可以返回 Promise
|
|
1298
|
+
*
|
|
1299
|
+
* @param sendParams - 要发送的消息参数
|
|
1300
|
+
* @returns ConversationMessageSend | Promise<ConversationMessageSend> | void - 返回处理后的发送参数
|
|
1301
|
+
*
|
|
1302
|
+
* @example
|
|
1303
|
+
* onHandleSendParams: (sendParams) => {
|
|
1304
|
+
* // 修改发送参数
|
|
1305
|
+
* return {
|
|
1306
|
+
* ...sendParams,
|
|
1307
|
+
* message: sendParams.message + ' (附加内容)'
|
|
1308
|
+
* }
|
|
1309
|
+
* }
|
|
1310
|
+
*/
|
|
1311
|
+
onHandleSendParams?: (sendParams: ConversationMessageSend) => ConversationMessageSend | Promise<ConversationMessageSend> | void;
|
|
1272
1312
|
}
|
|
1273
1313
|
|
|
1274
1314
|
/**
|
|
@@ -1600,4 +1640,4 @@ interface MessageRenderProps {
|
|
|
1600
1640
|
|
|
1601
1641
|
declare const _default: react.ForwardRefExoticComponent<ChatProps & react.RefAttributes<ChatHandle>>;
|
|
1602
1642
|
|
|
1603
|
-
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 CustomButtonProps, type FileTextType, type FileUploadConfig, type FileUrlType, type InputFile, type MessageRenderProps, type ReferencesType, type RequestInstance, type SenderProps };
|
|
1643
|
+
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 ConversationMessageSend, type ConversationStrategy, type CustomButtonProps, type FileTextType, type FileUploadConfig, type FileUrlType, type InputFile, type MessageRenderProps, type ReferencesType, type RequestInstance, type SenderProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -694,20 +694,20 @@ interface ChatHandle {
|
|
|
694
694
|
*/
|
|
695
695
|
switchConversation: (id: ConversationType['id']) => Promise<void>;
|
|
696
696
|
/**
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
697
|
+
* 切换智能体会话
|
|
698
|
+
* 切换到指定的智能体并创建或获取会话
|
|
699
|
+
*
|
|
700
|
+
* @param agentId - 目标智能体ID
|
|
701
|
+
* @param strategy - 会话策略,1-使用最近会话,2-创建新会话
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* // 切换到指定智能体并创建新会话
|
|
705
|
+
* chatRef.current?.switchAgentConversation('agent-001')
|
|
706
|
+
*
|
|
707
|
+
* @example
|
|
708
|
+
* // 切换到指定智能体并使用最近会话
|
|
709
|
+
* chatRef.current?.switchAgentConversation('agent-001', 1)
|
|
710
|
+
*/
|
|
711
711
|
/**
|
|
712
712
|
* 基于当前接收者创建新的会话
|
|
713
713
|
*
|
|
@@ -851,6 +851,29 @@ interface ChatHandle {
|
|
|
851
851
|
* chatRef.current?.senderFocus()
|
|
852
852
|
*/
|
|
853
853
|
senderFocus: ChatSenderHandle['focus'];
|
|
854
|
+
/**
|
|
855
|
+
* 设置会话spec
|
|
856
|
+
*
|
|
857
|
+
* @example
|
|
858
|
+
* // 设置会话spec
|
|
859
|
+
* chatRef.current?.setConversationSpec({
|
|
860
|
+
* model: {
|
|
861
|
+
* providerName: 'openai',
|
|
862
|
+
* modelName: 'gpt-4o',
|
|
863
|
+
* reasoning: true
|
|
864
|
+
* },
|
|
865
|
+
* skills: [{
|
|
866
|
+
* mode:1,
|
|
867
|
+
* items: [
|
|
868
|
+
* {
|
|
869
|
+
* id: 'skill-001',
|
|
870
|
+
* name: '技能1',
|
|
871
|
+
* }
|
|
872
|
+
* ]
|
|
873
|
+
* }]
|
|
874
|
+
* })
|
|
875
|
+
*/
|
|
876
|
+
setConversationSpec: (spec: AgentSpec) => void;
|
|
854
877
|
}
|
|
855
878
|
|
|
856
879
|
/**
|
|
@@ -1269,6 +1292,23 @@ interface ChatHooks {
|
|
|
1269
1292
|
* }
|
|
1270
1293
|
*/
|
|
1271
1294
|
onAfterSetReferences?: (references?: ReferencesType) => void;
|
|
1295
|
+
/**
|
|
1296
|
+
* 处理发送参数前回调
|
|
1297
|
+
* 在发送消息前调用,返回新的发送参数,如果是异步操作可以返回 Promise
|
|
1298
|
+
*
|
|
1299
|
+
* @param sendParams - 要发送的消息参数
|
|
1300
|
+
* @returns ConversationMessageSend | Promise<ConversationMessageSend> | void - 返回处理后的发送参数
|
|
1301
|
+
*
|
|
1302
|
+
* @example
|
|
1303
|
+
* onHandleSendParams: (sendParams) => {
|
|
1304
|
+
* // 修改发送参数
|
|
1305
|
+
* return {
|
|
1306
|
+
* ...sendParams,
|
|
1307
|
+
* message: sendParams.message + ' (附加内容)'
|
|
1308
|
+
* }
|
|
1309
|
+
* }
|
|
1310
|
+
*/
|
|
1311
|
+
onHandleSendParams?: (sendParams: ConversationMessageSend) => ConversationMessageSend | Promise<ConversationMessageSend> | void;
|
|
1272
1312
|
}
|
|
1273
1313
|
|
|
1274
1314
|
/**
|
|
@@ -1600,4 +1640,4 @@ interface MessageRenderProps {
|
|
|
1600
1640
|
|
|
1601
1641
|
declare const _default: react.ForwardRefExoticComponent<ChatProps & react.RefAttributes<ChatHandle>>;
|
|
1602
1642
|
|
|
1603
|
-
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 CustomButtonProps, type FileTextType, type FileUploadConfig, type FileUrlType, type InputFile, type MessageRenderProps, type ReferencesType, type RequestInstance, type SenderProps };
|
|
1643
|
+
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 ConversationMessageSend, type ConversationStrategy, type CustomButtonProps, type FileTextType, type FileUploadConfig, type FileUrlType, type InputFile, type MessageRenderProps, type ReferencesType, type RequestInstance, type SenderProps };
|
package/dist/index.esm.js
CHANGED
|
@@ -453,13 +453,6 @@ var defaultLayout = {
|
|
|
453
453
|
chatHeader: true,
|
|
454
454
|
messageList: true,
|
|
455
455
|
senderHeader: false,
|
|
456
|
-
sender: {
|
|
457
|
-
props: {
|
|
458
|
-
modelSelect: true,
|
|
459
|
-
skillsBtn: true,
|
|
460
|
-
reasoningBtn: true
|
|
461
|
-
}
|
|
462
|
-
},
|
|
463
456
|
senderFooter: false,
|
|
464
457
|
disclaimerNotice: true
|
|
465
458
|
};
|
|
@@ -1222,7 +1215,8 @@ function createChatStore() {
|
|
|
1222
1215
|
setHeaderOpen(false);
|
|
1223
1216
|
}
|
|
1224
1217
|
try {
|
|
1225
|
-
await config.
|
|
1218
|
+
const dealedParams = await config.hooks?.onHandleSendParams?.(sendParams);
|
|
1219
|
+
await config.services.request.sendMessageStream(dealedParams || sendParams, agent.agentInfo?.id || "");
|
|
1226
1220
|
config.hooks?.onAfterSend?.();
|
|
1227
1221
|
} finally {
|
|
1228
1222
|
}
|
|
@@ -2156,7 +2150,7 @@ var MdEdit_default = ({ data, loading }) => {
|
|
|
2156
2150
|
!loading && /* @__PURE__ */ jsx(Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsx(Button, { color: "primary", variant: "outlined", onClick: onOk, children: btnText }) })
|
|
2157
2151
|
] });
|
|
2158
2152
|
};
|
|
2159
|
-
var PreviewLink_default = ({ data, loading,
|
|
2153
|
+
var PreviewLink_default = ({ data, loading, message: message2, ...rest }) => {
|
|
2160
2154
|
const chatStore = useChatStore();
|
|
2161
2155
|
const getLinkFileName = (href) => {
|
|
2162
2156
|
const url = new URL(href, window.location.origin);
|
|
@@ -2172,7 +2166,15 @@ var PreviewLink_default = ({ data, loading, domNode, ...rest }) => {
|
|
|
2172
2166
|
}
|
|
2173
2167
|
};
|
|
2174
2168
|
const getPreviewFileUrl = (href) => {
|
|
2175
|
-
|
|
2169
|
+
const url = new URL(href, window.location.origin);
|
|
2170
|
+
const path = url.searchParams.get("path") || url.pathname;
|
|
2171
|
+
const fileName = getLinkFileName(href);
|
|
2172
|
+
console.log(path, fileName);
|
|
2173
|
+
if (isDocument(fileName)) {
|
|
2174
|
+
return chatStore.config.services.request.getPreviewUrl(message2.agentId, message2.conversationId, path, "preview");
|
|
2175
|
+
} else {
|
|
2176
|
+
return chatStore.config.services.request.getPreviewUrl(message2.agentId, message2.conversationId, path, "download");
|
|
2177
|
+
}
|
|
2176
2178
|
};
|
|
2177
2179
|
const handlePreviewLink = (href) => {
|
|
2178
2180
|
const fileName = getLinkFileName(href);
|
|
@@ -4599,7 +4601,7 @@ var KnowledgeBtn_default = ({}) => {
|
|
|
4599
4601
|
const [modalOpen, setModalOpen] = useState(false);
|
|
4600
4602
|
const knowledgeCount = conversationState.active.spec?.knowledge?.items?.length ?? 0;
|
|
4601
4603
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4602
|
-
/* @__PURE__ */ jsxs(
|
|
4604
|
+
/* @__PURE__ */ jsxs("div", { className: styles_module_default2.resourceBtn, onClick: () => setModalOpen(true), children: [
|
|
4603
4605
|
/* @__PURE__ */ jsx(IconFont_default, { type: "icon-remark" }),
|
|
4604
4606
|
/* @__PURE__ */ jsx(Text5, { children: "\u77E5\u8BC6\u5E93" }),
|
|
4605
4607
|
knowledgeCount > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -4727,7 +4729,7 @@ var ChatSender_default2 = forwardRef(
|
|
|
4727
4729
|
reasonBtn = true,
|
|
4728
4730
|
skillsBtn = false,
|
|
4729
4731
|
knowledgeBtn = false,
|
|
4730
|
-
modelSelect =
|
|
4732
|
+
modelSelect = false
|
|
4731
4733
|
}, ref) => {
|
|
4732
4734
|
const chatStore = useChatStore();
|
|
4733
4735
|
const configState = useSnapshot(chatStore.config);
|