perf: qa prompt

This commit is contained in:
archer
2023-08-26 19:21:15 +08:00
parent be33794a5f
commit eefc976d42
4 changed files with 16 additions and 12 deletions

View File

@@ -85,9 +85,9 @@ FastGPT 是一个基于 LLM 大语言模型的知识库问答系统,提供开
## 🏘️ 社区交流群
| 交流群 | 小助手 |
| --------------------------------------------------- | ---------------------------------------------- |
| ![](https://otnvvf-imgs.oss.laf.run/wxqun300-2.jpg) | ![](https://otnvvf-imgs.oss.laf.run/wx300.jpg) |
| 交流群 | 小助手 |
| ------------------------------------------------- | ---------------------------------------------- |
| ![](https://otnvvf-imgs.oss.laf.run/wxqun300.jpg) | ![](https://otnvvf-imgs.oss.laf.run/wx300.jpg) |
## 👀 其他

View File

@@ -187,20 +187,20 @@ const QAImport = ({ kbId }: { kbId: string }) => {
<Box mb={2}>
QA {' '}
<MyTooltip
label={`可输入关于文件内容的范围介绍,例如:\n1. 关于 Laf 的介绍\n2. xxx的简历`}
label={`可输入关于文件内容的范围介绍,例如:\n1. Laf 的介绍\n2. xxx的简历\n最终会补全为: 关于{输入的内容}`}
forceShow
>
<QuestionOutlineIcon ml={1} />
</MyTooltip>
</Box>
<Flex alignItems={'center'} fontSize={'sm'}>
<Box mr={2}></Box>
<Box mr={2}></Box>
<Input
flex={1}
placeholder={'Laf 云函数的介绍'}
bg={'myWhite.500'}
defaultValue={prompt}
onBlur={(e) => (e.target.value ? setPrompt(`下面是"${e.target.value}"`) : '')}
onBlur={(e) => (e.target.value ? setPrompt(`关于"${e.target.value}"`) : '')}
/>
</Flex>
</Box>

View File

@@ -64,14 +64,14 @@ export async function generateQA(): Promise<any> {
const messages: ChatCompletionRequestMessage[] = [
{
role: 'system',
content: `你是出题人${
data.prompt || '我会发送一段长文本'
},请从中提取出 25 个问题和答案. 答案详细完整,并按下面格式返回:
content: `我会给你发送一段长文本${
data.prompt ? `${data.prompt}` : ''
}请学习它,并用 markdown 格式给出 25 个问题和答案,问题可以多样化、自由扩展;答案详细、解读到位,答案包含普通文本、链接、代码、表格、公示、媒体链接等。按下面 QA 问答格式返回:
Q1:
A1:
Q2:
A2:
...`
……`
},
{
role: 'user',

View File

@@ -148,7 +148,7 @@ export const fileDownload = ({
* maxLen > overlapLen
*/
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 {
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(/\n{2,}/g, '\n');
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;
};