mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 11:58:38 +00:00
feat: admin set env
This commit is contained in:
@@ -201,7 +201,7 @@ export async function appKbSearch({
|
||||
searchPrompts: [
|
||||
{
|
||||
obj: ChatRoleEnum.System,
|
||||
value: `知识库:${systemPrompt}`
|
||||
value: `知识库:<${systemPrompt}>`
|
||||
},
|
||||
guidePrompt
|
||||
]
|
||||
|
@@ -8,7 +8,7 @@ import { axiosConfig } from '@/service/utils/tools';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
try {
|
||||
if (process.env.SENSITIVE_CHECK !== '1') {
|
||||
if (global.systemEnv.sensitiveCheck) {
|
||||
return jsonRes(res);
|
||||
}
|
||||
|
||||
|
32
client/src/pages/api/system/updateEnv.ts
Normal file
32
client/src/pages/api/system/updateEnv.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { jsonRes } from '@/service/response';
|
||||
import { System } from '@/service/models/system';
|
||||
import { authUser } from '@/service/utils/auth';
|
||||
|
||||
export type InitDateResponse = {
|
||||
beianText: string;
|
||||
googleVerKey: string;
|
||||
};
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
await authUser({ req, authRoot: true });
|
||||
updateSystemEnv();
|
||||
jsonRes<InitDateResponse>(res);
|
||||
}
|
||||
|
||||
export async function updateSystemEnv() {
|
||||
try {
|
||||
const mongoData = await System.findOne();
|
||||
|
||||
if (mongoData) {
|
||||
const obj = mongoData.toObject();
|
||||
global.systemEnv = {
|
||||
...global.systemEnv,
|
||||
...obj
|
||||
};
|
||||
}
|
||||
console.log('update env', global.systemEnv);
|
||||
} catch (error) {
|
||||
console.log('update system env error');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user