Skip to content

Commit

Permalink
v4.4.6 (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu authored Oct 7, 2023
1 parent c65a36d commit 98ce510
Show file tree
Hide file tree
Showing 56 changed files with 868 additions and 282 deletions.
2 changes: 1 addition & 1 deletion docSite/content/docs/installation/upgrading/40.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 'FastGPT 从旧版本升级到 V4.0 操作指南'
icon: 'upgrade'
draft: false
toc: true
weight: 1000
weight: 850
---

如果您是**从旧版本升级到 V4**,由于新版 MongoDB 表变更比较大,需要按照本文档的说明执行一些初始化脚本。
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/installation/upgrading/41.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 'FastGPT 从旧版本升级到 V4.1 操作指南'
icon: 'upgrade'
draft: false
toc: true
weight: 999
weight: 849
---

如果您是**从旧版本升级到 V4.1**,由于新版重新设置了对话存储结构,需要初始化原来的存储内容。
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/installation/upgrading/42.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 'FastGPT 从旧版本升级到 V4.2 操作指南'
icon: 'upgrade'
draft: false
toc: true
weight: 998
weight: 848
---

99.9%用户不影响,升级 4.2 主要是修改了配置文件中 QAModel 的格式。从原先的数组改成对象:
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/installation/upgrading/421.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 'FastGPT 从旧版本升级到 V4.2.1 操作指南'
icon: 'upgrade'
draft: false
toc: true
weight: 997
weight: 847
---

私有部署,如果添加了配置文件,需要在配置文件中修改 `VectorModels` 字段。增加 defaultToken 和 maxToken,分别对应直接分段时的默认 token 数量和该模型支持的 token 上限(通常不建议超过 3000)
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/installation/upgrading/43.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 'FastGPT 从旧版本升级到 V4.3 操作指南'
icon: 'upgrade'
draft: false
toc: true
weight: 996
weight: 846
---

## 执行初始化 API
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/installation/upgrading/44.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 'FastGPT 从旧版本升级到 V4.4 操作指南'
icon: 'upgrade'
draft: false
toc: true
weight: 995
weight: 845
---

## 执行初始化 API
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/installation/upgrading/441.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 'FastGPT 从旧版本升级到 V4.4.1 操作指南'
icon: 'upgrade'
draft: false
toc: true
weight: 994
weight: 844
---

## 执行初始化 API
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/installation/upgrading/442.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 'FastGPT 从旧版本升级到 V4.4.2 操作指南'
icon: 'upgrade'
draft: false
toc: true
weight: 993
weight: 843
---

## 执行初始化 API
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/installation/upgrading/445.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 'FastGPT V4.4.5 更新(需执行升级脚本)'
icon: 'upgrade'
draft: false
toc: true
weight: 992
weight: 842
---

## 执行初始化 API
Expand Down
14 changes: 14 additions & 0 deletions docSite/content/docs/installation/upgrading/446.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: 'V4.4.6'
description: 'FastGPT V4.4.6 更新'
icon: 'upgrade'
draft: false
toc: true
weight: 841
---

## 功能介绍

1. 高级编排新增模块 - 应用调用,可调用其他应用。
2. 新增 - 必要连接校验
3. 修复 - 下一步指引在免登录中身份问题。
File renamed without changes.
File renamed without changes.
57 changes: 57 additions & 0 deletions packages/core/ai/functions/createQuestionGuide.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ChatCompletionRequestMessage } from '../type';
import { getAIChatApi } from '../config';

export const Prompt_QuestionGuide = `我不太清楚问你什么问题,请帮我生成 3 个问题,引导我继续提问。问题的长度应小于20个字符,按 JSON 格式返回: ["问题1", "问题2", "问题3"]`;

export async function createQuestionGuide({
messages,
model
}: {
messages: ChatCompletionRequestMessage[];
model: string;
}) {
const chatAPI = getAIChatApi();
const { data } = await chatAPI.createChatCompletion({
model: model,
temperature: 0,
max_tokens: 200,
messages: [
...messages,
{
role: 'user',
content: Prompt_QuestionGuide
}
],
stream: false
});

const answer = data.choices?.[0].message?.content || '';
const totalTokens = data.usage?.total_tokens || 0;

const start = answer.indexOf('[');
const end = answer.lastIndexOf(']');

if (start === -1 || end === -1) {
return {
result: [],
tokens: totalTokens
};
}

const jsonStr = answer
.substring(start, end + 1)
.replace(/(\\n|\\)/g, '')
.replace(/ /g, '');

try {
return {
result: JSON.parse(jsonStr),
tokens: totalTokens
};
} catch (error) {
return {
result: [],
tokens: totalTokens
};
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app",
"version": "4.4.5",
"version": "4.4.6",
"private": false,
"scripts": {
"dev": "next dev",
Expand Down
17 changes: 8 additions & 9 deletions projects/app/public/docs/versionIntro.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
### Fast GPT V4.4.5
### Fast GPT V4.4.6

1. 新增 - 下一步指引选项,可以通过模型生成 3 个预测问题。
2. 新增 - 分享链接 hook 身份校验。
3. 新增 - Api Key 使用。增加别名、额度限制和过期时间。自带 appId,无需额外连接。
4. 去除 - 限定词。目前旧应用仍生效,9/25 后全面去除,请及时替换。
5. 新增 - 引用模板/引用提示词设置,可以 DIY 引用内容的格式,从而更好的适配场景。[参考文档](https://doc.fastgpt.run/docs/use-cases/prompt/)
6. [使用文档](https://doc.fastgpt.run/docs/intro/)
7. [点击查看高级编排介绍文档](https://doc.fastgpt.run/docs/workflow)
8. [点击查看商业版](https://doc.fastgpt.run/docs/commercial/)
1. 高级编排新增模块 - 应用调用
2. 新增 - 必要连接校验
3. 新增 - 下一步指引选项,可以通过模型生成 3 个预测问题。
4. 新增 - 分享链接 hook 身份校验。
5. [使用文档](https://doc.fastgpt.run/docs/intro/)
6. [点击查看高级编排介绍文档](https://doc.fastgpt.run/docs/workflow)
7. [点击查看商业版](https://doc.fastgpt.run/docs/commercial/)
Binary file added projects/app/public/imgs/module/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions projects/app/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"module question": "Question",
"module quoteList": "Quotes",
"module runningTime": "Time",
"module search response": "Search Result",
"module similarity": "Similarity",
"module temperature": "Temperature",
"module time": "Running Time",
Expand Down
1 change: 1 addition & 0 deletions projects/app/public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"module question": "问题",
"module quoteList": "引用内容",
"module runningTime": "运行时长",
"module search response": "搜索结果",
"module similarity": "相似度",
"module temperature": "温度",
"module time": "运行时长",
Expand Down
3 changes: 2 additions & 1 deletion projects/app/src/api/core/ai/agent/type.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChatCompletionRequestMessage } from '@fastgpt/core/aiApi/type';
import { ChatCompletionRequestMessage } from '@fastgpt/core/ai/type';

export type CreateQuestionGuideProps = {
messages: ChatCompletionRequestMessage[];
shareId?: string;
};
43 changes: 19 additions & 24 deletions projects/app/src/components/ChatBox/ResponseTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@ const QuoteModal = dynamic(() => import('./QuoteModal'), { ssr: false });
const ContextModal = dynamic(() => import('./ContextModal'), { ssr: false });
const WholeResponseModal = dynamic(() => import('./WholeResponseModal'), { ssr: false });

const ResponseTags = ({
chatId,
contentId,
responseData = []
}: {
chatId?: string;
contentId?: string;
responseData?: ChatHistoryItemResType[];
}) => {
const ResponseTags = ({ responseData = [] }: { responseData?: ChatHistoryItemResType[] }) => {
const { isPc } = useGlobalStore();
const { t } = useTranslation();
const [quoteModalData, setQuoteModalData] = useState<QuoteItemType[]>();
Expand All @@ -41,9 +33,12 @@ const ResponseTags = ({
return {
chatAccount: responseData.filter((item) => item.moduleType === FlowModuleTypeEnum.chatNode)
.length,
quoteList: chatData?.quoteList,
quoteList: responseData
.filter((item) => item.moduleType === FlowModuleTypeEnum.chatNode)
.map((item) => item.quoteList)
.flat(),
historyPreview: chatData?.historyPreview,
runningTime: responseData.reduce((sum, item) => sum + (item.runningTime || 0), 0).toFixed(2)
runningTime: +responseData.reduce((sum, item) => sum + (item.runningTime || 0), 0).toFixed(2)
};
}, [responseData]);

Expand All @@ -56,20 +51,20 @@ const ResponseTags = ({

return responseData.length === 0 ? null : (
<Flex alignItems={'center'} mt={2} flexWrap={'wrap'}>
{quoteList.length > 0 && (
<MyTooltip label="查看引用">
<Tag
colorSchema="blue"
cursor={'pointer'}
{...TagStyles}
onClick={() => setQuoteModalData(quoteList)}
>
{quoteList.length}条引用
</Tag>
</MyTooltip>
)}
{chatAccount === 1 && (
<>
{quoteList.length > 0 && (
<MyTooltip label="查看引用">
<Tag
colorSchema="blue"
cursor={'pointer'}
{...TagStyles}
onClick={() => setQuoteModalData(quoteList)}
>
{quoteList.length}条引用
</Tag>
</MyTooltip>
)}
{historyPreview.length > 0 && (
<MyTooltip label={'点击查看完整对话记录'}>
<Tag
Expand Down Expand Up @@ -120,4 +115,4 @@ const ResponseTags = ({
);
};

export default ResponseTags;
export default React.memo(ResponseTags);
17 changes: 6 additions & 11 deletions projects/app/src/components/ChatBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { feConfigs } from '@/store/static';
import { event } from '@/utils/plugin/eventbus';
import { adaptChat2GptMessages } from '@/utils/common/adapt/message';
import { useMarkdown } from '@/hooks/useMarkdown';
import { AppModuleItemType, VariableItemType } from '@/types/app';
import { AppModuleItemType } from '@/types/app';
import { VariableInputEnum } from '@/constants/app';
import { useForm } from 'react-hook-form';
import type { MessageItemType } from '@/types/core/chat/type';
Expand Down Expand Up @@ -81,7 +81,7 @@ export type StartChatFnProps = {
export type ComponentRef = {
getChatHistory: () => ChatSiteItemType[];
resetVariables: (data?: Record<string, any>) => void;
resetHistory: (chatId: ChatSiteItemType[]) => void;
resetHistory: (history: ChatSiteItemType[]) => void;
scrollToBottom: (behavior?: 'smooth' | 'auto') => void;
};

Expand All @@ -96,7 +96,6 @@ type Props = {
showMarkIcon?: boolean; // admin mark dataset
showVoiceIcon?: boolean;
showEmptyIntro?: boolean;
chatId?: string;
appAvatar?: string;
userAvatar?: string;
userGuideModule?: AppModuleItemType;
Expand All @@ -116,7 +115,6 @@ const ChatBox = (
showMarkIcon = false,
showVoiceIcon = true,
showEmptyIntro = false,
chatId,
appAvatar,
userAvatar,
userGuideModule,
Expand Down Expand Up @@ -265,7 +263,8 @@ const ChatBox = (

const result = await postQuestionGuide(
{
messages: adaptChat2GptMessages({ messages: history, reserveId: false }).slice(-6)
messages: adaptChat2GptMessages({ messages: history, reserveId: false }).slice(-6),
shareId: router.query.shareId as string
},
abortSignal
);
Expand All @@ -277,7 +276,7 @@ const ChatBox = (
}
} catch (error) {}
},
[questionGuide, scrollToBottom]
[questionGuide, scrollToBottom, router.query.shareId]
);

/**
Expand Down Expand Up @@ -743,11 +742,7 @@ const ChatBox = (
source={item.value}
isChatting={index === chatHistory.length - 1 && isChatting}
/>
<ResponseTags
chatId={chatId}
contentId={item.dataId}
responseData={item.responseData}
/>
<ResponseTags responseData={item.responseData} />
{/* question guide */}
{index === chatHistory.length - 1 &&
!isChatting &&
Expand Down
27 changes: 13 additions & 14 deletions projects/app/src/components/Markdown/chat/Guide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,28 @@ function MyLink(e: any) {
{text}
</Link>
) : (
<Box as={'ul'} mt={'0 !important'}>
<Box as={'li'} mb={1}>
<Box
as={'span'}
color={'blue.600'}
textDecoration={'underline'}
cursor={'pointer'}
onClick={() => {
event.emit('guideClick', { text });
}}
>
{text}
</Box>
<Box as={'li'} mb={1}>
<Box
as={'span'}
color={'blue.600'}
textDecoration={'underline'}
cursor={'pointer'}
onClick={() => {
event.emit('guideClick', { text });
}}
>
{text}
</Box>
</Box>
);
}

const Guide = ({ text }: { text: string }) => {
const formatText = useMemo(
() => text.replace(/\[(.*?)\]($|\n)/g, '[$1]()\n').replace(/\\n/g, '\n&nbsp;'),
() => text.replace(/\[(.*?)\]($|\n)/g, '[$1]()').replace(/\\n/g, '\n&nbsp;'),
[text]
);

return (
<ReactMarkdown
className={`markdown ${styles.markdown}`}
Expand Down
Loading

0 comments on commit 98ce510

Please sign in to comment.