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
85e11abc
authored
Apr 03, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 文件拆分
parent
becee69d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
13 deletions
+14
-13
src/pages/api/chat/lafGpt.ts
+1
-1
src/pages/model/detail/components/SelectFileModal.tsx
+12
-11
src/utils/tools.ts
+1
-1
No files found.
src/pages/api/chat/lafGpt.ts
View file @
85e11abc
...
@@ -85,7 +85,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -85,7 +85,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
4. 添加数据库数据,表为"users" ,内容为{phone, code, createTime}
4. 添加数据库数据,表为"users" ,内容为{phone, code, createTime}
5. 删除数据库数据,删除 code 记录
5. 删除数据库数据,删除 code 记录
---------------
---------------
更新
播
客记录。传入blogId,blogText,tags,还需要记录更新的时间
更新
博
客记录。传入blogId,blogText,tags,还需要记录更新的时间
1. 从 body 中获取 blogId,blogText 和 tags
1. 从 body 中获取 blogId,blogText 和 tags
2. 校验 blogId 是否为空,为空则返回 {error: "博客ID不能为空"}
2. 校验 blogId 是否为空,为空则返回 {error: "博客ID不能为空"}
3. 校验 blogText 是否为空,为空则返回 {error: "博客内容不能为空"}
3. 校验 blogText 是否为空,为空则返回 {error: "博客内容不能为空"}
...
...
src/pages/model/detail/components/SelectFileModal.tsx
View file @
85e11abc
...
@@ -9,7 +9,8 @@ import {
...
@@ -9,7 +9,8 @@ import {
ModalHeader
,
ModalHeader
,
ModalCloseButton
,
ModalCloseButton
,
ModalBody
,
ModalBody
,
Input
Input
,
Textarea
}
from
'@chakra-ui/react'
;
}
from
'@chakra-ui/react'
;
import
{
useToast
}
from
'@/hooks/useToast'
;
import
{
useToast
}
from
'@/hooks/useToast'
;
import
{
useSelectFile
}
from
'@/hooks/useSelectFile'
;
import
{
useSelectFile
}
from
'@/hooks/useSelectFile'
;
...
@@ -66,8 +67,8 @@ const SelectFileModal = ({
...
@@ -66,8 +67,8 @@ const SelectFileModal = ({
})
})
)
)
)
)
.
join
(
'
\n
'
)
.
join
(
'
'
)
.
replace
(
/
\n
+/g
,
'\n'
);
.
replace
(
/
(\\
n|
\n)
+/g
,
'\n'
);
setFileText
(
fileTexts
);
setFileText
(
fileTexts
);
console
.
log
(
encode
(
fileTexts
));
console
.
log
(
encode
(
fileTexts
));
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
...
@@ -142,18 +143,18 @@ const SelectFileModal = ({
...
@@ -142,18 +143,18 @@ const SelectFileModal = ({
size=
{
'sm'
}
size=
{
'sm'
}
/>
/>
</
Flex
>
</
Flex
>
<
Box
<
Textarea
flex=
{
'1 0 0'
}
flex=
{
'1 0 0'
}
h=
{
0
}
h=
{
0
}
w=
{
'100%'
}
w=
{
'100%'
}
overflowY=
{
'auto'
}
placeholder=
"文件内容"
p=
{
2
}
maxLength=
{
-
1
}
backgroundColor=
{
'blackAlpha.50'
}
resize=
{
'none'
}
whiteSpace=
{
'pre-wrap'
}
fontSize=
{
'xs'
}
fontSize=
{
'xs'
}
>
whiteSpace=
{
'pre-wrap'
}
{
fileText
}
value=
{
fileText
}
</
Box
>
onChange=
{
(
e
)
=>
setFileText
(
e
.
target
.
value
)
}
/>
</
ModalBody
>
</
ModalBody
>
<
Flex
px=
{
6
}
pt=
{
2
}
pb=
{
4
}
>
<
Flex
px=
{
6
}
pt=
{
2
}
pb=
{
4
}
>
...
...
src/utils/tools.ts
View file @
85e11abc
...
@@ -76,7 +76,7 @@ export const readPdfContent = (file: File) =>
...
@@ -76,7 +76,7 @@ export const readPdfContent = (file: File) =>
const
page
=
await
doc
.
getPage
(
pageNo
);
const
page
=
await
doc
.
getPage
(
pageNo
);
const
tokenizedText
=
await
page
.
getTextContent
();
const
tokenizedText
=
await
page
.
getTextContent
();
const
pageText
=
tokenizedText
.
items
.
map
((
token
:
any
)
=>
token
.
str
).
join
(
''
);
const
pageText
=
tokenizedText
.
items
.
map
((
token
:
any
)
=>
token
.
str
).
join
(
''
);
return
pageText
.
replaceAll
(
/
\s
+/g
,
'\n'
)
;
return
pageText
;
};
};
let
reader
=
new
FileReader
();
let
reader
=
new
FileReader
();
...
...
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