mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
configmap
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"FastAI-4k": {
|
||||
"model": "gpt-3.5-turbo",
|
||||
"name": "FastAI-4k",
|
||||
"contextMaxToken": 4000,
|
||||
"systemMaxToken": 2400,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 1.5
|
||||
},
|
||||
"FastAI-16k": {
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "FastAI-16k",
|
||||
"contextMaxToken": 16000,
|
||||
"systemMaxToken": 8000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 3
|
||||
},
|
||||
"FastAI-Plus": {
|
||||
"model": "gpt-4",
|
||||
"name": "FastAI-Plus",
|
||||
"contextMaxToken": 8000,
|
||||
"systemMaxToken": 4000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 45
|
||||
}
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"show_emptyChat": true,
|
||||
"show_register": true,
|
||||
"show_appStore": true,
|
||||
"show_userDetail": true,
|
||||
"show_git": true,
|
||||
"systemTitle": "FastAI",
|
||||
"authorText": "Made by FastAI Team."
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"FastAI-16k": {
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "FastAI-16k",
|
||||
"maxToken": 16000,
|
||||
"price": 3
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"vectorMaxProcess": 15,
|
||||
"qaMaxProcess": 15,
|
||||
"pgIvfflatProbe": 20,
|
||||
"sensitiveCheck": false
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"text-embedding-ada-002": {
|
||||
"model": "text-embedding-ada-002",
|
||||
"name": "Embedding-2",
|
||||
"price": 0.2
|
||||
}
|
||||
}
|
61
client/data/config.json
Normal file
61
client/data/config.json
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"FeConfig": {
|
||||
"show_emptyChat": true,
|
||||
"show_register": true,
|
||||
"show_appStore": true,
|
||||
"show_userDetail": true,
|
||||
"show_git": true,
|
||||
"systemTitle": "FastAI",
|
||||
"authorText": "Made by FastAI Team."
|
||||
},
|
||||
"SystemParams": {
|
||||
"beianText": "",
|
||||
"googleVerKey": "",
|
||||
"baiduTongji": "",
|
||||
"vectorMaxProcess": 15,
|
||||
"qaMaxProcess": 15,
|
||||
"pgIvfflatProbe": 20,
|
||||
"sensitiveCheck": false
|
||||
},
|
||||
"ChatModels": [
|
||||
{
|
||||
"model": "gpt-3.5-turbo",
|
||||
"name": "FastAI-4k",
|
||||
"contextMaxToken": 4000,
|
||||
"systemMaxToken": 2400,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 1.5
|
||||
},
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "FastAI-16k",
|
||||
"contextMaxToken": 16000,
|
||||
"systemMaxToken": 8000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 3
|
||||
},
|
||||
{
|
||||
"model": "gpt-4",
|
||||
"name": "FastAI-Plus",
|
||||
"contextMaxToken": 8000,
|
||||
"systemMaxToken": 4000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 45
|
||||
}
|
||||
],
|
||||
"QAModels": [
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "FastAI-16k",
|
||||
"maxToken": 16000,
|
||||
"price": 3
|
||||
}
|
||||
],
|
||||
"VectorModels": [
|
||||
{
|
||||
"model": "text-embedding-ada-002",
|
||||
"name": "Embedding-2",
|
||||
"price": 0.2
|
||||
}
|
||||
]
|
||||
}
|
@@ -19,50 +19,47 @@ const Navbar = ({ unread }: { unread: number }) => {
|
||||
const router = useRouter();
|
||||
const { userInfo } = useUserStore();
|
||||
const { lastChatAppId, lastChatId } = useChatStore();
|
||||
const navbarList = useMemo(
|
||||
() => [
|
||||
{
|
||||
label: '聊天',
|
||||
icon: 'chatLight',
|
||||
activeIcon: 'chatFill',
|
||||
link: `/chat?appId=${lastChatAppId}&chatId=${lastChatId}`,
|
||||
activeLink: ['/chat']
|
||||
},
|
||||
{
|
||||
label: '应用',
|
||||
icon: 'appLight',
|
||||
activeIcon: 'appFill',
|
||||
link: `/app/list`,
|
||||
activeLink: ['/app/list', '/app/detail']
|
||||
},
|
||||
{
|
||||
label: '知识库',
|
||||
icon: 'dbLight',
|
||||
activeIcon: 'dbFill',
|
||||
link: `/kb/list`,
|
||||
activeLink: ['/kb/list', '/kb/detail']
|
||||
},
|
||||
...(feConfigs?.show_appStore
|
||||
? [
|
||||
{
|
||||
label: '市场',
|
||||
icon: 'appStoreLight',
|
||||
activeIcon: 'appStoreFill',
|
||||
link: '/appStore',
|
||||
activeLink: ['/appStore']
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: '账号',
|
||||
icon: 'meLight',
|
||||
activeIcon: 'meFill',
|
||||
link: '/number',
|
||||
activeLink: ['/number']
|
||||
}
|
||||
],
|
||||
[lastChatId, lastChatAppId]
|
||||
);
|
||||
const navbarList = [
|
||||
{
|
||||
label: '聊天',
|
||||
icon: 'chatLight',
|
||||
activeIcon: 'chatFill',
|
||||
link: `/chat?appId=${lastChatAppId}&chatId=${lastChatId}`,
|
||||
activeLink: ['/chat']
|
||||
},
|
||||
{
|
||||
label: '应用',
|
||||
icon: 'appLight',
|
||||
activeIcon: 'appFill',
|
||||
link: `/app/list`,
|
||||
activeLink: ['/app/list', '/app/detail']
|
||||
},
|
||||
{
|
||||
label: '知识库',
|
||||
icon: 'dbLight',
|
||||
activeIcon: 'dbFill',
|
||||
link: `/kb/list`,
|
||||
activeLink: ['/kb/list', '/kb/detail']
|
||||
},
|
||||
...(feConfigs?.show_appStore
|
||||
? [
|
||||
{
|
||||
label: '市场',
|
||||
icon: 'appStoreLight',
|
||||
activeIcon: 'appStoreFill',
|
||||
link: '/appStore',
|
||||
activeLink: ['/appStore']
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: '账号',
|
||||
icon: 'meLight',
|
||||
activeIcon: 'meFill',
|
||||
link: '/number',
|
||||
activeLink: ['/number']
|
||||
}
|
||||
];
|
||||
|
||||
const itemStyles: any = {
|
||||
my: 3,
|
||||
|
@@ -41,7 +41,9 @@ function App({ Component, pageProps, isPc }: AppProps & { isPc?: boolean; respon
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const { googleVerKey, baiduTongji } = await clientInitData();
|
||||
const {
|
||||
systemEnv: { googleVerKey, baiduTongji }
|
||||
} = await clientInitData();
|
||||
setGoogleVerKey(googleVerKey);
|
||||
setBaiduTongji(baiduTongji);
|
||||
})();
|
||||
|
@@ -1,37 +1,44 @@
|
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
import type { FeConfigsType, SystemEnvType } from '@/types';
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { jsonRes } from '@/service/response';
|
||||
import { readFileSync } from 'fs';
|
||||
import {
|
||||
type QAModelItemType,
|
||||
type ChatModelItemType,
|
||||
type VectorModelItemType
|
||||
} from '@/types/model';
|
||||
import type { FeConfigsType } from '@/types';
|
||||
|
||||
export type InitDateResponse = {
|
||||
beianText: string;
|
||||
googleVerKey: string;
|
||||
baiduTongji: string;
|
||||
chatModels: ChatModelItemType[];
|
||||
qaModels: QAModelItemType[];
|
||||
vectorModels: VectorModelItemType[];
|
||||
systemEnv: SystemEnvType;
|
||||
feConfigs: FeConfigsType;
|
||||
};
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const envs = {
|
||||
beianText: process.env.SAFE_BEIAN_TEXT || '',
|
||||
googleVerKey: process.env.CLIENT_GOOGLE_VER_TOKEN || '',
|
||||
baiduTongji: process.env.BAIDU_TONGJI || ''
|
||||
};
|
||||
|
||||
jsonRes<InitDateResponse>(res, {
|
||||
data: {
|
||||
...envs,
|
||||
systemEnv: global.systemEnv,
|
||||
feConfigs: global.feConfigs,
|
||||
chatModels: global.chatModels,
|
||||
qaModels: global.qaModels,
|
||||
vectorModels: global.vectorModels,
|
||||
feConfigs: global.feConfigs
|
||||
vectorModels: global.vectorModels
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function getInitConfig() {
|
||||
try {
|
||||
const res = JSON.parse(readFileSync('data/config.json', 'utf-8'));
|
||||
console.log(res);
|
||||
|
||||
global.systemEnv = res.SystemParams;
|
||||
global.feConfigs = res.FeConfig;
|
||||
global.chatModels = res.ChatModels;
|
||||
global.qaModels = res.QAModels;
|
||||
global.vectorModels = res.VectorModels;
|
||||
} catch (error) {
|
||||
console.log('get init config error');
|
||||
}
|
||||
}
|
||||
|
@@ -1,123 +0,0 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { jsonRes } from '@/service/response';
|
||||
import { authUser } from '@/service/utils/auth';
|
||||
import { readFileSync } from 'fs';
|
||||
import {
|
||||
type QAModelItemType,
|
||||
type ChatModelItemType,
|
||||
type VectorModelItemType
|
||||
} from '@/types/model';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
await authUser({ req, authRoot: true });
|
||||
updateSystemEnv();
|
||||
jsonRes(res);
|
||||
}
|
||||
|
||||
export async function updateSystemEnv() {
|
||||
try {
|
||||
const res = JSON.parse(readFileSync('data/SystemParams.json', 'utf-8'));
|
||||
|
||||
global.systemEnv = {
|
||||
...global.systemEnv,
|
||||
...res
|
||||
};
|
||||
console.log(global.systemEnv);
|
||||
} catch (error) {
|
||||
console.log('update system env error');
|
||||
}
|
||||
}
|
||||
|
||||
const defaultmodels = {
|
||||
'FastAI-4k': {
|
||||
model: 'gpt-3.5-turbo',
|
||||
name: 'FastAI-4k',
|
||||
contextMaxToken: 4000,
|
||||
systemMaxToken: 2400,
|
||||
maxTemperature: 1.2,
|
||||
price: 1.5
|
||||
},
|
||||
'FastAI-16k': {
|
||||
model: 'gpt-3.5-turbo',
|
||||
name: 'FastAI-16k',
|
||||
contextMaxToken: 16000,
|
||||
systemMaxToken: 8000,
|
||||
maxTemperature: 1.2,
|
||||
price: 3
|
||||
},
|
||||
'FastAI-Plus': {
|
||||
model: 'gpt-4',
|
||||
name: 'FastAI-Plus',
|
||||
contextMaxToken: 8000,
|
||||
systemMaxToken: 4000,
|
||||
maxTemperature: 1.2,
|
||||
price: 45
|
||||
}
|
||||
};
|
||||
const defaultQaModels = {
|
||||
'FastAI-16k': {
|
||||
model: 'gpt-3.5-turbo',
|
||||
name: 'FastAI-16k',
|
||||
maxToken: 16000,
|
||||
price: 3
|
||||
}
|
||||
};
|
||||
const defaultVectorModels = {
|
||||
'text-embedding-ada-002': {
|
||||
model: 'text-embedding-ada-002',
|
||||
name: 'Embedding-2',
|
||||
price: 0.2
|
||||
}
|
||||
};
|
||||
export function initSystemModels() {
|
||||
const { chatModels, qaModels, vectorModels } = (() => {
|
||||
try {
|
||||
const chatModels = Object.values(JSON.parse(readFileSync('data/ChatModels.json', 'utf-8')));
|
||||
const qaModels = Object.values(JSON.parse(readFileSync('data/QAModels.json', 'utf-8')));
|
||||
const vectorModels = Object.values(
|
||||
JSON.parse(readFileSync('data/VectorModels.json', 'utf-8'))
|
||||
);
|
||||
|
||||
return {
|
||||
chatModels,
|
||||
qaModels,
|
||||
vectorModels
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
return {
|
||||
chatModels: Object.values(defaultmodels),
|
||||
qaModels: Object.values(defaultQaModels),
|
||||
vectorModels: Object.values(defaultVectorModels)
|
||||
};
|
||||
}
|
||||
})() as {
|
||||
chatModels: ChatModelItemType[];
|
||||
qaModels: QAModelItemType[];
|
||||
vectorModels: VectorModelItemType[];
|
||||
};
|
||||
global.chatModels = chatModels;
|
||||
global.qaModels = qaModels;
|
||||
global.vectorModels = vectorModels;
|
||||
console.log({
|
||||
chatModels,
|
||||
qaModels,
|
||||
vectorModels
|
||||
});
|
||||
|
||||
return {
|
||||
chatModels,
|
||||
qaModels,
|
||||
vectorModels
|
||||
};
|
||||
}
|
||||
|
||||
export function initFeConfig() {
|
||||
const feConfig = JSON.parse(readFileSync('data/FeConfig.json', 'utf-8'));
|
||||
|
||||
global.feConfigs = feConfig;
|
||||
console.log(feConfig);
|
||||
|
||||
return feConfig;
|
||||
}
|
@@ -147,7 +147,7 @@ const NumberSetting = ({ tableType }: { tableType: `${TableEnum}` }) => {
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box h={'100%'} overflow={'overlay'}>
|
||||
<Box py={[5, 10]} px={'5vw'}>
|
||||
<Grid gridTemplateColumns={['1fr', '3fr 300px']} gridGap={4}>
|
||||
<Card px={6} py={4}>
|
||||
@@ -257,7 +257,7 @@ const NumberSetting = ({ tableType }: { tableType: `${TableEnum}` }) => {
|
||||
{isOpenPayModal && <PayModal onClose={onClosePayModal} />}
|
||||
{isOpenWxConcat && <WxConcat onClose={onCloseWxConcat} />}
|
||||
<File onSelect={onSelectFile} />
|
||||
</>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import mongoose from 'mongoose';
|
||||
import tunnel from 'tunnel';
|
||||
import { startQueue } from './utils/tools';
|
||||
import { updateSystemEnv, initSystemModels, initFeConfig } from '@/pages/api/system/updateEnv';
|
||||
import { getInitConfig } from '@/pages/api/system/getInitData';
|
||||
|
||||
/**
|
||||
* 连接 MongoDB 数据库
|
||||
@@ -23,7 +23,6 @@ export async function connectToDatabase(): Promise<void> {
|
||||
};
|
||||
global.sendInformQueue = [];
|
||||
global.sendInformQueueLen = 0;
|
||||
global.feConfigs = {};
|
||||
// proxy obj
|
||||
if (process.env.AXIOS_PROXY_HOST && process.env.AXIOS_PROXY_PORT) {
|
||||
global.httpsAgent = tunnel.httpsOverHttp({
|
||||
@@ -35,9 +34,7 @@ export async function connectToDatabase(): Promise<void> {
|
||||
}
|
||||
|
||||
// init function
|
||||
initSystemModels();
|
||||
initFeConfig();
|
||||
updateSystemEnv();
|
||||
getInitConfig();
|
||||
|
||||
try {
|
||||
mongoose.set('strictQuery', true);
|
||||
|
@@ -8,9 +8,9 @@ import { getInitData } from '@/api/system';
|
||||
import { delay } from '@/utils/tools';
|
||||
import { FeConfigsType } from '@/types';
|
||||
|
||||
export let beianText = '';
|
||||
export let googleVerKey = '';
|
||||
export let baiduTongji = '';
|
||||
export let beianText: string | undefined;
|
||||
export let googleVerKey: string | undefined;
|
||||
export let baiduTongji: string | undefined;
|
||||
export let chatModelList: ChatModelItemType[] = [];
|
||||
export let qaModelList: QAModelItemType[] = [];
|
||||
export let vectorModelList: VectorModelItemType[] = [];
|
||||
@@ -26,9 +26,10 @@ export const clientInitData = async (): Promise<InitDateResponse> => {
|
||||
qaModelList = res.qaModels;
|
||||
vectorModelList = res.vectorModels;
|
||||
feConfigs = res.feConfigs;
|
||||
beianText = res.beianText;
|
||||
googleVerKey = res.googleVerKey;
|
||||
baiduTongji = res.baiduTongji;
|
||||
beianText = res.systemEnv.beianText;
|
||||
googleVerKey = res.systemEnv.googleVerKey;
|
||||
baiduTongji = res.systemEnv.baiduTongji;
|
||||
console.log(res);
|
||||
|
||||
return res;
|
||||
} catch (error) {
|
||||
|
16
client/src/types/index.d.ts
vendored
16
client/src/types/index.d.ts
vendored
@@ -22,6 +22,15 @@ export type FeConfigsType = {
|
||||
systemTitle?: string;
|
||||
authorText?: string;
|
||||
};
|
||||
export type SystemEnvType = {
|
||||
beianText?: string;
|
||||
googleVerKey?: string;
|
||||
baiduTongji?: string;
|
||||
vectorMaxProcess: number;
|
||||
qaMaxProcess: number;
|
||||
pgIvfflatProbe: number;
|
||||
sensitiveCheck: boolean;
|
||||
};
|
||||
|
||||
declare global {
|
||||
var mongodb: Mongoose | string | null;
|
||||
@@ -32,12 +41,7 @@ declare global {
|
||||
var OpenAiEncMap: Tiktoken;
|
||||
var sendInformQueue: (() => Promise<void>)[];
|
||||
var sendInformQueueLen: number;
|
||||
var systemEnv: {
|
||||
vectorMaxProcess: number;
|
||||
qaMaxProcess: number;
|
||||
pgIvfflatProbe: number;
|
||||
sensitiveCheck: boolean;
|
||||
};
|
||||
var systemEnv: SystemEnvType;
|
||||
var chatModels: ChatModelItemType[];
|
||||
var qaModels: QAModelItemType[];
|
||||
var vectorModels: VectorModelItemType[];
|
||||
|
Reference in New Issue
Block a user