mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? fix: Set the default value of Self RAG to false #1220 fix: Change all tool file names to kebab format ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { SupportedPreviewDocumentTypes } from '@/constants/common';
|
|
import { IChunk } from '@/interfaces/database/knowledge';
|
|
import { UploadFile } from 'antd';
|
|
import { v4 as uuid } from 'uuid';
|
|
|
|
export const buildChunkHighlights = (
|
|
selectedChunk: IChunk,
|
|
size: { width: number; height: number },
|
|
) => {
|
|
return Array.isArray(selectedChunk?.positions) &&
|
|
selectedChunk.positions.every((x) => Array.isArray(x))
|
|
? selectedChunk?.positions?.map((x) => {
|
|
const boundingRect = {
|
|
width: size.width,
|
|
height: size.height,
|
|
x1: x[1],
|
|
x2: x[2],
|
|
y1: x[3],
|
|
y2: x[4],
|
|
};
|
|
return {
|
|
id: uuid(),
|
|
comment: {
|
|
text: '',
|
|
emoji: '',
|
|
},
|
|
content: { text: selectedChunk.content_with_weight },
|
|
position: {
|
|
boundingRect: boundingRect,
|
|
rects: [boundingRect],
|
|
pageNumber: x[0],
|
|
},
|
|
};
|
|
})
|
|
: [];
|
|
};
|
|
|
|
export const isFileUploadDone = (file: UploadFile) => file.status === 'done';
|
|
|
|
export const getExtension = (name: string) =>
|
|
name?.slice(name.lastIndexOf('.') + 1).toLowerCase() ?? '';
|
|
|
|
export const isPdf = (name: string) => {
|
|
return getExtension(name) === 'pdf';
|
|
};
|
|
|
|
export const getUnSupportedFilesCount = (message: string) => {
|
|
return message.split('\n').length;
|
|
};
|
|
|
|
export const isSupportedPreviewDocumentType = (fileExtension: string) => {
|
|
return SupportedPreviewDocumentTypes.includes(fileExtension);
|
|
};
|