feat: 使用说明&价格表
This commit is contained in:
parent
4d64068591
commit
81e6821174
File diff suppressed because one or more lines are too long
@ -8,11 +8,12 @@ export const introPage = `
|
|||||||
|
|
||||||
[Git 仓库](https://github.com/c121914yu/FastGPT)
|
[Git 仓库](https://github.com/c121914yu/FastGPT)
|
||||||
|
|
||||||
时间比较赶,介绍没来得及完善,先直接上怎么使用:
|
### 快速开始
|
||||||
1. 使用邮箱注册账号。
|
1. 使用邮箱注册账号。
|
||||||
2. 进入账号页面,添加关联账号,目前只有 openai 的账号可以添加,直接去 openai 官网,把 API Key 粘贴过来。
|
2. 进入账号页面,添加关联账号,目前只有 openai 的账号可以添加,直接去 openai 官网,把 API Key 粘贴过来。
|
||||||
3. 进入模型页,创建一个模型,建议直接用 ChatGPT。
|
3. 如果填写了自己的 openai 账号,使用时会直接用你的账号。如果没有填写,需要付费使用平台的账号。
|
||||||
4. 在模型列表点击【对话】,即可使用 API 进行聊天。
|
4. 进入模型页,创建一个模型,建议直接用 ChatGPT。
|
||||||
|
5. 在模型列表点击【对话】,即可使用 API 进行聊天。
|
||||||
|
|
||||||
### 模型配置
|
### 模型配置
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export type ModelConstantsData = {
|
|||||||
price: number; // 多少钱 / 1字,单位: 0.00001元
|
price: number; // 多少钱 / 1字,单位: 0.00001元
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ModelList: ModelConstantsData[] = [
|
export const modelList: ModelConstantsData[] = [
|
||||||
{
|
{
|
||||||
serviceCompany: 'openai',
|
serviceCompany: 'openai',
|
||||||
name: 'chatGPT',
|
name: 'chatGPT',
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { ChatItemType } from '@/types/chat';
|
|||||||
import { jsonRes } from '@/service/response';
|
import { jsonRes } from '@/service/response';
|
||||||
import type { ModelSchema } from '@/types/mongoSchema';
|
import type { ModelSchema } from '@/types/mongoSchema';
|
||||||
import { PassThrough } from 'stream';
|
import { PassThrough } from 'stream';
|
||||||
import { ModelList } from '@/constants/model';
|
import { modelList } from '@/constants/model';
|
||||||
import { pushBill } from '@/service/events/bill';
|
import { pushBill } from '@/service/events/bill';
|
||||||
|
|
||||||
/* 发送提示词 */
|
/* 发送提示词 */
|
||||||
@ -60,7 +60,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 计算温度
|
// 计算温度
|
||||||
const modelConstantsData = ModelList.find((item) => item.model === model.service.modelName);
|
const modelConstantsData = modelList.find((item) => item.model === model.service.modelName);
|
||||||
if (!modelConstantsData) {
|
if (!modelConstantsData) {
|
||||||
throw new Error('模型异常');
|
throw new Error('模型异常');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { connectToDatabase } from '@/service/mongo';
|
|||||||
import { getOpenAIApi, authChat } from '@/service/utils/chat';
|
import { getOpenAIApi, authChat } from '@/service/utils/chat';
|
||||||
import { ChatItemType } from '@/types/chat';
|
import { ChatItemType } from '@/types/chat';
|
||||||
import { httpsAgent } from '@/service/utils/tools';
|
import { httpsAgent } from '@/service/utils/tools';
|
||||||
import { ModelList } from '@/constants/model';
|
import { modelList } from '@/constants/model';
|
||||||
import { pushBill } from '@/service/events/bill';
|
import { pushBill } from '@/service/events/bill';
|
||||||
|
|
||||||
/* 发送提示词 */
|
/* 发送提示词 */
|
||||||
@ -31,7 +31,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
const formatPrompts = prompt.map((item) => `${item.value}\n\n###\n\n`).join('');
|
const formatPrompts = prompt.map((item) => `${item.value}\n\n###\n\n`).join('');
|
||||||
|
|
||||||
// 计算温度
|
// 计算温度
|
||||||
const modelConstantsData = ModelList.find((item) => item.model === model.service.modelName);
|
const modelConstantsData = modelList.find((item) => item.model === model.service.modelName);
|
||||||
if (!modelConstantsData) {
|
if (!modelConstantsData) {
|
||||||
throw new Error('模型异常');
|
throw new Error('模型异常');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';
|
|||||||
import { jsonRes } from '@/service/response';
|
import { jsonRes } from '@/service/response';
|
||||||
import { connectToDatabase } from '@/service/mongo';
|
import { connectToDatabase } from '@/service/mongo';
|
||||||
import { authToken } from '@/service/utils/tools';
|
import { authToken } from '@/service/utils/tools';
|
||||||
import { ModelStatusEnum, ModelList, ChatModelNameEnum } from '@/constants/model';
|
import { ModelStatusEnum, modelList, ChatModelNameEnum } from '@/constants/model';
|
||||||
import { Model } from '@/service/models/model';
|
import { Model } from '@/service/models/model';
|
||||||
|
|
||||||
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
|
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
|
||||||
@ -25,7 +25,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
|||||||
// 凭证校验
|
// 凭证校验
|
||||||
const userId = await authToken(authorization);
|
const userId = await authToken(authorization);
|
||||||
|
|
||||||
const modelItem = ModelList.find((item) => item.model === serviceModelName);
|
const modelItem = modelList.find((item) => item.model === serviceModelName);
|
||||||
|
|
||||||
if (!modelItem) {
|
if (!modelItem) {
|
||||||
throw new Error('模型不存在');
|
throw new Error('模型不存在');
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import {
|
|||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { postCreateModel } from '@/api/model';
|
import { postCreateModel } from '@/api/model';
|
||||||
import type { ModelSchema } from '@/types/mongoSchema';
|
import type { ModelSchema } from '@/types/mongoSchema';
|
||||||
import { ModelList } from '@/constants/model';
|
import { modelList } from '@/constants/model';
|
||||||
import { formatPrice } from '@/utils/user';
|
import { formatPrice } from '@/utils/user';
|
||||||
|
|
||||||
interface CreateFormType {
|
interface CreateFormType {
|
||||||
@ -45,7 +45,7 @@ const CreateModel = ({
|
|||||||
formState: { errors }
|
formState: { errors }
|
||||||
} = useForm<CreateFormType>({
|
} = useForm<CreateFormType>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
serviceModelName: ModelList[0].model
|
serviceModelName: modelList[0].model
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ const CreateModel = ({
|
|||||||
required: '底层模型不能为空'
|
required: '底层模型不能为空'
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{ModelList.map((item) => (
|
{modelList.map((item) => (
|
||||||
<option key={item.model} value={item.model}>
|
<option key={item.model} value={item.model}>
|
||||||
{item.name}
|
{item.name}
|
||||||
</option>
|
</option>
|
||||||
@ -110,7 +110,7 @@ const CreateModel = ({
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
<Box mt={3} textAlign={'center'} fontSize={'sm'} color={'blackAlpha.600'}>
|
<Box mt={3} textAlign={'center'} fontSize={'sm'} color={'blackAlpha.600'}>
|
||||||
{formatPrice(
|
{formatPrice(
|
||||||
ModelList.find((item) => item.model === getValues('serviceModelName'))?.price || 0
|
modelList.find((item) => item.model === getValues('serviceModelName'))?.price || 0
|
||||||
) * 1000}
|
) * 1000}
|
||||||
元/1000字(包括上下文和标点符号)
|
元/1000字(包括上下文和标点符号)
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import { Card, Box, Flex, Button, Tag, Grid } from '@chakra-ui/react';
|
|||||||
import { useToast } from '@/hooks/useToast';
|
import { useToast } from '@/hooks/useToast';
|
||||||
import { useConfirm } from '@/hooks/useConfirm';
|
import { useConfirm } from '@/hooks/useConfirm';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { formatModelStatus, ModelStatusEnum, ModelList, defaultModel } from '@/constants/model';
|
import { formatModelStatus, ModelStatusEnum, modelList, defaultModel } from '@/constants/model';
|
||||||
import { useGlobalStore } from '@/store/global';
|
import { useGlobalStore } from '@/store/global';
|
||||||
import { useScreen } from '@/hooks/useScreen';
|
import { useScreen } from '@/hooks/useScreen';
|
||||||
import ModelEditForm from './components/ModelEditForm';
|
import ModelEditForm from './components/ModelEditForm';
|
||||||
@ -38,7 +38,7 @@ const ModelDetail = ({ modelId }: { modelId: string }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const canTrain = useMemo(() => {
|
const canTrain = useMemo(() => {
|
||||||
const openai = ModelList.find((item) => item.model === model?.service.modelName);
|
const openai = modelList.find((item) => item.model === model?.service.modelName);
|
||||||
return openai && openai.trainName;
|
return openai && openai.trainName;
|
||||||
}, [model]);
|
}, [model]);
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import { useUserStore } from '@/store/user';
|
|||||||
|
|
||||||
const CreateModel = dynamic(() => import('./components/CreateModel'));
|
const CreateModel = dynamic(() => import('./components/CreateModel'));
|
||||||
|
|
||||||
const ModelList = () => {
|
const modelList = () => {
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { isPc } = useScreen();
|
const { isPc } = useScreen();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -87,4 +87,4 @@ const ModelList = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ModelList;
|
export default modelList;
|
||||||
|
|||||||
@ -10,12 +10,21 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
Input,
|
Input,
|
||||||
Box,
|
Box,
|
||||||
Grid
|
Grid,
|
||||||
|
Table,
|
||||||
|
Thead,
|
||||||
|
Tbody,
|
||||||
|
Tr,
|
||||||
|
Th,
|
||||||
|
Td,
|
||||||
|
TableContainer
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { getPayCode, checkPayResult } from '@/api/user';
|
import { getPayCode, checkPayResult } from '@/api/user';
|
||||||
import { useToast } from '@/hooks/useToast';
|
import { useToast } from '@/hooks/useToast';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
|
import { modelList } from '@/constants/model';
|
||||||
|
import { formatPrice } from '../../../utils/user';
|
||||||
|
|
||||||
const PayModal = ({ onClose }: { onClose: () => void }) => {
|
const PayModal = ({ onClose }: { onClose: () => void }) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -82,9 +91,28 @@ const PayModal = ({ onClose }: { onClose: () => void }) => {
|
|||||||
<ModalHeader>充值</ModalHeader>
|
<ModalHeader>充值</ModalHeader>
|
||||||
{!payId && <ModalCloseButton />}
|
{!payId && <ModalCloseButton />}
|
||||||
|
|
||||||
<ModalBody>
|
<ModalBody py={0}>
|
||||||
{!payId && (
|
{!payId && (
|
||||||
<>
|
<>
|
||||||
|
{/* 价格表 */}
|
||||||
|
<TableContainer mb={4}>
|
||||||
|
<Table>
|
||||||
|
<Thead>
|
||||||
|
<Tr>
|
||||||
|
<Th>模型类型</Th>
|
||||||
|
<Th>价格(元/1000字符,包含所有上下文)</Th>
|
||||||
|
</Tr>
|
||||||
|
</Thead>
|
||||||
|
<Tbody>
|
||||||
|
{modelList.map((item, i) => (
|
||||||
|
<Tr key={item.model}>
|
||||||
|
<Td>{item.name}</Td>
|
||||||
|
<Td>{formatPrice(item.price) * 1000}</Td>
|
||||||
|
</Tr>
|
||||||
|
))}
|
||||||
|
</Tbody>
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
<Grid gridTemplateColumns={'repeat(4,1fr)'} gridGap={5} mb={4}>
|
<Grid gridTemplateColumns={'repeat(4,1fr)'} gridGap={5} mb={4}>
|
||||||
{[5, 10, 20, 50].map((item) => (
|
{[5, 10, 20, 50].map((item) => (
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -123,6 +123,9 @@ const NumberSetting = () => {
|
|||||||
充值
|
充值
|
||||||
</Button>
|
</Button>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
<Box fontSize={'xs'} color={'blackAlpha.500'}>
|
||||||
|
如果填写了自己的 openai 账号,将不会计费
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Card>
|
</Card>
|
||||||
<Card mt={6} px={6} py={4}>
|
<Card mt={6} px={6} py={4}>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { connectToDatabase, Bill, User } from '../mongo';
|
import { connectToDatabase, Bill, User } from '../mongo';
|
||||||
import { ModelList } from '@/constants/model';
|
import { modelList } from '@/constants/model';
|
||||||
|
|
||||||
export const pushBill = async ({
|
export const pushBill = async ({
|
||||||
modelName,
|
modelName,
|
||||||
@ -14,7 +14,7 @@ export const pushBill = async ({
|
|||||||
}) => {
|
}) => {
|
||||||
await connectToDatabase();
|
await connectToDatabase();
|
||||||
|
|
||||||
const modelItem = ModelList.find((item) => item.model === modelName);
|
const modelItem = modelList.find((item) => item.model === modelName);
|
||||||
|
|
||||||
if (!modelItem) return;
|
if (!modelItem) return;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user