head ,csv template and limit content size
This commit is contained in:
@@ -20,7 +20,7 @@ const fileExtension = '.csv';
|
||||
type FileItemType = {
|
||||
id: string;
|
||||
filename: string;
|
||||
chunks: { q: string; a: string }[];
|
||||
chunks: { q: string; a: string; source?: string }[];
|
||||
};
|
||||
|
||||
const CsvImport = ({ kbId }: { kbId: string }) => {
|
||||
@@ -61,7 +61,8 @@ const CsvImport = ({ kbId }: { kbId: string }) => {
|
||||
filename: file.name,
|
||||
chunks: data.map((item) => ({
|
||||
q: item[0],
|
||||
a: item[1]
|
||||
a: item[1],
|
||||
source: item[2]
|
||||
}))
|
||||
},
|
||||
...state
|
||||
@@ -88,7 +89,7 @@ const CsvImport = ({ kbId }: { kbId: string }) => {
|
||||
file.chunks.forEach((chunk) => {
|
||||
chunks.push({
|
||||
...chunk,
|
||||
source: file.filename
|
||||
source: chunk.source || file.filename
|
||||
});
|
||||
})
|
||||
);
|
||||
@@ -210,6 +211,7 @@ const CsvImport = ({ kbId }: { kbId: string }) => {
|
||||
<Box px={3} py={'1px'} border={theme.borders.base} borderRadius={'md'}>
|
||||
# {i + 1}
|
||||
</Box>
|
||||
{item.source && <Box ml={1}>({item.source})</Box>}
|
||||
<Box flex={1} />
|
||||
<DeleteIcon
|
||||
onClick={() => {
|
||||
|
||||
@@ -23,7 +23,7 @@ const FileSelect = ({
|
||||
...props
|
||||
}: Props) => {
|
||||
const { Loading: FileSelectLoading } = useLoading();
|
||||
const csvTemplate = `question,answer\n"什么是 laf","laf 是一个云函数开发平台……"\n"什么是 sealos","Sealos 是以 kubernetes 为内核的云操作系统发行版,可以……"`;
|
||||
const csvTemplate = `question,answer,source\n"什么是 laf","laf 是一个云函数开发平台……","laf git doc"\n"什么是 sealos","Sealos 是以 kubernetes 为内核的云操作系统发行版,可以……","sealos git doc"`;
|
||||
|
||||
const { File, onOpen } = useSelectFile({
|
||||
fileType: fileExtension,
|
||||
@@ -72,7 +72,7 @@ const FileSelect = ({
|
||||
})
|
||||
}
|
||||
>
|
||||
点击下载csv模板
|
||||
点击下载 CSV 模板
|
||||
</Box>
|
||||
)}
|
||||
<FileSelectLoading loading={isLoading} fixed={false} />
|
||||
|
||||
Reference in New Issue
Block a user