flow chat

This commit is contained in:
archer 2023-07-17 22:31:01 +08:00
parent ecce182a20
commit f71ce25c46
No known key found for this signature in database
GPG Key ID: 569A5660D2379E28
8 changed files with 92 additions and 49 deletions

View File

@ -1,12 +1,11 @@
### 常见问题 ### 常见问题
**Git 地址**: [项目地址,完全开源,随便用。](https://github.com/labring/FastGPT) **Git 地址**: [项目地址。V4-beta 暂为开源,在正式版发布后会开源。](https://github.com/c121914yu/FastGPT)
**问题文档**: [先看文档,再提问](https://kjqvjse66l.feishu.cn/docx/HtrgdT0pkonP4kxGx8qcu6XDnGh) **问题文档**: [先看文档,再提问](https://kjqvjse66l.feishu.cn/docx/HtrgdT0pkonP4kxGx8qcu6XDnGh)
**价格表** **价格表**
如果使用了自己的 Api Key网页上 openai 模型聊天不会计费。可以在账号页,看到详细账单。
| 计费项 | 价格: 元/ 1K tokens包含上下文| | 计费项 | 价格: 元/ 1K tokens包含上下文|
| --- | --- | | --- | --- |
| 知识库 - 索引 | 0.001 | | 知识库 - 索引 | 0.002 |
| FastAI4k - 对话 | 0.015 | | FastAI4k - 对话 | 0.015 |
| FastAI16k - 对话 | 0.03 | | FastAI16k - 对话 | 0.03 |
| FastAI-Plus - 对话 | 0.45 | | FastAI-Plus - 对话 | 0.45 |

View File

@ -1,6 +1,12 @@
### Fast GPT V3.9 ### Fast GPT V4.0-beta
<<<<<<< HEAD
1. 新增 - 直接分段训练,可调节段落大小。 1. 新增 - 直接分段训练,可调节段落大小。
2. 优化 - tokens 计算性能。 2. 优化 - tokens 计算性能。
3. 优化 - key 池管理,结合 one-api 项目,实现更方便的 key 池管理,具体参考[docker 部署 FastGpt](https://github.com/labring/FastGPT/blob/main/docs/deploy/docker.md) 3. 优化 - key 池管理,结合 one-api 项目,实现更方便的 key 池管理,具体参考[docker 部署 FastGpt](https://github.com/labring/FastGPT/blob/main/docs/deploy/docker.md)
4. 新增 - V2 版 OpenAPI可以在任意第三方套壳 ChatGpt 项目中直接使用 FastGpt 的应用,注意!是直接,不需要改任何代码。具体参考[API 文档中《在第三方应用中使用 FastGpt》](https://kjqvjse66l.feishu.cn/docx/DmLedTWtUoNGX8xui9ocdUEjnNh) 4. 新增 - V2 版 OpenAPI可以在任意第三方套壳 ChatGpt 项目中直接使用 FastGpt 的应用,注意!是直接,不需要改任何代码。具体参考[API 文档中《在第三方应用中使用 FastGpt》](https://kjqvjse66l.feishu.cn/docx/DmLedTWtUoNGX8xui9ocdUEjnNh)
=======
1. 全新交互,采用模块组合的方式构建知识库。
2. 问题分类 - 可以对用户的问题进行分类,再执行不同的操作。
3. beta 版本尚未稳定,请以测试为主。详细使用文档后续会补上。
>>>>>>> 5f8a88d (flow chat)

View File

@ -21,6 +21,7 @@ import MyIcon from '@/components/Icon';
import Avatar from '@/components/Avatar'; import Avatar from '@/components/Avatar';
import { adaptChatItem_openAI } from '@/utils/plugin/openai'; import { adaptChatItem_openAI } from '@/utils/plugin/openai';
import { useMarkdown } from '@/hooks/useMarkdown';
import { VariableItemType } from '@/types/app'; import { VariableItemType } from '@/types/app';
import { VariableInputEnum } from '@/constants/app'; import { VariableInputEnum } from '@/constants/app';
import { useForm } from 'react-hook-form'; import { useForm } from 'react-hook-form';
@ -68,8 +69,34 @@ const VariableLabel = ({
</Box> </Box>
); );
const Empty = () => {
const { data: chatProblem } = useMarkdown({ url: '/chatProblem.md' });
const { data: versionIntro } = useMarkdown({ url: '/versionIntro.md' });
return (
<Box
minH={'100%'}
w={'85%'}
maxW={'600px'}
m={'auto'}
py={'5vh'}
alignItems={'center'}
justifyContent={'center'}
>
{/* version intro */}
<Card p={4} mb={10}>
<Markdown source={versionIntro} />
</Card>
<Card p={4}>
<Markdown source={chatProblem} />
</Card>
</Box>
);
};
const ChatBox = ( const ChatBox = (
{ {
showEmptyIntro = false,
historyId, historyId,
appAvatar, appAvatar,
variableModules, variableModules,
@ -78,6 +105,7 @@ const ChatBox = (
onStartChat, onStartChat,
onDelMessage onDelMessage
}: { }: {
showEmptyIntro?: boolean;
historyId?: string; historyId?: string;
appAvatar: string; appAvatar: string;
variableModules?: VariableItemType[]; variableModules?: VariableItemType[];
@ -568,6 +596,8 @@ const ChatBox = (
</Flex> </Flex>
))} ))}
</Box> </Box>
{showEmptyIntro && chatHistory.length === 0 && !hasVariableInput && <Empty />}
</Box> </Box>
</Box> </Box>
{/* input */} {/* input */}

View File

@ -15,7 +15,7 @@ import MyIcon from '@/components/Icon';
import TotalUsage from './Charts/TotalUsage'; import TotalUsage from './Charts/TotalUsage';
const InfoModal = dynamic(() => import('./InfoModal')); const InfoModal = dynamic(() => import('./InfoModal'));
const AppEdit = dynamic(() => import('./edit'), { ssr: true }); import AppEdit from './edit';
import styles from '../../list/index.module.scss'; import styles from '../../list/index.module.scss';
const Settings = ({ appId }: { appId: string }) => { const Settings = ({ appId }: { appId: string }) => {

View File

@ -11,6 +11,7 @@ import MySelect from '@/components/Select';
import { chatModelList } from '@/store/static'; import { chatModelList } from '@/store/static';
import MySlider from '@/components/Slider'; import MySlider from '@/components/Slider';
import { Box } from '@chakra-ui/react'; import { Box } from '@chakra-ui/react';
import { formatPrice } from '@/utils/user';
const NodeChat = ({ const NodeChat = ({
data: { moduleId, inputs, outputs, onChangeNode, ...props } data: { moduleId, inputs, outputs, onChangeNode, ...props }
@ -29,45 +30,56 @@ const NodeChat = ({
onChangeNode={onChangeNode} onChangeNode={onChangeNode}
flowInputList={inputs} flowInputList={inputs}
CustomComponent={{ CustomComponent={{
model: (inputItem) => ( model: (inputItem) => {
<MySelect const list = chatModelList.map((item) => {
width={'100%'} const priceStr = `(${formatPrice(item.price, 1000)}元/1k Tokens)`;
value={inputItem.value}
list={inputItem.list || []}
onchange={(e) => {
onChangeNode({
moduleId,
key: inputItem.key,
value: e
});
// update max tokens
const model = chatModelList.find((item) => item.model === e);
if (!model) return;
onChangeNode({ return {
moduleId, value: item.model,
key: 'maxToken', label: `${item.name}${priceStr}`
valueKey: 'markList', };
value: [ });
{ label: '100', value: 100 },
{ label: `${model.contextMaxToken}`, value: model.contextMaxToken } return (
] <MySelect
}); width={'100%'}
onChangeNode({ value={inputItem.value}
moduleId, list={list}
key: 'maxToken', onchange={(e) => {
valueKey: 'max', onChangeNode({
value: model.contextMaxToken moduleId,
}); key: inputItem.key,
onChangeNode({ value: e
moduleId, });
key: 'maxToken', // update max tokens
valueKey: 'value', const model = chatModelList.find((item) => item.model === e);
value: model.contextMaxToken / 2 if (!model) return;
});
}} onChangeNode({
/> moduleId,
), key: 'maxToken',
valueKey: 'markList',
value: [
{ label: '100', value: 100 },
{ label: `${model.contextMaxToken}`, value: model.contextMaxToken }
]
});
onChangeNode({
moduleId,
key: 'maxToken',
valueKey: 'max',
value: model.contextMaxToken
});
onChangeNode({
moduleId,
key: 'maxToken',
valueKey: 'value',
value: model.contextMaxToken / 2
});
}}
/>
);
},
maxToken: (inputItem) => { maxToken: (inputItem) => {
const model = inputs.find((item) => item.key === 'model')?.value; const model = inputs.find((item) => item.key === 'model')?.value;
const modelData = chatModelList.find((item) => item.model === model); const modelData = chatModelList.find((item) => item.model === model);

View File

@ -296,6 +296,7 @@ const Chat = () => {
<Box flex={1}> <Box flex={1}>
<ChatBox <ChatBox
ref={ChatBoxRef} ref={ChatBoxRef}
showEmptyIntro
historyId={historyId} historyId={historyId}
appAvatar={chatData.app.avatar} appAvatar={chatData.app.avatar}
variableModules={chatData.app.variableModules} variableModules={chatData.app.variableModules}

View File

@ -13,7 +13,6 @@ import MyIcon from '@/components/Icon';
const Home = () => { const Home = () => {
const router = useRouter(); const router = useRouter();
const { inviterId } = router.query as { inviterId: string }; const { inviterId } = router.query as { inviterId: string };
const { data } = useMarkdown({ url: '/intro.md' });
const { isPc } = useGlobalStore(); const { isPc } = useGlobalStore();
const [star, setStar] = useState(1500); const [star, setStar] = useState(1500);
@ -211,10 +210,6 @@ const Home = () => {
</Flex> </Flex>
<Box w={'100%'} mt={'100vh'} px={[5, 10]} pb={[5, 10]}> <Box w={'100%'} mt={'100vh'} px={[5, 10]} pb={[5, 10]}>
<Card p={5} lineHeight={2}>
<Markdown source={data} isChatting={false} />
</Card>
<Card p={5} mt={4} textAlign={'center'}> <Card p={5} mt={4} textAlign={'center'}>
{beianText && ( {beianText && (
<Link href="https://beian.miit.gov.cn/" target="_blank"> <Link href="https://beian.miit.gov.cn/" target="_blank">

View File

@ -113,7 +113,7 @@ const PayModal = ({ onClose }: { onClose: () => void }) => {
source={` source={`
| | 价格: / 1K tokens()| | | 价格: / 1K tokens()|
| --- | --- | | --- | --- |
| - | 0.001 | | - | 0.002 |
| FastAI4k - | 0.015 | | FastAI4k - | 0.015 |
| FastAI16k - | 0.03 | | FastAI16k - | 0.03 |
| FastAI-Plus - | 0.45 | | FastAI-Plus - | 0.45 |