doc gpt V0.2

This commit is contained in:
archer
2023-02-19 14:35:25 +08:00
parent cc5cf99e7a
commit 0ecf576e4e
124 changed files with 11780 additions and 573 deletions

44
src/constants/common.ts Normal file
View File

@@ -0,0 +1,44 @@
export enum EmailTypeEnum {
register = 'register',
findPassword = 'findPassword'
}
export const introPage = `
## 欢迎使用 Doc GPT
时间比较赶,介绍没来得及完善,先直接上怎么使用:
1. 使用邮箱注册账号。
2. 进入账号页面,添加关联账号,目前只有 openai 的账号可以添加,直接去 openai 官网,把 API Key 粘贴过来。
3. 进入模型页,创建一个模型,建议直接用 ChatGPT。
4. 在模型列表点击【对话】,即可使用 API 进行聊天。
### 模型配置
1. **提示语**:会在每个对话框的第一句自动加入,用于限定该模型的对话内容。
2. **单句最大长度**:每个聊天,单次输入内容的最大长度。
3. **上下文最大长度**每个聊天最多的轮数除以2建议设置为偶数。可以持续聊天但是旧的聊天内容会被截断AI 就不会知道被截取的内容。
例如上下文最大长度为6。在第 4 轮对话时,第一轮对话的内容不会被计入。
4. **过期时间**:生成对话框后,这个对话框多久过期。
5. **聊天最大加载次数**:单个对话框最多被加载几次,设置为-1代表不限制正数代表只能加载 n 次,防止被盗刷。
### 对话框介绍
1. 每个对话框以 windowId 作为标识。
2. 每次点击【对话】,都会生成新的对话框,无法回到旧的对话框。对话框内刷新,会恢复对话内容。
3. 直接分享对话框(网页)的链接给朋友,会共享同一个对话内容。但是!!!千万不要两个人同时用一个链接,会串味,还没解决这个问题。
4. 如果想分享一个纯的对话框,可以把链接里 windowId 参数去掉。例如:
* 当前网页链接http://docgpt.ahapocket.cn/chat?chatId=6402c9f64cb5d6283f764&windowId=6402c94cb5d6283f76fb49
* 分享链接应为http://docgpt.ahapocket.cn/chat?chatId=6402c9f64cb5d6283f764
### 其他问题
还有其他问题,可以加我 wx拉个交流群大家一起聊聊。
![](/imgs/erweima.jpg)
`;

53
src/constants/model.ts Normal file
View File

@@ -0,0 +1,53 @@
export enum OpenAiModelEnum {
GPT35 = 'gpt-3.5-turbo',
GPT3 = 'text-davinci-003'
}
export const OpenAiList = [
{
name: 'chatGPT',
model: OpenAiModelEnum.GPT35,
trainName: 'turbo',
canTraining: false,
maxToken: 4060
},
{
name: 'GPT3',
model: OpenAiModelEnum.GPT3,
trainName: 'davinci',
canTraining: true,
maxToken: 4060
}
];
export enum TrainingStatusEnum {
pending = 'pending',
succeed = 'succeed',
errored = 'errored',
canceled = 'canceled'
}
export enum ModelStatusEnum {
running = 'running',
training = 'training',
pending = 'pending',
closed = 'closed'
}
export const formatModelStatus = {
[ModelStatusEnum.running]: {
colorTheme: 'green',
text: '运行中'
},
[ModelStatusEnum.training]: {
colorTheme: 'blue',
text: '训练中'
},
[ModelStatusEnum.pending]: {
colorTheme: 'gray',
text: '加载中'
},
[ModelStatusEnum.closed]: {
colorTheme: 'red',
text: '已关闭'
}
};

View File

@@ -0,0 +1,20 @@
export const ERROR_CODE: { [key: number]: string } = {
400: '请求失败',
401: '无权访问',
403: '紧张访问',
404: '请求不存在',
405: '请求方法错误',
406: '请求的格式错误',
410: '资源已删除',
422: '验证错误',
500: '服务器发生错误',
502: '网关错误',
503: '服务器暂时过载或维护',
504: '网关超时'
};
export const TOKEN_ERROR_CODE: { [key: number]: string } = {
506: '请先登录',
507: '请重新登录',
508: '登录已过期'
};

87
src/constants/theme.ts Normal file
View File

@@ -0,0 +1,87 @@
import { extendTheme, defineStyleConfig } from '@chakra-ui/react';
// @ts-ignore
import { modalAnatomy as parts } from '@chakra-ui/anatomy';
// @ts-ignore
import { createMultiStyleConfigHelpers } from '@chakra-ui/styled-system';
const { definePartsStyle, defineMultiStyleConfig } = createMultiStyleConfigHelpers(parts.keys);
// modal 弹窗
const ModalTheme = defineMultiStyleConfig({
baseStyle: definePartsStyle({
dialog: {
width: '90%'
}
})
});
// 按键
const Button = defineStyleConfig({
baseStyle: {},
sizes: {
sm: {
fontSize: 'sm',
px: 3,
py: 0,
fontWeight: 'normal',
height: '26px'
},
md: {
fontSize: 'md',
px: 6,
py: 0,
height: '34px',
fontWeight: 'normal'
},
lg: {
fontSize: 'lg',
px: 8,
py: 0,
height: '42px',
fontWeight: 'normal'
}
},
variants: {
outline: {
borderWidth: '1.5px'
}
},
defaultProps: {
size: 'md',
colorScheme: 'blue'
}
});
// 全局主题
export const theme = extendTheme({
styles: {
global: {
'html, body': {
color: 'blackAlpha.800',
fontSize: '14px'
}
}
},
fonts: {
body: 'system-ui, sans-serif'
},
fontSizes: {
xs: '0.8rem',
sm: '0.9rem',
md: '1rem',
lg: '1.125rem',
xl: '1.25rem',
'2xl': '1.5rem',
'3xl': '1.875rem',
'4xl': '2.25rem',
'5xl': '3rem',
'6xl': '3.75rem',
'7xl': '4.5rem',
'8xl': '6rem',
'9xl': '8rem'
},
components: {
Modal: ModalTheme,
Button
}
});

5
src/constants/user.ts Normal file
View File

@@ -0,0 +1,5 @@
export enum PageTypeEnum {
login = 'login',
register = 'register',
forgetPassword = 'forgetPassword'
}