This commit is contained in:
Archer
2023-10-22 23:54:04 +08:00
committed by GitHub
parent 3091a90df6
commit a3534407bf
365 changed files with 7266 additions and 6055 deletions

View File

@@ -1,7 +1,7 @@
import { App } from '../mongo';
import { MongoDataset } from '@fastgpt/core/dataset/schema';
import { MongoDataset } from '@fastgpt/service/core/dataset/schema';
import type { AppSchema } from '@/types/mongoSchema';
import { ERROR_ENUM } from '@fastgpt/common/constant/errorCode';
import { ERROR_ENUM } from '@fastgpt/global/common/error/errorCode';
// 模型使用权校验
export const authApp = async ({
@@ -37,13 +37,13 @@ export const authApp = async ({
};
// 知识库操作权限
export const authDataset = async ({ kbId, userId }: { kbId: string; userId: string }) => {
const kb = await MongoDataset.findOne({
_id: kbId,
export const authDataset = async ({ datasetId, userId }: { datasetId: string; userId: string }) => {
const dataset = await MongoDataset.findOne({
_id: datasetId,
userId
});
if (kb) {
return kb;
if (dataset) {
return dataset;
}
return Promise.reject(ERROR_ENUM.unAuthKb);
return Promise.reject(ERROR_ENUM.unAuthDataset);
};

View File

@@ -1,10 +1,17 @@
import type { NextApiResponse } from 'next';
import { generateQA } from '../events/generateQA';
import { generateVector } from '../events/generateVector';
/* start task */
export const startQueue = () => {
export const startQueue = (limit?: number) => {
if (!global.systemEnv) return;
if (limit) {
for (let i = 0; i < limit; i++) {
generateVector();
generateQA();
}
return;
}
for (let i = 0; i < global.systemEnv.qaMaxProcess; i++) {
generateQA();
}