mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 04:06:18 +00:00
fix: chat quote number (#4679)
This commit is contained in:
@@ -8,7 +8,6 @@ export const Prompt_QuoteTemplateList: PromptTemplateItem[] = [
|
||||
desc: i18nT('app:template.standard_template_des'),
|
||||
value: {
|
||||
['4.9.7']: `{
|
||||
"sourceIndex": "{{sourceIndex}}",
|
||||
"id": "{{id}}",
|
||||
"sourceName": "{{source}}",
|
||||
"content": "{{q}}\n{{a}}"
|
||||
@@ -39,7 +38,6 @@ export const Prompt_QuoteTemplateList: PromptTemplateItem[] = [
|
||||
desc: i18nT('app:template.standard_strict_des'),
|
||||
value: {
|
||||
['4.9.7']: `{
|
||||
"sourceIndex": "{{sourceIndex}}",
|
||||
"id": "{{id}}",
|
||||
"sourceName": "{{source}}",
|
||||
"content": "{{q}}\n{{a}}"
|
||||
@@ -90,8 +88,8 @@ export const Prompt_userQuotePromptList: PromptTemplateItem[] = [
|
||||
- 保持答案与 <Reference></Reference> 中描述的一致。
|
||||
- 使用 Markdown 语法优化回答格式。
|
||||
- 使用与问题相同的语言回答。
|
||||
- 使用 [id](QUOTE{{sourceIndex}}) 格式来引用<Reference></Reference>中的知识,其中 QUOTE 是固定常量, id 和 sourceIndex 分别为引文中的值。
|
||||
- 在每段结尾自然地整合引用。例如: "FastGPT 是一个基于大语言模型(LLM)的知识库问答系统[67e517e74767063e882d6861](QUOTE1)。"
|
||||
- 使用 [id](QUOTE) 格式来引用<Reference></Reference>中的知识,其中 QUOTE 是固定常量, id 为引文中的 id。
|
||||
- 在每段结尾自然地整合引用。例如: "FastGPT 是一个基于大语言模型(LLM)的知识库问答系统[67e517e74767063e882d6861](QUOTE)。"
|
||||
- 每段至少包含一个引用,也可根据内容需要加入多个引用,按顺序排列。`,
|
||||
['4.9.2']: `使用 <Reference></Reference> 标记中的内容作为本次对话的参考:
|
||||
|
||||
@@ -148,8 +146,8 @@ export const Prompt_userQuotePromptList: PromptTemplateItem[] = [
|
||||
- 保持答案与 <Reference></Reference> 中描述的一致。
|
||||
- 使用 Markdown 语法优化回答格式。
|
||||
- 使用与问题相同的语言回答。
|
||||
- 使用 [id](QUOTE{{sourceIndex}}) 格式来引用<Reference></Reference>中的知识,其中 QUOTE 是固定常量, id 和 sourceIndex 分别为引文中的值。
|
||||
- 在每段结尾自然地整合引用。例如: "FastGPT 是一个基于大语言模型(LLM)的知识库问答系统[67e517e74767063e882d6861](QUOTE1)。"
|
||||
- 使用 [id](QUOTE) 格式来引用<Reference></Reference>中的知识,其中 QUOTE 是固定常量, id 为引文中的 id。
|
||||
- 在每段结尾自然地整合引用。例如: "FastGPT 是一个基于大语言模型(LLM)的知识库问答系统[67e517e74767063e882d6861](QUOTE)。"
|
||||
- 每段至少包含一个引用,也可根据内容需要加入多个引用,按顺序排列。
|
||||
|
||||
问题:"""{{question}}"""`,
|
||||
@@ -219,8 +217,8 @@ export const Prompt_systemQuotePromptList: PromptTemplateItem[] = [
|
||||
- 保持答案与 <Reference></Reference> 中描述的一致。
|
||||
- 使用 Markdown 语法优化回答格式。
|
||||
- 使用与问题相同的语言回答。
|
||||
- 使用 [id](QUOTE{{sourceIndex}}) 格式来引用<Reference></Reference>中的知识,其中 QUOTE 是固定常量, id 和 sourceIndex 分别为引文中的值。
|
||||
- 在每段结尾自然地整合引用。例如: "FastGPT 是一个基于大语言模型(LLM)的知识库问答系统[67e517e74767063e882d6861](QUOTE1)。"
|
||||
- 使用 [id](QUOTE) 格式来引用<Reference></Reference>中的知识,其中 QUOTE 是固定常量, id 为引文中的 id。
|
||||
- 在每段结尾自然地整合引用。例如: "FastGPT 是一个基于大语言模型(LLM)的知识库问答系统[67e517e74767063e882d6861](QUOTE)。"
|
||||
- 每段至少包含一个引用,也可根据内容需要加入多个引用,按顺序排列。`,
|
||||
['4.9.2']: `使用 <Reference></Reference> 标记中的内容作为本次对话的参考:
|
||||
|
||||
@@ -273,8 +271,8 @@ export const Prompt_systemQuotePromptList: PromptTemplateItem[] = [
|
||||
- 保持答案与 <Reference></Reference> 中描述的一致。
|
||||
- 使用 Markdown 语法优化回答格式。
|
||||
- 使用与问题相同的语言回答。
|
||||
- 使用 [id](QUOTE{{sourceIndex}}) 格式来引用<Reference></Reference>中的知识,其中 QUOTE 是固定常量, id 和 sourceIndex 分别为引文中的值。
|
||||
- 在每段结尾自然地整合引用。例如: "FastGPT 是一个基于大语言模型(LLM)的知识库问答系统[67e517e74767063e882d6861](QUOTE1)。"
|
||||
- 使用 [id](QUOTE) 格式来引用<Reference></Reference>中的知识,其中 QUOTE 是固定常量, id 为引文中的 id。
|
||||
- 在每段结尾自然地整合引用。例如: "FastGPT 是一个基于大语言模型(LLM)的知识库问答系统[67e517e74767063e882d6861](QUOTE)。"
|
||||
- 每段至少包含一个引用,也可根据内容需要加入多个引用,按顺序排列。
|
||||
|
||||
问题:"""{{question}}"""`,
|
||||
|
@@ -348,17 +348,7 @@ async function filterDatasetQuote({
|
||||
model: LLMModelItemType;
|
||||
quoteTemplate: string;
|
||||
}) {
|
||||
function getValue({
|
||||
item,
|
||||
index,
|
||||
sourceList
|
||||
}: {
|
||||
item: SearchDataResponseItemType;
|
||||
index: number;
|
||||
sourceList: { sourceName: string; sourceId: string; sourceIndex: number }[];
|
||||
}) {
|
||||
const source = sourceList.find((source) => source.sourceId === item.sourceId);
|
||||
|
||||
function getValue({ item, index }: { item: SearchDataResponseItemType; index: number }) {
|
||||
return replaceVariable(quoteTemplate, {
|
||||
id: item.id,
|
||||
q: item.q,
|
||||
@@ -366,7 +356,6 @@ async function filterDatasetQuote({
|
||||
updateTime: formatTime2YMDHM(item.updateTime),
|
||||
source: item.sourceName,
|
||||
sourceId: String(item.sourceId || ''),
|
||||
sourceIndex: source?.sourceIndex || 1,
|
||||
index: index + 1
|
||||
});
|
||||
}
|
||||
@@ -374,24 +363,9 @@ async function filterDatasetQuote({
|
||||
// slice filterSearch
|
||||
const filterQuoteQA = await filterSearchResultsByMaxChars(quoteQA, model.quoteMaxToken);
|
||||
|
||||
const sourceList = Object.values(
|
||||
filterQuoteQA.reduce((acc: Record<string, SearchDataResponseItemType[]>, cur) => {
|
||||
if (!acc[cur.collectionId]) {
|
||||
acc[cur.collectionId] = [cur];
|
||||
}
|
||||
return acc;
|
||||
}, {})
|
||||
)
|
||||
.flat()
|
||||
.map((item, index) => ({
|
||||
sourceName: item.sourceName || '',
|
||||
sourceId: item.sourceId || '',
|
||||
sourceIndex: index + 1
|
||||
}));
|
||||
|
||||
const datasetQuoteText =
|
||||
filterQuoteQA.length > 0
|
||||
? `${filterQuoteQA.map((item, index) => getValue({ item, index, sourceList }).trim()).join('\n------\n')}`
|
||||
? `${filterQuoteQA.map((item, index) => getValue({ item, index }).trim()).join('\n------\n')}`
|
||||
: '';
|
||||
|
||||
return {
|
||||
|
Reference in New Issue
Block a user