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
fa3f3e62
authored
Sep 05, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
limit prompt template
parent
9bf5a3ec
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
31 additions
and
24 deletions
+31
-24
client/public/docs/chatProblem.md
+1
-1
client/public/locales/en/common.json
+1
-0
client/public/locales/zh/common.json
+1
-0
client/src/components/Markdown/img/MermaidCodeBlock.tsx
+1
-1
client/src/constants/flow/ModuleTemplate.ts
+5
-1
client/src/pages/account/components/PayModal.tsx
+1
-1
client/src/pages/chat/components/ChatHistorySlider.tsx
+5
-3
client/src/service/moduleDispatch/chat/oneapi.ts
+15
-16
client/src/utils/app.ts
+1
-1
No files found.
client/public/docs/chatProblem.md
View file @
fa3f3e62
...
...
@@ -14,7 +14,7 @@
| FastAI4k - 对话 | 0.015 |
| FastAI16k - 对话 | 0.03 |
| FastAI-Plus - 对话 | 0.45 |
| 文件拆分 | 0.03 |
| 文件
QA
拆分 | 0.03 |
**其他问题**
| 交流群 | 小助手 |
...
...
client/public/locales/en/common.json
View file @
fa3f3e62
...
...
@@ -38,6 +38,7 @@
"Admin Mark Content"
:
"Corrected response"
,
"Complete Response"
:
"Complete Response"
,
"Confirm to clear history"
:
"Confirm to clear history?"
,
"Confirm to clear share chat histroy"
:
" Are you sure to delete all chats?"
,
"Exit Chat"
:
"Exit"
,
"Feedback Close"
:
"Close Feedback"
,
"Feedback Failed"
:
"Feedback Failed"
,
...
...
client/public/locales/zh/common.json
View file @
fa3f3e62
...
...
@@ -38,6 +38,7 @@
"Admin Mark Content"
:
"纠正后的回复"
,
"Complete Response"
:
"完整响应"
,
"Confirm to clear history"
:
"确认清空该应用的在线聊天记录?分享和 API 调用的记录不会被清空。"
,
"Confirm to clear share chat histroy"
:
"确认删除所有聊天记录?"
,
"Exit Chat"
:
"退出聊天"
,
"Feedback Close"
:
"关闭反馈"
,
"Feedback Failed"
:
"提交反馈异常"
,
...
...
client/src/components/Markdown/img/MermaidCodeBlock.tsx
View file @
fa3f3e62
...
...
@@ -80,7 +80,7 @@ const MermaidBlock = ({ code }: { code: string }) => {
ctx
.
fillRect
(
0
,
0
,
w
,
h
);
const
img
=
new
Image
();
img
.
src
=
`data:image/svg+xml;charset=utf-8,
${
encodeURIComponent
(
ref
.
current
.
innerHTML
)}
`
;
img
.
src
=
`data:image/svg+xml;charset=utf-8,
${
encodeURIComponent
(
ref
.
current
?
.
innerHTML
)}
`;
img.onload = () => {
ctx.drawImage(img, 0, 0, w, h);
...
...
client/src/constants/flow/ModuleTemplate.ts
View file @
fa3f3e62
...
...
@@ -20,7 +20,7 @@ import { ContextExtractEnum, HttpPropsEnum } from './flowField';
export
const
ChatModelSystemTip
=
'模型固定的引导词,通过调整该内容,可以引导模型聊天方向。该内容会被固定在上下文的开头。可使用变量,例如 {{language}}'
;
export
const
ChatModelLimitTip
=
'限定模型对话范围,会被放置在本次提问前,拥有强引导和限定性。
可使用变量,例如 {{language}}。引导例子:\n1. 知识库是关于 Laf 的介绍,参考知识库回答问题,与 "Laf" 无关内容,直接回复: "我不知道"。\n2. 你仅回答关于 "xxx" 的问题,其他问题回复: "xxxx"
'
;
'限定模型对话范围,会被放置在本次提问前,拥有强引导和限定性。
不建议内容太长,会影响上下文,可使用变量,例如 {{language}}。可在文档中找到对应的限定例子
'
;
export
const
userGuideTip
=
'可以添加特殊的对话前后引导模块,更好的让用户进行对话'
;
export
const
welcomeTextTip
=
'每次对话开始前,发送一个初始内容。支持标准 Markdown 语法,可使用的额外标记:\n[快捷按键]: 用户点击后可以直接发送该问题'
;
...
...
@@ -156,6 +156,7 @@ export const ChatModule: FlowModuleTemplateType = {
key: 'systemPrompt',
type: FlowInputItemTypeEnum.textarea,
label: '系统提示词',
max: 300,
valueType: FlowValueTypeEnum.string,
description: ChatModelSystemTip,
placeholder: ChatModelSystemTip,
...
...
@@ -166,6 +167,7 @@ export const ChatModule: FlowModuleTemplateType = {
type: FlowInputItemTypeEnum.textarea,
valueType: FlowValueTypeEnum.string,
label: '限定词',
max: 500,
description: ChatModelLimitTip,
placeholder: ChatModelLimitTip,
value: ''
...
...
@@ -175,6 +177,7 @@ export const ChatModule: FlowModuleTemplateType = {
key: 'quoteQA',
type: FlowInputItemTypeEnum.target,
label: '引用内容',
description: "对象数组格式,结构:\n [{q:'问题',a:'回答'}]",
valueType: FlowValueTypeEnum.kbQuote
},
Input_Template_History,
...
...
@@ -666,6 +669,7 @@ export const appTemplates: (AppItemType & { avatar: string; intro: string })[] =
type: 'textarea',
valueType: 'string',
label: '限定词',
max: 500,
description:
'限定模型对话范围,会被放置在本次提问前,拥有强引导和限定性。可使用变量,例如 {{language}}。引导例子:\n1. 知识库是关于 Laf 的介绍,参考知识库回答问题,与 "Laf" 无关内容,直接回复: "我不知道"。\n2. 你仅回答关于 "xxx" 的问题,其他问题回复: "xxxx"',
placeholder:
...
...
client/src/pages/account/components/PayModal.tsx
View file @
fa3f3e62
...
...
@@ -104,7 +104,7 @@ const PayModal = ({ onClose }: { onClose: () => void }) => {
| FastAI4k - 对话 | 0.015 |
| FastAI16k - 对话 | 0.03 |
| FastAI-Plus - 对话 | 0.45 |
| 文件拆分 | 0.03 |`
}
| 文件
QA
拆分 | 0.03 |`
}
/>
</>
)
}
...
...
client/src/pages/chat/components/ChatHistorySlider.tsx
View file @
fa3f3e62
...
...
@@ -67,13 +67,17 @@ const ChatHistorySlider = ({
const
[
currentTab
,
setCurrentTab
]
=
useState
<
`
${
TabEnum
}
`
>
(
TabEnum
.
history
);
const
isShare
=
useMemo
(()
=>
!
appId
||
!
userInfo
,
[
appId
,
userInfo
]);
// custom title edit
const
{
onOpenModal
,
EditModal
:
EditTitleModal
}
=
useEditInfo
({
title
:
'自定义历史记录标题'
,
placeholder
:
'如果设置为空,会自动跟随聊天记录。'
});
const
{
openConfirm
,
ConfirmModal
}
=
useConfirm
({
content
:
t
(
'chat.Confirm to clear history'
)
content
:
isShare
?
t
(
'chat.Confirm to clear share chat histroy'
)
:
t
(
'chat.Confirm to clear history'
)
});
const
concatHistory
=
useMemo
<
HistoryItemType
[]
>
(
...
...
@@ -82,8 +86,6 @@ const ChatHistorySlider = ({
[
activeChatId
,
history
,
t
]
);
const
isShare
=
useMemo
(()
=>
!
appId
||
!
userInfo
,
[
appId
,
userInfo
]);
useQuery
([
'init'
],
()
=>
{
if
(
isShare
)
{
setCurrentTab
(
TabEnum
.
history
);
...
...
client/src/service/moduleDispatch/chat/oneapi.ts
View file @
fa3f3e62
...
...
@@ -237,25 +237,16 @@ function getChatMessages({
model
:
ChatModelItemType
;
hasQuoteOutput
:
boolean
;
})
{
const
limitText
=
(()
=>
{
if
(
!
quotePrompt
)
{
return
limitPrompt
;
}
const
defaultPrompt
=
`三引号引用的内容是我提供给你的知识,它们拥有最高优先级。instruction 是相关介绍
${
hasQuoteOutput
?
',output 是预期回答或补充'
:
''
}
,使用引用内容来回答我下面的问题。`
;
if
(
limitPrompt
)
{
return
`
${
defaultPrompt
}${
limitPrompt
}
`
;
}
return
`
${
defaultPrompt
}
\n回答内容限制:你仅回答三引号中提及的内容,下面我提出的问题与引用内容无关时,你可以直接回复: "你的问题没有在知识库中体现"`
;
})();
const
{
quoteGuidePrompt
}
=
getDefaultPrompt
({
hasQuoteOutput
});
const
systemText
=
`
${
quotePrompt
?
`
${
quoteGuidePrompt
}
\n\n`
:
''
}${
systemPrompt
}
`
;
const
messages
:
ChatItemType
[]
=
[
...(
system
Promp
t
...(
system
Tex
t
?
[
{
obj
:
ChatRoleEnum
.
System
,
value
:
system
Promp
t
value
:
system
Tex
t
}
]
:
[]),
...
...
@@ -268,11 +259,11 @@ function getChatMessages({
]
:
[]),
...
history
,
...(
limit
Tex
t
...(
limit
Promp
t
?
[
{
obj
:
ChatRoleEnum
.
System
,
value
:
limit
Tex
t
value
:
limit
Promp
t
}
]
:
[]),
...
...
@@ -385,3 +376,11 @@ async function streamResponse({
answer
};
}
function
getDefaultPrompt
({
hasQuoteOutput
}:
{
hasQuoteOutput
?:
boolean
})
{
return
{
quoteGuidePrompt
:
`三引号引用的内容是我提供给你的知识库,它们拥有最高优先级。instruction 是相关介绍
${
hasQuoteOutput
?
',output 是预期回答或补充。'
:
'。'
}
`
};
}
client/src/utils/app.ts
View file @
fa3f3e62
...
...
@@ -36,7 +36,7 @@ export type EditFormType = {
};
export
const
getDefaultAppForm
=
():
EditFormType
=>
{
const
defaultChatModel
=
chatModelList
[
0
];
const
defaultVectorModel
=
vectorModelList
[
0
];
return
{
chatModel
:
{
model
:
defaultChatModel
.
model
,
...
...
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