@gientech/modual 1.5.0 → 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.
- package/dist/assets/GientechStreamReader-KtCNi1G3.js +447 -0
- package/dist/assets/style3.css +1 -1
- package/dist/chat.js +911 -2202
- package/dist/index.js +1 -1
- package/dist/package.json +1 -1
- package/dist/streamFilesReader.js +1 -1
- package/dist/worker/pdf.worker1.min.js +23 -0
- package/package.json +1 -1
- package/public/worker/pdf.worker1.min.js +23 -0
- package/src/main.tsx.backup +5 -5
- package/src/modules/chat/ReferenceBar.tsx +520 -11
- package/src/modules/chat/index.tsx +21 -29
- package/src/{utils/gientechCommon/components → modules/chat}/referenceCom/DrawerTitle.tsx +1 -1
- package/src/{utils/gientechCommon/components → modules/chat}/referenceCom/TagCom.tsx +1 -1
- package/src/{utils/gientechCommon/components → modules/chat}/utils/index.ts +6 -6
- package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +231 -18
- package/src/utils/testconfigs/index.ts +1 -1
- package/stats.html +1 -1
- package/dist/assets/GientechStreamReader-BE_oxQLt.js +0 -446
- package/src/utils/gientechCommon/components/ReferenceListDrawer.tsx +0 -542
- package/src/utils/gientechCommon/components/hooks/useAichatEvent.ts +0 -10
- /package/src/{utils/gientechCommon/components → modules/chat}/referenceCom/DeleteModal.tsx +0 -0
- /package/src/{utils/gientechCommon/components → modules/chat}/referenceCom/DrawerContent.tsx +0 -0
- /package/src/{utils/gientechCommon/components → modules/chat}/referenceCom/DrawerDatabase.tsx +0 -0
- /package/src/{utils/gientechCommon/components → modules/chat}/referenceCom/DrawerGraphPreview.tsx +0 -0
- /package/src/{utils/gientechCommon/components → modules/chat}/referenceCom/DrawerPreview.tsx +0 -0
- /package/src/{utils/gientechCommon/components → modules/chat}/referenceCom/RenameModal.tsx +0 -0
- /package/src/{utils/gientechCommon/components → modules/chat}/style.css +0 -0
package/src/main.tsx.backup
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom/client';
|
|
3
|
-
import Chat from './examples/chat/index';
|
|
4
|
-
|
|
5
|
-
ReactDOM.createRoot(document.getElementById('root')!).render(<Chat />);
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
import Chat from './examples/chat/index';
|
|
4
|
+
|
|
5
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(<Chat />);
|
|
@@ -1,13 +1,522 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { ConfigProvider, Drawer, Tooltip } from 'antd';
|
|
2
|
+
import SingleQa from '../../assets/img/singleQa.png';
|
|
3
|
+
import DownLoad from '../../assets/img/downLoad.png';
|
|
4
|
+
import GraphIcon from '../../assets/img/graphIcon.png';
|
|
5
|
+
import WebSearch from '../../assets/img/webSearch.png';
|
|
6
|
+
import Database from '../../assets/img/database.png';
|
|
7
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import './style.css';
|
|
9
|
+
import DrawerGraphPreview from './referenceCom/DrawerGraphPreview';
|
|
10
|
+
import { DrawerContent } from './referenceCom/DrawerContent';
|
|
11
|
+
import DrawerPreview from './referenceCom/DrawerPreview';
|
|
12
|
+
import DrawerDatabase from './referenceCom/DrawerDatabase';
|
|
13
|
+
import DrawerTitle from './referenceCom/DrawerTitle';
|
|
14
|
+
import TagCom from './referenceCom/TagCom';
|
|
15
|
+
import {
|
|
16
|
+
downloadByStream,
|
|
17
|
+
getFileIcon,
|
|
18
|
+
getFileName,
|
|
19
|
+
getMarkExcludeType,
|
|
20
|
+
TempBaseUrl,
|
|
21
|
+
} from './utils';
|
|
22
|
+
import { DrawerType } from '../../lib_enter';
|
|
23
|
+
|
|
24
|
+
enum ListName {
|
|
25
|
+
KNOWLEDGE = 'knowledgeList',
|
|
26
|
+
SEARCH = 'searchList',
|
|
27
|
+
DATABASE = 'databaseList',
|
|
28
|
+
GRAPH = 'graphList',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const bgColor: any = {
|
|
32
|
+
[ListName.KNOWLEDGE]: '#EAF4FD',
|
|
33
|
+
[ListName.SEARCH]: '#E8F7F0',
|
|
34
|
+
[ListName.DATABASE]: '#FFF4E5',
|
|
35
|
+
[ListName.GRAPH]: '#E7F8FB',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const textColor: any = {
|
|
39
|
+
[ListName.KNOWLEDGE]: '#2072F0',
|
|
40
|
+
[ListName.SEARCH]: '#39B83F',
|
|
41
|
+
[ListName.DATABASE]: '#F48C14',
|
|
42
|
+
[ListName.GRAPH]: '#10BBD9',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const BTNS = [
|
|
46
|
+
{
|
|
47
|
+
key: ListName.KNOWLEDGE,
|
|
48
|
+
name: '知识库文档',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: ListName.SEARCH,
|
|
52
|
+
name: '联网搜索',
|
|
53
|
+
hideBtns: true,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: ListName.DATABASE,
|
|
57
|
+
name: '数据库',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
key: ListName.GRAPH,
|
|
61
|
+
name: '知识图谱',
|
|
62
|
+
hideBtns: true,
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
export const ReferenceBar = ({
|
|
67
|
+
type,
|
|
68
|
+
data,
|
|
69
|
+
token,
|
|
70
|
+
eventsEmit,
|
|
71
|
+
is_download,
|
|
72
|
+
}: {
|
|
73
|
+
type: string;
|
|
74
|
+
data: any;
|
|
75
|
+
token: string;
|
|
76
|
+
eventsEmit?: (eventName: string, data: any) => void;
|
|
77
|
+
is_download: boolean;
|
|
78
|
+
}) => {
|
|
79
|
+
const [btns, setBtns] = useState(BTNS);
|
|
80
|
+
const [drawerType, setDrawerType] = useState<string>('mark');
|
|
81
|
+
const [drawerOpen, setDrawerOpen] = useState<boolean>(false);
|
|
82
|
+
const [curFileInfo, setCurFileInfo] = useState<any>({});
|
|
83
|
+
const [activeBtn, setActiveBtn] = useState<any>(ListName.KNOWLEDGE);
|
|
84
|
+
const [lists, seLists] = useState<any>({
|
|
85
|
+
[ListName.KNOWLEDGE]: [],
|
|
86
|
+
[ListName.SEARCH]: [],
|
|
87
|
+
[ListName.DATABASE]: [],
|
|
88
|
+
[ListName.GRAPH]: [],
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const getEmptyBoxs = useMemo(() => {
|
|
92
|
+
const n = 4 - btns.length;
|
|
93
|
+
const arr = Array(n)
|
|
94
|
+
.fill(null)
|
|
95
|
+
.map((v, i) => {
|
|
96
|
+
return {
|
|
97
|
+
name: '',
|
|
98
|
+
key: 100 + i,
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const r = [...btns, ...arr];
|
|
103
|
+
console.log('rrrrrr', r);
|
|
104
|
+
|
|
105
|
+
return r;
|
|
106
|
+
}, [btns]);
|
|
107
|
+
|
|
108
|
+
const filterScore = (score: any) => {
|
|
109
|
+
if (isNaN(score)) {
|
|
110
|
+
return '';
|
|
111
|
+
} else {
|
|
112
|
+
return (+score).toFixed(2);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const getIcon = (btn: string, filtType?: string) => {
|
|
117
|
+
switch (btn) {
|
|
118
|
+
case ListName.KNOWLEDGE:
|
|
119
|
+
return getFileIcon(filtType as any);
|
|
120
|
+
case ListName.SEARCH:
|
|
121
|
+
return WebSearch;
|
|
122
|
+
case ListName.DATABASE:
|
|
123
|
+
return Database;
|
|
124
|
+
case ListName.GRAPH:
|
|
125
|
+
return GraphIcon;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const dealData = (type: string, data: any[]) => {
|
|
130
|
+
if (type === ListName.GRAPH) {
|
|
131
|
+
return data.map(item => {
|
|
132
|
+
return {
|
|
133
|
+
...item,
|
|
134
|
+
name: item.graphName,
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (type === ListName.KNOWLEDGE) {
|
|
140
|
+
return data.map(item => {
|
|
141
|
+
return {
|
|
142
|
+
...item,
|
|
143
|
+
name: item.file_name,
|
|
144
|
+
score: item.rrf_score,
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (type === ListName.SEARCH) {
|
|
150
|
+
return data.map(item => {
|
|
151
|
+
return {
|
|
152
|
+
...item,
|
|
153
|
+
name: item.file_name,
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return data;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const clickTag = (file: any, tag: any, btn: any) => {
|
|
162
|
+
switch (btn.key) {
|
|
163
|
+
case ListName.KNOWLEDGE:
|
|
164
|
+
console.log('click knowledge tag', file, tag);
|
|
165
|
+
const curFile = file;
|
|
166
|
+
const { pdfPages, parsedFilePath, order_num, metadata } = curFile;
|
|
167
|
+
const id = tag.id || order_num || 'Unknown ID';
|
|
168
|
+
// 解析 source 字段
|
|
169
|
+
const sourceParts = metadata.source.split('/');
|
|
170
|
+
const fileName = sourceParts[sourceParts.length - 1] || '';
|
|
171
|
+
const fileParts = fileName.split('.');
|
|
172
|
+
const label = fileParts.slice(0, -1).join('.') || 'Unknown Label';
|
|
173
|
+
const file_type = fileParts[fileParts.length - 1] || 'Unknown Type';
|
|
174
|
+
|
|
175
|
+
setCurFileInfo({
|
|
176
|
+
id,
|
|
177
|
+
title: label,
|
|
178
|
+
file_name: fileName,
|
|
179
|
+
file_type: file_type,
|
|
180
|
+
file_source: getMarkExcludeType(file_type)
|
|
181
|
+
? `${TempBaseUrl}${metadata.source}`
|
|
182
|
+
: parsedFilePath,
|
|
183
|
+
metadata: metadata,
|
|
184
|
+
pdfPages: pdfPages,
|
|
185
|
+
});
|
|
186
|
+
setDrawerType('mark');
|
|
187
|
+
setDrawerOpen(true);
|
|
188
|
+
break;
|
|
189
|
+
case ListName.SEARCH:
|
|
190
|
+
console.log('click search tag', file, tag);
|
|
191
|
+
break;
|
|
192
|
+
case ListName.DATABASE:
|
|
193
|
+
console.log('click database tag', file, tag);
|
|
194
|
+
break;
|
|
195
|
+
case ListName.GRAPH:
|
|
196
|
+
console.log('click graph tag', file, tag);
|
|
197
|
+
setDrawerType('graphPreview');
|
|
198
|
+
setCurFileInfo({
|
|
199
|
+
...file,
|
|
200
|
+
traceNode: (data?.traceNode || []).find((item: any) => {
|
|
201
|
+
return item.id === tag.id;
|
|
202
|
+
}),
|
|
8
203
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
204
|
+
setDrawerOpen(true);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
if (type !== DrawerType.REFERENCELIST) return;
|
|
211
|
+
console.log('data in reference drawer', data);
|
|
212
|
+
if (!data) return;
|
|
213
|
+
const { graphRefs, knowledgeRefs, webRefs } = data;
|
|
214
|
+
if (graphRefs?.length) {
|
|
215
|
+
lists[ListName.GRAPH] = dealData(ListName.GRAPH, graphRefs);
|
|
216
|
+
}
|
|
217
|
+
if (knowledgeRefs?.length) {
|
|
218
|
+
lists[ListName.KNOWLEDGE] = dealData(ListName.KNOWLEDGE, knowledgeRefs);
|
|
219
|
+
}
|
|
220
|
+
if (webRefs?.length) {
|
|
221
|
+
lists[ListName.SEARCH] = dealData(ListName.SEARCH, webRefs);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const curBtns = BTNS.filter((item: any) => {
|
|
225
|
+
return lists[item.key]?.length;
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
setBtns(curBtns);
|
|
229
|
+
|
|
230
|
+
if (curBtns?.length) {
|
|
231
|
+
setActiveBtn(curBtns[0].key);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
seLists({ ...lists });
|
|
235
|
+
}, [data]);
|
|
236
|
+
|
|
237
|
+
return (
|
|
238
|
+
<>
|
|
239
|
+
<div className="listWrap w-full h-full">
|
|
240
|
+
<DrawerTitle
|
|
241
|
+
title="知识溯源"
|
|
242
|
+
setOpen={() => {
|
|
243
|
+
const closeEvent = new CustomEvent('aichat:right_set', {
|
|
244
|
+
detail: { collapsed: true },
|
|
245
|
+
});
|
|
246
|
+
window.dispatchEvent(closeEvent);
|
|
247
|
+
}}
|
|
248
|
+
/>
|
|
249
|
+
<div style={{ height: 'calc(100% - 60px)' }}>
|
|
250
|
+
<div
|
|
251
|
+
className="tabs"
|
|
252
|
+
style={{ display: 'flex', justifyContent: 'space-between', padding: '12px 20px' }}
|
|
253
|
+
>
|
|
254
|
+
{getEmptyBoxs.map(item => (
|
|
255
|
+
<div
|
|
256
|
+
key={item.key}
|
|
257
|
+
className="tab-item"
|
|
258
|
+
style={{
|
|
259
|
+
display: 'inline-block',
|
|
260
|
+
padding: '5.5px 12px',
|
|
261
|
+
backgroundColor: !item.name
|
|
262
|
+
? 'transparent'
|
|
263
|
+
: activeBtn === item.key
|
|
264
|
+
? '#4E6EF2'
|
|
265
|
+
: '#F5F6F9',
|
|
266
|
+
cursor: 'pointer',
|
|
267
|
+
borderRadius: '4px',
|
|
268
|
+
color: activeBtn === item.key ? '#FFFFFF' : '#4E5969',
|
|
269
|
+
fontSize: '14px',
|
|
270
|
+
minWidth: '80px',
|
|
271
|
+
}}
|
|
272
|
+
onClick={() => {
|
|
273
|
+
if (item.name) {
|
|
274
|
+
setActiveBtn(item.key);
|
|
275
|
+
}
|
|
276
|
+
}}
|
|
277
|
+
>
|
|
278
|
+
{item.name}
|
|
279
|
+
</div>
|
|
280
|
+
))}
|
|
281
|
+
</div>
|
|
282
|
+
<div
|
|
283
|
+
className="listBox"
|
|
284
|
+
style={{
|
|
285
|
+
height: 'calc(100% - 66px)',
|
|
286
|
+
overflowY: 'auto',
|
|
287
|
+
display: 'flex',
|
|
288
|
+
flexDirection: 'column',
|
|
289
|
+
alignItems: 'center',
|
|
290
|
+
}}
|
|
291
|
+
>
|
|
292
|
+
{btns.map((item: any) => {
|
|
293
|
+
let list: any[] = lists[item.key] || [];
|
|
294
|
+
if (activeBtn !== item.key) return null;
|
|
295
|
+
return (
|
|
296
|
+
<div key={item.key}>
|
|
297
|
+
{list.map(
|
|
298
|
+
(i: {
|
|
299
|
+
name: string;
|
|
300
|
+
id: string;
|
|
301
|
+
score: number | string;
|
|
302
|
+
tags?: any[];
|
|
303
|
+
hideBtns?: boolean;
|
|
304
|
+
file_type?: string;
|
|
305
|
+
link?: string;
|
|
306
|
+
metadata: any;
|
|
307
|
+
file_name: any;
|
|
308
|
+
parsedFilePath: any;
|
|
309
|
+
}) => {
|
|
310
|
+
return (
|
|
311
|
+
<div
|
|
312
|
+
key={i.id}
|
|
313
|
+
style={{
|
|
314
|
+
width: '360px',
|
|
315
|
+
padding: '4px 8px',
|
|
316
|
+
borderRadius: '4px',
|
|
317
|
+
margin: '6px 0',
|
|
318
|
+
cursor: 'pointer',
|
|
319
|
+
}}
|
|
320
|
+
className="listItemBox"
|
|
321
|
+
onClick={() => {
|
|
322
|
+
if (item.key === ListName.SEARCH) {
|
|
323
|
+
window.open(i.link, '_blank');
|
|
324
|
+
}
|
|
325
|
+
}}
|
|
326
|
+
>
|
|
327
|
+
<div
|
|
328
|
+
style={{
|
|
329
|
+
display: 'flex',
|
|
330
|
+
justifyContent: 'space-between',
|
|
331
|
+
alignItems: 'center',
|
|
332
|
+
}}
|
|
333
|
+
>
|
|
334
|
+
<div
|
|
335
|
+
style={{
|
|
336
|
+
width: item.hideBtns ? '339px' : '288px',
|
|
337
|
+
fontSize: '14px',
|
|
338
|
+
color: '#1D2129',
|
|
339
|
+
fontWeight: '700',
|
|
340
|
+
display: 'flex',
|
|
341
|
+
alignItems: 'center',
|
|
342
|
+
}}
|
|
343
|
+
>
|
|
344
|
+
<img
|
|
345
|
+
src={getIcon(item.key, i.file_type)}
|
|
346
|
+
style={{ width: '16px', height: '16px', marginRight: '2px' }}
|
|
347
|
+
/>
|
|
348
|
+
<Tooltip
|
|
349
|
+
placement="topLeft"
|
|
350
|
+
title={i?.name?.length > 16 ? i.name : ''}
|
|
351
|
+
>
|
|
352
|
+
<div
|
|
353
|
+
style={{
|
|
354
|
+
whiteSpace: 'nowrap',
|
|
355
|
+
overflow: 'hidden',
|
|
356
|
+
textOverflow: 'ellipsis',
|
|
357
|
+
width: item.hideBtns ? '322px' : '258px',
|
|
358
|
+
}}
|
|
359
|
+
>
|
|
360
|
+
{i.name}
|
|
361
|
+
</div>
|
|
362
|
+
</Tooltip>
|
|
363
|
+
</div>
|
|
364
|
+
<div
|
|
365
|
+
style={{
|
|
366
|
+
width: '52px',
|
|
367
|
+
justifyContent: 'space-between',
|
|
368
|
+
alignItems: 'center',
|
|
369
|
+
marginRight: '8px',
|
|
370
|
+
display: item.hideBtns ? 'none' : 'flex',
|
|
371
|
+
}}
|
|
372
|
+
>
|
|
373
|
+
<img
|
|
374
|
+
src={SingleQa}
|
|
375
|
+
style={{ width: '16px', height: '16px', cursor: 'pointer' }}
|
|
376
|
+
onClick={() => {
|
|
377
|
+
eventsEmit?.('referenceFile_filechat', {
|
|
378
|
+
data: {
|
|
379
|
+
...i,
|
|
380
|
+
file_type: i.file_type,
|
|
381
|
+
file_name: i.file_name,
|
|
382
|
+
metadata: i.metadata,
|
|
383
|
+
parsedFilePath: i.parsedFilePath,
|
|
384
|
+
},
|
|
385
|
+
});
|
|
386
|
+
}}
|
|
387
|
+
/>
|
|
388
|
+
<div
|
|
389
|
+
style={{ borderRight: '1px solid #E5E6EB', height: '14px' }}
|
|
390
|
+
></div>
|
|
391
|
+
<img
|
|
392
|
+
src={DownLoad}
|
|
393
|
+
style={{
|
|
394
|
+
width: '16px',
|
|
395
|
+
height: '16px',
|
|
396
|
+
cursor: is_download ? 'pointer' : 'not-allowed',
|
|
397
|
+
}}
|
|
398
|
+
onClick={() => {
|
|
399
|
+
if (!i?.metadata || !is_download) return;
|
|
400
|
+
downloadByStream({
|
|
401
|
+
filePath: `${TempBaseUrl}${i.metadata.source}`,
|
|
402
|
+
fileName: getFileName(i),
|
|
403
|
+
token,
|
|
404
|
+
});
|
|
405
|
+
}}
|
|
406
|
+
/>
|
|
407
|
+
</div>
|
|
408
|
+
</div>
|
|
409
|
+
{(typeof i.score === 'string' ||
|
|
410
|
+
typeof i.score === 'number' ||
|
|
411
|
+
(i?.tags?.length && i.tags.length > 0 && i.tags.length <= 10)) && (
|
|
412
|
+
<div
|
|
413
|
+
style={{
|
|
414
|
+
display: 'flex',
|
|
415
|
+
justifyContent: 'space-between',
|
|
416
|
+
height: '18px',
|
|
417
|
+
marginTop: '4px',
|
|
418
|
+
}}
|
|
419
|
+
>
|
|
420
|
+
{(typeof i.score === 'string' || typeof i.score === 'number') && (
|
|
421
|
+
<div
|
|
422
|
+
style={{
|
|
423
|
+
backgroundColor: '#F2F2FB',
|
|
424
|
+
borderRadius: '4px',
|
|
425
|
+
padding: '2px 3px',
|
|
426
|
+
display: 'flex',
|
|
427
|
+
justifyContent: 'center',
|
|
428
|
+
alignItems: 'center',
|
|
429
|
+
fontSize: '12px',
|
|
430
|
+
}}
|
|
431
|
+
>
|
|
432
|
+
<span style={{ color: '#4E5969', marginRight: '6px' }}>
|
|
433
|
+
分数:
|
|
434
|
+
</span>
|
|
435
|
+
<span style={{ color: '#1D2129' }}>{filterScore(i.score)}</span>
|
|
436
|
+
</div>
|
|
437
|
+
)}
|
|
438
|
+
<div style={{ flex: 1, display: 'flex', justifyContent: 'flex-end' }}>
|
|
439
|
+
{(i?.tags?.length && i.tags.length > 0 && i.tags.length <= 10
|
|
440
|
+
? i.tags
|
|
441
|
+
: []
|
|
442
|
+
).map((j: any) => {
|
|
443
|
+
return (
|
|
444
|
+
<TagCom
|
|
445
|
+
key={j.id}
|
|
446
|
+
i={i}
|
|
447
|
+
item={item}
|
|
448
|
+
j={j}
|
|
449
|
+
clickTag={clickTag}
|
|
450
|
+
/>
|
|
451
|
+
);
|
|
452
|
+
})}
|
|
453
|
+
</div>
|
|
454
|
+
</div>
|
|
455
|
+
)}
|
|
456
|
+
<div
|
|
457
|
+
style={{
|
|
458
|
+
flex: 1,
|
|
459
|
+
display: 'flex',
|
|
460
|
+
justifyContent: 'flex-start',
|
|
461
|
+
marginTop: '4px',
|
|
462
|
+
}}
|
|
463
|
+
>
|
|
464
|
+
{(i?.tags?.length && i.tags.length > 10 ? i.tags : []).map((j: any) => {
|
|
465
|
+
return (
|
|
466
|
+
<TagCom key={j.id} i={i} item={item} j={j} clickTag={clickTag} />
|
|
467
|
+
);
|
|
468
|
+
})}
|
|
469
|
+
</div>
|
|
470
|
+
</div>
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
)}
|
|
474
|
+
</div>
|
|
475
|
+
);
|
|
476
|
+
})}
|
|
477
|
+
</div>
|
|
478
|
+
</div>
|
|
479
|
+
</div>
|
|
480
|
+
<ConfigProvider
|
|
481
|
+
drawer={{
|
|
482
|
+
styles: {
|
|
483
|
+
body: { padding: 0 },
|
|
484
|
+
header: { display: 'none' },
|
|
485
|
+
},
|
|
486
|
+
}}
|
|
487
|
+
>
|
|
488
|
+
<Drawer
|
|
489
|
+
autoFocus={false}
|
|
490
|
+
onClose={() => setDrawerOpen(false)}
|
|
491
|
+
open={drawerOpen}
|
|
492
|
+
width={720}
|
|
493
|
+
className="overflow-x-hidden"
|
|
494
|
+
destroyOnClose
|
|
495
|
+
getContainer={false}
|
|
496
|
+
afterOpenChange={open => {
|
|
497
|
+
if (!open) {
|
|
498
|
+
setCurFileInfo(null);
|
|
499
|
+
}
|
|
500
|
+
}}
|
|
501
|
+
>
|
|
502
|
+
{drawerType === 'graphPreview' && (
|
|
503
|
+
<DrawerGraphPreview
|
|
504
|
+
curFileInfo={curFileInfo as any}
|
|
505
|
+
onClose={setDrawerOpen}
|
|
506
|
+
token={token}
|
|
507
|
+
/>
|
|
508
|
+
)}
|
|
509
|
+
{drawerType === 'mark' && (
|
|
510
|
+
<DrawerContent content={curFileInfo as any} onClose={setDrawerOpen} token={token} />
|
|
511
|
+
)}
|
|
512
|
+
{drawerType === 'preview' && (
|
|
513
|
+
<DrawerPreview curFileInfo={curFileInfo} onClose={setDrawerOpen} token={token} />
|
|
514
|
+
)}
|
|
515
|
+
{drawerType === 'database' && (
|
|
516
|
+
<DrawerDatabase curFileInfo={curFileInfo} onClose={setDrawerOpen} />
|
|
517
|
+
)}
|
|
518
|
+
</Drawer>
|
|
519
|
+
</ConfigProvider>
|
|
520
|
+
</>
|
|
12
521
|
);
|
|
13
|
-
}
|
|
522
|
+
};
|
|
@@ -9,9 +9,10 @@ import '@mxmweb/rtext/style.css';
|
|
|
9
9
|
import '@mxmweb/aichat/style.css';
|
|
10
10
|
import '@mxmweb/zui/style.css';
|
|
11
11
|
import { defaultTheme, deepMergeTheme, type Styles } from '@mxmweb/zui';
|
|
12
|
-
import ReferenceBar from './ReferenceBar';
|
|
13
12
|
import { DefaultSenderConfig } from './constants';
|
|
14
13
|
import GientechConversationPanel from './Conversations';
|
|
14
|
+
import { registerPDFWorker } from '@mxmweb/fviewer';
|
|
15
|
+
registerPDFWorker('/worker/pdf.worker1.min.js');
|
|
15
16
|
import {
|
|
16
17
|
convertQueryReplyPairListToMessages,
|
|
17
18
|
getFileTypeByName,
|
|
@@ -38,8 +39,7 @@ import DisplayError from '../../utils/gientechCommon/components/DisplayError';
|
|
|
38
39
|
import { maxPollCount, maxPollInterval } from '../../utils/gientechCommon/configs/commonConfig';
|
|
39
40
|
import { RenameModal } from '../../utils/gientechCommon/components/RenameModal';
|
|
40
41
|
import { DeleteModal } from '../../utils/gientechCommon/components/DeleteModal';
|
|
41
|
-
import
|
|
42
|
-
import { ReferenceListDrawer } from '../../utils/gientechCommon/components/ReferenceListDrawer';
|
|
42
|
+
import { ReferenceBar } from './ReferenceBar';
|
|
43
43
|
|
|
44
44
|
export enum DrawerType {
|
|
45
45
|
REFERENCELIST = 'referencelist',
|
|
@@ -118,11 +118,6 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
118
118
|
scrollOld,
|
|
119
119
|
...rest
|
|
120
120
|
}: GientechChatAdopterProps) {
|
|
121
|
-
const [drawerConfig, setDrawerConfig] = useState<{ type: string; data?: any }>({
|
|
122
|
-
type: 'string',
|
|
123
|
-
});
|
|
124
|
-
const [open, setOpen] = useState(false);
|
|
125
|
-
const {} = useAichatEvent();
|
|
126
121
|
// 统一归一化样式:使用 UI 库的 deepMergeTheme
|
|
127
122
|
const normalizedStyles: Styles = useMemo(() => {
|
|
128
123
|
const baseStyles: Styles = { theme: defaultTheme, mode: 'light' };
|
|
@@ -1482,6 +1477,7 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
1482
1477
|
console.log('error', error);
|
|
1483
1478
|
}
|
|
1484
1479
|
};
|
|
1480
|
+
|
|
1485
1481
|
/**
|
|
1486
1482
|
* 统一事件分发器,连接业务逻辑与所有子组件的事件
|
|
1487
1483
|
* @param {string} eventName - 事件名称
|
|
@@ -1676,21 +1672,24 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
1676
1672
|
eventsEmit?.('referenceFile_download', data);
|
|
1677
1673
|
break;
|
|
1678
1674
|
case 'references:click': {
|
|
1679
|
-
setDrawerConfig({
|
|
1680
|
-
type: DrawerType.REFERENCELIST,
|
|
1681
|
-
data,
|
|
1682
|
-
});
|
|
1683
|
-
setOpen(true);
|
|
1684
1675
|
// 使用 AiChat 内置的右侧栏事件
|
|
1685
1676
|
const Content = () => {
|
|
1686
|
-
const safe = (() => {
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
})();
|
|
1693
|
-
return
|
|
1677
|
+
// const safe = (() => {
|
|
1678
|
+
// try {
|
|
1679
|
+
// return typeof data === 'string' ? data : JSON.stringify(data, null, 2);
|
|
1680
|
+
// } catch (e) {
|
|
1681
|
+
// return String(data);
|
|
1682
|
+
// }
|
|
1683
|
+
// })();
|
|
1684
|
+
return (
|
|
1685
|
+
<ReferenceBar
|
|
1686
|
+
type={DrawerType.REFERENCELIST}
|
|
1687
|
+
data={data}
|
|
1688
|
+
token={token}
|
|
1689
|
+
eventsEmit={eventsEmit}
|
|
1690
|
+
is_download={is_download}
|
|
1691
|
+
/>
|
|
1692
|
+
);
|
|
1694
1693
|
};
|
|
1695
1694
|
const setContentEvent = new CustomEvent('aichat:right_set_content', {
|
|
1696
1695
|
detail: { content: <Content /> },
|
|
@@ -2041,6 +2040,7 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
2041
2040
|
CustomComponents={mergedCustomComponents}
|
|
2042
2041
|
activeSessionId={activeSessionId}
|
|
2043
2042
|
scrollOld={scrollOld}
|
|
2043
|
+
rightbarWidth={'400px'}
|
|
2044
2044
|
/>
|
|
2045
2045
|
<FeedBackModal
|
|
2046
2046
|
open={openFeed}
|
|
@@ -2060,14 +2060,6 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
2060
2060
|
handleCancel={() => handleEvent('close_remove')}
|
|
2061
2061
|
data={curEditData?.data || {}}
|
|
2062
2062
|
/>
|
|
2063
|
-
<ReferenceListDrawer
|
|
2064
|
-
open={open}
|
|
2065
|
-
setOpen={setOpen}
|
|
2066
|
-
type={drawerConfig.type}
|
|
2067
|
-
data={drawerConfig.data}
|
|
2068
|
-
token={token}
|
|
2069
|
-
eventsEmit={eventsEmit}
|
|
2070
|
-
/>
|
|
2071
2063
|
</div>
|
|
2072
2064
|
);
|
|
2073
2065
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import xls from '
|
|
2
|
-
import txt from '
|
|
3
|
-
import doc from '
|
|
4
|
-
import pdf from '
|
|
5
|
-
import ppt from '
|
|
6
|
-
import img from '
|
|
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
7
|
import dayjs from 'dayjs';
|
|
8
8
|
import axios from 'axios';
|
|
9
9
|
|