mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
feat: add training retry time (#3187)
* feat: add training retry time * remoce log
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
} from '@fastgpt/global/support/permission/constant';
|
||||
import { CommonErrEnum } from '@fastgpt/global/common/error/code/common';
|
||||
import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/next';
|
||||
import { DatasetTypeEnum } from '@fastgpt/global/core/dataset/constants';
|
||||
import { DatasetTypeEnum, TrainingModeEnum } from '@fastgpt/global/core/dataset/constants';
|
||||
import { ClientSession } from 'mongoose';
|
||||
import { parseParentIdInMongo } from '@fastgpt/global/common/parentFolder/utils';
|
||||
import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun';
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
import { authUserPer } from '@fastgpt/service/support/permission/user/auth';
|
||||
import { TeamWritePermissionVal } from '@fastgpt/global/support/permission/user/constant';
|
||||
import { DatasetErrEnum } from '@fastgpt/global/common/error/code/dataset';
|
||||
import { MongoDatasetTraining } from '@fastgpt/service/core/dataset/training/schema';
|
||||
|
||||
export type DatasetUpdateQuery = {};
|
||||
export type DatasetUpdateResponse = any;
|
||||
@@ -84,6 +85,12 @@ async function handler(
|
||||
|
||||
const isFolder = dataset.type === DatasetTypeEnum.folder;
|
||||
|
||||
updateTraining({
|
||||
teamId: dataset.teamId,
|
||||
datasetId: id,
|
||||
agentModel: agentModel?.model
|
||||
});
|
||||
|
||||
const onUpdate = async (session?: ClientSession) => {
|
||||
await MongoDataset.findByIdAndUpdate(
|
||||
id,
|
||||
@@ -137,3 +144,29 @@ async function handler(
|
||||
}
|
||||
}
|
||||
export default NextAPI(handler);
|
||||
|
||||
async function updateTraining({
|
||||
teamId,
|
||||
datasetId,
|
||||
agentModel
|
||||
}: {
|
||||
teamId: string;
|
||||
datasetId: string;
|
||||
agentModel?: string;
|
||||
}) {
|
||||
if (!agentModel) return;
|
||||
|
||||
await MongoDatasetTraining.updateMany(
|
||||
{
|
||||
teamId,
|
||||
datasetId,
|
||||
mode: { $in: [TrainingModeEnum.qa, TrainingModeEnum.auto] }
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
model: agentModel,
|
||||
retryCount: 5
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -39,11 +39,13 @@ export async function generateQA(): Promise<any> {
|
||||
try {
|
||||
const data = await MongoDatasetTraining.findOneAndUpdate(
|
||||
{
|
||||
lockTime: { $lte: addMinutes(new Date(), -6) },
|
||||
mode: TrainingModeEnum.qa
|
||||
mode: TrainingModeEnum.qa,
|
||||
retryCount: { $gte: 0 },
|
||||
lockTime: { $lte: addMinutes(new Date(), -6) }
|
||||
},
|
||||
{
|
||||
lockTime: new Date()
|
||||
lockTime: new Date(),
|
||||
$inc: { retryCount: -1 }
|
||||
}
|
||||
)
|
||||
.select({
|
||||
|
@@ -39,10 +39,12 @@ export async function generateVector(): Promise<any> {
|
||||
const data = await MongoDatasetTraining.findOneAndUpdate(
|
||||
{
|
||||
mode: TrainingModeEnum.chunk,
|
||||
lockTime: { $lte: addMinutes(new Date(), -1) }
|
||||
retryCount: { $gte: 0 },
|
||||
lockTime: { $lte: addMinutes(new Date(), -6) }
|
||||
},
|
||||
{
|
||||
lockTime: new Date()
|
||||
lockTime: new Date(),
|
||||
$inc: { retryCount: -1 }
|
||||
}
|
||||
).select({
|
||||
_id: 1,
|
||||
|
Reference in New Issue
Block a user