Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
81e68211
authored
Mar 24, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 使用说明&价格表
parent
4d640685
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
54 additions
and
22 deletions
+54
-22
public/test.txt
+0
-0
src/constants/common.ts
+4
-3
src/constants/model.ts
+1
-1
src/pages/api/chat/chatGpt.ts
+2
-2
src/pages/api/chat/gpt3.ts
+2
-2
src/pages/api/model/create.ts
+2
-2
src/pages/model/components/CreateModel.tsx
+4
-4
src/pages/model/detail.tsx
+2
-2
src/pages/model/list.tsx
+2
-2
src/pages/number/components/PayModal.tsx
+30
-2
src/pages/number/setting.tsx
+3
-0
src/service/events/bill.ts
+2
-2
No files found.
public/test.txt
deleted
100644 → 0
View file @
4d640685
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/constants/common.ts
View file @
81e68211
...
@@ -8,11 +8,12 @@ export const introPage = `
...
@@ -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 进行聊天。
### 模型配置
### 模型配置
...
...
src/constants/model.ts
View file @
81e68211
...
@@ -16,7 +16,7 @@ export type ModelConstantsData = {
...
@@ -16,7 +16,7 @@ export type ModelConstantsData = {
price
:
number
;
// 多少钱 / 1字,单位: 0.00001元
price
:
number
;
// 多少钱 / 1字,单位: 0.00001元
};
};
export
const
M
odelList
:
ModelConstantsData
[]
=
[
export
const
m
odelList
:
ModelConstantsData
[]
=
[
{
{
serviceCompany
:
'openai'
,
serviceCompany
:
'openai'
,
name
:
'chatGPT'
,
name
:
'chatGPT'
,
...
...
src/pages/api/chat/chatGpt.ts
View file @
81e68211
...
@@ -8,7 +8,7 @@ import { ChatItemType } from '@/types/chat';
...
@@ -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
{
M
odelList
}
from
'@/constants/model'
;
import
{
m
odelList
}
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)
...
@@ -60,7 +60,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
}
// 计算温度
// 计算温度
const
modelConstantsData
=
M
odelList
.
find
((
item
)
=>
item
.
model
===
model
.
service
.
modelName
);
const
modelConstantsData
=
m
odelList
.
find
((
item
)
=>
item
.
model
===
model
.
service
.
modelName
);
if
(
!
modelConstantsData
)
{
if
(
!
modelConstantsData
)
{
throw
new
Error
(
'模型异常'
);
throw
new
Error
(
'模型异常'
);
}
}
...
...
src/pages/api/chat/gpt3.ts
View file @
81e68211
...
@@ -5,7 +5,7 @@ import { connectToDatabase } from '@/service/mongo';
...
@@ -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
{
M
odelList
}
from
'@/constants/model'
;
import
{
m
odelList
}
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)
...
@@ -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
=
M
odelList
.
find
((
item
)
=>
item
.
model
===
model
.
service
.
modelName
);
const
modelConstantsData
=
m
odelList
.
find
((
item
)
=>
item
.
model
===
model
.
service
.
modelName
);
if
(
!
modelConstantsData
)
{
if
(
!
modelConstantsData
)
{
throw
new
Error
(
'模型异常'
);
throw
new
Error
(
'模型异常'
);
}
}
...
...
src/pages/api/model/create.ts
View file @
81e68211
...
@@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';
...
@@ -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
,
M
odelList
,
ChatModelNameEnum
}
from
'@/constants/model'
;
import
{
ModelStatusEnum
,
m
odelList
,
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<
...
@@ -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
=
M
odelList
.
find
((
item
)
=>
item
.
model
===
serviceModelName
);
const
modelItem
=
m
odelList
.
find
((
item
)
=>
item
.
model
===
serviceModelName
);
if
(
!
modelItem
)
{
if
(
!
modelItem
)
{
throw
new
Error
(
'模型不存在'
);
throw
new
Error
(
'模型不存在'
);
...
...
src/pages/model/components/CreateModel.tsx
View file @
81e68211
...
@@ -18,7 +18,7 @@ import {
...
@@ -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
{
M
odelList
}
from
'@/constants/model'
;
import
{
m
odelList
}
from
'@/constants/model'
;
import
{
formatPrice
}
from
'@/utils/user'
;
import
{
formatPrice
}
from
'@/utils/user'
;
interface
CreateFormType
{
interface
CreateFormType
{
...
@@ -45,7 +45,7 @@ const CreateModel = ({
...
@@ -45,7 +45,7 @@ const CreateModel = ({
formState
:
{
errors
}
formState
:
{
errors
}
}
=
useForm
<
CreateFormType
>
({
}
=
useForm
<
CreateFormType
>
({
defaultValues
:
{
defaultValues
:
{
serviceModelName
:
M
odelList
[
0
].
model
serviceModelName
:
m
odelList
[
0
].
model
}
}
});
});
...
@@ -98,7 +98,7 @@ const CreateModel = ({
...
@@ -98,7 +98,7 @@ const CreateModel = ({
required
:
'底层模型不能为空'
required
:
'底层模型不能为空'
})}
})}
>
>
{
M
odelList
.
map
((
item
)
=>
(
{
m
odelList
.
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 = ({
...
@@ -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
(
M
odelList
.
find
((
item
)
=>
item
.
model
===
getValues
(
'serviceModelName'
))?.
price
||
0
m
odelList
.
find
((
item
)
=>
item
.
model
===
getValues
(
'serviceModelName'
))?.
price
||
0
)
*
1000
}
)
*
1000
}
元/1000字(包括上下文和标点符号)
元/1000字(包括上下文和标点符号)
</
Box
>
</
Box
>
...
...
src/pages/model/detail.tsx
View file @
81e68211
...
@@ -13,7 +13,7 @@ import { Card, Box, Flex, Button, Tag, Grid } from '@chakra-ui/react';
...
@@ -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
,
M
odelList
,
defaultModel
}
from
'@/constants/model'
;
import
{
formatModelStatus
,
ModelStatusEnum
,
m
odelList
,
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 }) => {
...
@@ -38,7 +38,7 @@ const ModelDetail = ({ modelId }: { modelId: string }) => {
});
});
const
canTrain
=
useMemo
(()
=>
{
const
canTrain
=
useMemo
(()
=>
{
const
openai
=
M
odelList
.
find
((
item
)
=>
item
.
model
===
model
?.
service
.
modelName
);
const
openai
=
m
odelList
.
find
((
item
)
=>
item
.
model
===
model
?.
service
.
modelName
);
return
openai
&&
openai
.
trainName
;
return
openai
&&
openai
.
trainName
;
},
[
model
]);
},
[
model
]);
...
...
src/pages/model/list.tsx
View file @
81e68211
...
@@ -14,7 +14,7 @@ import { useUserStore } from '@/store/user';
...
@@ -14,7 +14,7 @@ import { useUserStore } from '@/store/user';
const
CreateModel
=
dynamic
(()
=>
import
(
'./components/CreateModel'
));
const
CreateModel
=
dynamic
(()
=>
import
(
'./components/CreateModel'
));
const
M
odelList
=
()
=>
{
const
m
odelList
=
()
=>
{
const
{
toast
}
=
useToast
();
const
{
toast
}
=
useToast
();
const
{
isPc
}
=
useScreen
();
const
{
isPc
}
=
useScreen
();
const
router
=
useRouter
();
const
router
=
useRouter
();
...
@@ -87,4 +87,4 @@ const ModelList = () => {
...
@@ -87,4 +87,4 @@ const ModelList = () => {
);
);
};
};
export
default
M
odelList
;
export
default
m
odelList
;
src/pages/number/components/PayModal.tsx
View file @
81e68211
...
@@ -10,12 +10,21 @@ import {
...
@@ -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 }) => {
...
@@ -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
...
...
src/pages/number/setting.tsx
View file @
81e68211
...
@@ -123,6 +123,9 @@ const NumberSetting = () => {
...
@@ -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
}
>
...
...
src/service/events/bill.ts
View file @
81e68211
import
{
connectToDatabase
,
Bill
,
User
}
from
'../mongo'
;
import
{
connectToDatabase
,
Bill
,
User
}
from
'../mongo'
;
import
{
M
odelList
}
from
'@/constants/model'
;
import
{
m
odelList
}
from
'@/constants/model'
;
export
const
pushBill
=
async
({
export
const
pushBill
=
async
({
modelName
,
modelName
,
...
@@ -14,7 +14,7 @@ export const pushBill = async ({
...
@@ -14,7 +14,7 @@ export const pushBill = async ({
})
=>
{
})
=>
{
await
connectToDatabase
();
await
connectToDatabase
();
const
modelItem
=
M
odelList
.
find
((
item
)
=>
item
.
model
===
modelName
);
const
modelItem
=
m
odelList
.
find
((
item
)
=>
item
.
model
===
modelName
);
if
(
!
modelItem
)
return
;
if
(
!
modelItem
)
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment