perf: quote output prompt

This commit is contained in:
archer
2023-08-28 13:47:33 +08:00
parent 5fcdf28c5c
commit 64b9367ca1
4 changed files with 16 additions and 11 deletions

View File

@@ -163,7 +163,7 @@ const DataCard = ({ kbId }: { kbId: string }) => {
maxW={['60%', '300px']}
size={'sm'}
value={searchText}
placeholder="根据匹配知识,补充知识和来源进行搜索"
placeholder="根据匹配知识,预期答案和来源进行搜索"
onChange={(e) => {
setSearchText(e.target.value);
getFirstData();

View File

@@ -95,7 +95,7 @@ const ManualImport = ({ kbId }: { kbId: string }) => {
</Box>
<Box flex={1} h={['50%', '100%']}>
<Flex>
<Box h={'30px'}>{'补充知识'}</Box>
<Box h={'30px'}>{'预期答案'}</Box>
<MyTooltip
label={'匹配的知识点被命中后,这部分内容会随匹配知识点一起注入模型,引导模型回答'}
>
@@ -104,7 +104,7 @@ const ManualImport = ({ kbId }: { kbId: string }) => {
</Flex>
<Textarea
placeholder={
'补充知识。这部分内容不会被搜索,但会作为"匹配的知识点"的内容补充,你可以讲一些细节的内容填写在这里。总和最多 3000 字。'
'预期答案。这部分内容不会被搜索,但会作为"匹配的知识点"的内容补充,通常是问题的答案。总和最多 3000 字。'
}
h={['250px', '500px']}
maxLength={3000}

View File

@@ -164,7 +164,7 @@ const InputDataModal = ({
</Box>
<Box flex={1} h={['50%', '100%']}>
<Flex>
<Box h={'30px'}>{'补充知识'}</Box>
<Box h={'30px'}>{'预期答案'}</Box>
<MyTooltip
label={'匹配的知识点被命中后,这部分内容会随匹配知识点一起注入模型,引导模型回答'}
>
@@ -173,7 +173,7 @@ const InputDataModal = ({
</Flex>
<Textarea
placeholder={
'补充知识。这部分内容不会被搜索,但会作为"匹配的知识点"的内容补充,你可以讲一些细节的内容填写在这里。总和最多 3000 字。'
'预期答案。这部分内容不会被搜索,但会作为"匹配的知识点"的内容补充,通常是问题的答案。总和最多 3000 字。'
}
maxLength={3000}
resize={'none'}

View File

@@ -68,7 +68,7 @@ export const dispatchChatCompletion = async (props: Record<string, any>): Promis
return Promise.reject('The chat model is undefined, you need to select a chat model.');
}
const { filterQuoteQA, quotePrompt } = filterQuote({
const { filterQuoteQA, quotePrompt, hasQuoteOutput } = filterQuote({
quoteQA,
model: modelConstantsData
});
@@ -89,7 +89,8 @@ export const dispatchChatCompletion = async (props: Record<string, any>): Promis
quotePrompt,
userChatInput,
systemPrompt,
limitPrompt
limitPrompt,
hasQuoteOutput
});
const { max_tokens } = getMaxTokens({
model: modelConstantsData,
@@ -219,7 +220,8 @@ function filterQuote({
return {
filterQuoteQA,
quotePrompt
quotePrompt,
hasQuoteOutput: !!filterQuoteQA.find((item) => item.a)
};
}
function getChatMessages({
@@ -228,7 +230,8 @@ function getChatMessages({
systemPrompt,
limitPrompt,
userChatInput,
model
model,
hasQuoteOutput
}: {
quotePrompt: string;
history: ChatProps['history'];
@@ -236,13 +239,15 @@ function getChatMessages({
limitPrompt: string;
userChatInput: string;
model: ChatModelItemType;
hasQuoteOutput: boolean;
}) {
const limitText = (() => {
if (!quotePrompt) {
return limitPrompt;
}
const defaultPrompt =
'三引号是我提供给你的专属知识它们拥有最高优先级。instruction 是相关介绍output 是预期回答,使用引用内容来回答我下面的问题。';
const defaultPrompt = `三引号引用的内容是我提供给你的知识它们拥有最高优先级。instruction 是相关介绍${
hasQuoteOutput ? 'output 是预期回答或补充' : ''
},使用引用内容来回答我下面的问题。`;
if (limitPrompt) {
return `${defaultPrompt}${limitPrompt}`;
}