Skip to content

Commit 11848b8

Browse files
authored
v4.4.5-3 (#357)
1 parent a11e0bd commit 11848b8

File tree

34 files changed

+395
-62
lines changed

34 files changed

+395
-62
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ ARG name
2626

2727
# copy common node_modules and one project node_modules
2828
COPY --from=deps /app/node_modules ./node_modules
29+
COPY --from=deps /app/packages ./packages
2930
COPY ./projects/$name ./projects/$name
3031
COPY --from=deps /app/projects/$name/node_modules ./projects/$name/node_modules
3132
COPY pnpm-lock.yaml pnpm-workspace.yaml ./

docSite/content/docs/installation/upgrading/445.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: '升级到 V4.4.5'
3-
description: 'FastGPT 从旧版本升级到 V4.4.5 操作指南'
2+
title: 'V4.4.5'
3+
description: 'FastGPT V4.4.5 更新(需执行升级脚本)'
44
icon: 'upgrade'
55
draft: false
66
toc: true
@@ -21,3 +21,11 @@ curl --location --request POST 'https://{{host}}/api/admin/initv445' \
2121

2222
初始化了 variable 模块,将其合并到用户引导模块中。
2323

24+
## 功能介绍
25+
26+
### Fast GPT V4.4.5
27+
28+
1. 新增 - 下一步指引选项,可以通过模型生成 3 个预测问题。
29+
2. 新增 - 分享链接 hook 身份校验。
30+
3. 新增 - Api Key 使用。增加别名、额度限制和过期时间。自带 appId,无需额外连接。
31+
4. 优化 - 全局变量与开场白合并成同一模块。

docSite/content/docs/installation/upgrading/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
weight: 760
3-
title: "版本升级"
4-
description: "FastGPT 升级指南"
3+
title: "版本更新/升级操作"
4+
description: "FastGPT 版本更新介绍及升级操作"
55
icon: upgrade
66
draft: false
77
images: []

projects/app/data/config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,13 @@
7575
"maxToken": 16000,
7676
"price": 0,
7777
"prompt": ""
78+
},
79+
"QGModel": {
80+
"model": "gpt-3.5-turbo",
81+
"name": "GPT35-4k",
82+
"maxToken": 4000,
83+
"price": 0,
84+
"prompt": "",
85+
"functionCall": false
7886
}
7987
}
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
### Fast GPT V4.4.5
22

3-
1. 优化 - Api Key 使用。增加别名、额度限制和过期时间。自带 appId,无需额外连接。
4-
2. 去除 - 限定词。目前旧应用仍生效,9/25 后全面去除,请及时替换。
5-
3. 新增 - 引用模板/引用提示词设置,可以 DIY 引用内容的格式,从而更好的适配场景。[参考文档](https://doc.fastgpt.run/docs/use-cases/prompt/)
6-
4. [使用文档](https://doc.fastgpt.run/docs/intro/)
7-
5. [点击查看高级编排介绍文档](https://doc.fastgpt.run/docs/workflow)
8-
6. [点击查看商业版](https://doc.fastgpt.run/docs/commercial/)
3+
1. 新增 - 下一步指引选项,可以通过模型生成 3 个预测问题。
4+
2. 新增 - 分享链接 hook 身份校验。
5+
3. 新增 - Api Key 使用。增加别名、额度限制和过期时间。自带 appId,无需额外连接。
6+
4. 去除 - 限定词。目前旧应用仍生效,9/25 后全面去除,请及时替换。
7+
5. 新增 - 引用模板/引用提示词设置,可以 DIY 引用内容的格式,从而更好的适配场景。[参考文档](https://doc.fastgpt.run/docs/use-cases/prompt/)
8+
6. [使用文档](https://doc.fastgpt.run/docs/intro/)
9+
7. [点击查看高级编排介绍文档](https://doc.fastgpt.run/docs/workflow)
10+
8. [点击查看商业版](https://doc.fastgpt.run/docs/commercial/)

projects/app/public/locales/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"Mark Description": "The annotation feature is currently in beta. \n\n After clicking Add annotation, you need to select a knowledge base in order to store annotation data. You can use this feature to quickly annotate questions and expected answers to guide the model to the next answer. At present, the annotation function, like other data in the knowledge base, is affected by the model, which does not mean that the annotation meets 100% expectations. The \n\n annotation data is only unidirectional synchronization with the knowledge base. If the knowledge base modifies the annotation data, the annotation data displayed in the log cannot be synchronized",
6868
"Mark Description Title": "Mark Description",
6969
"New Chat": "New Chat",
70+
"Question Guide Tips": "I guess what you're asking is",
7071
"Read Mark Description": "Read mark description",
7172
"Read User Feedback": "Read user feedback",
7273
"Select Mark Kb": "Select Dataset",

projects/app/public/locales/zh/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"Mark Description": "当前标注功能为测试版。\n\n点击添加标注后,需要选择一个知识库,以便存储标注数据。你可以通过该功能快速的标注问题和预期回答,以便引导模型下次的回答。\n\n目前,标注功能同知识库其他数据一样,受模型的影响,不代表标注后 100% 符合预期。\n\n标注数据仅单向与知识库同步,如果知识库修改了该标注数据,日志展示的标注数据无法同步",
6868
"Mark Description Title": "标注功能介绍",
6969
"New Chat": "新对话",
70+
"Question Guide Tips": "猜你想问",
7071
"Read Mark Description": "查看标注功能介绍",
7172
"Read User Feedback": "查看用户反馈",
7273
"Select Mark Kb": "选择知识库",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { GET, POST, PUT, DELETE } from '@/api/request';
2+
import { CreateQuestionGuideProps } from './type';
3+
4+
export const postQuestionGuide = (data: CreateQuestionGuideProps, cancelToken: AbortController) =>
5+
POST<string[]>('/core/ai/agent/createQuestionGuide', data, { cancelToken });
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { ChatCompletionRequestMessage } from '@fastgpt/core/aiApi/type';
2+
3+
export type CreateQuestionGuideProps = {
4+
messages: ChatCompletionRequestMessage[];
5+
};

projects/app/src/api/request.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface ConfigType {
1212
hold?: boolean;
1313
timeout?: number;
1414
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
15+
cancelToken?: AbortController;
1516
}
1617
interface ResponseDataType {
1718
code: number;
@@ -88,7 +89,12 @@ instance.interceptors.request.use(requestStart, (err) => Promise.reject(err));
8889
/* 响应拦截 */
8990
instance.interceptors.response.use(responseSuccess, (err) => Promise.reject(err));
9091

91-
function request(url: string, data: any, config: ConfigType, method: Method): any {
92+
function request(
93+
url: string,
94+
data: any,
95+
{ cancelToken, ...config }: ConfigType,
96+
method: Method
97+
): any {
9298
/* 去空 */
9399
for (const key in data) {
94100
if (data[key] === null || data[key] === undefined) {
@@ -103,6 +109,7 @@ function request(url: string, data: any, config: ConfigType, method: Method): an
103109
method,
104110
data: ['POST', 'PUT'].includes(method) ? data : null,
105111
params: !['POST', 'PUT'].includes(method) ? data : null,
112+
signal: cancelToken?.signal,
106113
...config // 用户自定义配置,可以覆盖前面的配置
107114
})
108115
.then((res) => checkRes(res.data))

projects/app/src/api/response/chat.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import type { AppSchema } from '@/types/mongoSchema';
22
import type { ChatItemType } from '@/types/chat';
3-
import { VariableItemType } from '@/types/app';
3+
import { AppModuleItemType, VariableItemType } from '@/types/app';
44

55
export interface InitChatResponse {
66
chatId: string;
77
appId: string;
88
app: {
9-
variableModules?: VariableItemType[];
10-
welcomeText?: string;
9+
userGuideModule?: AppModuleItemType;
1110
chatModels?: string[];
1211
name: string;
1312
avatar: string;

projects/app/src/components/ChatBox/index.tsx

Lines changed: 101 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { feConfigs } from '@/store/static';
2424
import { event } from '@/utils/plugin/eventbus';
2525
import { adaptChat2GptMessages } from '@/utils/common/adapt/message';
2626
import { useMarkdown } from '@/hooks/useMarkdown';
27-
import { VariableItemType } from '@/types/app';
27+
import { AppModuleItemType, VariableItemType } from '@/types/app';
2828
import { VariableInputEnum } from '@/constants/app';
2929
import { useForm } from 'react-hook-form';
3030
import { MessageItemType } from '@/pages/api/openapi/v1/chat/completions';
@@ -51,6 +51,8 @@ const InputDataModal = dynamic(() => import('@/pages/kb/detail/components/InputD
5151

5252
import styles from './index.module.scss';
5353
import Script from 'next/script';
54+
import { postQuestionGuide } from '@/api/core/ai/agent/api';
55+
import { splitGuideModule } from './utils';
5456

5557
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 24);
5658

@@ -137,8 +139,7 @@ const ChatBox = (
137139
chatId,
138140
appAvatar,
139141
userAvatar,
140-
variableModules,
141-
welcomeText,
142+
userGuideModule,
142143
active = true,
143144
onUpdateVariable,
144145
onStartChat,
@@ -151,8 +152,7 @@ const ChatBox = (
151152
chatId?: string;
152153
appAvatar?: string;
153154
userAvatar?: string;
154-
variableModules?: VariableItemType[];
155-
welcomeText?: string;
155+
userGuideModule?: AppModuleItemType;
156156
active?: boolean;
157157
onUpdateVariable?: (e: Record<string, any>) => void;
158158
onStartChat?: (e: StartChatFnProps) => Promise<{
@@ -171,31 +171,41 @@ const ChatBox = (
171171
const { toast } = useToast();
172172
const { isPc } = useGlobalStore();
173173
const TextareaDom = useRef<HTMLTextAreaElement>(null);
174-
const controller = useRef(new AbortController());
174+
const chatController = useRef(new AbortController());
175+
const questionGuideController = useRef(new AbortController());
175176

176177
const [refresh, setRefresh] = useState(false);
177-
const [variables, setVariables] = useState<Record<string, any>>({});
178+
const [variables, setVariables] = useState<Record<string, any>>({}); // settings variable
178179
const [chatHistory, setChatHistory] = useState<ChatSiteItemType[]>([]);
179180
const [feedbackId, setFeedbackId] = useState<string>();
180181
const [readFeedbackData, setReadFeedbackData] = useState<{
182+
// read feedback modal data
181183
chatItemId: string;
182184
content: string;
183185
isMarked: boolean;
184186
}>();
185187
const [adminMarkData, setAdminMarkData] = useState<{
188+
// mark modal data
186189
kbId?: string;
187190
chatItemId: string;
188191
dataId?: string;
189192
q: string;
190193
a: string;
191194
}>();
195+
const [questionGuides, setQuestionGuide] = useState<string[]>([]);
192196

193197
const isChatting = useMemo(
194198
() =>
195199
chatHistory[chatHistory.length - 1] &&
196200
chatHistory[chatHistory.length - 1]?.status !== 'finish',
197201
[chatHistory]
198202
);
203+
204+
const { welcomeText, variableModules, questionGuide } = useMemo(
205+
() => splitGuideModule(userGuideModule),
206+
[userGuideModule]
207+
);
208+
199209
// compute variable input is finish.
200210
const [variableInputFinish, setVariableInputFinish] = useState(false);
201211
const variableIsFinish = useMemo(() => {
@@ -287,6 +297,32 @@ const ChatBox = (
287297
}, 100);
288298
}, []);
289299

300+
// create question guide
301+
const createQuestionGuide = useCallback(
302+
async ({ history }: { history: ChatSiteItemType[] }) => {
303+
if (!questionGuide || chatController.current?.signal?.aborted) return;
304+
305+
try {
306+
const abortSignal = new AbortController();
307+
questionGuideController.current = abortSignal;
308+
309+
const result = await postQuestionGuide(
310+
{
311+
messages: adaptChat2GptMessages({ messages: history, reserveId: false }).slice(-6)
312+
},
313+
abortSignal
314+
);
315+
if (Array.isArray(result)) {
316+
setQuestionGuide(result);
317+
setTimeout(() => {
318+
scrollToBottom();
319+
}, 100);
320+
}
321+
} catch (error) {}
322+
},
323+
[questionGuide, scrollToBottom]
324+
);
325+
290326
/**
291327
* user confirm send prompt
292328
*/
@@ -300,6 +336,7 @@ const ChatBox = (
300336
});
301337
return;
302338
}
339+
questionGuideController.current?.abort('stop');
303340
// get input value
304341
const val = inputVal.trim();
305342

@@ -332,18 +369,19 @@ const ChatBox = (
332369

333370
// 清空输入内容
334371
resetInputVal('');
372+
setQuestionGuide([]);
335373
setTimeout(() => {
336374
scrollToBottom();
337375
}, 100);
338376

339377
try {
340378
// create abort obj
341379
const abortSignal = new AbortController();
342-
controller.current = abortSignal;
380+
chatController.current = abortSignal;
343381

344382
const messages = adaptChat2GptMessages({ messages: newChatList, reserveId: true });
345383

346-
const { responseData } = await onStartChat({
384+
const { responseData, responseText } = await onStartChat({
347385
chatList: newChatList,
348386
messages,
349387
controller: abortSignal,
@@ -364,6 +402,16 @@ const ChatBox = (
364402
);
365403

366404
setTimeout(() => {
405+
createQuestionGuide({
406+
history: newChatList.map((item, i) =>
407+
i === newChatList.length - 1
408+
? {
409+
...item,
410+
value: responseText
411+
}
412+
: item
413+
)
414+
});
367415
generatingScroll();
368416
isPc && TextareaDom.current?.focus();
369417
}, 100);
@@ -393,13 +441,14 @@ const ChatBox = (
393441
}
394442
},
395443
[
396-
isChatting,
397444
chatHistory,
445+
onStartChat,
446+
isChatting,
398447
resetInputVal,
399448
toast,
400449
scrollToBottom,
401-
onStartChat,
402450
generatingMessage,
451+
createQuestionGuide,
403452
generatingScroll,
404453
isPc
405454
]
@@ -494,7 +543,8 @@ const ChatBox = (
494543
// page change and abort request
495544
useEffect(() => {
496545
return () => {
497-
controller.current?.abort('leave');
546+
chatController.current?.abort('leave');
547+
questionGuideController.current?.abort('leave');
498548
// close voice
499549
cancelBroadcast();
500550
};
@@ -528,6 +578,7 @@ const ChatBox = (
528578
<Flex flexDirection={'column'} h={'100%'}>
529579
<Script src="/js/html2pdf.bundle.min.js" strategy="lazyOnload"></Script>
530580

581+
{/* chat box container */}
531582
<Box ref={ChatBoxRef} flex={'1 0 0'} h={0} w={'100%'} overflow={'overlay'} px={[4, 0]} pb={3}>
532583
<Box id="chat-container" maxW={['100%', '92%']} h={'100%'} mx={'auto'}>
533584
{showEmpty && <Empty />}
@@ -839,6 +890,43 @@ const ChatBox = (
839890
contentId={item.dataId}
840891
responseData={item.responseData}
841892
/>
893+
{/* question guide */}
894+
{index === chatHistory.length - 1 &&
895+
!isChatting &&
896+
questionGuides.length > 0 && (
897+
<Flex
898+
mt={2}
899+
borderTop={theme.borders.sm}
900+
alignItems={'center'}
901+
flexWrap={'wrap'}
902+
>
903+
<Box
904+
color={'myGray.500'}
905+
mt={2}
906+
mr={2}
907+
fontSize={'sm'}
908+
fontStyle={'italic'}
909+
>
910+
{t('chat.Question Guide Tips')}
911+
</Box>
912+
{questionGuides.map((item) => (
913+
<Button
914+
mt={2}
915+
key={item}
916+
mr="2"
917+
borderRadius={'md'}
918+
variant={'outline'}
919+
colorScheme={'gray'}
920+
size={'xs'}
921+
onClick={() => {
922+
resetInputVal(item);
923+
}}
924+
>
925+
{item}
926+
</Button>
927+
))}
928+
</Flex>
929+
)}
842930
{/* admin mark content */}
843931
{showMarkIcon && item.adminFeedback && (
844932
<Box>
@@ -928,7 +1016,7 @@ const ChatBox = (
9281016
cursor={'pointer'}
9291017
name={'stop'}
9301018
color={'gray.500'}
931-
onClick={() => controller.current?.abort('stop')}
1019+
onClick={() => chatController.current?.abort('stop')}
9321020
/>
9331021
) : (
9341022
<MyIcon

0 commit comments

Comments
 (0)