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
cfb31afb
authored
Jun 25, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: select ui;perf: max link and compose
parent
5be57da4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
178 additions
and
27 deletions
+178
-27
client/.env.template
+1
-1
client/src/components/Select/index.tsx
+14
-6
client/src/pages/model/components/detail/components/Settings.tsx
+5
-5
client/src/service/mongo.ts
+3
-3
client/src/service/pg.ts
+1
-1
docs/deploy/fastgpt/docker-compose.yml
+154
-11
No files found.
client/.env.template
View file @
cfb31afb
# 运行端口,如果不是 3000 口运行,需要改成其他的。注意:不是改了这个变量就会变成其他端口,而是因为改成其他端口,才用这个变量。
# 运行端口,如果不是 3000 口运行,需要改成其他的。注意:不是改了这个变量就会变成其他端口,而是因为改成其他端口,才用这个变量。
PORT=3000
PORT=3000
# database max link
# database max link
DB_MAX_LINK=
1
5
DB_MAX_LINK=5
# 代理
# 代理
# AXIOS_PROXY_HOST=127.0.0.1
# AXIOS_PROXY_HOST=127.0.0.1
# AXIOS_PROXY_PORT=7890
# AXIOS_PROXY_PORT=7890
...
...
client/src/components/Select/index.tsx
View file @
cfb31afb
import
React
from
'react'
;
import
React
,
{
useRef
}
from
'react'
;
import
{
Menu
,
MenuButton
,
MenuList
,
MenuItem
,
Button
,
useDisclosure
}
from
'@chakra-ui/react'
;
import
{
Menu
,
MenuButton
,
MenuList
,
MenuItem
,
Button
,
useDisclosure
}
from
'@chakra-ui/react'
;
import
type
{
ButtonProps
}
from
'@chakra-ui/react'
;
import
type
{
ButtonProps
}
from
'@chakra-ui/react'
;
import
{
ChevronDownIcon
}
from
'@chakra-ui/icons'
;
import
{
ChevronDownIcon
}
from
'@chakra-ui/icons'
;
...
@@ -13,6 +13,7 @@ interface Props extends ButtonProps {
...
@@ -13,6 +13,7 @@ interface Props extends ButtonProps {
}
}
const
MySelect
=
({
placeholder
,
value
,
width
=
'auto'
,
list
,
onchange
,
...
props
}:
Props
)
=>
{
const
MySelect
=
({
placeholder
,
value
,
width
=
'auto'
,
list
,
onchange
,
...
props
}:
Props
)
=>
{
const
ref
=
useRef
<
HTMLDivElement
>
(
null
);
const
menuItemStyles
=
{
const
menuItemStyles
=
{
borderRadius
:
'sm'
,
borderRadius
:
'sm'
,
py
:
2
,
py
:
2
,
...
@@ -26,8 +27,9 @@ const MySelect = ({ placeholder, value, width = 'auto', list, onchange, ...props
...
@@ -26,8 +27,9 @@ const MySelect = ({ placeholder, value, width = 'auto', list, onchange, ...props
return
(
return
(
<
Menu
autoSelect=
{
false
}
onOpen=
{
onOpen
}
onClose=
{
onClose
}
>
<
Menu
autoSelect=
{
false
}
onOpen=
{
onOpen
}
onClose=
{
onClose
}
>
<
MenuButton
style=
{
{
width
:
'100%'
}
}
as=
{
'span'
}
>
<
MenuButton
style=
{
{
width
:
'100%'
,
position
:
'relative'
}
}
as=
{
'span'
}
>
<
Button
<
Button
ref=
{
ref
}
width=
{
width
}
width=
{
width
}
px=
{
3
}
px=
{
3
}
variant=
{
'base'
}
variant=
{
'base'
}
...
@@ -47,9 +49,15 @@ const MySelect = ({ placeholder, value, width = 'auto', list, onchange, ...props
...
@@ -47,9 +49,15 @@ const MySelect = ({ placeholder, value, width = 'auto', list, onchange, ...props
</
Button
>
</
Button
>
</
MenuButton
>
</
MenuButton
>
<
MenuList
<
MenuList
minW=
{
minW=
{
(()
=>
{
Array
.
isArray
(
width
)
?
width
.
map
((
item
)
=>
`${item} !important`
)
:
`${width} !important`
const
w
=
ref
.
current
?.
clientWidth
;
}
if
(
w
)
{
return
`${w}px !important`
;
}
return
Array
.
isArray
(
width
)
?
width
.
map
((
item
)
=>
`${item} !important`
)
:
`${width} !important`
;
})()
}
p=
{
'6px'
}
p=
{
'6px'
}
border=
{
'1px solid #fff'
}
border=
{
'1px solid #fff'
}
boxShadow=
{
'0px 2px 4px rgba(161, 167, 179, 0.25), 0px 0px 1px rgba(121, 141, 159, 0.25);'
}
boxShadow=
{
'0px 2px 4px rgba(161, 167, 179, 0.25), 0px 0px 1px rgba(121, 141, 159, 0.25);'
}
...
@@ -78,4 +86,4 @@ const MySelect = ({ placeholder, value, width = 'auto', list, onchange, ...props
...
@@ -78,4 +86,4 @@ const MySelect = ({ placeholder, value, width = 'auto', list, onchange, ...props
);
);
};
};
export
default
MySelect
;
export
default
React
.
memo
(
MySelect
)
;
client/src/pages/model/components/detail/components/Settings.tsx
View file @
cfb31afb
...
@@ -75,7 +75,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
...
@@ -75,7 +75,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
}
}
return
max
;
return
max
;
},
[
getValues
,
setValue
]);
},
[
getValues
,
setValue
,
refresh
]);
// 提交保存模型修改
// 提交保存模型修改
const
saveSubmitSuccess
=
useCallback
(
const
saveSubmitSuccess
=
useCallback
(
...
@@ -240,12 +240,12 @@ const Settings = ({ modelId }: { modelId: string }) => {
...
@@ -240,12 +240,12 @@ const Settings = ({ modelId }: { modelId: string }) => {
对话模型
对话模型
</Box>
</Box>
<MySelect
<MySelect
width={['
10
0%', '280px']}
width={['
9
0%', '280px']}
value={getValues('chat.chatModel')}
value={getValues('chat.chatModel')}
list={chatModelList.map((item) => ({
list={chatModelList.map((item) => ({
id: item.chatModel,
id: item.chatModel,
label: `
$
{
item
.
name
}
(
$
{
formatPrice
(
label: `
$
{
item
.
name
}
(
$
{
formatPrice
(
ChatModelMap
[
getValues
(
'chat.chatModel'
)
]?.
price
,
ChatModelMap
[
item
.
chatModel
]?.
price
,
1000
1000
)}
元
/
1
k
tokens
)
`
)}
元
/
1
k
tokens
)
`
}))}
}))}
...
@@ -265,7 +265,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
...
@@ -265,7 +265,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
{ label: '严谨', value: 0 },
{ label: '严谨', value: 0 },
{ label: '发散', value: 10 }
{ label: '发散', value: 10 }
]}
]}
width={['
10
0%', '260px']}
width={['
9
0%', '260px']}
min={0}
min={0}
max={10}
max={10}
activeVal={getValues('chat.temperature')}
activeVal={getValues('chat.temperature')}
...
@@ -286,7 +286,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
...
@@ -286,7 +286,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
{ label: '100', value: 100 },
{ label: '100', value: 100 },
{ label: `
$
{
tokenLimit
}
`, value: tokenLimit }
{ label: `
$
{
tokenLimit
}
`, value: tokenLimit }
]}
]}
width={['
10
0%', '260px']}
width={['
9
0%', '260px']}
min={100}
min={100}
max={tokenLimit}
max={tokenLimit}
step={50}
step={50}
...
...
client/src/service/mongo.ts
View file @
cfb31afb
...
@@ -36,9 +36,9 @@ export async function connectToDatabase(): Promise<void> {
...
@@ -36,9 +36,9 @@ export async function connectToDatabase(): Promise<void> {
global
.
mongodb
=
await
mongoose
.
connect
(
process
.
env
.
MONGODB_URI
as
string
,
{
global
.
mongodb
=
await
mongoose
.
connect
(
process
.
env
.
MONGODB_URI
as
string
,
{
bufferCommands
:
true
,
bufferCommands
:
true
,
dbName
:
process
.
env
.
MONGODB_NAME
,
dbName
:
process
.
env
.
MONGODB_NAME
,
maxConnecting
:
Number
(
process
.
env
.
DB_MAX_LINK
||
10
),
maxConnecting
:
Number
(
process
.
env
.
DB_MAX_LINK
||
5
),
maxPoolSize
:
Number
(
process
.
env
.
DB_MAX_LINK
||
10
),
maxPoolSize
:
Number
(
process
.
env
.
DB_MAX_LINK
||
5
),
minPoolSize
:
5
minPoolSize
:
2
});
});
console
.
log
(
'mongo connected'
);
console
.
log
(
'mongo connected'
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
client/src/service/pg.ts
View file @
cfb31afb
...
@@ -12,7 +12,7 @@ export const connectPg = async () => {
...
@@ -12,7 +12,7 @@ export const connectPg = async () => {
user
:
process
.
env
.
PG_USER
,
user
:
process
.
env
.
PG_USER
,
password
:
process
.
env
.
PG_PASSWORD
,
password
:
process
.
env
.
PG_PASSWORD
,
database
:
process
.
env
.
PG_DB_NAME
,
database
:
process
.
env
.
PG_DB_NAME
,
max
:
Number
(
process
.
env
.
DB_MAX_LINK
||
10
),
max
:
Number
(
process
.
env
.
DB_MAX_LINK
||
5
),
idleTimeoutMillis
:
30000
,
idleTimeoutMillis
:
30000
,
connectionTimeoutMillis
:
5000
connectionTimeoutMillis
:
5000
});
});
...
...
docs/deploy/fastgpt/docker-compose.yml
View file @
cfb31afb
#
host 版本。
#
非 host 版本, 不使用本机代理
version
:
'
3.3'
version
:
'
3.3'
services
:
services
:
pg
:
pg
:
...
@@ -6,8 +6,10 @@ services:
...
@@ -6,8 +6,10 @@ services:
image
:
registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.4.2
# 阿里云
image
:
registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.4.2
# 阿里云
container_name
:
pg
container_name
:
pg
restart
:
always
restart
:
always
ports
:
ports
:
# 生产环境建议不要暴露
-
8100:5432
-
8100:5432
networks
:
-
fastgpt
environment
:
environment
:
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
-
POSTGRES_USER=fastgpt
-
POSTGRES_USER=fastgpt
...
@@ -17,13 +19,15 @@ services:
...
@@ -17,13 +19,15 @@ services:
# 刚创建的文件
# 刚创建的文件
-
/root/fastgpt/pg/init.sql:/docker-entrypoint-initdb.d/init.sh
-
/root/fastgpt/pg/init.sql:/docker-entrypoint-initdb.d/init.sh
-
/root/fastgpt/pg/data:/var/lib/postgresql/data
-
/root/fastgpt/pg/data:/var/lib/postgresql/data
mongo
db
:
mongo
:
# image: mongo:5.0.18
# image: mongo:5.0.18
image
:
registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18
# 阿里云
image
:
registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18
# 阿里云
container_name
:
mongo
container_name
:
mongo
restart
:
always
restart
:
always
ports
:
ports
:
# 生产环境建议不要暴露
-
27017:27017
-
27017:27017
networks
:
-
fastgpt
environment
:
environment
:
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
-
MONGO_INITDB_ROOT_USERNAME=username
-
MONGO_INITDB_ROOT_USERNAME=username
...
@@ -32,14 +36,21 @@ services:
...
@@ -32,14 +36,21 @@ services:
-
/root/fastgpt/mongo/data:/data/db
-
/root/fastgpt/mongo/data:/data/db
-
/root/fastgpt/mongo/logs:/var/log/mongodb
-
/root/fastgpt/mongo/logs:/var/log/mongodb
fastgpt
:
fastgpt
:
container_name
:
fastgpt
# image: c121914yu/fast-gpt:latest # docker hub
# image: c121914yu/fast-gpt:latest # docker hub
image
:
registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest
# 阿里云
image
:
registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest
# 阿里云
# network_mode: host #
# network_mode: host #
ports
:
-
3000:3000
networks
:
-
fastgpt
depends_on
:
-
mongo
-
pg
restart
:
always
restart
:
always
container_name
:
fastgpt
environment
:
# 可选的变量,不需要的话需要去掉
environment
:
# 可选的变量,不需要的话需要去掉
-
PORT=3000
# 运行的端口地址,如果不是 3000,需要修改成实际地址。
-
PORT=3000
# 运行的端口地址,如果不是 3000,需要修改成实际地址。
-
DB_MAX_LINK=
1
5
# database max link
-
DB_MAX_LINK=5
# database max link
# proxy(可选)
# proxy(可选)
-
AXIOS_PROXY_HOST=127.0.0.1
-
AXIOS_PROXY_HOST=127.0.0.1
-
AXIOS_PROXY_PORT=7890
-
AXIOS_PROXY_PORT=7890
...
@@ -59,10 +70,10 @@ services:
...
@@ -59,10 +70,10 @@ services:
# root key, 最高权限,可以内部接口互相调用
# root key, 最高权限,可以内部接口互相调用
-
ROOT_KEY=root_key
-
ROOT_KEY=root_key
# 和上方mongo镜像的username,password对应
# 和上方mongo镜像的username,password对应
-
MONGODB_URI=mongodb://username:password@
0.0.0.0
:27017/?authSource=admin
-
MONGODB_URI=mongodb://username:password@
mongo
:27017/?authSource=admin
-
MONGODB_NAME=fastgpt
-
MONGODB_NAME=fastgpt
-
PG_HOST=
0.0.0.0
-
PG_HOST=
pg
-
PG_PORT=
8100
-
PG_PORT=
5432
# 和上方PG镜像对应.
# 和上方PG镜像对应.
-
PG_USER=fastgpt
-
PG_USER=fastgpt
-
PG_PASSWORD=1234
-
PG_PASSWORD=1234
...
@@ -80,13 +91,18 @@ services:
...
@@ -80,13 +91,18 @@ services:
restart
:
always
restart
:
always
ports
:
ports
:
-
3001:3001
-
3001:3001
networks
:
-
fastgpt
depends_on
:
-
mongo
-
fastgpt
environment
:
environment
:
-
MONGODB_URI=mongodb://username:password@
0.0.0.0
:27017/?authSource=admin
-
MONGODB_URI=mongodb://username:password@
mongo
:27017/?authSource=admin
-
MONGODB_NAME=fastgpt
-
MONGODB_NAME=fastgpt
-
ADMIN_USER=username
-
ADMIN_USER=username
-
ADMIN_PASS=password
-
ADMIN_PASS=password
-
ADMIN_SECRET=any
-
ADMIN_SECRET=any
-
PARENT_URL=http://
0.0.0.0
:3000
-
PARENT_URL=http://
fastgpt
:3000
-
PARENT_ROOT_KEY=root_key
-
PARENT_ROOT_KEY=root_key
key-admin
:
key-admin
:
container_name
:
key-admin
container_name
:
key-admin
...
@@ -111,3 +127,130 @@ services:
...
@@ -111,3 +127,130 @@ services:
# https证书,没有的话不填,对应的nginx.conf也要修改
# https证书,没有的话不填,对应的nginx.conf也要修改
-
/root/fastgpt/nginx/ssl/docgpt.key:/ssl/docgpt.key
-
/root/fastgpt/nginx/ssl/docgpt.key:/ssl/docgpt.key
-
/root/fastgpt/nginx/ssl/docgpt.pem:/ssl/docgpt.pem
-
/root/fastgpt/nginx/ssl/docgpt.pem:/ssl/docgpt.pem
networks
:
fastgpt
:
# host 版本, 不推荐,推荐直接用上面的,用个 BASE_URL 中转
# version: '3.3'
# services:
# pg:
# # image: ankane/pgvector:v0.4.2 # dockerhub
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.4.2 # 阿里云
# container_name: pg
# restart: always
# ports: # 生产环境建议不要暴露
# - 8100:5432
# networks:
# - fastgpt
# environment:
# # 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
# - POSTGRES_USER=fastgpt
# - POSTGRES_PASSWORD=1234
# - POSTGRES_DB=fastgpt
# volumes:
# # 刚创建的文件
# - /root/fastgpt/pg/init.sql:/docker-entrypoint-initdb.d/init.sh
# - /root/fastgpt/pg/data:/var/lib/postgresql/data
# mongo:
# # image: mongo:5.0.18
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # 阿里云
# container_name: mongo
# restart: always
# ports: # 生产环境建议不要暴露
# - 27017:27017
# networks:
# - fastgpt
# environment:
# # 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
# - MONGO_INITDB_ROOT_USERNAME=username
# - MONGO_INITDB_ROOT_PASSWORD=password
# volumes:
# - /root/fastgpt/mongo/data:/data/db
# - /root/fastgpt/mongo/logs:/var/log/mongodb
# fastgpt:
# # image: ghcr.io/c121914yu/fastgpt:latest # github
# # image: c121914yu/fast-gpt:latest # docker hub
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest # 阿里云
# network_mode: host
# restart: always
# container_name: fastgpt
# environment: # 可选的变量,不需要的话需要去掉
# - PORT=3000 # 运行的端口地址,如果不是 3000,需要修改成实际地址。
# - DB_MAX_LINK=15 # database max link
# # proxy(可选)
# - AXIOS_PROXY_HOST=127.0.0.1
# - AXIOS_PROXY_PORT=7890
# # 发送邮箱验证码配置。用的是QQ邮箱。参考 nodeMail 获取MAILE_CODE,自行百度。
# - MY_MAIL=54545@qq.com
# - MAILE_CODE=1234
# # 阿里短信服务(邮箱和短信至少二选一)
# - aliAccessKeyId=xxxx
# - aliAccessKeySecret=xxxx
# - aliSignName=xxxxx
# - aliTemplateCode=SMS_xxxx
# # google V3 安全校验(可选)
# - CLIENT_GOOGLE_VER_TOKEN=xxx
# - SERVICE_GOOGLE_VER_TOKEN=xx
# # token加密凭证(随便填,作为登录凭证)
# - TOKEN_KEY=xxxx
# # root key, 最高权限,可以内部接口互相调用
# - ROOT_KEY=xxx
# # 和上方mongo镜像的username,password对应
# - MONGODB_URI=mongodb://username:password@0.0.0.0:27017/?authSource=admin
# - MONGODB_NAME=fastgpt
# - PG_HOST=0.0.0.0
# - PG_PORT=8100
# # 和上方PG镜像对应.
# - PG_USER=fastgpt
# - PG_PASSWORD=1234
# - PG_DB_NAME=fastgpt
# # oneapi 配置 推荐使用 one-api 管理key
# - ONEAPI_URL=https://kfcwurtbijvh.cloud.sealos.io/v1
# - ONEAPI_KEY=sk-itJ9v8qthRiFDzfs62Ea21Aa9b004c8791937dCf4cC568Ff
# # openai 相关配置:使用了 oneapi 后,下面只需要填下 OPENAI_BASE_URL (国外可全忽略)
# - OPENAIKEY=sk-xxxxx
# - OPENAI_BASE_URL=https://api.openai.com/v1
# - OPENAI_BASE_URL_AUTH=可选的安全凭证,会放到 header.auth 里
# fastgpt-admin:
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-admin:latest
# container_name: fastgpt-admin
# restart: always
# ports:
# - 3001:3001
# networks:
# - fastgpt
# depends_on:
# - mongo
# - fastgpt
# environment:
# - MONGODB_URI=mongodb://username:password@mongo:27017/?authSource=admin
# - MONGODB_NAME=fastgpt
# - ADMIN_USER=username
# - ADMIN_PASS=password
# - ADMIN_SECRET=any
# - PARENT_URL=http://fastgpt:3000
# - PARENT_ROOT_KEY=root_key
# key-admin:
# container_name: key-admin
# image: justsong/one-api
# restart: always
# ports:
# - 3002:3000
# environment:
# - TZ=Asia/Shanghai
# volumes:
# - /home/ubuntu/data/one-api:/data
# nginx: # 宝塔不需要额外装 nginx
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/nginx:alpine3.17
# # image: nginx:alpine3.17
# container_name: nginx
# restart: always
# network_mode: host
# volumes:
# # 刚创建的文件
# - /root/fastgpt/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
# - /root/fastgpt/nginx/logs:/var/log/nginx
# # https证书,没有的话不填,对应的nginx.conf也要修改
# - /root/fastgpt/nginx/ssl/docgpt.key:/ssl/docgpt.key
# - /root/fastgpt/nginx/ssl/docgpt.pem:/ssl/docgpt.pem
# networks:
# fastgpt:
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