Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
eb5a2526
authored
Aug 04, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: csv select
parent
a19c8b91
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
20 deletions
+22
-20
client/src/pages/kb/detail/components/Import/Csv.tsx
+22
-20
No files found.
client/src/pages/kb/detail/components/Import/Csv.tsx
View file @
eb5a2526
...
...
@@ -48,27 +48,29 @@ const CsvImport = ({ kbId }: { kbId: string }) => {
setSelecting
(
true
);
try
{
let
promise
=
Promise
.
resolve
();
files
.
forEach
((
file
)
=>
{
promise
=
promise
.
then
(
async
()
=>
{
const
{
header
,
data
}
=
await
readCsvContent
(
file
);
if
(
header
[
0
]
!==
'question'
||
header
[
1
]
!==
'answer'
)
{
throw
new
Error
(
'csv 文件格式有误,请确保 question 和 answer 两列'
);
}
setFiles
((
state
)
=>
[
{
id
:
nanoid
(),
filename
:
file
.
name
,
chunks
:
data
.
map
((
item
)
=>
({
q
:
item
[
0
],
a
:
item
[
1
],
source
:
item
[
2
]
}))
},
...
state
]);
files
.
filter
((
file
)
=>
/csv$/
.
test
(
file
.
name
))
.
forEach
((
file
)
=>
{
promise
=
promise
.
then
(
async
()
=>
{
const
{
header
,
data
}
=
await
readCsvContent
(
file
);
if
(
header
[
0
]
!==
'question'
||
header
[
1
]
!==
'answer'
)
{
throw
new
Error
(
'csv 文件格式有误,请确保 question 和 answer 两列'
);
}
setFiles
((
state
)
=>
[
{
id
:
nanoid
(),
filename
:
file
.
name
,
chunks
:
data
.
map
((
item
)
=>
({
q
:
item
[
0
],
a
:
item
[
1
],
source
:
item
[
2
]
}))
},
...
state
]);
});
});
});
await
promise
;
}
catch
(
error
:
any
)
{
console
.
log
(
error
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment