From 752dc9b19d6f5ad0f97d7c76756b867ed5b53913 Mon Sep 17 00:00:00 2001
From: archer <545436317@qq.com>
Date: Sun, 10 Sep 2023 15:34:05 +0800
Subject: [PATCH] fix: preview chunk
---
client/public/imgs/files/file.svg | 2 +-
client/src/pages/kb/detail/components/Import/Chunk.tsx | 9 ++++++---
.../src/pages/kb/detail/components/Import/FileSelect.tsx | 2 +-
client/src/pages/kb/detail/components/Import/QA.tsx | 8 +++++---
4 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/client/public/imgs/files/file.svg b/client/public/imgs/files/file.svg
index f1b07130b..1f106af9e 100644
--- a/client/public/imgs/files/file.svg
+++ b/client/public/imgs/files/file.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/client/src/pages/kb/detail/components/Import/Chunk.tsx b/client/src/pages/kb/detail/components/Import/Chunk.tsx
index cce870213..aa1cf37e5 100644
--- a/client/src/pages/kb/detail/components/Import/Chunk.tsx
+++ b/client/src/pages/kb/detail/components/Import/Chunk.tsx
@@ -106,12 +106,15 @@ const ChunkImport = ({ kbId }: { kbId: string }) => {
text: file.text,
maxLen: chunkLen
});
+
return {
...file,
tokens: splitRes.tokens,
- chunks: file.chunks.map((chunk, i) => ({
- ...chunk,
- q: splitRes.chunks[i]
+ chunks: splitRes.chunks.map((chunk) => ({
+ a: '',
+ source: file.filename,
+ file_id: file.id,
+ q: chunk
}))
};
})
diff --git a/client/src/pages/kb/detail/components/Import/FileSelect.tsx b/client/src/pages/kb/detail/components/Import/FileSelect.tsx
index 4d91b8c1c..b1d31a11a 100644
--- a/client/src/pages/kb/detail/components/Import/FileSelect.tsx
+++ b/client/src/pages/kb/detail/components/Import/FileSelect.tsx
@@ -129,7 +129,7 @@ const FileSelect = ({
maxLen: chunkLen
});
const fileItem: FileItemType = {
- id: nanoid(),
+ id: filesId[0],
filename: file.name,
icon,
text,
diff --git a/client/src/pages/kb/detail/components/Import/QA.tsx b/client/src/pages/kb/detail/components/Import/QA.tsx
index e69c003d1..503ec60b5 100644
--- a/client/src/pages/kb/detail/components/Import/QA.tsx
+++ b/client/src/pages/kb/detail/components/Import/QA.tsx
@@ -97,9 +97,11 @@ const QAImport = ({ kbId }: { kbId: string }) => {
return {
...file,
tokens: splitRes.tokens,
- chunks: file.chunks.map((chunk, i) => ({
- ...chunk,
- q: splitRes.chunks[i]
+ chunks: splitRes.chunks.map((chunk) => ({
+ a: '',
+ source: file.filename,
+ file_id: file.id,
+ q: chunk
}))
};
})