mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-18 17:51:24 +00:00
perf: Add tool call prompt (#4683)
* update i18n * perf: Add tool call prompt
This commit is contained in:
14
packages/global/core/ai/prompt/dataset.ts
Normal file
14
packages/global/core/ai/prompt/dataset.ts
Normal 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)。"
|
||||||
|
- 每段话至少包含一个引用,也可根据内容需要加入多个引用,按顺序排列。`;
|
||||||
|
};
|
@@ -17,6 +17,7 @@ import { i18nT } from '../../../../../web/i18n/utils';
|
|||||||
import { filterDatasetsByTmbId } from '../../../dataset/utils';
|
import { filterDatasetsByTmbId } from '../../../dataset/utils';
|
||||||
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
|
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
|
||||||
import { addEndpointToImageUrl } from '../../../../common/file/image/utils';
|
import { addEndpointToImageUrl } from '../../../../common/file/image/utils';
|
||||||
|
import { getDatasetSearchToolResponsePrompt } from '../../../../../global/core/ai/prompt/dataset';
|
||||||
|
|
||||||
type DatasetSearchProps = ModuleDispatchProps<{
|
type DatasetSearchProps = ModuleDispatchProps<{
|
||||||
[NodeInputKeyEnum.datasetSelectList]: SelectedDatasetType;
|
[NodeInputKeyEnum.datasetSelectList]: SelectedDatasetType;
|
||||||
@@ -264,10 +265,14 @@ export async function dispatchDatasetSearch(
|
|||||||
quoteQA: searchRes,
|
quoteQA: searchRes,
|
||||||
[DispatchNodeResponseKeyEnum.nodeResponse]: responseData,
|
[DispatchNodeResponseKeyEnum.nodeResponse]: responseData,
|
||||||
nodeDispatchUsages,
|
nodeDispatchUsages,
|
||||||
[DispatchNodeResponseKeyEnum.toolResponses]: searchRes.map((item) => ({
|
[DispatchNodeResponseKeyEnum.toolResponses]: {
|
||||||
sourceName: item.sourceName,
|
prompt: getDatasetSearchToolResponsePrompt(),
|
||||||
updateTime: item.updateTime,
|
quotes: searchRes.map((item) => ({
|
||||||
content: addEndpointToImageUrl(`${item.q}\n${item.a}`.trim())
|
id: item.id,
|
||||||
}))
|
sourceName: item.sourceName,
|
||||||
|
updateTime: item.updateTime,
|
||||||
|
content: addEndpointToImageUrl(`${item.q}\n${item.a}`.trim())
|
||||||
|
}))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -979,6 +979,7 @@
|
|||||||
"new_create": "Create New",
|
"new_create": "Create New",
|
||||||
"no": "No",
|
"no": "No",
|
||||||
"no_laf_env": "System Not Configured with Laf Environment",
|
"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_model_config": "No related model configured",
|
||||||
"not_permission": "The current subscription package does not support team operation logs",
|
"not_permission": "The current subscription package does not support team operation logs",
|
||||||
"not_yet_introduced": "No Introduction Yet",
|
"not_yet_introduced": "No Introduction Yet",
|
||||||
@@ -1043,6 +1044,7 @@
|
|||||||
"plugin.contribute": "Contribute Plugin",
|
"plugin.contribute": "Contribute Plugin",
|
||||||
"plugin.go to laf": "Go to Write",
|
"plugin.go to laf": "Go to Write",
|
||||||
"plugin.path": "Path",
|
"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",
|
"prompt_input_placeholder": "Please enter the prompt word",
|
||||||
"question_feedback": "Work order",
|
"question_feedback": "Work order",
|
||||||
"read_quote": "View citations",
|
"read_quote": "View citations",
|
||||||
|
@@ -978,6 +978,7 @@
|
|||||||
"new_create": "新建",
|
"new_create": "新建",
|
||||||
"no": "否",
|
"no": "否",
|
||||||
"no_laf_env": "系统未配置Laf环境",
|
"no_laf_env": "系统未配置Laf环境",
|
||||||
|
"no_pay_way": "系统无合适的支付渠道",
|
||||||
"not_model_config": "未配置相关模型",
|
"not_model_config": "未配置相关模型",
|
||||||
"not_permission": "当前订阅套餐不支持团队操作日志",
|
"not_permission": "当前订阅套餐不支持团队操作日志",
|
||||||
"not_yet_introduced": "暂无介绍",
|
"not_yet_introduced": "暂无介绍",
|
||||||
@@ -1042,6 +1043,7 @@
|
|||||||
"plugin.contribute": "贡献插件",
|
"plugin.contribute": "贡献插件",
|
||||||
"plugin.go to laf": "去编写",
|
"plugin.go to laf": "去编写",
|
||||||
"plugin.path": "路径",
|
"plugin.path": "路径",
|
||||||
|
"price_over_wx_limit": "超出支付提供商限额:微信支付仅支持 6000 元以下",
|
||||||
"prompt_input_placeholder": "请输入提示词",
|
"prompt_input_placeholder": "请输入提示词",
|
||||||
"question_feedback": "工单咨询",
|
"question_feedback": "工单咨询",
|
||||||
"read_quote": "查看引用",
|
"read_quote": "查看引用",
|
||||||
|
@@ -978,6 +978,7 @@
|
|||||||
"new_create": "建立新項目",
|
"new_create": "建立新項目",
|
||||||
"no": "否",
|
"no": "否",
|
||||||
"no_laf_env": "系統未設定 LAF 環境",
|
"no_laf_env": "系統未設定 LAF 環境",
|
||||||
|
"no_pay_way": "系統無合適的支付渠道",
|
||||||
"not_model_config": "未設定相關模型",
|
"not_model_config": "未設定相關模型",
|
||||||
"not_permission": "當前訂閱套餐不支持團隊操作日誌",
|
"not_permission": "當前訂閱套餐不支持團隊操作日誌",
|
||||||
"not_yet_introduced": "暫無介紹",
|
"not_yet_introduced": "暫無介紹",
|
||||||
@@ -1042,6 +1043,7 @@
|
|||||||
"plugin.contribute": "貢獻外掛程式",
|
"plugin.contribute": "貢獻外掛程式",
|
||||||
"plugin.go to laf": "前往編寫",
|
"plugin.go to laf": "前往編寫",
|
||||||
"plugin.path": "路徑",
|
"plugin.path": "路徑",
|
||||||
|
"price_over_wx_limit": "超出支付提供商限額:微信支付僅支持 6000 元以下",
|
||||||
"prompt_input_placeholder": "請輸入提示詞",
|
"prompt_input_placeholder": "請輸入提示詞",
|
||||||
"question_feedback": "工單諮詢",
|
"question_feedback": "工單諮詢",
|
||||||
"read_quote": "檢視引用",
|
"read_quote": "檢視引用",
|
||||||
|
@@ -25,14 +25,6 @@ import { getSourceNameIcon } from '@fastgpt/global/core/dataset/utils';
|
|||||||
const A = ({ children, ...props }: any) => {
|
const A = ({ children, ...props }: any) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const {
|
|
||||||
data: quoteData,
|
|
||||||
loading,
|
|
||||||
runAsync
|
|
||||||
} = useRequest2(getQuoteData, {
|
|
||||||
manual: true
|
|
||||||
});
|
|
||||||
|
|
||||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||||
|
|
||||||
// empty href link
|
// empty href link
|
||||||
@@ -56,6 +48,13 @@ const A = ({ children, ...props }: any) => {
|
|||||||
|
|
||||||
// Quote
|
// Quote
|
||||||
if (props.href?.startsWith('QUOTE') && typeof children?.[0] === 'string') {
|
if (props.href?.startsWith('QUOTE') && typeof children?.[0] === 'string') {
|
||||||
|
const {
|
||||||
|
data: quoteData,
|
||||||
|
loading,
|
||||||
|
runAsync: getQuoteDataById
|
||||||
|
} = useRequest2(getQuoteData, {
|
||||||
|
manual: true
|
||||||
|
});
|
||||||
const sourceData = useMemo(
|
const sourceData = useMemo(
|
||||||
() => getCollectionSourceData(quoteData?.collection),
|
() => getCollectionSourceData(quoteData?.collection),
|
||||||
[quoteData?.collection]
|
[quoteData?.collection]
|
||||||
@@ -75,7 +74,7 @@ const A = ({ children, ...props }: any) => {
|
|||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
onOpen={() => {
|
onOpen={() => {
|
||||||
onOpen();
|
onOpen();
|
||||||
runAsync(String(children));
|
getQuoteDataById(String(children));
|
||||||
}}
|
}}
|
||||||
trigger={'hover'}
|
trigger={'hover'}
|
||||||
gutter={4}
|
gutter={4}
|
||||||
|
Reference in New Issue
Block a user