增加标签管理 模型调优
This commit is contained in:
parent
37a988860a
commit
b824aeda6c
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.finetuningtask;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.finetuningtask.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.finetuningtask.FineTuningTaskDO;
|
||||
import cn.iocoder.yudao.module.llm.service.finetuningtask.FineTuningTaskService;
|
||||
|
||||
@Tag(name = "管理后台 - 模型调优 —— 微调任务")
|
||||
@RestController
|
||||
@RequestMapping("/llm/fine-tuning-task")
|
||||
@Validated
|
||||
public class FineTuningTaskController {
|
||||
|
||||
@Resource
|
||||
private FineTuningTaskService fineTuningTaskService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建模型调优 —— 微调任务")
|
||||
@PreAuthorize("@ss.hasPermission('llm:fine-tuning-task:create')")
|
||||
public CommonResult<Long> createFineTuningTask(@Valid @RequestBody FineTuningTaskSaveReqVO createReqVO) {
|
||||
return success(fineTuningTaskService.createFineTuningTask(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新模型调优 —— 微调任务")
|
||||
@PreAuthorize("@ss.hasPermission('llm:fine-tuning-task:update')")
|
||||
public CommonResult<Boolean> updateFineTuningTask(@Valid @RequestBody FineTuningTaskSaveReqVO updateReqVO) {
|
||||
fineTuningTaskService.updateFineTuningTask(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除模型调优 —— 微调任务")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('llm:fine-tuning-task:delete')")
|
||||
public CommonResult<Boolean> deleteFineTuningTask(@RequestParam("id") Long id) {
|
||||
fineTuningTaskService.deleteFineTuningTask(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得模型调优 —— 微调任务")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('llm:fine-tuning-task:query')")
|
||||
public CommonResult<FineTuningTaskRespVO> getFineTuningTask(@RequestParam("id") Long id) {
|
||||
FineTuningTaskDO fineTuningTask = fineTuningTaskService.getFineTuningTask(id);
|
||||
return success(BeanUtils.toBean(fineTuningTask, FineTuningTaskRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得模型调优 —— 微调任务分页")
|
||||
@PreAuthorize("@ss.hasPermission('llm:fine-tuning-task:query')")
|
||||
public CommonResult<PageResult<FineTuningTaskRespVO>> getFineTuningTaskPage(@Valid FineTuningTaskPageReqVO pageReqVO) {
|
||||
PageResult<FineTuningTaskDO> pageResult = fineTuningTaskService.getFineTuningTaskPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, FineTuningTaskRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出模型调优 —— 微调任务 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('llm:fine-tuning-task:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportFineTuningTaskExcel(@Valid FineTuningTaskPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<FineTuningTaskDO> list = fineTuningTaskService.getFineTuningTaskPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "模型调优 —— 微调任务.xls", "数据", FineTuningTaskRespVO.class,
|
||||
BeanUtils.toBean(list, FineTuningTaskRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.finetuningtask.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 模型调优 —— 微调任务分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class FineTuningTaskPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "任务名称", example = "李四")
|
||||
private String taskName;
|
||||
|
||||
@Schema(description = "基础模型,使用字典(llm_base_model)")
|
||||
private String baseModel;
|
||||
|
||||
@Schema(description = "训练阶段,使用字典(llm_training_stage)")
|
||||
private Integer trainStage;
|
||||
|
||||
@Schema(description = "微调方法,使用字典(llm_fine_tuning_method)")
|
||||
private Integer method;
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String taskIntro;
|
||||
|
||||
@Schema(description = "GPU类型,使用字典(llm_gpu_type)", example = "1")
|
||||
private Integer gpuType;
|
||||
|
||||
@Schema(description = "GPU数量", example = "7626")
|
||||
private Integer gpuCount;
|
||||
|
||||
@Schema(description = "数据集ID")
|
||||
private Long dataset;
|
||||
|
||||
@Schema(description = "学习率")
|
||||
private Integer learningRate;
|
||||
|
||||
@Schema(description = "训练轮数")
|
||||
private Integer epoch;
|
||||
|
||||
@Schema(description = "截断长度")
|
||||
private Integer cutoffLen;
|
||||
|
||||
@Schema(description = "批处理大小")
|
||||
private Integer batchSize;
|
||||
|
||||
@Schema(description = "梯度累积")
|
||||
private Integer gradientAccumulation;
|
||||
|
||||
@Schema(description = "预热步数")
|
||||
private Integer warmup;
|
||||
|
||||
@Schema(description = "LoRAy秩")
|
||||
private Integer lorayRank;
|
||||
|
||||
@Schema(description = "LoRAy缩放系数")
|
||||
private Integer lorayScaleFactor;
|
||||
|
||||
@Schema(description = "LoRAy随机丢弃")
|
||||
private Integer lorayDropout;
|
||||
|
||||
@Schema(description = "LoRAy作用模块")
|
||||
private String lorayModule;
|
||||
|
||||
@Schema(description = "DeepSpeed stage,使用字典(llm_deep_speed_stage)")
|
||||
private String deepSpeedStage;
|
||||
|
||||
@Schema(description = "加速方法,使用字典(llm_acceleration_method)")
|
||||
private String accelerationMethod;
|
||||
|
||||
@Schema(description = "DeepSpeed offload,使用字典(infra_boolean_string)")
|
||||
private Boolean deepSpeedOffload;
|
||||
|
||||
@Schema(description = "保存间隔")
|
||||
private Integer saveInterval;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "状态,使用字典(llm_fine_tuning_task_status)", example = "1")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,125 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.finetuningtask.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
|
||||
@Schema(description = "管理后台 - 模型调优 —— 微调任务 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class FineTuningTaskRespVO {
|
||||
|
||||
@Schema(description = "任务ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "3218")
|
||||
@ExcelProperty("任务ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@ExcelProperty("任务名称")
|
||||
private String taskName;
|
||||
|
||||
@Schema(description = "基础模型,使用字典(llm_base_model)")
|
||||
@ExcelProperty(value = "基础模型,使用字典(llm_base_model)", converter = DictConvert.class)
|
||||
@DictFormat("llm_base_model") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private String baseModel;
|
||||
|
||||
@Schema(description = "训练阶段,使用字典(llm_training_stage)")
|
||||
@ExcelProperty(value = "训练阶段,使用字典(llm_training_stage)", converter = DictConvert.class)
|
||||
@DictFormat("llm_training_stage") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer trainStage;
|
||||
|
||||
@Schema(description = "微调方法,使用字典(llm_fine_tuning_method)")
|
||||
@ExcelProperty(value = "微调方法,使用字典(llm_fine_tuning_method)", converter = DictConvert.class)
|
||||
@DictFormat("llm_fine_tuning_method") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer method;
|
||||
|
||||
@Schema(description = "描述")
|
||||
@ExcelProperty("描述")
|
||||
private String taskIntro;
|
||||
|
||||
@Schema(description = "GPU类型,使用字典(llm_gpu_type)", example = "1")
|
||||
@ExcelProperty(value = "GPU类型,使用字典(llm_gpu_type)", converter = DictConvert.class)
|
||||
@DictFormat("llm_gpu_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer gpuType;
|
||||
|
||||
@Schema(description = "GPU数量", example = "7626")
|
||||
@ExcelProperty("GPU数量")
|
||||
private Integer gpuCount;
|
||||
|
||||
@Schema(description = "数据集ID")
|
||||
@ExcelProperty("数据集ID")
|
||||
private Long dataset;
|
||||
|
||||
@Schema(description = "学习率")
|
||||
@ExcelProperty("学习率")
|
||||
private Integer learningRate;
|
||||
|
||||
@Schema(description = "训练轮数")
|
||||
@ExcelProperty("训练轮数")
|
||||
private Integer epoch;
|
||||
|
||||
@Schema(description = "截断长度")
|
||||
@ExcelProperty("截断长度")
|
||||
private Integer cutoffLen;
|
||||
|
||||
@Schema(description = "批处理大小")
|
||||
@ExcelProperty("批处理大小")
|
||||
private Integer batchSize;
|
||||
|
||||
@Schema(description = "梯度累积")
|
||||
@ExcelProperty("梯度累积")
|
||||
private Integer gradientAccumulation;
|
||||
|
||||
@Schema(description = "预热步数")
|
||||
@ExcelProperty("预热步数")
|
||||
private Integer warmup;
|
||||
|
||||
@Schema(description = "LoRAy秩")
|
||||
@ExcelProperty("LoRAy秩")
|
||||
private Integer lorayRank;
|
||||
|
||||
@Schema(description = "LoRAy缩放系数")
|
||||
@ExcelProperty("LoRAy缩放系数")
|
||||
private Integer lorayScaleFactor;
|
||||
|
||||
@Schema(description = "LoRAy随机丢弃")
|
||||
@ExcelProperty("LoRAy随机丢弃")
|
||||
private Integer lorayDropout;
|
||||
|
||||
@Schema(description = "LoRAy作用模块")
|
||||
@ExcelProperty("LoRAy作用模块")
|
||||
private String lorayModule;
|
||||
|
||||
@Schema(description = "DeepSpeed stage,使用字典(llm_deep_speed_stage)")
|
||||
@ExcelProperty(value = "DeepSpeed stage,使用字典(llm_deep_speed_stage)", converter = DictConvert.class)
|
||||
@DictFormat("llm_deep_speed_stage") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private String deepSpeedStage;
|
||||
|
||||
@Schema(description = "加速方法,使用字典(llm_acceleration_method)")
|
||||
@ExcelProperty(value = "加速方法,使用字典(llm_acceleration_method)", converter = DictConvert.class)
|
||||
@DictFormat("llm_acceleration_method") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private String accelerationMethod;
|
||||
|
||||
@Schema(description = "DeepSpeed offload,使用字典(infra_boolean_string)")
|
||||
@ExcelProperty(value = "DeepSpeed offload,使用字典(infra_boolean_string)", converter = DictConvert.class)
|
||||
@DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Boolean deepSpeedOffload;
|
||||
|
||||
@Schema(description = "保存间隔")
|
||||
@ExcelProperty("保存间隔")
|
||||
private Integer saveInterval;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "状态,使用字典(llm_fine_tuning_task_status)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "状态,使用字典(llm_fine_tuning_task_status)", converter = DictConvert.class)
|
||||
@DictFormat("llm_fine_tuning_task_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.finetuningtask.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 模型调优 —— 微调任务新增/修改 Request VO")
|
||||
@Data
|
||||
public class FineTuningTaskSaveReqVO {
|
||||
|
||||
@Schema(description = "任务ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "3218")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@NotEmpty(message = "任务名称不能为空")
|
||||
private String taskName;
|
||||
|
||||
@Schema(description = "基础模型,使用字典(llm_base_model)")
|
||||
private String baseModel;
|
||||
|
||||
@Schema(description = "训练阶段,使用字典(llm_training_stage)")
|
||||
private Integer trainStage;
|
||||
|
||||
@Schema(description = "微调方法,使用字典(llm_fine_tuning_method)")
|
||||
private Integer method;
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String taskIntro;
|
||||
|
||||
@Schema(description = "GPU类型,使用字典(llm_gpu_type)", example = "1")
|
||||
private Integer gpuType;
|
||||
|
||||
@Schema(description = "GPU数量", example = "7626")
|
||||
private Integer gpuCount;
|
||||
|
||||
@Schema(description = "数据集ID")
|
||||
private Long dataset;
|
||||
|
||||
@Schema(description = "学习率")
|
||||
private Integer learningRate;
|
||||
|
||||
@Schema(description = "训练轮数")
|
||||
private Integer epoch;
|
||||
|
||||
@Schema(description = "截断长度")
|
||||
private Integer cutoffLen;
|
||||
|
||||
@Schema(description = "批处理大小")
|
||||
private Integer batchSize;
|
||||
|
||||
@Schema(description = "梯度累积")
|
||||
private Integer gradientAccumulation;
|
||||
|
||||
@Schema(description = "预热步数")
|
||||
private Integer warmup;
|
||||
|
||||
@Schema(description = "LoRAy秩")
|
||||
private Integer lorayRank;
|
||||
|
||||
@Schema(description = "LoRAy缩放系数")
|
||||
private Integer lorayScaleFactor;
|
||||
|
||||
@Schema(description = "LoRAy随机丢弃")
|
||||
private Integer lorayDropout;
|
||||
|
||||
@Schema(description = "LoRAy作用模块")
|
||||
private String lorayModule;
|
||||
|
||||
@Schema(description = "DeepSpeed stage,使用字典(llm_deep_speed_stage)")
|
||||
private String deepSpeedStage;
|
||||
|
||||
@Schema(description = "加速方法,使用字典(llm_acceleration_method)")
|
||||
private String accelerationMethod;
|
||||
|
||||
@Schema(description = "DeepSpeed offload,使用字典(infra_boolean_string)")
|
||||
private Boolean deepSpeedOffload;
|
||||
|
||||
@Schema(description = "保存间隔")
|
||||
private Integer saveInterval;
|
||||
|
||||
@Schema(description = "状态,使用字典(llm_fine_tuning_task_status)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态,使用字典(llm_fine_tuning_task_status)不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.label;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.label.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.label.LabelDO;
|
||||
import cn.iocoder.yudao.module.llm.service.label.LabelService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Tag(name = "管理后台 - 标签管理")
|
||||
@RestController
|
||||
@RequestMapping("/llm/label")
|
||||
@Validated
|
||||
public class LabelController {
|
||||
|
||||
@Resource
|
||||
private LabelService labelService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建标签管理")
|
||||
// @PreAuthorize("@ss.hasPermission('llm:label:create')")
|
||||
public CommonResult<Long> createLabel(@Valid @RequestBody LabelSaveReqVO createReqVO) {
|
||||
return success(labelService.createLabel(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新标签管理")
|
||||
@PreAuthorize("@ss.hasPermission('llm:label:update')")
|
||||
public CommonResult<Boolean> updateLabel(@Valid @RequestBody LabelSaveReqVO updateReqVO) {
|
||||
labelService.updateLabel(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除标签管理")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('llm:label:delete')")
|
||||
public CommonResult<Boolean> deleteLabel(@RequestParam("id") Long id) {
|
||||
labelService.deleteLabel(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得标签管理")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('llm:label:query')")
|
||||
public CommonResult<LabelRespVO> getLabel(@RequestParam("id") Long id) {
|
||||
LabelDO label = labelService.getLabel(id);
|
||||
return success(BeanUtils.toBean(label, LabelRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得标签管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('llm:label:query')")
|
||||
public CommonResult<PageResult<LabelRespVO>> getLabelPage(@Valid LabelPageReqVO pageReqVO) {
|
||||
PageResult<LabelDO> pageResult = labelService.getLabelPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, LabelRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出标签管理 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('llm:label:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportLabelExcel(@Valid LabelPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<LabelDO> list = labelService.getLabelPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "标签管理.xls", "数据", LabelRespVO.class,
|
||||
BeanUtils.toBean(list, LabelRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.label.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 标签管理分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class LabelPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "标签分类", example = "张三")
|
||||
private String labelName;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "使用状态(0启用 1停用),使用字典(llm_label_status)", example = "1")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.label.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 标签管理 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class LabelRespVO {
|
||||
|
||||
@Schema(description = "标签ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "529")
|
||||
@ExcelProperty("标签ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "标签分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@ExcelProperty("标签分类")
|
||||
private String labelName;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "使用状态(0启用 1停用),使用字典(llm_label_status)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("使用状态(0启用 1停用),使用字典(llm_label_status)")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "标签排序")
|
||||
@NotNull(message = "标签排序不能为空")
|
||||
private String sorted;
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.label.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 标签管理新增/修改 Request VO")
|
||||
@Data
|
||||
public class LabelSaveReqVO {
|
||||
|
||||
@Schema(description = "标签ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "529")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "标签分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@NotEmpty(message = "标签分类不能为空")
|
||||
private String labelName;
|
||||
|
||||
@Schema(description = "标签排序")
|
||||
@NotNull(message = "标签排序不能为空")
|
||||
private String sorted;
|
||||
|
||||
@Schema(description = "使用状态(0启用 1停用),使用字典(llm_label_status)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
// @NotNull(message = "使用状态(0启用 1停用),使用字典(llm_label_status)不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,139 @@
|
||||
package cn.iocoder.yudao.module.llm.dal.dataobject.finetuningtask;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 模型调优 —— 微调任务 DO
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@TableName("llm_fine_tuning_task")
|
||||
@KeySequence("llm_fine_tuning_task_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FineTuningTaskDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 任务ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
private String taskName;
|
||||
/**
|
||||
* 基础模型,使用字典(llm_base_model)
|
||||
*
|
||||
* 枚举 {@link TODO llm_base_model 对应的类}
|
||||
*/
|
||||
private String baseModel;
|
||||
/**
|
||||
* 训练阶段,使用字典(llm_training_stage)
|
||||
*
|
||||
* 枚举 {@link TODO llm_training_stage 对应的类}
|
||||
*/
|
||||
private Integer trainStage;
|
||||
/**
|
||||
* 微调方法,使用字典(llm_fine_tuning_method)
|
||||
*
|
||||
* 枚举 {@link TODO llm_fine_tuning_method 对应的类}
|
||||
*/
|
||||
private Integer method;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String taskIntro;
|
||||
/**
|
||||
* GPU类型,使用字典(llm_gpu_type)
|
||||
*
|
||||
* 枚举 {@link TODO llm_gpu_type 对应的类}
|
||||
*/
|
||||
private Integer gpuType;
|
||||
/**
|
||||
* GPU数量
|
||||
*/
|
||||
private Integer gpuCount;
|
||||
/**
|
||||
* 数据集ID
|
||||
*/
|
||||
private Long dataset;
|
||||
/**
|
||||
* 学习率
|
||||
*/
|
||||
private Integer learningRate;
|
||||
/**
|
||||
* 训练轮数
|
||||
*/
|
||||
private Integer epoch;
|
||||
/**
|
||||
* 截断长度
|
||||
*/
|
||||
private Integer cutoffLen;
|
||||
/**
|
||||
* 批处理大小
|
||||
*/
|
||||
private Integer batchSize;
|
||||
/**
|
||||
* 梯度累积
|
||||
*/
|
||||
private Integer gradientAccumulation;
|
||||
/**
|
||||
* 预热步数
|
||||
*/
|
||||
private Integer warmup;
|
||||
/**
|
||||
* LoRAy秩
|
||||
*/
|
||||
private Integer lorayRank;
|
||||
/**
|
||||
* LoRAy缩放系数
|
||||
*/
|
||||
private Integer lorayScaleFactor;
|
||||
/**
|
||||
* LoRAy随机丢弃
|
||||
*/
|
||||
private Integer lorayDropout;
|
||||
/**
|
||||
* LoRAy作用模块
|
||||
*/
|
||||
private String lorayModule;
|
||||
/**
|
||||
* DeepSpeed stage,使用字典(llm_deep_speed_stage)
|
||||
*
|
||||
* 枚举 {@link TODO llm_deep_speed_stage 对应的类}
|
||||
*/
|
||||
private String deepSpeedStage;
|
||||
/**
|
||||
* 加速方法,使用字典(llm_acceleration_method)
|
||||
*
|
||||
* 枚举 {@link TODO llm_acceleration_method 对应的类}
|
||||
*/
|
||||
private String accelerationMethod;
|
||||
/**
|
||||
* DeepSpeed offload,使用字典(infra_boolean_string)
|
||||
*
|
||||
* 枚举 {@link TODO infra_boolean_string 对应的类}
|
||||
*/
|
||||
private Boolean deepSpeedOffload;
|
||||
/**
|
||||
* 保存间隔
|
||||
*/
|
||||
private Integer saveInterval;
|
||||
/**
|
||||
* 状态,使用字典(llm_fine_tuning_task_status)
|
||||
*
|
||||
* 枚举 {@link TODO llm_fine_tuning_task_status 对应的类}
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.llm.dal.dataobject.label;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 标签管理 DO
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@TableName("llm_label")
|
||||
@KeySequence("llm_label_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LabelDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 标签ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 标签分类
|
||||
*/
|
||||
private String labelName;
|
||||
/**
|
||||
* 使用状态(0启用 1停用),使用字典(llm_label_status)
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 标签排序
|
||||
*/
|
||||
private Integer sorted;
|
||||
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.module.llm.dal.mysql.finetuningtask;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.finetuningtask.FineTuningTaskDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.finetuningtask.vo.*;
|
||||
|
||||
/**
|
||||
* 模型调优 —— 微调任务 Mapper
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@Mapper
|
||||
public interface FineTuningTaskMapper extends BaseMapperX<FineTuningTaskDO> {
|
||||
|
||||
default PageResult<FineTuningTaskDO> selectPage(FineTuningTaskPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<FineTuningTaskDO>()
|
||||
.likeIfPresent(FineTuningTaskDO::getTaskName, reqVO.getTaskName())
|
||||
.eqIfPresent(FineTuningTaskDO::getBaseModel, reqVO.getBaseModel())
|
||||
.eqIfPresent(FineTuningTaskDO::getTrainStage, reqVO.getTrainStage())
|
||||
.eqIfPresent(FineTuningTaskDO::getMethod, reqVO.getMethod())
|
||||
.eqIfPresent(FineTuningTaskDO::getTaskIntro, reqVO.getTaskIntro())
|
||||
.eqIfPresent(FineTuningTaskDO::getGpuType, reqVO.getGpuType())
|
||||
.eqIfPresent(FineTuningTaskDO::getGpuCount, reqVO.getGpuCount())
|
||||
.eqIfPresent(FineTuningTaskDO::getDataset, reqVO.getDataset())
|
||||
.eqIfPresent(FineTuningTaskDO::getLearningRate, reqVO.getLearningRate())
|
||||
.eqIfPresent(FineTuningTaskDO::getEpoch, reqVO.getEpoch())
|
||||
.eqIfPresent(FineTuningTaskDO::getCutoffLen, reqVO.getCutoffLen())
|
||||
.eqIfPresent(FineTuningTaskDO::getBatchSize, reqVO.getBatchSize())
|
||||
.eqIfPresent(FineTuningTaskDO::getGradientAccumulation, reqVO.getGradientAccumulation())
|
||||
.eqIfPresent(FineTuningTaskDO::getWarmup, reqVO.getWarmup())
|
||||
.eqIfPresent(FineTuningTaskDO::getLorayRank, reqVO.getLorayRank())
|
||||
.eqIfPresent(FineTuningTaskDO::getLorayScaleFactor, reqVO.getLorayScaleFactor())
|
||||
.eqIfPresent(FineTuningTaskDO::getLorayDropout, reqVO.getLorayDropout())
|
||||
.eqIfPresent(FineTuningTaskDO::getLorayModule, reqVO.getLorayModule())
|
||||
.eqIfPresent(FineTuningTaskDO::getDeepSpeedStage, reqVO.getDeepSpeedStage())
|
||||
.eqIfPresent(FineTuningTaskDO::getAccelerationMethod, reqVO.getAccelerationMethod())
|
||||
.eqIfPresent(FineTuningTaskDO::getDeepSpeedOffload, reqVO.getDeepSpeedOffload())
|
||||
.eqIfPresent(FineTuningTaskDO::getSaveInterval, reqVO.getSaveInterval())
|
||||
.betweenIfPresent(FineTuningTaskDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(FineTuningTaskDO::getStatus, reqVO.getStatus())
|
||||
.eq(FineTuningTaskDO::getDeleted, false)
|
||||
.orderByDesc(FineTuningTaskDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.llm.dal.mysql.label;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.label.LabelDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.label.vo.*;
|
||||
|
||||
/**
|
||||
* 标签管理 Mapper
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@Mapper
|
||||
public interface LabelMapper extends BaseMapperX<LabelDO> {
|
||||
|
||||
default PageResult<LabelDO> selectPage(LabelPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<LabelDO>()
|
||||
.likeIfPresent(LabelDO::getLabelName, reqVO.getLabelName())
|
||||
.betweenIfPresent(LabelDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(LabelDO::getStatus, reqVO.getStatus())
|
||||
.orderByAsc(LabelDO::getSorted));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.llm.service.finetuningtask;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.finetuningtask.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.finetuningtask.FineTuningTaskDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 模型调优 —— 微调任务 Service 接口
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
public interface FineTuningTaskService {
|
||||
|
||||
/**
|
||||
* 创建模型调优 —— 微调任务
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createFineTuningTask(@Valid FineTuningTaskSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新模型调优 —— 微调任务
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateFineTuningTask(@Valid FineTuningTaskSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除模型调优 —— 微调任务
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteFineTuningTask(Long id);
|
||||
|
||||
/**
|
||||
* 获得模型调优 —— 微调任务
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 模型调优 —— 微调任务
|
||||
*/
|
||||
FineTuningTaskDO getFineTuningTask(Long id);
|
||||
|
||||
/**
|
||||
* 获得模型调优 —— 微调任务分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 模型调优 —— 微调任务分页
|
||||
*/
|
||||
PageResult<FineTuningTaskDO> getFineTuningTaskPage(FineTuningTaskPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package cn.iocoder.yudao.module.llm.service.finetuningtask;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.finetuningtask.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.finetuningtask.FineTuningTaskDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.llm.dal.mysql.finetuningtask.FineTuningTaskMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
|
||||
/**
|
||||
* 模型调优 —— 微调任务 Service 实现类
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class FineTuningTaskServiceImpl implements FineTuningTaskService {
|
||||
|
||||
@Resource
|
||||
private FineTuningTaskMapper fineTuningTaskMapper;
|
||||
|
||||
@Override
|
||||
public Long createFineTuningTask(FineTuningTaskSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
FineTuningTaskDO fineTuningTask = BeanUtils.toBean(createReqVO, FineTuningTaskDO.class);
|
||||
fineTuningTaskMapper.insert(fineTuningTask);
|
||||
// 返回
|
||||
return fineTuningTask.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFineTuningTask(FineTuningTaskSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateFineTuningTaskExists(updateReqVO.getId());
|
||||
// 更新
|
||||
FineTuningTaskDO updateObj = BeanUtils.toBean(updateReqVO, FineTuningTaskDO.class);
|
||||
fineTuningTaskMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFineTuningTask(Long id) {
|
||||
// 校验存在
|
||||
validateFineTuningTaskExists(id);
|
||||
// 删除
|
||||
LambdaUpdateWrapper<FineTuningTaskDO> wrapper = new LambdaUpdateWrapper<>();
|
||||
wrapper.eq(FineTuningTaskDO::getId, id)
|
||||
.set(FineTuningTaskDO::getDeleted,true);
|
||||
fineTuningTaskMapper.update(null,wrapper);
|
||||
// fineTuningTaskMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateFineTuningTaskExists(Long id) {
|
||||
if (fineTuningTaskMapper.selectById(id) == null) {
|
||||
// throw exception(FINE_TUNING_TASK_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FineTuningTaskDO getFineTuningTask(Long id) {
|
||||
return fineTuningTaskMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<FineTuningTaskDO> getFineTuningTaskPage(FineTuningTaskPageReqVO pageReqVO) {
|
||||
return fineTuningTaskMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.llm.service.label;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.label.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.label.LabelDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 标签管理 Service 接口
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
public interface LabelService {
|
||||
|
||||
/**
|
||||
* 创建标签管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createLabel(@Valid LabelSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新标签管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateLabel(@Valid LabelSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除标签管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteLabel(Long id);
|
||||
|
||||
/**
|
||||
* 获得标签管理
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 标签管理
|
||||
*/
|
||||
LabelDO getLabel(Long id);
|
||||
|
||||
/**
|
||||
* 获得标签管理分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 标签管理分页
|
||||
*/
|
||||
PageResult<LabelDO> getLabelPage(LabelPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.llm.service.label;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.label.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.label.LabelDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.llm.dal.mysql.label.LabelMapper;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 标签管理 Service 实现类
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class LabelServiceImpl implements LabelService {
|
||||
|
||||
@Resource
|
||||
private LabelMapper labelMapper;
|
||||
|
||||
@Override
|
||||
public Long createLabel(LabelSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
LabelDO label = BeanUtils.toBean(createReqVO, LabelDO.class);
|
||||
labelMapper.insert(label);
|
||||
// 返回
|
||||
return label.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLabel(LabelSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateLabelExists(updateReqVO.getId());
|
||||
// 更新
|
||||
LabelDO updateObj = BeanUtils.toBean(updateReqVO, LabelDO.class);
|
||||
labelMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLabel(Long id) {
|
||||
// 校验存在
|
||||
validateLabelExists(id);
|
||||
// 删除
|
||||
labelMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateLabelExists(Long id) {
|
||||
if (labelMapper.selectById(id) == null) {
|
||||
// throw exception(LABEL_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LabelDO getLabel(Long id) {
|
||||
return labelMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<LabelDO> getLabelPage(LabelPageReqVO pageReqVO) {
|
||||
return labelMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.llm.dal.mysql.finetuningtask.FineTuningTaskMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.llm.dal.mysql.label.LabelMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user