diff --git a/packages/global/core/ai/prompt/dataset.ts b/packages/global/core/ai/prompt/dataset.ts new file mode 100644 index 000000000..a6639e666 --- /dev/null +++ b/packages/global/core/ai/prompt/dataset.ts @@ -0,0 +1,14 @@ +export const getDatasetSearchToolResponsePrompt = () => { + return `## Role +你是一个知识库回答助手,可以 "quotes" 中的内容作为本次对话的参考。为了使回答结果更加可信并且可追溯,你需要在每段话结尾添加引用标记。 + +## Rules +- 如果你不清楚答案,你需要澄清。 +- 避免提及你是从 "quotes" 获取的知识。 +- 保持答案与 "quotes" 中描述的一致。 +- 使用 Markdown 语法优化回答格式。尤其是图片、表格、序列号等内容,需严格完整输出。 +- 使用与问题相同的语言回答。 +- 使用 [id](QUOTE) 格式来引用 "quotes" 中的知识,其中 QUOTE 是固定常量, id 为引文中的 id。 +- 在每段话结尾自然地整合引用。例如: "FastGPT 是一个基于大语言模型(LLM)的知识库问答系统[67e517e74767063e882d6861](QUOTE)。" +- 每段话至少包含一个引用,也可根据内容需要加入多个引用,按顺序排列。`; +}; diff --git a/packages/service/core/workflow/dispatch/dataset/search.ts b/packages/service/core/workflow/dispatch/dataset/search.ts index 6169e0e38..4e97fe690 100644 --- a/packages/service/core/workflow/dispatch/dataset/search.ts +++ b/packages/service/core/workflow/dispatch/dataset/search.ts @@ -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()) + })) + } }; } diff --git a/packages/web/i18n/en/common.json b/packages/web/i18n/en/common.json index 60f941690..df5cd4a4d 100644 --- a/packages/web/i18n/en/common.json +++ b/packages/web/i18n/en/common.json @@ -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", diff --git a/packages/web/i18n/zh-CN/common.json b/packages/web/i18n/zh-CN/common.json index c8079a64e..c0d330b1d 100644 --- a/packages/web/i18n/zh-CN/common.json +++ b/packages/web/i18n/zh-CN/common.json @@ -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": "查看引用", diff --git a/packages/web/i18n/zh-Hant/common.json b/packages/web/i18n/zh-Hant/common.json index f3b50c1e8..63a536b9f 100644 --- a/packages/web/i18n/zh-Hant/common.json +++ b/packages/web/i18n/zh-Hant/common.json @@ -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": "檢視引用", diff --git a/projects/app/src/components/Markdown/A.tsx b/projects/app/src/components/Markdown/A.tsx index 893f618e2..aff405749 100644 --- a/projects/app/src/components/Markdown/A.tsx +++ b/projects/app/src/components/Markdown/A.tsx @@ -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}