perf: qa prompt
This commit is contained in:
parent
be33794a5f
commit
eefc976d42
@ -86,8 +86,8 @@ FastGPT 是一个基于 LLM 大语言模型的知识库问答系统,提供开
|
|||||||
## 🏘️ 社区交流群
|
## 🏘️ 社区交流群
|
||||||
|
|
||||||
| 交流群 | 小助手 |
|
| 交流群 | 小助手 |
|
||||||
| --------------------------------------------------- | ---------------------------------------------- |
|
| ------------------------------------------------- | ---------------------------------------------- |
|
||||||
|  |  |
|
|  |  |
|
||||||
|
|
||||||
## 👀 其他
|
## 👀 其他
|
||||||
|
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
@ -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',
|
||||||
|
|||||||
@ -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) => {
|
|||||||
text = text.replace(/([\u4e00-\u9fa5])\s+([\u4e00-\u9fa5])/g, '$1$2');
|
text = text.replace(/([\u4e00-\u9fa5])\s+([\u4e00-\u9fa5])/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(/[^\x00-\x7F]/g, ' ');
|
|
||||||
|
text = text.replace(/\\x([0-9A-Fa-f]{2})/g, function (match, hex) {
|
||||||
|
return String.fromCharCode(parseInt(hex, 16));
|
||||||
|
});
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user