@zero-library/chat-agent 1.0.0 → 2.0.0
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 +149 -95
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +33 -4
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.esm.js +151 -96
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs.js
CHANGED
|
@@ -3,20 +3,18 @@
|
|
|
3
3
|
var common = require('@zero-library/common');
|
|
4
4
|
var antd = require('antd');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var TextArea = require('antd/es/input/TextArea');
|
|
7
6
|
var react = require('react');
|
|
8
7
|
var icons = require('@ant-design/icons');
|
|
9
|
-
var valtio = require('valtio');
|
|
10
|
-
var dayjs = require('dayjs');
|
|
11
8
|
var x = require('@ant-design/x');
|
|
12
9
|
var classNames2 = require('classnames');
|
|
10
|
+
var valtio = require('valtio');
|
|
11
|
+
var dayjs = require('dayjs');
|
|
13
12
|
var InfiniteScroll = require('react-infinite-scroll-component');
|
|
14
13
|
|
|
15
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
15
|
|
|
17
|
-
var TextArea__default = /*#__PURE__*/_interopDefault(TextArea);
|
|
18
|
-
var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
|
|
19
16
|
var classNames2__default = /*#__PURE__*/_interopDefault(classNames2);
|
|
17
|
+
var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
|
|
20
18
|
var InfiniteScroll__default = /*#__PURE__*/_interopDefault(InfiniteScroll);
|
|
21
19
|
|
|
22
20
|
var __defProp = Object.defineProperty;
|
|
@@ -42,7 +40,11 @@ var init_styles_module = __esm({
|
|
|
42
40
|
styles_module_default2 = {
|
|
43
41
|
appCard: "styles_module_appCard",
|
|
44
42
|
fileView: "styles_module_fileView",
|
|
45
|
-
|
|
43
|
+
fileEdit: "styles_module_fileEdit",
|
|
44
|
+
fileEditHeader: "styles_module_fileEditHeader",
|
|
45
|
+
fileEditContent: "styles_module_fileEditContent",
|
|
46
|
+
quoteList: "styles_module_quoteList",
|
|
47
|
+
mdEdit: "styles_module_mdEdit"
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
});
|
|
@@ -105,48 +107,36 @@ var init_IndexQuote = __esm({
|
|
|
105
107
|
const onClick = () => {
|
|
106
108
|
window.open(data.fileUrl, "_blank");
|
|
107
109
|
};
|
|
108
|
-
const Content = /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.
|
|
109
|
-
|
|
110
|
-
/* @__PURE__ */ jsxRuntime.jsx("a", { onClick, children: data.fileName })
|
|
111
|
-
] }) });
|
|
112
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, size: "small", wrapperClassName: "inline-block index-quote", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Popover, { content: Content, title: data.title, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { bordered: false, color: "processing", className: "cursor-pointer", children: data.index }) }) });
|
|
110
|
+
const Content = /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", gap: 8, children: /* @__PURE__ */ jsxRuntime.jsx("a", { onClick, children: data.fileName }) }) });
|
|
111
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, size: "small", wrapperClassName: "inline-block index-quote", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Popover, { content: Content, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { bordered: false, color: "processing", className: "cursor-pointer", children: data.index }) }) });
|
|
113
112
|
};
|
|
114
113
|
}
|
|
115
114
|
});
|
|
116
115
|
|
|
117
|
-
// src/ui/common/markdownAlert/
|
|
118
|
-
var
|
|
119
|
-
__export(
|
|
120
|
-
default: () =>
|
|
116
|
+
// src/ui/common/markdownAlert/MdEdit.tsx
|
|
117
|
+
var MdEdit_exports = {};
|
|
118
|
+
__export(MdEdit_exports, {
|
|
119
|
+
default: () => MdEdit_default
|
|
121
120
|
});
|
|
122
|
-
var
|
|
123
|
-
var
|
|
124
|
-
"src/ui/common/markdownAlert/
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
react.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
135
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
136
|
-
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
137
|
-
}, [editing]);
|
|
121
|
+
var MdEdit_default;
|
|
122
|
+
var init_MdEdit = __esm({
|
|
123
|
+
"src/ui/common/markdownAlert/MdEdit.tsx"() {
|
|
124
|
+
init_Context();
|
|
125
|
+
init_styles_module();
|
|
126
|
+
MdEdit_default = ({ data, loading }) => {
|
|
127
|
+
const chatStore = useChatStore();
|
|
128
|
+
const [value, setValue] = react.useState("");
|
|
129
|
+
const onOk = () => {
|
|
130
|
+
console.log("value", value);
|
|
131
|
+
chatStore.sendMessage("\u5F00\u59CB\u5199\u4F5C", [], { outline: value });
|
|
132
|
+
};
|
|
138
133
|
react.useEffect(() => {
|
|
139
|
-
|
|
140
|
-
}, [
|
|
141
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxRuntime.
|
|
142
|
-
|
|
143
|
-
{
|
|
144
|
-
|
|
145
|
-
value,
|
|
146
|
-
onChange: (e) => setValue(e.target.value),
|
|
147
|
-
placeholder: "\u8BF7\u8F93\u5165 Markdown \u5185\u5BB9..."
|
|
148
|
-
}
|
|
149
|
-
) : /* @__PURE__ */ jsxRuntime.jsx("div", { onClick: () => setEditing(true), style: { cursor: "pointer", minHeight: 24 }, children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content: value }) }) }) });
|
|
134
|
+
setValue(data.content);
|
|
135
|
+
}, [data.content]);
|
|
136
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.mdEdit, children: [
|
|
137
|
+
/* @__PURE__ */ jsxRuntime.jsx(common.MarkdownEditor, { disabled: loading, value, onChange: setValue, showToolbar: false }),
|
|
138
|
+
!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: "\u786E\u8BA4\u63D0\u7EB2\u601D\u8DEF\uFF0C\u5F00\u59CB\u5199\u4F5C" }) })
|
|
139
|
+
] }) });
|
|
150
140
|
};
|
|
151
141
|
}
|
|
152
142
|
});
|
|
@@ -164,11 +154,14 @@ var init_FileEdit = __esm({
|
|
|
164
154
|
FileEdit_default = ({ data, loading }) => {
|
|
165
155
|
const chatStore = useChatStore();
|
|
166
156
|
const onClick = () => {
|
|
167
|
-
chatStore.setPreview(data,
|
|
157
|
+
chatStore.setPreview(data, true);
|
|
168
158
|
};
|
|
169
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, {
|
|
170
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
171
|
-
/* @__PURE__ */ jsxRuntime.
|
|
159
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: styles_module_default2.fileEdit, children: [
|
|
160
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, justify: "end", className: styles_module_default2.fileEditHeader, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlayCircleOutlined, {}), onClick, children: "\u9884\u89C8\u7F16\u8F91" }) }),
|
|
161
|
+
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, align: "center", className: styles_module_default2.fileEditContent, children: [
|
|
162
|
+
/* @__PURE__ */ jsxRuntime.jsx(common.FileIcon, { suffix: "md" }),
|
|
163
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ellipsis", title: data.fileName, children: data.fileName })
|
|
164
|
+
] })
|
|
172
165
|
] }) });
|
|
173
166
|
};
|
|
174
167
|
}
|
|
@@ -184,7 +177,6 @@ var init_QuoteList = __esm({
|
|
|
184
177
|
"src/ui/common/markdownAlert/QuoteList.tsx"() {
|
|
185
178
|
init_styles_module();
|
|
186
179
|
QuoteList_default = ({ data, loading }) => {
|
|
187
|
-
console.log("QuoteList data", data, loading);
|
|
188
180
|
const onClick = (item) => {
|
|
189
181
|
window.open(item.fileUrl, "_blank");
|
|
190
182
|
};
|
|
@@ -199,7 +191,7 @@ var init_QuoteList = __esm({
|
|
|
199
191
|
{
|
|
200
192
|
key: "1",
|
|
201
193
|
label: "\u53C2\u8003\u8D44\u6599",
|
|
202
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 4, children: data.list.map((item) => /* @__PURE__ */ jsxRuntime.jsx("p", { onClick: () => onClick(item), className: "cursor-pointer", children: item.
|
|
194
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 4, children: data.list.map((item) => /* @__PURE__ */ jsxRuntime.jsx("p", { onClick: () => onClick(item), className: "cursor-pointer", children: item.title }, item.fileUrl)) })
|
|
203
195
|
}
|
|
204
196
|
]
|
|
205
197
|
}
|
|
@@ -398,7 +390,7 @@ var updateFeedback = (params) => {
|
|
|
398
390
|
var uploadFile = (formData) => {
|
|
399
391
|
return common.request.post("/agent/file", formData);
|
|
400
392
|
};
|
|
401
|
-
var
|
|
393
|
+
var sendChatMessage = (params) => {
|
|
402
394
|
return fetchRequest_default.post(
|
|
403
395
|
"/agent/chat",
|
|
404
396
|
{ ...params, stream: true },
|
|
@@ -439,12 +431,15 @@ function createChatStore() {
|
|
|
439
431
|
preview: {
|
|
440
432
|
file: {},
|
|
441
433
|
isEdit: false
|
|
434
|
+
// 未使用
|
|
435
|
+
// isShow: 0, // 0 不显示 1 显示 2 用户关闭
|
|
436
|
+
// isIntact: false // true 完整 false 不完整
|
|
442
437
|
},
|
|
443
438
|
userInfo: {},
|
|
444
439
|
params: {}
|
|
445
440
|
});
|
|
446
441
|
const setPreview = (file = {}, isEdit = false) => {
|
|
447
|
-
if (config.layout.preview) {
|
|
442
|
+
if (common.shouldRender(config.layout.preview)) {
|
|
448
443
|
config.preview = {
|
|
449
444
|
file,
|
|
450
445
|
isEdit
|
|
@@ -452,6 +447,8 @@ function createChatStore() {
|
|
|
452
447
|
} else {
|
|
453
448
|
if (file?.fileUrl) {
|
|
454
449
|
window.open(file.fileUrl, "_blank");
|
|
450
|
+
} else {
|
|
451
|
+
console.log("\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9884\u89C8");
|
|
455
452
|
}
|
|
456
453
|
}
|
|
457
454
|
};
|
|
@@ -553,8 +550,15 @@ function createChatStore() {
|
|
|
553
550
|
};
|
|
554
551
|
const agent = valtio.proxy({
|
|
555
552
|
active: {},
|
|
556
|
-
loading: false
|
|
553
|
+
loading: false,
|
|
554
|
+
params: {}
|
|
557
555
|
});
|
|
556
|
+
const setAgentParams = (params = {}) => {
|
|
557
|
+
agent.params = {
|
|
558
|
+
thinkMode: 2,
|
|
559
|
+
...params
|
|
560
|
+
};
|
|
561
|
+
};
|
|
558
562
|
const switchAgent = async ({ appKey, agentKey, isVerify = false }, conversationId) => {
|
|
559
563
|
const agentId = `${appKey}:${agentKey}`;
|
|
560
564
|
if (agent.active.id === agentId) return;
|
|
@@ -566,6 +570,7 @@ function createChatStore() {
|
|
|
566
570
|
}
|
|
567
571
|
const { data } = await agentInfoQuery(agentId);
|
|
568
572
|
agent.active = data;
|
|
573
|
+
setAgentParams();
|
|
569
574
|
config.hooks?.onAfterSwitchAgent?.(agentId);
|
|
570
575
|
switchConversation({ key: conversationId });
|
|
571
576
|
} finally {
|
|
@@ -698,16 +703,16 @@ function createChatStore() {
|
|
|
698
703
|
}
|
|
699
704
|
conversation.messages[chunk.conversationId].loading = false;
|
|
700
705
|
};
|
|
701
|
-
const
|
|
706
|
+
const sendMessage = async (message4, files = [], params) => {
|
|
702
707
|
const conversationId = conversation.active.key;
|
|
703
708
|
if (conversation.messages[conversationId].loading) return;
|
|
704
709
|
let newMsgContent = "", newImgList;
|
|
710
|
+
const references = conversation.messages[conversationId].references;
|
|
705
711
|
if (message4) {
|
|
706
712
|
newMsgContent = message4;
|
|
707
713
|
newImgList = files;
|
|
708
714
|
} else {
|
|
709
|
-
|
|
710
|
-
if (references?.type === 1 && references.content.markdown) {
|
|
715
|
+
if (references?.type === 1 && references?.content?.markdown) {
|
|
711
716
|
newMsgContent = references.content.markdown + "\n";
|
|
712
717
|
}
|
|
713
718
|
newMsgContent = newMsgContent + conversation.messages[conversationId].content;
|
|
@@ -732,6 +737,13 @@ function createChatStore() {
|
|
|
732
737
|
status: "loading"
|
|
733
738
|
};
|
|
734
739
|
conversation.messages[conversationId].message.items.push(userMsg, placeholder);
|
|
740
|
+
const extraParams = {
|
|
741
|
+
...config.params
|
|
742
|
+
};
|
|
743
|
+
if (!extraParams.params) {
|
|
744
|
+
extraParams.params = {};
|
|
745
|
+
}
|
|
746
|
+
Object.assign(extraParams.params, agent.params, message4 ? {} : references?.params, params);
|
|
735
747
|
if (!message4) {
|
|
736
748
|
setContent("");
|
|
737
749
|
setFileList([]);
|
|
@@ -740,12 +752,12 @@ function createChatStore() {
|
|
|
740
752
|
}
|
|
741
753
|
removeQuestionList(conversationId);
|
|
742
754
|
try {
|
|
743
|
-
|
|
755
|
+
sendChatMessage({
|
|
744
756
|
agentId: agent.active.id,
|
|
745
757
|
conversationId: conversationId.endsWith(DEFAULT_NEW_CONV_ID) ? void 0 : conversationId,
|
|
746
758
|
message: userMsg.content,
|
|
747
759
|
files: userMsg.files,
|
|
748
|
-
...
|
|
760
|
+
...extraParams,
|
|
749
761
|
onMessageEvent: (event) => {
|
|
750
762
|
updatePlaceholderMessage(conversationId, placeholderId, event);
|
|
751
763
|
}
|
|
@@ -756,7 +768,7 @@ function createChatStore() {
|
|
|
756
768
|
conversation.messages[conversationId].loading = false;
|
|
757
769
|
}
|
|
758
770
|
};
|
|
759
|
-
const
|
|
771
|
+
const cancelReceive = () => {
|
|
760
772
|
conversation.messages[conversation.active.key].loading = false;
|
|
761
773
|
};
|
|
762
774
|
return {
|
|
@@ -779,17 +791,19 @@ function createChatStore() {
|
|
|
779
791
|
conversations,
|
|
780
792
|
setInitMessage,
|
|
781
793
|
agent,
|
|
794
|
+
setAgentParams,
|
|
782
795
|
switchAgent,
|
|
783
796
|
getConversations,
|
|
784
797
|
getMessages,
|
|
785
798
|
switchConversation,
|
|
786
799
|
delConversation,
|
|
787
800
|
removePlaceholder,
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
onCancelReceive
|
|
801
|
+
sendMessage,
|
|
802
|
+
cancelReceive
|
|
791
803
|
};
|
|
792
804
|
}
|
|
805
|
+
|
|
806
|
+
// src/ui/layouts/index.tsx
|
|
793
807
|
init_Context();
|
|
794
808
|
|
|
795
809
|
// src/ui/common/AgentHeader.tsx
|
|
@@ -805,6 +819,7 @@ var styles_module_default = {
|
|
|
805
819
|
nsBody: "styles_module_nsBody",
|
|
806
820
|
nsBodyWidth: "styles_module_nsBodyWidth",
|
|
807
821
|
nsBubbleList: "styles_module_nsBubbleList",
|
|
822
|
+
nsAgentHeader: "styles_module_nsAgentHeader",
|
|
808
823
|
nsChatTitle: "styles_module_nsChatTitle",
|
|
809
824
|
nsChatHeaderPopover: "styles_module_nsChatHeaderPopover",
|
|
810
825
|
chatWelcomeWrap: "styles_module_chatWelcomeWrap",
|
|
@@ -815,7 +830,8 @@ var styles_module_default = {
|
|
|
815
830
|
senderListItem: "styles_module_senderListItem",
|
|
816
831
|
senderListFooter: "styles_module_senderListFooter",
|
|
817
832
|
nsChatUserName: "styles_module_nsChatUserName",
|
|
818
|
-
|
|
833
|
+
nsSenderReferenceHeaderTitle: "styles_module_nsSenderReferenceHeaderTitle",
|
|
834
|
+
nsSenderReferenceHeaderContent: "styles_module_nsSenderReferenceHeaderContent"
|
|
819
835
|
};
|
|
820
836
|
var ConversationList_default = () => {
|
|
821
837
|
const chatStore = useChatStore();
|
|
@@ -871,7 +887,7 @@ var AgentHeader_default = () => {
|
|
|
871
887
|
const agentState = valtio.useSnapshot(chatStore.agent);
|
|
872
888
|
const configState = valtio.useSnapshot(chatStore.config);
|
|
873
889
|
const conversationsState = valtio.useSnapshot(chatStore.conversations);
|
|
874
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", className:
|
|
890
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", className: styles_module_default.nsAgentHeader, children: [
|
|
875
891
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 4, align: "center", children: [
|
|
876
892
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
877
893
|
common.RenderWrapper,
|
|
@@ -914,7 +930,7 @@ var AgentHeader_default = () => {
|
|
|
914
930
|
common.RenderWrapper,
|
|
915
931
|
{
|
|
916
932
|
control: configState.layout.headerCloseBtn,
|
|
917
|
-
DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", size: "large", onClick: configState.hooks?.
|
|
933
|
+
DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", size: "large", onClick: configState.hooks?.onHeaderClose, icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseOutlined, {}) })
|
|
918
934
|
}
|
|
919
935
|
)
|
|
920
936
|
] })
|
|
@@ -926,7 +942,7 @@ var customComponents = {
|
|
|
926
942
|
appCard: () => Promise.resolve().then(() => (init_AppCard(), AppCard_exports)),
|
|
927
943
|
fileView: () => Promise.resolve().then(() => (init_FileView(), FileView_exports)),
|
|
928
944
|
indexQuote: () => Promise.resolve().then(() => (init_IndexQuote(), IndexQuote_exports)),
|
|
929
|
-
|
|
945
|
+
mdEdit: () => Promise.resolve().then(() => (init_MdEdit(), MdEdit_exports)),
|
|
930
946
|
fileEdit: () => Promise.resolve().then(() => (init_FileEdit(), FileEdit_exports)),
|
|
931
947
|
quoteList: () => Promise.resolve().then(() => (init_QuoteList(), QuoteList_exports))
|
|
932
948
|
};
|
|
@@ -1352,6 +1368,7 @@ var ChatSender_default = react.forwardRef(
|
|
|
1352
1368
|
onHeaderOpenChange,
|
|
1353
1369
|
onSend,
|
|
1354
1370
|
onCancel,
|
|
1371
|
+
onFocus,
|
|
1355
1372
|
extraHeader,
|
|
1356
1373
|
extraFooter,
|
|
1357
1374
|
extraFooterBelow,
|
|
@@ -1398,6 +1415,7 @@ var ChatSender_default = react.forwardRef(
|
|
|
1398
1415
|
header: senderHeader,
|
|
1399
1416
|
onSubmit,
|
|
1400
1417
|
onChange: setInputValue,
|
|
1418
|
+
onFocus,
|
|
1401
1419
|
autoSize: { minRows: 2, maxRows: 6 },
|
|
1402
1420
|
onCancel,
|
|
1403
1421
|
footer: ({ components }) => {
|
|
@@ -1436,12 +1454,13 @@ var ChatSender_default2 = () => {
|
|
|
1436
1454
|
if (chatMessage?.loading) return;
|
|
1437
1455
|
chatStore.setContent(con);
|
|
1438
1456
|
setTimeout(() => {
|
|
1439
|
-
chatStore.
|
|
1457
|
+
chatStore.sendMessage();
|
|
1440
1458
|
}, 10);
|
|
1441
1459
|
};
|
|
1442
1460
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1443
1461
|
ChatSender_default,
|
|
1444
1462
|
{
|
|
1463
|
+
placeholder: configState.layout.sender?.props?.placeholder,
|
|
1445
1464
|
content: chatMessage.content,
|
|
1446
1465
|
fileList: chatMessage.files,
|
|
1447
1466
|
headerOpen: chatMessage.headerOpen,
|
|
@@ -1449,26 +1468,37 @@ var ChatSender_default2 = () => {
|
|
|
1449
1468
|
onContentChange: chatStore.setContent,
|
|
1450
1469
|
onFileListChange: chatStore.setFileList,
|
|
1451
1470
|
onHeaderOpenChange: chatStore.setHeaderOpen,
|
|
1452
|
-
onSend: () => chatStore.
|
|
1471
|
+
onSend: () => chatStore.sendMessage(),
|
|
1472
|
+
onFocus: chatStore.config.hooks?.onSenderFocus,
|
|
1453
1473
|
fileUpload: {
|
|
1454
1474
|
...agentState.active?.parameters?.fileUpload,
|
|
1455
1475
|
extraParams: { agentId: agentState.active.id }
|
|
1456
1476
|
},
|
|
1457
1477
|
extraFooter: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1458
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1478
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1479
|
+
antd.Button,
|
|
1480
|
+
{
|
|
1481
|
+
size: "small",
|
|
1482
|
+
color: agentState.params.thinkMode === 1 ? "primary" : "default",
|
|
1483
|
+
variant: "filled",
|
|
1484
|
+
onClick: () => chatStore.setAgentParams({ thinkMode: agentState.params.thinkMode === 1 ? 2 : 1 }),
|
|
1485
|
+
children: "\u6DF1\u5EA6\u601D\u8003"
|
|
1486
|
+
}
|
|
1487
|
+
),
|
|
1459
1488
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.senderExtraBtn })
|
|
1460
1489
|
] }),
|
|
1461
1490
|
extraHeader: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1462
1491
|
x.Sender.Header,
|
|
1463
1492
|
{
|
|
1464
|
-
title: /* @__PURE__ */ jsxRuntime.jsxs(antd.
|
|
1493
|
+
title: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 4, children: [
|
|
1465
1494
|
/* @__PURE__ */ jsxRuntime.jsx(icons.EnterOutlined, {}),
|
|
1466
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { type: "secondary", children: chatMessage?.references?.content?.name })
|
|
1495
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { type: "secondary", ellipsis: true, children: chatMessage?.references?.content?.name })
|
|
1467
1496
|
] }),
|
|
1468
1497
|
open: !!chatMessage?.references?.content?.name,
|
|
1469
1498
|
onOpenChange: () => chatStore.setReferences(),
|
|
1470
1499
|
classNames: {
|
|
1471
|
-
|
|
1500
|
+
header: styles_module_default.nsSenderReferenceHeaderTitle,
|
|
1501
|
+
content: common.shouldRender(configState.layout.referencesBtn) ? "" : styles_module_default.nsSenderReferenceHeaderContent
|
|
1472
1502
|
},
|
|
1473
1503
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1474
1504
|
common.RenderWrapper,
|
|
@@ -1529,7 +1559,7 @@ var SenderPromptsItems_default = () => {
|
|
|
1529
1559
|
split: false,
|
|
1530
1560
|
className: styles_module_default.senderList,
|
|
1531
1561
|
dataSource: question.hotQuestionList,
|
|
1532
|
-
renderItem: (item) => /* @__PURE__ */ jsxRuntime.jsx(antd.List.Item, { onClick: () => chatStore.
|
|
1562
|
+
renderItem: (item) => /* @__PURE__ */ jsxRuntime.jsx(antd.List.Item, { onClick: () => chatStore.sendMessage(item.question), className: styles_module_default.senderListItem, children: item.question }),
|
|
1533
1563
|
footer: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { justify: "end", className: styles_module_default.senderListFooter, children: "(\u60A8\u53EF\u70B9\u51FB\u4EE5\u4E0A\u95EE\u9898\u5F00\u542FAI\u4F53\u9A8C)" })
|
|
1534
1564
|
}
|
|
1535
1565
|
),
|
|
@@ -1578,7 +1608,7 @@ var layouts_default = react.forwardRef(({ theme, params, hooks, layout, defaultA
|
|
|
1578
1608
|
react.useImperativeHandle(
|
|
1579
1609
|
ref,
|
|
1580
1610
|
() => ({
|
|
1581
|
-
sendMessage: chatStore.
|
|
1611
|
+
sendMessage: chatStore.sendMessage,
|
|
1582
1612
|
switchAgent: chatStore.switchAgent,
|
|
1583
1613
|
switchConversation: chatStore.switchConversation,
|
|
1584
1614
|
setReferences: chatStore.setReferences,
|
|
@@ -1592,6 +1622,9 @@ var layouts_default = react.forwardRef(({ theme, params, hooks, layout, defaultA
|
|
|
1592
1622
|
const setSplitterSizes = (sizes) => {
|
|
1593
1623
|
console.log(sizes);
|
|
1594
1624
|
};
|
|
1625
|
+
const hasPreView = react.useMemo(() => {
|
|
1626
|
+
return common.shouldRender(configState.layout.preview) && (!!configState.preview.file.fileUrl || !!configState.preview.file.content);
|
|
1627
|
+
}, [configState.layout.preview, configState.preview.file]);
|
|
1595
1628
|
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: [
|
|
1596
1629
|
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: [
|
|
1597
1630
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1609,33 +1642,54 @@ var layouts_default = react.forwardRef(({ theme, params, hooks, layout, defaultA
|
|
|
1609
1642
|
}
|
|
1610
1643
|
) })
|
|
1611
1644
|
] }) }),
|
|
1612
|
-
|
|
1613
|
-
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, {
|
|
1614
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1615
|
-
|
|
1616
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1645
|
+
hasPreView && /* @__PURE__ */ jsxRuntime.jsxs(antd.Splitter.Panel, { collapsible: false, resizable: false, children: [
|
|
1646
|
+
configState.preview.file.fileUrl && /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: "height-full", children: [
|
|
1647
|
+
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", gap: 16, className: styles_module_default3.nsPreviewHeader, children: [
|
|
1648
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default3.nsPreviewHeaderTitle, children: configState.preview.file.fileName }),
|
|
1649
|
+
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, justify: "center", align: "center", children: [
|
|
1650
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1651
|
+
antd.Button,
|
|
1652
|
+
{
|
|
1653
|
+
color: "primary",
|
|
1654
|
+
variant: "outlined",
|
|
1655
|
+
onClick: () => common.downloadFile(configState.preview.file.fileUrl, configState.preview.file.fileName),
|
|
1656
|
+
children: "\u4E0B\u8F7D"
|
|
1657
|
+
}
|
|
1658
|
+
),
|
|
1659
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: () => chatStore.setPreview(), children: "\u5173\u95ED" })
|
|
1660
|
+
] })
|
|
1661
|
+
] }),
|
|
1662
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1663
|
+
common.FilePreview,
|
|
1664
|
+
{
|
|
1665
|
+
...configState.preview.file,
|
|
1666
|
+
pdfParams: {
|
|
1667
|
+
isHasThumbnails: false
|
|
1623
1668
|
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
] })
|
|
1669
|
+
}
|
|
1670
|
+
) })
|
|
1627
1671
|
] }),
|
|
1628
|
-
|
|
1629
|
-
common.
|
|
1672
|
+
configState.preview.file.content && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1673
|
+
common.MarkdownEditor,
|
|
1630
1674
|
{
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1675
|
+
value: configState.preview.file.content,
|
|
1676
|
+
onQuote: (text) => {
|
|
1677
|
+
chatStore.setReferences({
|
|
1678
|
+
type: 2,
|
|
1679
|
+
content: {
|
|
1680
|
+
name: text,
|
|
1681
|
+
markdown: text
|
|
1682
|
+
},
|
|
1683
|
+
params: {
|
|
1684
|
+
outline: text
|
|
1685
|
+
}
|
|
1686
|
+
});
|
|
1687
|
+
},
|
|
1688
|
+
extraNav: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { bordered: false, color: "default", className: "cursor-pointer", onClick: () => chatStore.setPreview(), children: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseOutlined, {}) }) })
|
|
1635
1689
|
}
|
|
1636
|
-
)
|
|
1637
|
-
] })
|
|
1638
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { collapsible: false, resizable: false, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames2__default.default("height-full"), children: [
|
|
1690
|
+
)
|
|
1691
|
+
] }),
|
|
1692
|
+
/* @__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: [
|
|
1639
1693
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.header, DefaultComponent: AgentHeader_default }),
|
|
1640
1694
|
/* @__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: [
|
|
1641
1695
|
common.shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(
|