perf: quote output prompt
This commit is contained in:
@@ -163,7 +163,7 @@ const DataCard = ({ kbId }: { kbId: string }) => {
|
|||||||
maxW={['60%', '300px']}
|
maxW={['60%', '300px']}
|
||||||
size={'sm'}
|
size={'sm'}
|
||||||
value={searchText}
|
value={searchText}
|
||||||
placeholder="根据匹配知识,补充知识和来源进行搜索"
|
placeholder="根据匹配知识,预期答案和来源进行搜索"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setSearchText(e.target.value);
|
setSearchText(e.target.value);
|
||||||
getFirstData();
|
getFirstData();
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ const ManualImport = ({ kbId }: { kbId: string }) => {
|
|||||||
</Box>
|
</Box>
|
||||||
<Box flex={1} h={['50%', '100%']}>
|
<Box flex={1} h={['50%', '100%']}>
|
||||||
<Flex>
|
<Flex>
|
||||||
<Box h={'30px'}>{'补充知识'}</Box>
|
<Box h={'30px'}>{'预期答案'}</Box>
|
||||||
<MyTooltip
|
<MyTooltip
|
||||||
label={'匹配的知识点被命中后,这部分内容会随匹配知识点一起注入模型,引导模型回答'}
|
label={'匹配的知识点被命中后,这部分内容会随匹配知识点一起注入模型,引导模型回答'}
|
||||||
>
|
>
|
||||||
@@ -104,7 +104,7 @@ const ManualImport = ({ kbId }: { kbId: string }) => {
|
|||||||
</Flex>
|
</Flex>
|
||||||
<Textarea
|
<Textarea
|
||||||
placeholder={
|
placeholder={
|
||||||
'补充知识。这部分内容不会被搜索,但会作为"匹配的知识点"的内容补充,你可以讲一些细节的内容填写在这里。总和最多 3000 字。'
|
'预期答案。这部分内容不会被搜索,但会作为"匹配的知识点"的内容补充,通常是问题的答案。总和最多 3000 字。'
|
||||||
}
|
}
|
||||||
h={['250px', '500px']}
|
h={['250px', '500px']}
|
||||||
maxLength={3000}
|
maxLength={3000}
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ const InputDataModal = ({
|
|||||||
</Box>
|
</Box>
|
||||||
<Box flex={1} h={['50%', '100%']}>
|
<Box flex={1} h={['50%', '100%']}>
|
||||||
<Flex>
|
<Flex>
|
||||||
<Box h={'30px'}>{'补充知识'}</Box>
|
<Box h={'30px'}>{'预期答案'}</Box>
|
||||||
<MyTooltip
|
<MyTooltip
|
||||||
label={'匹配的知识点被命中后,这部分内容会随匹配知识点一起注入模型,引导模型回答'}
|
label={'匹配的知识点被命中后,这部分内容会随匹配知识点一起注入模型,引导模型回答'}
|
||||||
>
|
>
|
||||||
@@ -173,7 +173,7 @@ const InputDataModal = ({
|
|||||||
</Flex>
|
</Flex>
|
||||||
<Textarea
|
<Textarea
|
||||||
placeholder={
|
placeholder={
|
||||||
'补充知识。这部分内容不会被搜索,但会作为"匹配的知识点"的内容补充,你可以讲一些细节的内容填写在这里。总和最多 3000 字。'
|
'预期答案。这部分内容不会被搜索,但会作为"匹配的知识点"的内容补充,通常是问题的答案。总和最多 3000 字。'
|
||||||
}
|
}
|
||||||
maxLength={3000}
|
maxLength={3000}
|
||||||
resize={'none'}
|
resize={'none'}
|
||||||
|
|||||||
@@ -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.');
|
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,
|
quoteQA,
|
||||||
model: modelConstantsData
|
model: modelConstantsData
|
||||||
});
|
});
|
||||||
@@ -89,7 +89,8 @@ export const dispatchChatCompletion = async (props: Record<string, any>): Promis
|
|||||||
quotePrompt,
|
quotePrompt,
|
||||||
userChatInput,
|
userChatInput,
|
||||||
systemPrompt,
|
systemPrompt,
|
||||||
limitPrompt
|
limitPrompt,
|
||||||
|
hasQuoteOutput
|
||||||
});
|
});
|
||||||
const { max_tokens } = getMaxTokens({
|
const { max_tokens } = getMaxTokens({
|
||||||
model: modelConstantsData,
|
model: modelConstantsData,
|
||||||
@@ -219,7 +220,8 @@ function filterQuote({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
filterQuoteQA,
|
filterQuoteQA,
|
||||||
quotePrompt
|
quotePrompt,
|
||||||
|
hasQuoteOutput: !!filterQuoteQA.find((item) => item.a)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function getChatMessages({
|
function getChatMessages({
|
||||||
@@ -228,7 +230,8 @@ function getChatMessages({
|
|||||||
systemPrompt,
|
systemPrompt,
|
||||||
limitPrompt,
|
limitPrompt,
|
||||||
userChatInput,
|
userChatInput,
|
||||||
model
|
model,
|
||||||
|
hasQuoteOutput
|
||||||
}: {
|
}: {
|
||||||
quotePrompt: string;
|
quotePrompt: string;
|
||||||
history: ChatProps['history'];
|
history: ChatProps['history'];
|
||||||
@@ -236,13 +239,15 @@ function getChatMessages({
|
|||||||
limitPrompt: string;
|
limitPrompt: string;
|
||||||
userChatInput: string;
|
userChatInput: string;
|
||||||
model: ChatModelItemType;
|
model: ChatModelItemType;
|
||||||
|
hasQuoteOutput: boolean;
|
||||||
}) {
|
}) {
|
||||||
const limitText = (() => {
|
const limitText = (() => {
|
||||||
if (!quotePrompt) {
|
if (!quotePrompt) {
|
||||||
return limitPrompt;
|
return limitPrompt;
|
||||||
}
|
}
|
||||||
const defaultPrompt =
|
const defaultPrompt = `三引号引用的内容是我提供给你的知识,它们拥有最高优先级。instruction 是相关介绍${
|
||||||
'三引号是我提供给你的专属知识,它们拥有最高优先级。instruction 是相关介绍,output 是预期回答,使用引用内容来回答我下面的问题。';
|
hasQuoteOutput ? ',output 是预期回答或补充' : ''
|
||||||
|
},使用引用内容来回答我下面的问题。`;
|
||||||
if (limitPrompt) {
|
if (limitPrompt) {
|
||||||
return `${defaultPrompt}${limitPrompt}`;
|
return `${defaultPrompt}${limitPrompt}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user