Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
5357aa40
authored
Apr 27, 2025
by
Archer
Committed by
GitHub
Apr 27, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: Add tool call prompt (#4683)
* update i18n * perf: Add tool call prompt
parent
9923a402
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
10 deletions
+34
-10
packages/global/core/ai/prompt/dataset.ts
+14
-0
packages/service/core/workflow/dispatch/dataset/search.ts
+6
-1
packages/web/i18n/en/common.json
+2
-0
packages/web/i18n/zh-CN/common.json
+2
-0
packages/web/i18n/zh-Hant/common.json
+2
-0
projects/app/src/components/Markdown/A.tsx
+8
-9
No files found.
packages/global/core/ai/prompt/dataset.ts
0 → 100644
View file @
5357aa40
export
const
getDatasetSearchToolResponsePrompt
=
()
=>
{
return
`## Role
你是一个知识库回答助手,可以 "quotes" 中的内容作为本次对话的参考。为了使回答结果更加可信并且可追溯,你需要在每段话结尾添加引用标记。
## Rules
- 如果你不清楚答案,你需要澄清。
- 避免提及你是从 "quotes" 获取的知识。
- 保持答案与 "quotes" 中描述的一致。
- 使用 Markdown 语法优化回答格式。尤其是图片、表格、序列号等内容,需严格完整输出。
- 使用与问题相同的语言回答。
- 使用 [id](QUOTE) 格式来引用 "quotes" 中的知识,其中 QUOTE 是固定常量, id 为引文中的 id。
- 在每段话结尾自然地整合引用。例如: "FastGPT 是一个基于大语言模型(LLM)的知识库问答系统[67e517e74767063e882d6861](QUOTE)。"
- 每段话至少包含一个引用,也可根据内容需要加入多个引用,按顺序排列。`
;
};
packages/service/core/workflow/dispatch/dataset/search.ts
View file @
5357aa40
...
...
@@ -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
)
=>
({
[
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
())
}))
}
};
}
packages/web/i18n/en/common.json
View file @
5357aa40
...
...
@@ -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"
,
...
...
packages/web/i18n/zh-CN/common.json
View file @
5357aa40
...
...
@@ -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"
:
"查看引用"
,
...
...
packages/web/i18n/zh-Hant/common.json
View file @
5357aa40
...
...
@@ -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"
:
"檢視引用"
,
...
...
projects/app/src/components/Markdown/A.tsx
View file @
5357aa40
...
...
@@ -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
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment