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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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": "檢視引用",

View File

@ -25,14 +25,6 @@ import { getSourceNameIcon } from '@fastgpt/global/core/dataset/utils';
const A = ({ children, ...props }: any) => {
const { t } = useTranslation();
const {
data: quoteData,
loading,
runAsync
} = useRequest2(getQuoteData, {
manual: true
});
const { isOpen, onOpen, onClose } = useDisclosure();
// empty href link
@ -56,6 +48,13 @@ const A = ({ children, ...props }: any) => {
// Quote
if (props.href?.startsWith('QUOTE') && typeof children?.[0] === 'string') {
const {
data: quoteData,
loading,
runAsync: getQuoteDataById
} = useRequest2(getQuoteData, {
manual: true
});
const sourceData = useMemo(
() => getCollectionSourceData(quoteData?.collection),
[quoteData?.collection]
@ -75,7 +74,7 @@ const A = ({ children, ...props }: any) => {
onClose={onClose}
onOpen={() => {
onOpen();
runAsync(String(children));
getQuoteDataById(String(children));
}}
trigger={'hover'}
gutter={4}