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
eefc976d
authored
Aug 26, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: qa prompt
parent
be33794a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
12 deletions
+16
-12
README.md
+3
-3
client/src/pages/kb/detail/components/Import/QA.tsx
+3
-3
client/src/service/events/generateQA.ts
+4
-4
client/src/utils/file.ts
+6
-2
No files found.
README.md
View file @
eefc976d
...
@@ -85,9 +85,9 @@ FastGPT 是一个基于 LLM 大语言模型的知识库问答系统,提供开
...
@@ -85,9 +85,9 @@ FastGPT 是一个基于 LLM 大语言模型的知识库问答系统,提供开
## 🏘️ 社区交流群
## 🏘️ 社区交流群
| 交流群
| 小助手 |
| 交流群 | 小助手 |
| -------------------------------------------------
--
| ---------------------------------------------- |
| ------------------------------------------------- | ---------------------------------------------- |
| !
[
](https://otnvvf-imgs.oss.laf.run/wxqun300
-2
.jpg) | 
|
| !
[
](https://otnvvf-imgs.oss.laf.run/wxqun300.jpg) | 
|
## 👀 其他
## 👀 其他
...
...
client/src/pages/kb/detail/components/Import/QA.tsx
View file @
eefc976d
...
@@ -187,20 +187,20 @@ const QAImport = ({ kbId }: { kbId: string }) => {
...
@@ -187,20 +187,20 @@ const QAImport = ({ kbId }: { kbId: string }) => {
<
Box
mb=
{
2
}
>
<
Box
mb=
{
2
}
>
QA 拆分引导词
{
' '
}
QA 拆分引导词
{
' '
}
<
MyTooltip
<
MyTooltip
label=
{
`可输入关于文件内容的范围介绍,例如:\n1.
关于 Laf 的介绍\n2. xxx的简历
`
}
label=
{
`可输入关于文件内容的范围介绍,例如:\n1.
Laf 的介绍\n2. xxx的简历\n最终会补全为: 关于{输入的内容}
`
}
forceShow
forceShow
>
>
<
QuestionOutlineIcon
ml=
{
1
}
/>
<
QuestionOutlineIcon
ml=
{
1
}
/>
</
MyTooltip
>
</
MyTooltip
>
</
Box
>
</
Box
>
<
Flex
alignItems=
{
'center'
}
fontSize=
{
'sm'
}
>
<
Flex
alignItems=
{
'center'
}
fontSize=
{
'sm'
}
>
<
Box
mr=
{
2
}
>
下面是
</
Box
>
<
Box
mr=
{
2
}
>
关于
</
Box
>
<
Input
<
Input
flex=
{
1
}
flex=
{
1
}
placeholder=
{
'Laf 云函数的介绍'
}
placeholder=
{
'Laf 云函数的介绍'
}
bg=
{
'myWhite.500'
}
bg=
{
'myWhite.500'
}
defaultValue=
{
prompt
}
defaultValue=
{
prompt
}
onBlur=
{
(
e
)
=>
(
e
.
target
.
value
?
setPrompt
(
`
下面是
"${e.target.value}"`
)
:
''
)
}
onBlur=
{
(
e
)
=>
(
e
.
target
.
value
?
setPrompt
(
`
关于
"${e.target.value}"`
)
:
''
)
}
/>
/>
</
Flex
>
</
Flex
>
</
Box
>
</
Box
>
...
...
client/src/service/events/generateQA.ts
View file @
eefc976d
...
@@ -64,14 +64,14 @@ export async function generateQA(): Promise<any> {
...
@@ -64,14 +64,14 @@ export async function generateQA(): Promise<any> {
const
messages
:
ChatCompletionRequestMessage
[]
=
[
const
messages
:
ChatCompletionRequestMessage
[]
=
[
{
{
role
:
'system'
,
role
:
'system'
,
content
:
`
你是出题人
,
${
content
:
`
我会给你发送一段长文本
,
${
data
.
prompt
||
'我会发送一段长文本
'
data
.
prompt
?
`是
${
data
.
prompt
}
,`
:
'
'
}
,请从中提取出 25 个问题和答案. 答案详细完整,并按下面
格式返回:
}
请学习它,并用 markdown 格式给出 25 个问题和答案,问题可以多样化、自由扩展;答案要详细、解读到位,答案包含普通文本、链接、代码、表格、公示、媒体链接等。按下面 QA 问答
格式返回:
Q1:
Q1:
A1:
A1:
Q2:
Q2:
A2:
A2:
...
`
……
`
},
},
{
{
role
:
'user'
,
role
:
'user'
,
...
...
client/src/utils/file.ts
View file @
eefc976d
...
@@ -148,7 +148,7 @@ export const fileDownload = ({
...
@@ -148,7 +148,7 @@ export const fileDownload = ({
* maxLen > overlapLen
* maxLen > overlapLen
*/
*/
export
const
splitText2Chunks
=
({
text
,
maxLen
}:
{
text
:
string
;
maxLen
:
number
})
=>
{
export
const
splitText2Chunks
=
({
text
,
maxLen
}:
{
text
:
string
;
maxLen
:
number
})
=>
{
const
overlapLen
=
Math
.
floor
(
maxLen
*
0.
3
);
// Overlap length
const
overlapLen
=
Math
.
floor
(
maxLen
*
0.
25
);
// Overlap length
try
{
try
{
const
splitTexts
=
text
.
split
(
/
(?<
=
[
。!?;.!?;
])
/g
);
const
splitTexts
=
text
.
split
(
/
(?<
=
[
。!?;.!?;
])
/g
);
...
@@ -281,6 +281,10 @@ export const simpleText = (text: string) => {
...
@@ -281,6 +281,10 @@ export const simpleText = (text: string) => {
text
=
text
.
replace
(
/
([\u
4e00-
\u
9fa5
])\s
+
([\u
4e00-
\u
9fa5
])
/g
,
'$1$2'
);
text
=
text
.
replace
(
/
([\u
4e00-
\u
9fa5
])\s
+
([\u
4e00-
\u
9fa5
])
/g
,
'$1$2'
);
text
=
text
.
replace
(
/
\n{2,}
/g
,
'\n'
);
text
=
text
.
replace
(
/
\n{2,}
/g
,
'\n'
);
text
=
text
.
replace
(
/
\s{2,}
/g
,
' '
);
text
=
text
.
replace
(
/
\s{2,}
/g
,
' '
);
text
=
text
.
replace
(
/
[^\x
00-
\x
7F
]
/g
,
' '
);
text
=
text
.
replace
(
/
\\
x
([
0-9A-Fa-f
]{2})
/g
,
function
(
match
,
hex
)
{
return
String
.
fromCharCode
(
parseInt
(
hex
,
16
));
});
return
text
;
return
text
;
};
};
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