[update] 停用/删除基础模型校验模型调优
This commit is contained in:
parent
4ad0d41892
commit
6940f7c7cc
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.llm.controller.admin.basemodel.vo.BaseModelSaveRe
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.basemodel.BaseModelDO;
|
||||
import cn.iocoder.yudao.module.llm.dal.mysql.basemodel.BaseModelMapper;
|
||||
import cn.iocoder.yudao.module.llm.service.application.ApplicationService;
|
||||
import cn.iocoder.yudao.module.llm.service.finetuningtask.FineTuningTaskService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@ -37,6 +38,9 @@ public class BaseModelServiceImpl implements BaseModelService {
|
||||
@Resource
|
||||
private ApplicationService applicationService;
|
||||
|
||||
@Resource
|
||||
private FineTuningTaskService fineTuningTaskService;
|
||||
|
||||
@Override
|
||||
public Long createBaseModel (BaseModelSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@ -132,14 +136,12 @@ public class BaseModelServiceImpl implements BaseModelService {
|
||||
|
||||
// 校验 基座模型 是否在 应用中心 有使用
|
||||
validateModelUsesInApplicationCenter(id, modelName);
|
||||
// // 校验 基座模型 是否在 模型调优 有使用 (是否为等待中)
|
||||
// validateModelUsesInModelTuning(id, modelName);
|
||||
// 校验 基座模型 是否在 模型调优 有使用 (是否为等待中)
|
||||
validateModelUsesInModelTuning(id, modelName);
|
||||
// // 校验 基座模型 是否在 模型评估任务 有使用 (是否为进行中)
|
||||
// validateModelUsesInModelAssessmentTask(id, modelName);
|
||||
// // 校验 基座模型 是否在 模型评估任务备份 有使用
|
||||
// validateModelUsesInModelAssessmentTaskBackup(id, modelName);
|
||||
// // 校验 基座模型 是否在 数据回流 有使用
|
||||
// validateModelUsesInDataReplay(id, modelName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,59 +158,45 @@ public class BaseModelServiceImpl implements BaseModelService {
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 校验模型是否在 模型调优 有使用
|
||||
// *
|
||||
// * @param id 模型ID
|
||||
// * @param modelName 模型名称
|
||||
// */
|
||||
// private void validateModelUsesInModelTuning (Long id, String modelName) {
|
||||
// Map<Long, String> modelTuning = modelTuningService.getModelTuningByLabelId(id);
|
||||
// if (CollectionUtils.isNotEmpty(modelTuning)) {
|
||||
// String msg = String.format("模型【%s】在模型调优 %s 有使用,请先取消使用", modelName, modelTuning.values());
|
||||
// throw exception(new ErrorCode(10022_002, msg));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 校验模型是否在 模型评估任务 有使用
|
||||
// *
|
||||
// * @param id 模型ID
|
||||
// * @param modelName 模型名称
|
||||
// */
|
||||
// private void validateModelUsesInModelAssessmentTask (Long id, String modelName) {
|
||||
// Map<Long, String> modelAssessmentTask = modelAssessmentTaskService.getModelAssessmentTaskByLabelId(id);
|
||||
// if (CollectionUtils.isNotEmpty(modelAssessmentTask)) {
|
||||
// String msg = String.format("模型【%s】在模型评估任务 %s 有使用,请先取消使用", modelName, modelAssessmentTask.values());
|
||||
// throw exception(new ErrorCode(10022_003, msg));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 校验模型是否在 模型评估任务备份 有使用
|
||||
// *
|
||||
// * @param id 模型ID
|
||||
// * @param modelName 模型名称
|
||||
// */
|
||||
// private void validateModelUsesInModelAssessmentTaskBackup (Long id, String modelName) {
|
||||
// Map<Long, String> modelAssessmentTaskBackup = modelAssessmentTaskBackupService.getModelAssessmentTaskBackupByLabelId(id);
|
||||
// if (CollectionUtils.isNotEmpty(modelAssessmentTaskBackup)) {
|
||||
// String msg = String.format("模型【%s】在模型评估任务备份 %s 有使用,请先取消使用", modelName, modelAssessmentTaskBackup.values());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 校验模型是否在 数据回流 有使用
|
||||
// *
|
||||
// * @param id 模型ID
|
||||
// * @param modelName 模型名称
|
||||
// */
|
||||
// private void validateModelUsesInDataReplay (Long id, String modelName) {
|
||||
// Map<Long, String> dataReplay = dataReplayService.getDataReplayByLabelId(id);
|
||||
// if (CollectionUtils.isNotEmpty(dataReplay)) {
|
||||
// String msg = String.format("模型【%s】在数据回流 %s 有使用,请先取消使用", modelName, dataReplay.values());
|
||||
// throw exception(new ErrorCode(10022_004, msg));
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* 校验模型是否在 模型调优 有使用
|
||||
*
|
||||
* @param id 模型ID
|
||||
* @param modelName 模型名称
|
||||
*/
|
||||
private void validateModelUsesInModelTuning (Long id, String modelName) {
|
||||
Map<Long, String> modelTuning = fineTuningTaskService.getModelTuningByLabelId(id);
|
||||
if (CollectionUtils.isNotEmpty(modelTuning)) {
|
||||
String msg = String.format("模型【%s】在模型调优 %s 有使用,请先取消使用", modelName, modelTuning.values());
|
||||
throw exception(new ErrorCode(10022_002, msg));
|
||||
}
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * 校验模型是否在 模型评估任务 有使用
|
||||
// *
|
||||
// * @param id 模型ID
|
||||
// * @param modelName 模型名称
|
||||
// */
|
||||
// private void validateModelUsesInModelAssessmentTask (Long id, String modelName) {
|
||||
// Map<Long, String> modelAssessmentTask = modelAssessmentTaskService.getModelAssessmentTaskByLabelId(id);
|
||||
// if (CollectionUtils.isNotEmpty(modelAssessmentTask)) {
|
||||
// String msg = String.format("模型【%s】在模型评估任务 %s 有使用,请先取消使用", modelName, modelAssessmentTask.values());
|
||||
// throw exception(new ErrorCode(10022_003, msg));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 校验模型是否在 模型评估任务备份 有使用
|
||||
// *
|
||||
// * @param id 模型ID
|
||||
// * @param modelName 模型名称
|
||||
// */
|
||||
// private void validateModelUsesInModelAssessmentTaskBackup (Long id, String modelName) {
|
||||
// Map<Long, String> modelAssessmentTaskBackup = modelAssessmentTaskBackupService.getModelAssessmentTaskBackupByLabelId(id);
|
||||
// if (CollectionUtils.isNotEmpty(modelAssessmentTaskBackup)) {
|
||||
// String msg = String.format("模型【%s】在模型评估任务备份 %s 有使用,请先取消使用", modelName, modelAssessmentTaskBackup.values());
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.llm.dal.dataobject.finetuningtask.FineTuningTaskD
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 模型调优 —— 微调任务 Service 接口
|
||||
@ -84,4 +85,12 @@ public interface FineTuningTaskService {
|
||||
* @return 已部署完成的调优任务
|
||||
*/
|
||||
List<FineTuningTaskRespVO> selectEnable ();
|
||||
|
||||
/**
|
||||
* 根据 基础模型id 获取 模型调优
|
||||
*
|
||||
* @param baseModelId 基础模型id
|
||||
* @return 模型调优
|
||||
*/
|
||||
Map<Long, String> getModelTuningByLabelId (Long baseModelId);
|
||||
}
|
||||
|
@ -15,10 +15,13 @@ import cn.iocoder.yudao.module.llm.enums.FinetuningTaskStatusEnum;
|
||||
import cn.iocoder.yudao.module.llm.service.async.AsyncFineTuningTaskService;
|
||||
import cn.iocoder.yudao.module.llm.service.http.TrainHttpService;
|
||||
import cn.iocoder.yudao.module.llm.service.http.vo.AigcFineTuningDetailRespVO;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import jodd.util.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -42,6 +45,7 @@ import static cn.iocoder.yudao.module.llm.enums.ErrorCodeConstants.*;
|
||||
@Validated
|
||||
public class FineTuningTaskServiceImpl implements FineTuningTaskService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FineTuningTaskServiceImpl.class);
|
||||
@Resource
|
||||
private FineTuningTaskMapper fineTuningTaskMapper;
|
||||
@Resource
|
||||
@ -192,6 +196,30 @@ public class FineTuningTaskServiceImpl implements FineTuningTaskService {
|
||||
return BeanUtils.toBean(fineTuningTaskDOS, FineTuningTaskRespVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 基础模型id 获取 模型调优
|
||||
*
|
||||
* @param baseModelId 基础模型id
|
||||
* @return 模型调优
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> getModelTuningByLabelId (Long baseModelId) {
|
||||
|
||||
if (baseModelId == null){
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
List<FineTuningTaskDO> fineTuningTaskDOS = fineTuningTaskMapper.selectList(new LambdaQueryWrapper<FineTuningTaskDO>()
|
||||
.eq(FineTuningTaskDO::getBaseModelId, baseModelId)
|
||||
.eq(FineTuningTaskDO::getStatus, FinetuningTaskStatusEnum.WAITING.getStatus()));
|
||||
|
||||
if (CollectionUtils.isNotEmpty(fineTuningTaskDOS)){
|
||||
return fineTuningTaskDOS.stream().collect(Collectors.toMap(FineTuningTaskDO::getId, FineTuningTaskDO::getTaskName));
|
||||
}
|
||||
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopFineTuningTask(Long id) {
|
||||
FineTuningTaskDO fineTuningTaskDO = validateFineTuningTaskExists(id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user