Remove quote prompt in api request (#4724)

* chat completion add parsequote param (#4720)

* chat completion add parsequote param

* fix

* perf: quote prompt

---------

Co-authored-by: heheer <heheer@sealos.io>
This commit is contained in:
Archer
2025-04-29 13:10:17 +08:00
committed by GitHub
parent b0297d2915
commit 360a2ec392
9 changed files with 48 additions and 10 deletions

View File

@@ -321,13 +321,24 @@ export const Prompt_systemQuotePromptList: PromptTemplateItem[] = [
}
];
export const getQuotePrompt = (version?: string, role: 'user' | 'system' = 'user') => {
export const getQuotePrompt = (
version?: string,
role: 'user' | 'system' = 'user',
parseQuote = true
) => {
const quotePromptTemplates =
role === 'user' ? Prompt_userQuotePromptList : Prompt_systemQuotePromptList;
const defaultTemplate = quotePromptTemplates[0].value;
return getPromptByVersion(version, defaultTemplate);
return parseQuote
? getPromptByVersion(version, defaultTemplate)
: getPromptByVersion(version, defaultTemplate).replace(
`- 使用 [id](QUOTE) 格式来引用<Reference></Reference>中的知识,其中 QUOTE 是固定常量, id 为引文中的 id。
- 在每段结尾自然地整合引用。例如: "FastGPT 是一个基于大语言模型(LLM)的知识库问答系统[67e517e74767063e882d6861](QUOTE)。"
- 每段至少包含一个引用,也可根据内容需要加入多个引用,按顺序排列。`,
''
);
};
// Document quote prompt

View File

@@ -1,5 +1,6 @@
export const getDatasetSearchToolResponsePrompt = () => {
return `## Role
export const getDatasetSearchToolResponsePrompt = (parseQuote: boolean) => {
return parseQuote
? `## Role
你是一个知识库回答助手,可以 "quotes" 中的内容作为本次对话的参考。为了使回答结果更加可信并且可追溯,你需要在每段话结尾添加引用标记。
## Rules
@@ -10,5 +11,14 @@ export const getDatasetSearchToolResponsePrompt = () => {
- 使用与问题相同的语言回答。
- 使用 [id](QUOTE) 格式来引用 "quotes" 中的知识,其中 QUOTE 是固定常量, id 为引文中的 id。
- 在每段话结尾自然地整合引用。例如: "FastGPT 是一个基于大语言模型(LLM)的知识库问答系统[67e517e74767063e882d6861](QUOTE)。"
- 每段话至少包含一个引用,也可根据内容需要加入多个引用,按顺序排列。`;
- 每段话至少包含一个引用,也可根据内容需要加入多个引用,按顺序排列。`
: `## Role
你是一个知识库回答助手,可以 "quotes" 中的内容作为本次对话的参考。
## Rules
- 如果你不清楚答案,你需要澄清。
- 避免提及你是从 "quotes" 获取的知识。
- 保持答案与 "quotes" 中描述的一致。
- 使用 Markdown 语法优化回答格式。尤其是图片、表格、序列号等内容,需严格完整输出。
- 使用与问题相同的语言回答。`;
};

View File

@@ -58,6 +58,7 @@ export type ChatDispatchProps = {
chatConfig: AppSchema['chatConfig'];
lastInteractive?: WorkflowInteractiveResponseType; // last interactive response
stream: boolean;
parseQuote?: boolean;
maxRunTimes: number;
isToolCall?: boolean;
workflowStreamResponse?: WorkflowResponseType;