@gientech/modual 1.4.7 → 1.5.2

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.
Files changed (65) hide show
  1. package/dist/assets/GientechStreamReader-KtCNi1G3.js +447 -0
  2. package/dist/assets/Input-CNqIA41v.js +236 -0
  3. package/dist/assets/index-Bof0D4vl.js +1088 -0
  4. package/dist/assets/{index-BVENTW1Q.js → index-C5RhLYRh.js} +1 -1
  5. package/dist/assets/index-COcmK9my.js +1 -0
  6. package/dist/assets/index-CysDmrpo.js +1798 -0
  7. package/dist/assets/{index-7rZAt9P3.js → index-DP8Ki8qW.js} +1 -1
  8. package/dist/assets/index-pybYlMAT.js +11 -0
  9. package/dist/assets/{plus-CrtEUXaQ.js → plus-CzbYbK8K.js} +1 -1
  10. package/dist/assets/style3.css +1 -1
  11. package/dist/assets/worker-BbpylX7l.js +13 -0
  12. package/dist/assets/{x-Dr3EBTzJ.js → x-DdRafKQU.js} +1 -1
  13. package/dist/chat.d.ts +17 -0
  14. package/dist/chat.js +2539 -52
  15. package/dist/database.js +2 -2
  16. package/dist/databaseId.js +1 -11
  17. package/dist/databaseTable.js +2 -2
  18. package/dist/index.d.ts +4 -0
  19. package/dist/index.js +1 -14
  20. package/dist/modelManage.js +1 -1
  21. package/dist/package.json +1 -1
  22. package/dist/sensitive.js +1 -1
  23. package/dist/streamFilesReader.js +1 -1
  24. package/dist/worker/pdf.worker1.min.js +23 -0
  25. package/package.json +6 -6
  26. package/public/worker/pdf.worker1.min.js +23 -0
  27. package/scripts/README.md +133 -133
  28. package/scripts/build-demo.js +88 -88
  29. package/scripts/demo-selector.js +216 -216
  30. package/scripts/preview-demo.js +130 -130
  31. package/scripts/run-demo.bat +34 -34
  32. package/src/assets/img/close.png +0 -0
  33. package/src/assets/img/database.png +0 -0
  34. package/src/assets/img/downLoad.png +0 -0
  35. package/src/assets/img/graphIcon.png +0 -0
  36. package/src/assets/img/pdf.png +0 -0
  37. package/src/assets/img/singleQa.png +0 -0
  38. package/src/assets/img/webSearch.png +0 -0
  39. package/src/examples/chat/index.tsx +5 -29
  40. package/src/main.tsx.backup +5 -5
  41. package/src/modules/chat/ReferenceBar.tsx +522 -0
  42. package/src/modules/chat/constants.tsx +29 -6
  43. package/src/modules/chat/index.tsx +118 -4
  44. package/src/modules/chat/referenceCom/DeleteModal.tsx +75 -0
  45. package/src/modules/chat/referenceCom/DrawerContent.tsx +136 -0
  46. package/src/modules/chat/referenceCom/DrawerDatabase.tsx +110 -0
  47. package/src/modules/chat/referenceCom/DrawerGraphPreview.tsx +86 -0
  48. package/src/modules/chat/referenceCom/DrawerPreview.tsx +73 -0
  49. package/src/modules/chat/referenceCom/DrawerTitle.tsx +26 -0
  50. package/src/modules/chat/referenceCom/RenameModal.tsx +86 -0
  51. package/src/modules/chat/referenceCom/TagCom.tsx +30 -0
  52. package/src/modules/chat/style.css +3 -0
  53. package/src/modules/chat/utils/index.ts +326 -0
  54. package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +231 -18
  55. package/src/utils/testconfigs/index.ts +1 -1
  56. package/stats.html +1 -1
  57. package/dist/assets/AppLoading-mci3gLZt.js +0 -414
  58. package/dist/assets/GientechStreamReader-4496nAm0.js +0 -446
  59. package/dist/assets/index-Bb8_WB-l.js +0 -1
  60. package/dist/assets/index-BpJ9Bm5x.js +0 -21
  61. package/dist/assets/index-CNxDI4h-.js +0 -1078
  62. package/dist/assets/index-CWzpBU29.js +0 -1
  63. package/dist/assets/index-D1m34Ij7.js +0 -1429
  64. package/dist/assets/index-_gBtdXQV.js +0 -585
  65. package/dist/assets/style4.css +0 -1
@@ -0,0 +1,26 @@
1
+ import Close from '../../../assets/img/close.png';
2
+ const DrawerTitle = ({ title, setOpen }: { title: string; setOpen: (arg: boolean) => void }) => {
3
+ return (
4
+ <div
5
+ style={{
6
+ width: '100%',
7
+ height: '60px',
8
+ borderBottom: '1px solid #EBEBEB',
9
+ padding: '20px',
10
+ display: 'flex',
11
+ justifyContent: 'space-between',
12
+ alignItems: 'center',
13
+ fontSize: '16px',
14
+ fontWeight: 600,
15
+ }}
16
+ >
17
+ <div>{title}</div>
18
+ <img
19
+ src={Close}
20
+ style={{ width: '16px', height: '16px', cursor: 'pointer' }}
21
+ onClick={() => setOpen(false)}
22
+ />
23
+ </div>
24
+ );
25
+ };
26
+ export default DrawerTitle;
@@ -0,0 +1,86 @@
1
+ import { BorderBottomOutlined } from "@ant-design/icons";
2
+ import { Button, ConfigProvider, Form, Input, Modal } from "antd";
3
+ import { useForm } from "antd/es/form/Form";
4
+ import { useEffect } from "react";
5
+
6
+ export const RenameModal = ({
7
+ isModalOpen,
8
+ handleOk,
9
+ handleCancel,
10
+ data
11
+ }: any) => {
12
+ const modalStyles = {
13
+ header: {
14
+ height: "60px",
15
+ borderBottom: "1px solid #F0F0F0",
16
+ display: "flex",
17
+ paddingLeft: "24px",
18
+ alignItems: "center",
19
+ marginBottom: "16px"
20
+ },
21
+ title: { fontSize: "16px" },
22
+ body: { padding: "0 24px" },
23
+ mask: {},
24
+ footer: { marginTop: "0px", padding: "0 24px 16px 24px" },
25
+ content: { padding: 0 }
26
+ };
27
+ const [rename_form] = useForm();
28
+ useEffect(() => {
29
+ if (!isModalOpen) {
30
+ rename_form.resetFields();
31
+ return;
32
+ }
33
+ rename_form.setFieldValue("new_name", data?.label);
34
+ }, [data, isModalOpen]);
35
+ return (
36
+ <ConfigProvider
37
+ modal={{
38
+ styles: modalStyles
39
+ }}
40
+ >
41
+ <Modal
42
+ title={<div className="text-[16px]">编辑会话名称</div>}
43
+ closeIcon={null}
44
+ open={isModalOpen}
45
+ width={520}
46
+ centered
47
+ className="[&:[.ant-modal-content]]:bg-red"
48
+ footer={
49
+ <div className="mt-[16px] flex justify-end">
50
+ <Button
51
+ children="取消"
52
+ onClick={handleCancel}
53
+ className="mr-[8px]"
54
+ />
55
+ <Button
56
+ children="确认"
57
+ onClick={async () => {
58
+ try {
59
+ const data = await rename_form.validateFields();
60
+ handleOk("ok_rename", data);
61
+ } catch (e) {
62
+ console.log(e);
63
+ return;
64
+ }
65
+ }}
66
+ type="primary"
67
+ className="border-none"
68
+ />
69
+ </div>
70
+ }
71
+ >
72
+ <Form form={rename_form}>
73
+ <Form.Item
74
+ name="new_name"
75
+ rules={[
76
+ { required: true, message: "请输入" },
77
+ { max: 100, message: "最大字数限制100" }
78
+ ]}
79
+ >
80
+ <Input />
81
+ </Form.Item>
82
+ </Form>
83
+ </Modal>
84
+ </ConfigProvider>
85
+ );
86
+ };
@@ -0,0 +1,30 @@
1
+ import { bgColor, textColor } from '../ReferenceBar';
2
+
3
+ const TagCom = ({ i, item, j, clickTag }: any) => {
4
+ console.log('j in tag', j);
5
+ console.log('i in tag', i);
6
+ console.log('item in tag', item);
7
+
8
+ return (
9
+ <div
10
+ key={j.id}
11
+ style={{
12
+ minWidth: '16px',
13
+ height: '16px',
14
+ backgroundColor: bgColor[item.key],
15
+ margin: '0 4px',
16
+ color: textColor[item.key],
17
+ display: 'flex',
18
+ justifyContent: 'center',
19
+ alignItems: 'center',
20
+ borderRadius: '2px',
21
+ fontSize: '12px',
22
+ cursor: 'pointer',
23
+ }}
24
+ onClick={() => clickTag && clickTag(i, j, item)}
25
+ >
26
+ {j.index}
27
+ </div>
28
+ );
29
+ };
30
+ export default TagCom;
@@ -0,0 +1,3 @@
1
+ .listWrap .listBox .listItemBox:hover {
2
+ background-color: #eaf4fd;
3
+ }
@@ -0,0 +1,326 @@
1
+ import xls from '../../../assets/img/excel.png';
2
+ import txt from '../../../assets/img/txt.png';
3
+ import doc from '../../../assets/img/word.png';
4
+ import pdf from '../../../assets/img/pdf.png';
5
+ import ppt from '../../../assets/img/ppt.png';
6
+ import img from '../../../assets/img/img.png';
7
+ import dayjs from 'dayjs';
8
+ import axios from 'axios';
9
+
10
+ export const dealMinioUrl = (url: string) => {
11
+ // | undefined | string[]
12
+ return url || '';
13
+ // if (!url) return "";
14
+ // if (Array.isArray(url)) {
15
+ // const urlArr = url.map((item) => {
16
+ // const arr = item.split("/").slice(3);
17
+ // return `${getMinioUrlPrefix()}/` + arr.join("/");
18
+ // });
19
+ // return urlArr;
20
+ // }
21
+
22
+ // const arr = url.split("/").slice(3);
23
+
24
+ // return `${getMinioUrlPrefix()}/` + arr.join("/");
25
+ };
26
+
27
+ export const uniqArr2By = (array1: any[], array2: any[], key: string) => {
28
+ return array2.filter(item2 => !array1.some(item1 => item1[key] === item2[key]));
29
+ };
30
+
31
+ export const fileViewTypes = [
32
+ //"txt",
33
+ 'pdf',
34
+ // "xlsx",
35
+ // "xls",
36
+ // "csv",
37
+ 'md',
38
+ 'jpeg',
39
+ 'jpg',
40
+ 'png',
41
+ ];
42
+
43
+ export const getMarkExcludeType = (file_type: string) => {
44
+ return [''].includes(file_type); //"xls", "xlsx", "csv"
45
+ };
46
+
47
+ export const isImage = (type: string) => {
48
+ return ['png', 'jpg', 'jpeg'].includes(type);
49
+ };
50
+
51
+ export const TempBaseUrl = `http://${location.hostname}:9000/`;
52
+
53
+ export const getFileHost = (convertedPath: string) => {
54
+ if (convertedPath.includes('http')) {
55
+ const url = new URL(convertedPath);
56
+ return `${url.origin}/`;
57
+ }
58
+ return TempBaseUrl;
59
+ };
60
+ export const FILEIMG: any = {
61
+ docx: doc,
62
+ doc: doc,
63
+ pdf: pdf,
64
+ xls: xls,
65
+ xlsx: xls,
66
+ csv: xls,
67
+ ppt: ppt,
68
+ pptx: ppt,
69
+ pub: ppt,
70
+ txt: txt,
71
+ png: img,
72
+ jpg: img,
73
+ jpge: img,
74
+ };
75
+
76
+ export const getFileIcon = (fileType: string) => {
77
+ return FILEIMG[fileType] || FILEIMG['txt'];
78
+ };
79
+
80
+ export const smoothScroll = (container: any, distance?: number) => {
81
+ const d = distance || 20;
82
+ const { scrollTop, scrollHeight, clientHeight } = container;
83
+ const isBottom = scrollTop + clientHeight >= scrollHeight;
84
+ requestAnimationFrame(() => {
85
+ if (!isBottom) {
86
+ if (scrollTop + clientHeight + d < scrollHeight) {
87
+ container.scrollBy({
88
+ top: d,
89
+ behavior: 'smooth',
90
+ });
91
+ smoothScroll(container, d);
92
+ } else {
93
+ container.scrollTo({
94
+ top: scrollHeight,
95
+ behavior: 'smooth',
96
+ });
97
+ }
98
+ }
99
+ });
100
+ };
101
+
102
+ export const judgeXlS = (item: { type?: string; fileName: string }) => {
103
+ const validTypes = ['xlsx', 'xls', 'csv', 'png', 'jpg', 'jpeg'];
104
+ const fileExtension = item.fileName.split('.').pop()?.toLowerCase();
105
+ return validTypes.includes(item.type || '') || validTypes.includes(fileExtension || '');
106
+ };
107
+
108
+ export const FileModalSize = {
109
+ width: 960,
110
+ height: 742,
111
+ };
112
+
113
+ export const formatTime = (val: string) => {
114
+ return val ? dayjs(val).format('YY-MM-DD HH:mm') : '';
115
+ };
116
+
117
+ export const getUrlPrefix = () => {
118
+ return import.meta.env.VITE_RAG_PREFIX;
119
+ };
120
+
121
+ export const getMinioUrlPrefix = () => {
122
+ return import.meta.env.VITE_MINIO_PREFIX;
123
+ };
124
+
125
+ export const getCecUrlPrefix = () => {
126
+ return import.meta.env.VITE_CEC_PREFIX;
127
+ };
128
+
129
+ export const handleDownLoad = async (url: string) => {
130
+ if (!url) return;
131
+
132
+ try {
133
+ const response = await fetch(encodeURI(url)); // 处理特殊字符
134
+ const blob = await response.blob();
135
+ const blobUrl = URL.createObjectURL(blob);
136
+
137
+ const link = document.createElement('a');
138
+ link.href = blobUrl;
139
+ link.download = url.split('/').pop() || 'file.pdf'; // 提取文件名
140
+ link.style.display = 'none';
141
+
142
+ document.body.appendChild(link);
143
+ link.click();
144
+
145
+ // 清理资源
146
+ setTimeout(() => {
147
+ URL.revokeObjectURL(blobUrl);
148
+ document.body.removeChild(link);
149
+ }, 100);
150
+ } catch (error) {
151
+ console.error('下载失败:', error);
152
+ }
153
+ };
154
+
155
+ /**
156
+ * 获取文档预览组件数据
157
+ */
158
+
159
+ export const getFilePath = (content: {
160
+ file_type?: string;
161
+ file_source?: string;
162
+ metadata: { source?: string };
163
+ }) => {
164
+ let fileType = content?.file_type;
165
+ const source = content?.metadata?.source;
166
+ if (source) {
167
+ fileType = source.split('.').slice(-1)[0];
168
+ } else {
169
+ return content?.file_source || '';
170
+ }
171
+ if (fileViewTypes.includes(fileType)) {
172
+ if (source.includes('http')) {
173
+ return source;
174
+ } else {
175
+ return `${TempBaseUrl}${source}`;
176
+ }
177
+ } else {
178
+ return content?.file_source || '';
179
+ }
180
+ };
181
+
182
+ export const getFileName = (content: {
183
+ file_name?: string;
184
+ file_source?: string;
185
+ metadata: { source?: string };
186
+ }) => {
187
+ if (!content) return '';
188
+ const { file_name } = content;
189
+ if (file_name) return file_name;
190
+ const source = content?.metadata?.source;
191
+ if (source) {
192
+ const arr = source.split('/');
193
+ if (!arr.length) return '';
194
+ return arr[arr.length - 1];
195
+ } else {
196
+ return '';
197
+ }
198
+ };
199
+
200
+ export const getFileType = (content: { metadata: { source?: string } }, filePath: string) => {
201
+ if (!content) return '';
202
+ const source = content?.metadata?.source;
203
+ if (source) {
204
+ const arr = source.split('.');
205
+ if (!arr.length) return '';
206
+ const type = arr[arr.length - 1];
207
+
208
+ const _arr = (filePath || '').split('.');
209
+ if (!_arr.length) return '';
210
+ const _type = _arr[_arr.length - 1];
211
+ switch (type.toLocaleLowerCase()) {
212
+ case 'ppt':
213
+ case 'pub':
214
+ case 'pptx':
215
+ return 'pdf_slides';
216
+ case 'xls':
217
+ case 'xlsx':
218
+ case 'csv':
219
+ case 'md':
220
+ if (_type === 'pdf') return 'pdf';
221
+ return 'markdown_table';
222
+ case 'png':
223
+ case 'jpg':
224
+ case 'jpeg':
225
+ return 'image';
226
+ case 'html':
227
+ case 'htm':
228
+ return 'html';
229
+ case 'txt':
230
+ return 'text';
231
+ default:
232
+ if (_type === 'ppt' || _type === 'pub' || _type === 'pptx') return 'pdf_slides';
233
+ return 'pdf';
234
+ }
235
+ } else {
236
+ return '';
237
+ }
238
+ };
239
+
240
+ export const downloadByStream = async ({
241
+ filePath,
242
+ fileName,
243
+ token,
244
+ }: {
245
+ filePath: string;
246
+ fileName: string;
247
+ token: string;
248
+ }) => {
249
+ if (filePath && fileName) {
250
+ try {
251
+ const response: any = await axios.post(
252
+ '/proxy/index/knowledgeBase/file/stream',
253
+ { convertedFilePath: filePath },
254
+ {
255
+ headers: {
256
+ 'Content-Type': 'application/json',
257
+ Authorization: token,
258
+ },
259
+ responseType: 'arraybuffer',
260
+ }
261
+ );
262
+ //const response = await fetch(filePath);
263
+ console.log('response', response);
264
+ const blob = new Blob([response.data]);
265
+ const url = window.URL.createObjectURL(blob);
266
+ const _link = document.createElement('a');
267
+ const _body = document.body;
268
+
269
+ _link.href = url;
270
+ _link.download = fileName;
271
+ _link.style.display = 'none';
272
+ _body.appendChild(_link);
273
+
274
+ const event = new MouseEvent('click', {
275
+ view: window,
276
+ bubbles: true,
277
+ cancelable: true,
278
+ });
279
+ _link.dispatchEvent(event);
280
+
281
+ setTimeout(() => {
282
+ _body.removeChild(_link);
283
+ window.URL.revokeObjectURL(url);
284
+ }, 100);
285
+ } catch (error) {
286
+ console.error('下载文件失败:', error);
287
+ }
288
+ } else {
289
+ console.error('缺少文件名或文件地址:');
290
+ }
291
+ };
292
+
293
+ export const getInitialZoom = (boxWidth: number, curContent: any) => {
294
+ try {
295
+ if (!curContent?.metadata?.page_size?.length) {
296
+ const filePath = dealMinioUrl(getFilePath(curContent));
297
+ const fileType = getFileType(curContent, filePath);
298
+ let file_type = fileType;
299
+ const s = curContent?.file_name || curContent?.metadata?.source;
300
+ if (s) {
301
+ const sarr = s.split('.');
302
+ file_type = sarr?.[sarr.length - 1];
303
+ }
304
+ return judgePPT(fileType) || judgePPT(file_type) ? 0.6 : 1;
305
+ } else {
306
+ let pageSize = curContent?.metadata?.page_size || [[0, 0]];
307
+ if (!Array.isArray(pageSize)) {
308
+ pageSize = JSON.parse(pageSize);
309
+ }
310
+ const pageWidth = pageSize[0]?.[0] || 0;
311
+ const pageHeight = pageSize[0]?.[1] || 0;
312
+ if (pageHeight > pageWidth) return 1;
313
+ if (!boxWidth || !pageWidth) return 1;
314
+ if (pageWidth <= boxWidth) return 1;
315
+ return +(boxWidth / pageWidth).toFixed(4);
316
+ }
317
+ } catch (error) {
318
+ console.log('error', error);
319
+ return 1;
320
+ }
321
+ };
322
+
323
+ export const judgePPT = (type: string) => {
324
+ const types = ['ppt', 'pptx', 'pub'];
325
+ return types.includes(type.toLocaleLowerCase());
326
+ };