perf: Add tool call prompt (#4683)

* update i18n

* perf: Add tool call prompt
This commit is contained in:
Archer
2025-04-27 18:29:10 +08:00
committed by GitHub
parent 9923a402d9
commit 5357aa402b
6 changed files with 38 additions and 14 deletions

View File

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

View File

@@ -17,6 +17,7 @@ import { i18nT } from '../../../../../web/i18n/utils';
import { filterDatasetsByTmbId } from '../../../dataset/utils';
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
import { addEndpointToImageUrl } from '../../../../common/file/image/utils';
import { getDatasetSearchToolResponsePrompt } from '../../../../../global/core/ai/prompt/dataset';
type DatasetSearchProps = ModuleDispatchProps<{
[NodeInputKeyEnum.datasetSelectList]: SelectedDatasetType;
@@ -264,10 +265,14 @@ export async function dispatchDatasetSearch(
quoteQA: searchRes,
[DispatchNodeResponseKeyEnum.nodeResponse]: responseData,
nodeDispatchUsages,
[DispatchNodeResponseKeyEnum.toolResponses]: searchRes.map((item) => ({
sourceName: item.sourceName,
updateTime: item.updateTime,
content: addEndpointToImageUrl(`${item.q}\n${item.a}`.trim())
}))
[DispatchNodeResponseKeyEnum.toolResponses]: {
prompt: getDatasetSearchToolResponsePrompt(),
quotes: searchRes.map((item) => ({
id: item.id,
sourceName: item.sourceName,
updateTime: item.updateTime,
content: addEndpointToImageUrl(`${item.q}\n${item.a}`.trim())
}))
}
};
}

View File

@@ -979,6 +979,7 @@
"new_create": "Create New",
"no": "No",
"no_laf_env": "System Not Configured with Laf Environment",
"no_pay_way": "There is no suitable payment channel in the system",
"not_model_config": "No related model configured",
"not_permission": "The current subscription package does not support team operation logs",
"not_yet_introduced": "No Introduction Yet",
@@ -1043,6 +1044,7 @@
"plugin.contribute": "Contribute Plugin",
"plugin.go to laf": "Go to Write",
"plugin.path": "Path",
"price_over_wx_limit": "Exceed payment provider limit: WeChat Pay only supports less than 6,000 yuan",
"prompt_input_placeholder": "Please enter the prompt word",
"question_feedback": "Work order",
"read_quote": "View citations",

View File

@@ -978,6 +978,7 @@
"new_create": "新建",
"no": "否",
"no_laf_env": "系统未配置Laf环境",
"no_pay_way": "系统无合适的支付渠道",
"not_model_config": "未配置相关模型",
"not_permission": "当前订阅套餐不支持团队操作日志",
"not_yet_introduced": "暂无介绍",
@@ -1042,6 +1043,7 @@
"plugin.contribute": "贡献插件",
"plugin.go to laf": "去编写",
"plugin.path": "路径",
"price_over_wx_limit": "超出支付提供商限额:微信支付仅支持 6000 元以下",
"prompt_input_placeholder": "请输入提示词",
"question_feedback": "工单咨询",
"read_quote": "查看引用",

View File

@@ -978,6 +978,7 @@
"new_create": "建立新項目",
"no": "否",
"no_laf_env": "系統未設定 LAF 環境",
"no_pay_way": "系統無合適的支付渠道",
"not_model_config": "未設定相關模型",
"not_permission": "當前訂閱套餐不支持團隊操作日誌",
"not_yet_introduced": "暫無介紹",
@@ -1042,6 +1043,7 @@
"plugin.contribute": "貢獻外掛程式",
"plugin.go to laf": "前往編寫",
"plugin.path": "路徑",
"price_over_wx_limit": "超出支付提供商限額:微信支付僅支持 6000 元以下",
"prompt_input_placeholder": "請輸入提示詞",
"question_feedback": "工單諮詢",
"read_quote": "檢視引用",