feat: admin set env

This commit is contained in:
archer
2023-06-10 22:56:57 +08:00
parent 7dd8e7bea1
commit b8a75921ed
18 changed files with 243 additions and 58 deletions

View File

@@ -201,7 +201,7 @@ export async function appKbSearch({
searchPrompts: [
{
obj: ChatRoleEnum.System,
value: `知识库:${systemPrompt}`
value: `知识库:<${systemPrompt}>`
},
guidePrompt
]

View File

@@ -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);
}

View 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');
}
}