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
b6e156db
authored
Aug 07, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: chunk filter
parent
7fe20ef0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
client/src/pages/kb/detail/components/Import/Chunk.tsx
+3
-3
client/src/pages/kb/detail/components/Import/QA.tsx
+3
-3
client/src/utils/file.ts
+1
-1
No files found.
client/src/pages/kb/detail/components/Import/Chunk.tsx
View file @
b6e156db
...
@@ -16,7 +16,7 @@ import { useConfirm } from '@/hooks/useConfirm';
...
@@ -16,7 +16,7 @@ import { useConfirm } from '@/hooks/useConfirm';
import
{
readTxtContent
,
readPdfContent
,
readDocContent
}
from
'@/utils/file'
;
import
{
readTxtContent
,
readPdfContent
,
readDocContent
}
from
'@/utils/file'
;
import
{
useMutation
}
from
'@tanstack/react-query'
;
import
{
useMutation
}
from
'@tanstack/react-query'
;
import
{
postKbDataFromList
}
from
'@/api/plugins/kb'
;
import
{
postKbDataFromList
}
from
'@/api/plugins/kb'
;
import
{
splitText
_token
}
from
'@/utils/file'
;
import
{
splitText
2Chunks
}
from
'@/utils/file'
;
import
{
getErrText
}
from
'@/utils/tools'
;
import
{
getErrText
}
from
'@/utils/tools'
;
import
{
formatPrice
}
from
'@/utils/user'
;
import
{
formatPrice
}
from
'@/utils/user'
;
import
{
vectorModelList
}
from
'@/store/static'
;
import
{
vectorModelList
}
from
'@/store/static'
;
...
@@ -96,7 +96,7 @@ const ChunkImport = ({ kbId }: { kbId: string }) => {
...
@@ -96,7 +96,7 @@ const ChunkImport = ({ kbId }: { kbId: string }) => {
})();
})();
if
(
icon
&&
text
)
{
if
(
icon
&&
text
)
{
const
splitRes
=
splitText
_token
({
const
splitRes
=
splitText
2Chunks
({
text
:
text
,
text
:
text
,
maxLen
:
chunkLen
maxLen
:
chunkLen
});
});
...
@@ -178,7 +178,7 @@ const ChunkImport = ({ kbId }: { kbId: string }) => {
...
@@ -178,7 +178,7 @@ const ChunkImport = ({ kbId }: { kbId: string }) => {
const
onRePreview
=
useCallback
(
async
()
=>
{
const
onRePreview
=
useCallback
(
async
()
=>
{
try
{
try
{
const
splitRes
=
files
.
map
((
item
)
=>
const
splitRes
=
files
.
map
((
item
)
=>
splitText
_token
({
splitText
2Chunks
({
text
:
item
.
text
,
text
:
item
.
text
,
maxLen
:
chunkLen
maxLen
:
chunkLen
})
})
...
...
client/src/pages/kb/detail/components/Import/QA.tsx
View file @
b6e156db
...
@@ -5,7 +5,7 @@ import { useConfirm } from '@/hooks/useConfirm';
...
@@ -5,7 +5,7 @@ import { useConfirm } from '@/hooks/useConfirm';
import
{
readTxtContent
,
readPdfContent
,
readDocContent
}
from
'@/utils/file'
;
import
{
readTxtContent
,
readPdfContent
,
readDocContent
}
from
'@/utils/file'
;
import
{
useMutation
}
from
'@tanstack/react-query'
;
import
{
useMutation
}
from
'@tanstack/react-query'
;
import
{
postKbDataFromList
}
from
'@/api/plugins/kb'
;
import
{
postKbDataFromList
}
from
'@/api/plugins/kb'
;
import
{
splitText
_token
}
from
'@/utils/file'
;
import
{
splitText
2Chunks
}
from
'@/utils/file'
;
import
{
getErrText
}
from
'@/utils/tools'
;
import
{
getErrText
}
from
'@/utils/tools'
;
import
{
formatPrice
}
from
'@/utils/user'
;
import
{
formatPrice
}
from
'@/utils/user'
;
import
{
qaModelList
}
from
'@/store/static'
;
import
{
qaModelList
}
from
'@/store/static'
;
...
@@ -86,7 +86,7 @@ const QAImport = ({ kbId }: { kbId: string }) => {
...
@@ -86,7 +86,7 @@ const QAImport = ({ kbId }: { kbId: string }) => {
})();
})();
if
(
icon
&&
text
)
{
if
(
icon
&&
text
)
{
const
splitRes
=
splitText
_token
({
const
splitRes
=
splitText
2Chunks
({
text
:
text
,
text
:
text
,
maxLen
:
chunkLen
maxLen
:
chunkLen
});
});
...
@@ -169,7 +169,7 @@ const QAImport = ({ kbId }: { kbId: string }) => {
...
@@ -169,7 +169,7 @@ const QAImport = ({ kbId }: { kbId: string }) => {
const
onRePreview
=
useCallback
(
async
()
=>
{
const
onRePreview
=
useCallback
(
async
()
=>
{
try
{
try
{
const
splitRes
=
files
.
map
((
item
)
=>
const
splitRes
=
files
.
map
((
item
)
=>
splitText
_token
({
splitText
2Chunks
({
text
:
item
.
text
,
text
:
item
.
text
,
maxLen
:
chunkLen
maxLen
:
chunkLen
})
})
...
...
client/src/utils/file.ts
View file @
b6e156db
...
@@ -147,7 +147,7 @@ export const fileDownload = ({
...
@@ -147,7 +147,7 @@ export const fileDownload = ({
* overlapLen - The size of the before and after Text
* overlapLen - The size of the before and after Text
* maxLen > overlapLen
* maxLen > overlapLen
*/
*/
export
const
splitText
_token
=
({
text
,
maxLen
}:
{
text
:
string
;
maxLen
:
number
})
=>
{
export
const
splitText
2Chunks
=
({
text
,
maxLen
}:
{
text
:
string
;
maxLen
:
number
})
=>
{
const
overlapLen
=
Math
.
floor
(
maxLen
*
0.3
);
// Overlap length
const
overlapLen
=
Math
.
floor
(
maxLen
*
0.3
);
// Overlap length
try
{
try
{
...
...
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