@zero-library/chat-agent 2.0.2 → 2.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 CHANGED
@@ -7,14 +7,14 @@ var jsxRuntime = require('react/jsx-runtime');
7
7
  var react = require('react');
8
8
  var icons = require('@ant-design/icons');
9
9
  var x = require('@ant-design/x');
10
- var classNames2 = require('classnames');
10
+ var classNames5 = require('classnames');
11
11
  var valtio = require('valtio');
12
12
  var InfiniteScroll = require('react-infinite-scroll-component');
13
13
 
14
14
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
15
 
16
16
  var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
17
- var classNames2__default = /*#__PURE__*/_interopDefault(classNames2);
17
+ var classNames5__default = /*#__PURE__*/_interopDefault(classNames5);
18
18
  var InfiniteScroll__default = /*#__PURE__*/_interopDefault(InfiniteScroll);
19
19
 
20
20
  var __defProp = Object.defineProperty;
@@ -210,6 +210,7 @@ var init_IndexQuote = __esm({
210
210
  if (!el) return;
211
211
  const previous = el.previousElementSibling;
212
212
  if (!previous) return;
213
+ console.log("previous", previous, el);
213
214
  previous.appendChild(el);
214
215
  }, []);
215
216
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: rootRef, className: "inline-block m-l-8", children: [
@@ -501,7 +502,8 @@ var defaultLayout = {
501
502
  headerTitle: true,
502
503
  headerConversationListBtn: true,
503
504
  headerNewConversationBtn: true,
504
- headerCloseBtn: false
505
+ headerCloseBtn: false,
506
+ disclaimerNotice: true
505
507
  };
506
508
  function createChatStore() {
507
509
  const config = valtio.proxy({
@@ -895,7 +897,6 @@ init_Context();
895
897
  var styles_module_default = {
896
898
  loadingMessage: "styles_module_loadingMessage",
897
899
  nsConversations: "styles_module_nsConversations",
898
- nsBody: "styles_module_nsBody",
899
900
  nsBodyWidth: "styles_module_nsBodyWidth",
900
901
  nsBubbleList: "styles_module_nsBubbleList",
901
902
  nsAgentHeader: "styles_module_nsAgentHeader",
@@ -965,7 +966,6 @@ var AgentHeader_default = () => {
965
966
  const chatStore = useChatStore();
966
967
  const agentState = valtio.useSnapshot(chatStore.agent);
967
968
  const configState = valtio.useSnapshot(chatStore.config);
968
- valtio.useSnapshot(chatStore.conversations);
969
969
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", className: styles_module_default.nsAgentHeader, children: [
970
970
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 4, align: "center", children: [
971
971
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1092,7 +1092,7 @@ var MessageAIRender_default = ({ message: message4, placement }) => {
1092
1092
  x.Bubble,
1093
1093
  {
1094
1094
  placement,
1095
- className: classNames2__default.default({ [styles_module_default.loadingMessage]: message4.status === "loading" }),
1095
+ className: classNames5__default.default({ [styles_module_default.loadingMessage]: message4.status === "loading" }),
1096
1096
  content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1097
1097
  thinkContents.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1098
1098
  antd.Collapse,
@@ -1152,7 +1152,7 @@ var BubbleListItems_default = ({ avatar = true }) => {
1152
1152
  /* @__PURE__ */ jsxRuntime.jsx(
1153
1153
  x.Welcome,
1154
1154
  {
1155
- className: classNames2__default.default(styles_module_default.chatWelcome, "p-t-32"),
1155
+ className: classNames5__default.default(styles_module_default.chatWelcome, "p-t-32"),
1156
1156
  variant: "borderless",
1157
1157
  icon: /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { shape: "square", size: 58, src: agentState.active.iconUrl }),
1158
1158
  title: `\u4F60\u597D\uFF0C\u6211\u662F${agentState.active.name || ""}`,
@@ -1170,7 +1170,7 @@ var BubbleListItems_default = ({ avatar = true }) => {
1170
1170
  label: "\u{1F914} \u63A8\u8350\u95EE\u9898:",
1171
1171
  children: agentState.active.recommendQuestions.map(({ question, id }) => ({
1172
1172
  key: id,
1173
- description: /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => chatStore.onSendMessage(question), className: classNames2__default.default(styles_module_default.chatWelcomePrompts, "text-ellipsis"), children: question })
1173
+ description: /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => chatStore.sendMessage(question), className: classNames5__default.default(styles_module_default.chatWelcomePrompts, "text-ellipsis"), children: question })
1174
1174
  }))
1175
1175
  }
1176
1176
  ]
@@ -1198,7 +1198,7 @@ var BubbleListItems_default = ({ avatar = true }) => {
1198
1198
  vertical: true,
1199
1199
  items: chatMessage?.questionList.map(({ question, id }) => ({
1200
1200
  key: id,
1201
- description: /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => chatStore.onSendMessage(question), children: question })
1201
+ description: /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => chatStore.sendMessage(question), children: question })
1202
1202
  }))
1203
1203
  }
1204
1204
  ),
@@ -1269,7 +1269,7 @@ var BubbleListItems_default = ({ avatar = true }) => {
1269
1269
  {
1270
1270
  ref: listRef,
1271
1271
  items: bubbleListItems,
1272
- className: classNames2__default.default(styles_module_default.nsBubbleList, "height-full", "scroll-fade-in")
1272
+ className: classNames5__default.default(styles_module_default.nsBubbleList, "height-full", "scroll-fade-in")
1273
1273
  },
1274
1274
  conversationState.active.key
1275
1275
  );
@@ -1616,7 +1616,7 @@ var ConversationListHeader_default = () => {
1616
1616
  type: "primary",
1617
1617
  shape: "round",
1618
1618
  onClick: () => chatStore.switchConversation(),
1619
- className: classNames2__default.default("m-t-16"),
1619
+ className: classNames5__default.default("m-t-16"),
1620
1620
  icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {}),
1621
1621
  children: "\u65B0\u5EFA\u4F1A\u8BDD"
1622
1622
  }
@@ -1649,7 +1649,7 @@ var SenderPromptsItems_default = () => {
1649
1649
  title: /* @__PURE__ */ jsxRuntime.jsx(
1650
1650
  "div",
1651
1651
  {
1652
- className: classNames2__default.default(styles_module_default.senderListTitle, "text-ellipsis"),
1652
+ className: classNames5__default.default(styles_module_default.senderListTitle, "text-ellipsis"),
1653
1653
  children: `${agentState.active.name}\u5F00\u59CB\u5173\u6CE8${question.labelName}\u5185\u5BB9\uFF01`
1654
1654
  }
1655
1655
  ),
@@ -1667,7 +1667,9 @@ var SenderPromptsItems_default = () => {
1667
1667
  var styles_module_default3 = {
1668
1668
  nsPreviewHeader: "styles_module_nsPreviewHeader",
1669
1669
  nsPreviewHeaderTitle: "styles_module_nsPreviewHeaderTitle",
1670
- nsChatTitle: "styles_module_nsChatTitle2"
1670
+ nsChatSenderHeader: "styles_module_nsChatSenderHeader",
1671
+ nsDisclaimerNotice: "styles_module_nsDisclaimerNotice",
1672
+ nsChatLayout: "styles_module_nsChatLayout"
1671
1673
  };
1672
1674
  var layouts_default = react.forwardRef(({ theme, params, hooks, layout, defaultAgent }, ref) => {
1673
1675
  const chatStore = react.useMemo(() => createChatStore(), []);
@@ -1708,7 +1710,7 @@ var layouts_default = react.forwardRef(({ theme, params, hooks, layout, defaultA
1708
1710
  const hasPreView = react.useMemo(() => {
1709
1711
  return common.shouldRender(configState.layout.preview) && (!!configState.preview.file.fileUrl || !!configState.preview.file.content);
1710
1712
  }, [configState.layout.preview, configState.preview.file]);
1711
- return /* @__PURE__ */ jsxRuntime.jsx(x.XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsxRuntime.jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: agentState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden height-full", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Splitter, { onResize: setSplitterSizes, children: [
1713
+ return /* @__PURE__ */ jsxRuntime.jsx(x.XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsxRuntime.jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: agentState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames5__default.default(styles_module_default3.nsChatLayout, "height-full"), children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Splitter, { onResize: setSplitterSizes, children: [
1712
1714
  common.shouldRender(configState.layout.conversationList) && /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { size: 360, collapsible: false, resizable: false, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: "height-full", children: [
1713
1715
  /* @__PURE__ */ jsxRuntime.jsx(
1714
1716
  common.RenderWrapper,
@@ -1772,9 +1774,9 @@ var layouts_default = react.forwardRef(({ theme, params, hooks, layout, defaultA
1772
1774
  }
1773
1775
  )
1774
1776
  ] }),
1775
- /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { collapsible: false, resizable: false, size: hasPreView ? 400 : void 0, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames2__default.default("height-full"), children: [
1777
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { collapsible: false, resizable: false, size: hasPreView ? 400 : void 0, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames5__default.default("height-full"), children: [
1776
1778
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.header, DefaultComponent: AgentHeader_default }),
1777
- /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, className: classNames2__default.default("full-scroll", styles_module_default.nsBody), children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "center", vertical: true, gap: 24, className: classNames2__default.default("height-full", styles_module_default.nsBodyWidth), children: [
1779
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, className: classNames5__default.default("full-scroll"), children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "center", vertical: true, gap: 24, className: classNames5__default.default("height-full p-t-8 p-b-8", styles_module_default.nsBodyWidth), children: [
1778
1780
  common.shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(
1779
1781
  common.RenderWrapper,
1780
1782
  {
@@ -1786,7 +1788,7 @@ var layouts_default = react.forwardRef(({ theme, params, hooks, layout, defaultA
1786
1788
  common.RenderWrapper,
1787
1789
  {
1788
1790
  control: configState.layout.senderHeader,
1789
- DefaultComponent: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default3.nsChatTitle, children: [
1791
+ DefaultComponent: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default3.nsChatSenderHeader, children: [
1790
1792
  "\u6211\u662F ",
1791
1793
  agentState.active.name
1792
1794
  ] })
@@ -1800,7 +1802,14 @@ var layouts_default = react.forwardRef(({ theme, params, hooks, layout, defaultA
1800
1802
  DefaultComponent: SenderPromptsItems_default
1801
1803
  }
1802
1804
  ),
1803
- /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.sender, DefaultComponent: ChatSender_default2 })
1805
+ /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.sender, DefaultComponent: ChatSender_default2 }),
1806
+ /* @__PURE__ */ jsxRuntime.jsx(
1807
+ common.RenderWrapper,
1808
+ {
1809
+ control: configState.layout.disclaimerNotice,
1810
+ DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default3.nsDisclaimerNotice, children: "\u5185\u5BB9\u7531AI\u751F\u6210\uFF0C\u4EC5\u4F9B\u53C2\u8003\uFF0C\u8BF7\u4ED4\u7EC6\u7504\u522B" })
1811
+ }
1812
+ )
1804
1813
  ] }),
1805
1814
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.senderFooter, DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}) })
1806
1815
  ] }) })