Commit 93030afe by archer

fix: limit prompt

parent dfc40db8
...@@ -211,7 +211,7 @@ function filterQuote({ ...@@ -211,7 +211,7 @@ function filterQuote({
const quotePrompt = const quotePrompt =
filterQuoteQA.length > 0 filterQuoteQA.length > 0
? `"""${filterQuoteQA ? `"""${filterQuoteQA
.map((item) => (item.a ? `[${item.q}\n${item.a}]` : `[${item.q}]`)) .map((item) => (item.a ? `[${item.q}\n${item.a}]` : `${item.q}`))
.join('\n\n')}"""` .join('\n\n')}"""`
: ''; : '';
...@@ -236,12 +236,13 @@ function getChatMessages({ ...@@ -236,12 +236,13 @@ function getChatMessages({
model: ChatModelItemType; model: ChatModelItemType;
}) { }) {
const limitText = (() => { const limitText = (() => {
if (limitPrompt) if (!quotePrompt) {
return `Use the provided content delimited by triple quotes to answer questions. ${limitPrompt}`; return limitPrompt;
if (quotePrompt && !limitPrompt) {
return `Use the provided content delimited by triple quotes to answer questions.Your task is to answer the question using only the provided content. If the content does not contain the information needed to answer this question then simply write: "你的问题没有在知识库中体现".`;
} }
return ``; if (limitPrompt) {
return `Use the provided documents delimited by triple quotes to answer questions. ${limitPrompt}`;
}
return `Use the provided documents delimited by triple quotes to answer questions.Your task is to answer the question using only the provided documents. If the documents does not contain the information needed to answer this question then simply write: "你的问题没有在知识库中体现"`;
})(); })();
const messages: ChatItemType[] = [ const messages: ChatItemType[] = [
...@@ -261,6 +262,7 @@ function getChatMessages({ ...@@ -261,6 +262,7 @@ function getChatMessages({
} }
] ]
: []), : []),
...history,
...(limitText ...(limitText
? [ ? [
{ {
...@@ -269,7 +271,6 @@ function getChatMessages({ ...@@ -269,7 +271,6 @@ function getChatMessages({
} }
] ]
: []), : []),
...history,
{ {
obj: ChatRoleEnum.Human, obj: ChatRoleEnum.Human,
value: userChatInput value: userChatInput
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment