@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.d.mts CHANGED
@@ -1418,7 +1418,7 @@ interface ChatHandle {
1418
1418
  * // 设置扩展参数, 透传大模型
1419
1419
  * chatRef.current?.setParams({
1420
1420
  * params: {
1421
- * textInfo: '税务局',
1421
+ * citation: '税务局',
1422
1422
  * }
1423
1423
  * })
1424
1424
  */
package/dist/index.d.ts CHANGED
@@ -1418,7 +1418,7 @@ interface ChatHandle {
1418
1418
  * // 设置扩展参数, 透传大模型
1419
1419
  * chatRef.current?.setParams({
1420
1420
  * params: {
1421
- * textInfo: '税务局',
1421
+ * citation: '税务局',
1422
1422
  * }
1423
1423
  * })
1424
1424
  */
package/dist/index.esm.js CHANGED
@@ -136,20 +136,20 @@ var init_IndexQuote = __esm({
136
136
  citations = JSON.parse(message2.citations);
137
137
  } catch (e) {
138
138
  }
139
- return citations.find((item) => String(item.citationId) === String(data.citationId));
139
+ return citations?.find((item) => String(item.citationId) === String(data.citationId));
140
140
  }, [data.citationId, message2.citations]);
141
141
  const onClick = () => {
142
- if (!citation.citationUrl) return;
142
+ if (!citation?.citationUrl) return;
143
143
  if (isExternal(citation.citationUrl)) {
144
144
  window.open(citation.citationUrl, "_blank");
145
145
  } else {
146
146
  setOpen(true);
147
147
  }
148
148
  };
149
- const Content = /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Flex, { align: "center", gap: 8, children: /* @__PURE__ */ jsx("a", { onClick, children: citation.citationName }) }) });
149
+ const Content = /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Flex, { align: "center", gap: 8, children: /* @__PURE__ */ jsx("a", { onClick, children: citation?.citationName }) }) });
150
150
  return /* @__PURE__ */ jsxs("div", { className: "inline-block m-l-8", children: [
151
- /* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsx(Popover, { content: Content, children: /* @__PURE__ */ jsx(Tag, { bordered: false, color: "processing", className: "cursor-pointer", children: data.citationName }) }) }),
152
- open && /* @__PURE__ */ jsx(DocDrawer_default, { paramsStr: citation.citationUrl, title: citation.citationName, open, onClose: () => setOpen(false) })
151
+ /* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsx(Popover, { content: Content, children: /* @__PURE__ */ jsx(Tag, { bordered: false, color: "processing", className: "cursor-pointer", children: data?.citationName }) }) }),
152
+ open && /* @__PURE__ */ jsx(DocDrawer_default, { paramsStr: citation?.citationUrl, title: citation?.citationName, open, onClose: () => setOpen(false) })
153
153
  ] });
154
154
  };
155
155
  }
@@ -168,15 +168,16 @@ var init_MdEdit = __esm({
168
168
  MdEdit_default = ({ data, loading }) => {
169
169
  const chatStore = useChatStore();
170
170
  const [value, setValue] = useState("");
171
+ const btnText = data.btnText || "\u7EE7\u7EED";
171
172
  const onOk = () => {
172
- chatStore.sendMessage("\u5F00\u59CB\u5199\u4F5C", [], { outline: value });
173
+ chatStore.sendMessage(btnText, [], { citation: value });
173
174
  };
174
175
  useEffect(() => {
175
176
  setValue(data.content);
176
177
  }, [data.content]);
177
178
  return /* @__PURE__ */ jsxs("div", { className: styles_module_default.mdEdit, children: [
178
179
  /* @__PURE__ */ jsx(MarkdownEditor, { disabled: loading, value, onChange: setValue, showToolbar: false }),
179
- !loading && /* @__PURE__ */ jsx(Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsx(Button, { color: "primary", variant: "outlined", onClick: onOk, children: "\u786E\u8BA4\u63D0\u7EB2\u601D\u8DEF\uFF0C\u5F00\u59CB\u5199\u4F5C" }) })
180
+ !loading && /* @__PURE__ */ jsx(Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsx(Button, { color: "primary", variant: "outlined", onClick: onOk, children: btnText }) })
180
181
  ] });
181
182
  };
182
183
  }
@@ -874,7 +875,6 @@ function createChatStore() {
874
875
  await config.services.request.conversationMessageSend(sendParams);
875
876
  config.hooks?.onAfterSend?.();
876
877
  } finally {
877
- conversation.messages[conversationId].loading = false;
878
878
  }
879
879
  };
880
880
  const cancelReceive = async () => {
@@ -940,6 +940,7 @@ function createChatStore() {
940
940
  const messages = conversation.messages[msg.conversationId]?.message;
941
941
  const idx = findMsgIndex(msg.id, messages);
942
942
  if (idx === -1) return;
943
+ conversation.messages[msg.conversationId].loading = true;
943
944
  messages[idx] = {
944
945
  ...messages[idx],
945
946
  citations: msg.msgContent
@@ -1080,13 +1081,13 @@ var MessageRender_default = ({ message: message2, placement }) => {
1080
1081
  () => `${message2.msgContent || ""}${message2.msgContent && message2.tempContent ? "\n\n" : ""}${message2.tempContent || ""}`,
1081
1082
  [message2.msgContent, message2.tempContent]
1082
1083
  );
1083
- const paramsTextInfo = useMemo(() => {
1084
- let textInfo = "";
1084
+ const paramsCitation = useMemo(() => {
1085
+ let citation = "";
1085
1086
  try {
1086
- textInfo = JSON.parse(message2.params || "{}").textInfo || "";
1087
+ citation = JSON.parse(message2.params || "{}").citation || "";
1087
1088
  } catch (e) {
1088
1089
  }
1089
- return textInfo;
1090
+ return citation;
1090
1091
  }, [message2.params]);
1091
1092
  return /* @__PURE__ */ jsx(Flex, { vertical: true, children: !(message2.msgContent || message2.tempContent || message2.msgFiles.length) ? /* @__PURE__ */ jsx(Typography, { children: /* @__PURE__ */ jsx(Spin, { size: "small" }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1092
1093
  content && /* @__PURE__ */ jsx(
@@ -1125,7 +1126,7 @@ var MessageRender_default = ({ message: message2, placement }) => {
1125
1126
  content: /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, children: [
1126
1127
  message2.quoteMsg.msgContent && /* @__PURE__ */ jsxs(Flex, { children: [
1127
1128
  /* @__PURE__ */ jsx("span", { children: "\u3010\u5F15\u7528\u6D88\u606F\u3011\uFF1A" }),
1128
- /* @__PURE__ */ jsx(Flex, { flex: 1, className: "text-ellipsis", children: /* @__PURE__ */ jsx(RenderMarkdown, { content: message2.quoteMsg.msgContent }) })
1129
+ /* @__PURE__ */ jsx(Flex, { flex: 1, className: "text-ellipsis", title: message2.quoteMsg.msgContent, children: /* @__PURE__ */ jsx(RenderMarkdown, { content: message2.quoteMsg.msgContent }) })
1129
1130
  ] }),
1130
1131
  message2.quoteMsg?.msgFiles && message2.quoteMsg.msgFiles.length > 0 && /* @__PURE__ */ jsxs(Flex, { children: [
1131
1132
  /* @__PURE__ */ jsx("span", { children: "\u3010\u5F15\u7528\u6587\u4EF6\u3011\uFF1A" }),
@@ -1143,14 +1144,14 @@ var MessageRender_default = ({ message: message2, placement }) => {
1143
1144
  ] })
1144
1145
  ] })
1145
1146
  }
1146
- ) : paramsTextInfo && /* @__PURE__ */ jsx(
1147
+ ) : paramsCitation && /* @__PURE__ */ jsx(
1147
1148
  Bubble,
1148
1149
  {
1149
1150
  className: classNames9(styles_module_default2.chatQuoteMsg),
1150
1151
  placement,
1151
1152
  content: /* @__PURE__ */ jsx(Flex, { vertical: true, gap: 8, children: /* @__PURE__ */ jsxs(Flex, { children: [
1152
1153
  /* @__PURE__ */ jsx("span", { children: "\u3010\u5F15\u7528\u6D88\u606F\u3011\uFF1A" }),
1153
- /* @__PURE__ */ jsx(Flex, { flex: 1, className: "text-ellipsis", children: /* @__PURE__ */ jsx(RenderMarkdown, { content: paramsTextInfo }) })
1154
+ /* @__PURE__ */ jsx(Flex, { flex: 1, className: "text-ellipsis", title: paramsCitation, children: /* @__PURE__ */ jsx(RenderMarkdown, { content: paramsCitation }) })
1154
1155
  ] }) })
1155
1156
  }
1156
1157
  )
@@ -2107,13 +2108,13 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
2107
2108
  value: configState.preview.file.content,
2108
2109
  onQuote: (text) => {
2109
2110
  chatStore.setReferences({
2110
- type: 1,
2111
+ type: 2,
2111
2112
  content: {
2112
2113
  name: text,
2113
2114
  markdown: text
2114
2115
  },
2115
2116
  params: {
2116
- outline: text
2117
+ citation: text
2117
2118
  }
2118
2119
  });
2119
2120
  },