mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
v4.6.4 (#585)
* perf: md format * add systemConfig schema (#2) * fix: markdown * fix: root * fix: root --------- Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
This commit is contained in:
@@ -151,6 +151,7 @@ export const splitText2Chunks = (props: {
|
||||
const maxLen = splitTexts.length > 1 ? stepReges[step].maxLen : chunkLen;
|
||||
const minChunkLen = chunkLen * 0.7;
|
||||
const miniChunkLen = 30;
|
||||
// console.log(splitTexts, stepReges[step].reg);
|
||||
|
||||
const chunks: string[] = [];
|
||||
for (let i = 0; i < splitTexts.length; i++) {
|
||||
|
13
packages/global/common/system/config/constants.ts
Normal file
13
packages/global/common/system/config/constants.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export enum SystemConfigsTypeEnum {
|
||||
fastgpt = 'fastgpt',
|
||||
fastgptPro = 'fastgptPro'
|
||||
}
|
||||
|
||||
export const SystemConfigsTypeMap = {
|
||||
[SystemConfigsTypeEnum.fastgpt]: {
|
||||
label: 'fastgpt'
|
||||
},
|
||||
[SystemConfigsTypeEnum.fastgptPro]: {
|
||||
label: 'fastgptPro'
|
||||
}
|
||||
};
|
8
packages/global/common/system/config/type.d.ts
vendored
Normal file
8
packages/global/common/system/config/type.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { SystemConfigsTypeEnum } from "./constants";
|
||||
|
||||
export type SystemConfigsType = {
|
||||
_id: string;
|
||||
type: `${SystemConfigsTypeEnum}`;
|
||||
value: Record<string, any>;
|
||||
createTime: Date;
|
||||
};
|
32
packages/service/common/system/config/schema.ts
Normal file
32
packages/service/common/system/config/schema.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { SystemConfigsType } from '@fastgpt/global/common/system/config/type';
|
||||
import { connectionMongo, type Model } from '../../../common/mongo';
|
||||
import { SystemConfigsTypeMap } from '@fastgpt/global/common/system/config/constants';
|
||||
|
||||
const { Schema, model, models } = connectionMongo;
|
||||
|
||||
const collectionName = 'systemConfigs';
|
||||
const systemConfigSchema = new Schema({
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
enum: Object.keys(SystemConfigsTypeMap)
|
||||
},
|
||||
value: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
createTime: {
|
||||
type: Date,
|
||||
default: () => new Date()
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
systemConfigSchema.index({ createTime: -1 }, { expireAfterSeconds: 90 * 24 * 60 * 60 });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
export const MongoSystemConfigs: Model<SystemConfigsType>=
|
||||
models[collectionName] || model(collectionName, systemConfigSchema);
|
||||
MongoSystemConfigs.syncIndexes();
|
@@ -151,6 +151,7 @@ export async function parseHeaderCert({
|
||||
authType: AuthUserTypeEnum.root
|
||||
};
|
||||
}
|
||||
// apikey: abandon
|
||||
if (authApiKey && apikey) {
|
||||
// apikey
|
||||
const parseResult = await authOpenApiKey({ apikey });
|
||||
@@ -164,20 +165,8 @@ export async function parseHeaderCert({
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
uid: '',
|
||||
teamId: '',
|
||||
tmbId: '',
|
||||
appId: '',
|
||||
openApiKey: '',
|
||||
authType: AuthUserTypeEnum.token
|
||||
};
|
||||
})();
|
||||
|
||||
// not rootUser and no uid, reject request
|
||||
if (!rootkey && !uid && !teamId && !tmbId) {
|
||||
return Promise.reject(ERROR_ENUM.unAuthorization);
|
||||
}
|
||||
})();
|
||||
|
||||
return {
|
||||
userId: String(uid),
|
||||
|
Reference in New Issue
Block a user