mirror of
https://github.com/dataelement/bisheng.git
synced 2026-10-30 18:42:04 +08:00
fix: 审计溯源展示逻辑
This commit is contained in:
@@ -16,7 +16,7 @@ export type FileType =
|
||||
| 'docx'
|
||||
| 'ppt'
|
||||
| 'pptx'
|
||||
| 'md' | 'html' | 'txt'
|
||||
| 'md' | 'html' | 'txt' | 'json'
|
||||
| 'jpg'
|
||||
| 'jpeg'
|
||||
| 'png'
|
||||
@@ -29,6 +29,7 @@ export type FileType =
|
||||
const iconComponents: Record<FileType, React.ComponentType<any>> = {
|
||||
pdf: PdfIcon,
|
||||
txt: TxtIcon,
|
||||
json: TxtIcon,
|
||||
doc: DocIcon,
|
||||
docx: DocxIcon,
|
||||
ppt: PptIcon,
|
||||
@@ -58,7 +59,7 @@ export const FileIcon = forwardRef<
|
||||
|
||||
if (!IconComponent) {
|
||||
console.warn(`No icon found for type: ${props.type}`);
|
||||
return null;
|
||||
return <TxtIcon ref={ref} className={props.className} {...props} />;
|
||||
}
|
||||
|
||||
return <IconComponent ref={ref} className={props.className} {...props} />;
|
||||
|
||||
@@ -790,7 +790,7 @@ export async function getSourceChunksApi(chatId: string, messageId: number, keys
|
||||
});
|
||||
|
||||
return Object.keys(fileMap).map(fileId => {
|
||||
const { file_id: id, source: fileName, source_url: fileUrl, original_url: originUrl, ...other } = fileMap[fileId][0]
|
||||
const { file_id: id, source: fileName, source_url, original_url: originUrl, ...other } = fileMap[fileId][0]
|
||||
|
||||
const chunks = fileMap[fileId].sort((a, b) => b.score - a.score)
|
||||
.map(chunk => ({
|
||||
@@ -799,7 +799,20 @@ export async function getSourceChunksApi(chatId: string, messageId: number, keys
|
||||
}))
|
||||
const score = chunks[0].score
|
||||
|
||||
return { id, fileName, fileUrl, originUrl, chunks, ...other, score }
|
||||
// 兼容后端历史逻辑
|
||||
let fileUrl = ''
|
||||
let suffix = fileName.split('.').pop().toLowerCase()
|
||||
let isNew = false
|
||||
if (['uns', 'local'].includes(other.parse_type)) {
|
||||
fileUrl = other.chunk_bboxes ? source_url : originUrl;
|
||||
if (other.chunk_bboxes) {
|
||||
suffix = 'pdf'
|
||||
}
|
||||
} else if (['etl4lm', 'un_etl4lm'].includes(other.parse_type)) {
|
||||
fileUrl = source_url || originUrl
|
||||
isNew = true
|
||||
}
|
||||
return { id, fileName, suffix, isNew, fileUrl, originUrl, chunks, ...other, score }
|
||||
}).sort((a, b) => b.score - a.score)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user