@zero-library/chat-agent 2.2.2 → 2.2.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 +18 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +18 -17
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -144,20 +144,20 @@ var init_IndexQuote = __esm({
|
|
|
144
144
|
citations = JSON.parse(message2.citations);
|
|
145
145
|
} catch (e) {
|
|
146
146
|
}
|
|
147
|
-
return citations
|
|
147
|
+
return citations?.find((item) => String(item.citationId) === String(data.citationId));
|
|
148
148
|
}, [data.citationId, message2.citations]);
|
|
149
149
|
const onClick = () => {
|
|
150
|
-
if (!citation
|
|
150
|
+
if (!citation?.citationUrl) return;
|
|
151
151
|
if (common.isExternal(citation.citationUrl)) {
|
|
152
152
|
window.open(citation.citationUrl, "_blank");
|
|
153
153
|
} else {
|
|
154
154
|
setOpen(true);
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
|
-
const Content = /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", gap: 8, children: /* @__PURE__ */ jsxRuntime.jsx("a", { onClick, children: citation
|
|
157
|
+
const Content = /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", gap: 8, children: /* @__PURE__ */ jsxRuntime.jsx("a", { onClick, children: citation?.citationName }) }) });
|
|
158
158
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inline-block m-l-8", children: [
|
|
159
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Popover, { content: Content, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { bordered: false, color: "processing", className: "cursor-pointer", children: data
|
|
160
|
-
open && /* @__PURE__ */ jsxRuntime.jsx(DocDrawer_default, { paramsStr: citation
|
|
159
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Popover, { content: Content, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { bordered: false, color: "processing", className: "cursor-pointer", children: data?.citationName }) }) }),
|
|
160
|
+
open && /* @__PURE__ */ jsxRuntime.jsx(DocDrawer_default, { paramsStr: citation?.citationUrl, title: citation?.citationName, open, onClose: () => setOpen(false) })
|
|
161
161
|
] });
|
|
162
162
|
};
|
|
163
163
|
}
|
|
@@ -176,15 +176,16 @@ var init_MdEdit = __esm({
|
|
|
176
176
|
MdEdit_default = ({ data, loading }) => {
|
|
177
177
|
const chatStore = useChatStore();
|
|
178
178
|
const [value, setValue] = react.useState("");
|
|
179
|
+
const btnText = data.btnText || "\u7EE7\u7EED";
|
|
179
180
|
const onOk = () => {
|
|
180
|
-
chatStore.sendMessage(
|
|
181
|
+
chatStore.sendMessage(btnText, [], { citation: value });
|
|
181
182
|
};
|
|
182
183
|
react.useEffect(() => {
|
|
183
184
|
setValue(data.content);
|
|
184
185
|
}, [data.content]);
|
|
185
186
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default.mdEdit, children: [
|
|
186
187
|
/* @__PURE__ */ jsxRuntime.jsx(common.MarkdownEditor, { disabled: loading, value, onChange: setValue, showToolbar: false }),
|
|
187
|
-
!loading && /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "primary", variant: "outlined", onClick: onOk, children:
|
|
188
|
+
!loading && /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "primary", variant: "outlined", onClick: onOk, children: btnText }) })
|
|
188
189
|
] });
|
|
189
190
|
};
|
|
190
191
|
}
|
|
@@ -882,7 +883,6 @@ function createChatStore() {
|
|
|
882
883
|
await config.services.request.conversationMessageSend(sendParams);
|
|
883
884
|
config.hooks?.onAfterSend?.();
|
|
884
885
|
} finally {
|
|
885
|
-
conversation.messages[conversationId].loading = false;
|
|
886
886
|
}
|
|
887
887
|
};
|
|
888
888
|
const cancelReceive = async () => {
|
|
@@ -948,6 +948,7 @@ function createChatStore() {
|
|
|
948
948
|
const messages = conversation.messages[msg.conversationId]?.message;
|
|
949
949
|
const idx = findMsgIndex(msg.id, messages);
|
|
950
950
|
if (idx === -1) return;
|
|
951
|
+
conversation.messages[msg.conversationId].loading = true;
|
|
951
952
|
messages[idx] = {
|
|
952
953
|
...messages[idx],
|
|
953
954
|
citations: msg.msgContent
|
|
@@ -1088,13 +1089,13 @@ var MessageRender_default = ({ message: message2, placement }) => {
|
|
|
1088
1089
|
() => `${message2.msgContent || ""}${message2.msgContent && message2.tempContent ? "\n\n" : ""}${message2.tempContent || ""}`,
|
|
1089
1090
|
[message2.msgContent, message2.tempContent]
|
|
1090
1091
|
);
|
|
1091
|
-
const
|
|
1092
|
-
let
|
|
1092
|
+
const paramsCitation = react.useMemo(() => {
|
|
1093
|
+
let citation = "";
|
|
1093
1094
|
try {
|
|
1094
|
-
|
|
1095
|
+
citation = JSON.parse(message2.params || "{}").citation || "";
|
|
1095
1096
|
} catch (e) {
|
|
1096
1097
|
}
|
|
1097
|
-
return
|
|
1098
|
+
return citation;
|
|
1098
1099
|
}, [message2.params]);
|
|
1099
1100
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, children: !(message2.msgContent || message2.tempContent || message2.msgFiles.length) ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography, { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { size: "small" }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1100
1101
|
content && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1133,7 +1134,7 @@ var MessageRender_default = ({ message: message2, placement }) => {
|
|
|
1133
1134
|
content: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 8, children: [
|
|
1134
1135
|
message2.quoteMsg.msgContent && /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
1135
1136
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u3010\u5F15\u7528\u6D88\u606F\u3011\uFF1A" }),
|
|
1136
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { flex: 1, className: "text-ellipsis", children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content: message2.quoteMsg.msgContent }) })
|
|
1137
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { flex: 1, className: "text-ellipsis", title: message2.quoteMsg.msgContent, children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content: message2.quoteMsg.msgContent }) })
|
|
1137
1138
|
] }),
|
|
1138
1139
|
message2.quoteMsg?.msgFiles && message2.quoteMsg.msgFiles.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
1139
1140
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u3010\u5F15\u7528\u6587\u4EF6\u3011\uFF1A" }),
|
|
@@ -1151,14 +1152,14 @@ var MessageRender_default = ({ message: message2, placement }) => {
|
|
|
1151
1152
|
] })
|
|
1152
1153
|
] })
|
|
1153
1154
|
}
|
|
1154
|
-
) :
|
|
1155
|
+
) : paramsCitation && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1155
1156
|
x.Bubble,
|
|
1156
1157
|
{
|
|
1157
1158
|
className: classNames9__default.default(styles_module_default2.chatQuoteMsg),
|
|
1158
1159
|
placement,
|
|
1159
1160
|
content: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 8, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
1160
1161
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u3010\u5F15\u7528\u6D88\u606F\u3011\uFF1A" }),
|
|
1161
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { flex: 1, className: "text-ellipsis", children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content:
|
|
1162
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { flex: 1, className: "text-ellipsis", title: paramsCitation, children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content: paramsCitation }) })
|
|
1162
1163
|
] }) })
|
|
1163
1164
|
}
|
|
1164
1165
|
)
|
|
@@ -2115,13 +2116,13 @@ var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout
|
|
|
2115
2116
|
value: configState.preview.file.content,
|
|
2116
2117
|
onQuote: (text) => {
|
|
2117
2118
|
chatStore.setReferences({
|
|
2118
|
-
type:
|
|
2119
|
+
type: 2,
|
|
2119
2120
|
content: {
|
|
2120
2121
|
name: text,
|
|
2121
2122
|
markdown: text
|
|
2122
2123
|
},
|
|
2123
2124
|
params: {
|
|
2124
|
-
|
|
2125
|
+
citation: text
|
|
2125
2126
|
}
|
|
2126
2127
|
});
|
|
2127
2128
|
},
|