perf: md引入;docker-compose;

This commit is contained in:
archer
2023-04-09 22:56:08 +08:00
parent 5e4c4dd79b
commit 99e5fbd0f5
17 changed files with 185 additions and 149 deletions

1
src/api/common.ts Normal file
View File

@@ -0,0 +1 @@
import { GET, POST, DELETE } from './request';

View File

@@ -23,7 +23,7 @@ const WxConcat = ({ onClose }: { onClose: () => void }) => {
<ModalBody textAlign={'center'}>
<Image
style={{ margin: 'auto' }}
src={'/imgs/wxerweima300.jpg'}
src={'/imgs/wx300.jpg'}
width={200}
height={200}
alt=""
@@ -31,7 +31,7 @@ const WxConcat = ({ onClose }: { onClose: () => void }) => {
<Box mt={2}>
:
<Box as={'span'} userSelect={'all'}>
YNyiqi
fastgpt123
</Box>
</Box>
</ModalBody>

View File

@@ -4,69 +4,3 @@ export enum EmailTypeEnum {
}
export const PRICE_SCALE = 100000;
export const introPage = `
## 欢迎使用 Fast GPT
[Git 仓库](https://github.com/c121914yu/FastGPT)
### 交流群/问题反馈
wx号: YNyiqi
![](/imgs/wxerweima300.jpg)
### 快速开始
1. 使用邮箱注册账号。
2. 进入账号页面,添加关联账号,目前只有 openai 的账号可以添加,直接去 openai 官网,把 API Key 粘贴过来。
3. 如果填写了自己的 openai 账号,使用时会直接用你的账号。如果没有填写,需要付费使用平台的账号。
4. 进入模型页,创建一个模型,建议直接用 ChatGPT。
5. 在模型列表点击【对话】,即可使用 API 进行聊天。
### 定制 prompt
1. 进入模型编辑页
2. 调整温度和提示词
3. 使用该模型对话。每次对话时,提示词和温度都会自动注入,方便管理个人的模型。建议把自己日常经常需要使用的 5~10 个方向预设好。
### 知识库
1. 创建模型时选择【知识库】
2. 进入模型编辑页
3. 导入数据,可以选择手动导入,或者选择文件导入。文件导入会自动调用 chatGPT 理解文件内容,并生成知识库。
4. 使用该模型对话。
注意使用知识库模型对话时tokens 消耗会加快。
### 价格表
如果使用了自己的 Api Key不会计费。可以在账号页看到详细账单。单纯使用 chatGPT 模型进行对话,只有一个计费项目。使用知识库时,包含**对话**和**索引**生成两个计费项。
| 计费项 | 价格: 元/ 1K tokens包含上下文|
| --- | --- |
| chatgpt - 对话 | 0.03 |
| 知识库 - 对话 | 0.03 |
| 知识库 - 索引 | 0.004 |
| 文件拆分 | 0.03 |
`;
export const chatProblem = `
## 常见问题
**内容长度**
单次最长 4000 tokens, 上下文最长 8000 tokens, 上下文超长时会被截断。
**删除和复制**
点击对话头像,可以选择复制或删除该条内容。
**代理出错**
服务器代理不稳定,可以过一会儿再尝试。
`;
export const versionIntro = `
## Fast GPT V2.5
* 内容压缩替换中文标点符号和多余符号减少一些上下文tokens。
* 优化 QA 拆分记账。
`;
export const shareHint = `
你正准备分享对话,请确保分享链接不会滥用,因为它是使用的是你的 API key。
* 分享空白对话:为该模型创建一个空白的聊天分享出去。
* 分享当前对话:会把当前聊天的内容也分享出去,但是要注意不要多个人同时用一个聊天内容。
`;

15
src/hooks/useMarkdown.ts Normal file
View File

@@ -0,0 +1,15 @@
import { useQuery } from '@tanstack/react-query';
export const getMd = async (url: string) => {
const response = await fetch(`/docs/${url}`);
const textContent = await response.text();
return textContent;
};
export const useMarkdown = ({ url }: { url: string }) => {
const { data = '' } = useQuery([url], () => getMd(url));
return {
data
};
};

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { Card, Box, Mark } from '@chakra-ui/react';
import { versionIntro, chatProblem } from '@/constants/common';
import { Card, Box } from '@chakra-ui/react';
import { useMarkdown } from '@/hooks/useMarkdown';
import Markdown from '@/components/Markdown';
const Empty = ({ intro }: { intro: string }) => {
@@ -9,6 +9,9 @@ const Empty = ({ intro }: { intro: string }) => {
{children}
</Box>
);
const { data: chatProblem } = useMarkdown({ url: '/chatProblem.md' });
const { data: versionIntro } = useMarkdown({ url: '/versionIntro.md' });
return (
<Box
minH={'100%'}

View File

@@ -30,9 +30,9 @@ import { getToken } from '@/utils/user';
import MyIcon from '@/components/Icon';
import { useCopyData } from '@/utils/tools';
import Markdown from '@/components/Markdown';
import { shareHint } from '@/constants/common';
import { getChatSiteId } from '@/api/chat';
import WxConcat from '@/components/WxConcat';
import { useMarkdown } from '@/hooks/useMarkdown';
const SlideBar = ({
name,
@@ -55,6 +55,7 @@ const SlideBar = ({
const [hasReady, setHasReady] = useState(false);
const { isOpen: isOpenShare, onOpen: onOpenShare, onClose: onCloseShare } = useDisclosure();
const { isOpen: isOpenWx, onOpen: onOpenWx, onClose: onCloseWx } = useDisclosure();
const { data: shareHint } = useMarkdown({ url: '/chatProblem.md' });
const { isSuccess } = useQuery(['init'], getMyModels, {
cacheTime: 5 * 60 * 1000

View File

@@ -1,12 +1,14 @@
import React from 'react';
import { Card } from '@chakra-ui/react';
import Markdown from '@/components/Markdown';
import { introPage } from '@/constants/common';
import { useMarkdown } from '@/hooks/useMarkdown';
const Home = () => {
const { data } = useMarkdown({ url: '/intro.md' });
return (
<Card p={5} lineHeight={2}>
<Markdown source={introPage} isChatting={false} />
<Markdown source={data} isChatting={false} />
</Card>
);
};

View File

@@ -49,10 +49,6 @@ const ModelPhoneList = ({
<Box flex={'0 0 100px'}>AI模型: </Box>
<Box color={'blackAlpha.500'}>{model.service.modelName}</Box>
</Flex>
<Flex mt={5}>
<Box flex={'0 0 100px'}>: </Box>
<Box color={'blackAlpha.500'}>{model.trainingTimes}</Box>
</Flex>
<Flex mt={5} justifyContent={'flex-end'}>
<Button
mr={3}

View File

@@ -60,11 +60,6 @@ const ModelTable = ({
</Box>
)
},
{
title: '训练次数',
key: 'trainingTimes',
dataIndex: 'trainingTimes'
},
{
title: '操作',
key: 'control',

View File

@@ -25,11 +25,8 @@ export const jsonRes = <T = any>(
msg = error;
} else if (proxyError[error?.code]) {
msg = '服务器代理出错';
} else if (error?.response?.data?.error) {
msg =
openaiError2[error?.response?.data?.error?.type] ||
error?.response?.data?.error?.message ||
'openai 错误';
} else if (openaiError2[error?.response?.data?.error?.type]) {
msg = openaiError2[error?.response?.data?.error?.type];
} else if (openaiError[error?.response?.statusText]) {
msg = openaiError[error.response.statusText];
}