mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-19 18:44:17 +00:00
feat: system config type;fix: retraining permission (#4772)
* feat: system config type * fix: retraining permission
This commit is contained in:
@@ -28,4 +28,5 @@ weight: 792
|
||||
2. 打开知识库搜索参数后,重排选项自动被打开。
|
||||
3. LLM json_schema 模式 API 请求格式错误。
|
||||
4. 重新训练时,图片过期索引未成功清除,导致图片会丢失。
|
||||
5. 重新训练权限问题。
|
||||
|
||||
|
@@ -1,7 +1,8 @@
|
||||
export enum SystemConfigsTypeEnum {
|
||||
fastgpt = 'fastgpt',
|
||||
fastgptPro = 'fastgptPro',
|
||||
systemMsgModal = 'systemMsgModal'
|
||||
systemMsgModal = 'systemMsgModal',
|
||||
license = 'license'
|
||||
}
|
||||
|
||||
export const SystemConfigsTypeMap = {
|
||||
@@ -13,5 +14,8 @@ export const SystemConfigsTypeMap = {
|
||||
},
|
||||
[SystemConfigsTypeEnum.systemMsgModal]: {
|
||||
label: 'systemMsgModal'
|
||||
},
|
||||
[SystemConfigsTypeEnum.license]: {
|
||||
label: 'license'
|
||||
}
|
||||
};
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { jsonRes } from '../response';
|
||||
import type { NextApiResponse } from 'next';
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { withNextCors } from './cors';
|
||||
import { type ApiRequestProps } from '../../type/next';
|
||||
import { addLog } from '../system/log';
|
||||
@@ -9,14 +9,21 @@ export type NextApiHandler<T = any> = (
|
||||
res: NextApiResponse<T>
|
||||
) => unknown | Promise<unknown>;
|
||||
|
||||
export const NextEntry = ({ beforeCallback = [] }: { beforeCallback?: Promise<any>[] }) => {
|
||||
export const NextEntry = ({
|
||||
beforeCallback = []
|
||||
}: {
|
||||
beforeCallback?: ((req: NextApiRequest, res: NextApiResponse) => Promise<any>)[];
|
||||
}) => {
|
||||
return (...args: NextApiHandler[]): NextApiHandler => {
|
||||
return async function api(req: ApiRequestProps, res: NextApiResponse) {
|
||||
const start = Date.now();
|
||||
addLog.debug(`Request start ${req.url}`);
|
||||
|
||||
try {
|
||||
await Promise.all([withNextCors(req, res), ...beforeCallback]);
|
||||
await Promise.all([
|
||||
withNextCors(req, res),
|
||||
...beforeCallback.map((item) => item(req, res))
|
||||
]);
|
||||
|
||||
let response = null;
|
||||
for await (const handler of args) {
|
||||
|
@@ -8,7 +8,7 @@
|
||||
"@xmldom/xmldom": "^0.8.10",
|
||||
"@zilliz/milvus2-sdk-node": "2.4.2",
|
||||
"axios": "^1.8.2",
|
||||
"bullmq": "^5.44.0",
|
||||
"bullmq": "^5.52.2",
|
||||
"chalk": "^5.3.0",
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
"cookie": "^0.7.1",
|
||||
|
18
pnpm-lock.yaml
generated
18
pnpm-lock.yaml
generated
@@ -191,8 +191,8 @@ importers:
|
||||
specifier: ^1.8.2
|
||||
version: 1.8.4
|
||||
bullmq:
|
||||
specifier: ^5.44.0
|
||||
version: 5.44.0
|
||||
specifier: ^5.52.2
|
||||
version: 5.52.2
|
||||
chalk:
|
||||
specifier: ^5.3.0
|
||||
version: 5.4.1
|
||||
@@ -4193,8 +4193,8 @@ packages:
|
||||
buffer@6.0.3:
|
||||
resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
|
||||
|
||||
bullmq@5.44.0:
|
||||
resolution: {integrity: sha512-OnEtkuXyrUx2Jm5BpH92+ttrobblBdCbkhOe3OoR0hxZuAilI3mPWlwELslhfImRpDv8rK+C/0/VK7I8f3xIig==}
|
||||
bullmq@5.52.2:
|
||||
resolution: {integrity: sha512-fK/dKIv8ymyys4K+zeNEPA+yuYWzRPmBWUmwIMz8DvYekadl8VG19yUx94Na0n0cLAi+spdn3a/+ufkYK7CBUg==}
|
||||
|
||||
bundle-n-require@1.1.2:
|
||||
resolution: {integrity: sha512-bEk2jakVK1ytnZ9R2AAiZEeK/GxPUM8jvcRxHZXifZDMcjkI4EG/GlsJ2YGSVYT9y/p/gA9/0yDY8rCGsSU6Tg==}
|
||||
@@ -13902,7 +13902,7 @@ snapshots:
|
||||
base64-js: 1.5.1
|
||||
ieee754: 1.2.1
|
||||
|
||||
bullmq@5.44.0:
|
||||
bullmq@5.52.2:
|
||||
dependencies:
|
||||
cron-parser: 4.9.0
|
||||
ioredis: 5.6.0
|
||||
@@ -15142,7 +15142,7 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
eslint-module-utils@2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.56.0)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.9.0)(eslint@8.56.0):
|
||||
eslint-module-utils@2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.56.0)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.9.0(eslint-plugin-import@2.31.0)(eslint@8.56.0))(eslint@8.56.0):
|
||||
dependencies:
|
||||
debug: 3.2.7
|
||||
optionalDependencies:
|
||||
@@ -15153,7 +15153,7 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
eslint-module-utils@2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.9.0)(eslint@8.57.1):
|
||||
eslint-module-utils@2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.9.0(eslint-plugin-import@2.31.0)(eslint@8.57.1))(eslint@8.57.1):
|
||||
dependencies:
|
||||
debug: 3.2.7
|
||||
optionalDependencies:
|
||||
@@ -15175,7 +15175,7 @@ snapshots:
|
||||
doctrine: 2.1.0
|
||||
eslint: 8.56.0
|
||||
eslint-import-resolver-node: 0.3.9
|
||||
eslint-module-utils: 2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.56.0)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.9.0)(eslint@8.56.0)
|
||||
eslint-module-utils: 2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.56.0)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.9.0(eslint-plugin-import@2.31.0)(eslint@8.56.0))(eslint@8.56.0)
|
||||
hasown: 2.0.2
|
||||
is-core-module: 2.16.1
|
||||
is-glob: 4.0.3
|
||||
@@ -15204,7 +15204,7 @@ snapshots:
|
||||
doctrine: 2.1.0
|
||||
eslint: 8.57.1
|
||||
eslint-import-resolver-node: 0.3.9
|
||||
eslint-module-utils: 2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.9.0)(eslint@8.57.1)
|
||||
eslint-module-utils: 2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.9.0(eslint-plugin-import@2.31.0)(eslint@8.57.1))(eslint@8.57.1)
|
||||
hasown: 2.0.2
|
||||
is-core-module: 2.16.1
|
||||
is-glob: 4.0.3
|
||||
|
@@ -140,25 +140,27 @@ const DataCard = () => {
|
||||
<TagsPopOver currentCollection={collection} />
|
||||
)}
|
||||
</Box>
|
||||
{datasetDetail.type !== 'websiteDataset' && !!collection?.chunkSize && (
|
||||
<Button
|
||||
ml={2}
|
||||
variant={'whitePrimary'}
|
||||
size={['sm', 'md']}
|
||||
onClick={() => {
|
||||
router.push({
|
||||
query: {
|
||||
datasetId,
|
||||
currentTab: TabEnum.import,
|
||||
source: ImportDataSourceEnum.reTraining,
|
||||
collectionId
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t('dataset:retain_collection')}
|
||||
</Button>
|
||||
)}
|
||||
{datasetDetail.type !== 'websiteDataset' &&
|
||||
!!collection?.chunkSize &&
|
||||
collection.permission?.hasWritePer && (
|
||||
<Button
|
||||
ml={2}
|
||||
variant={'whitePrimary'}
|
||||
size={['sm', 'md']}
|
||||
onClick={() => {
|
||||
router.push({
|
||||
query: {
|
||||
datasetId,
|
||||
currentTab: TabEnum.import,
|
||||
source: ImportDataSourceEnum.reTraining,
|
||||
collectionId
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t('dataset:retain_collection')}
|
||||
</Button>
|
||||
)}
|
||||
{canWrite && (
|
||||
<Button
|
||||
ml={2}
|
||||
|
@@ -12,8 +12,8 @@ import { type ApiRequestProps } from '@fastgpt/service/type/next';
|
||||
import { delCollection } from '@fastgpt/service/core/dataset/collection/controller';
|
||||
import { authDatasetCollection } from '@fastgpt/service/support/permission/dataset/auth';
|
||||
import { CommonErrEnum } from '@fastgpt/global/common/error/code/common';
|
||||
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||
import { i18nT } from '@fastgpt/web/i18n/utils';
|
||||
import { WritePermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||
|
||||
type RetrainingCollectionResponse = {
|
||||
collectionId: string;
|
||||
@@ -35,7 +35,7 @@ async function handler(
|
||||
authToken: true,
|
||||
authApiKey: true,
|
||||
collectionId: collectionId,
|
||||
per: ReadPermissionVal
|
||||
per: WritePermissionVal
|
||||
});
|
||||
|
||||
const sourceReadType = await (async () => {
|
||||
|
@@ -45,7 +45,7 @@ async function handler(req: NextApiRequest) {
|
||||
await Promise.all(
|
||||
datasets.map((dataset) => {
|
||||
if (dataset.type === DatasetTypeEnum.websiteDataset)
|
||||
return removeWebsiteSyncJobScheduler(String(dataset._id));
|
||||
return removeWebsiteSyncJobScheduler(dataset._id);
|
||||
})
|
||||
);
|
||||
|
||||
|
@@ -277,10 +277,10 @@ const updateSyncSchedule = async ({
|
||||
if (dataset.type === DatasetTypeEnum.websiteDataset) {
|
||||
if (autoSync) {
|
||||
// upsert Job Scheduler
|
||||
upsertWebsiteSyncJobScheduler({ datasetId: String(dataset._id) });
|
||||
return upsertWebsiteSyncJobScheduler({ datasetId: dataset._id });
|
||||
} else {
|
||||
// remove Job Scheduler
|
||||
removeWebsiteSyncJobScheduler(String(dataset._id));
|
||||
return removeWebsiteSyncJobScheduler(dataset._id);
|
||||
}
|
||||
} else {
|
||||
// Other dataset, update the collection sync
|
||||
|
Reference in New Issue
Block a user