微调任务API对接
This commit is contained in:
parent
8f33f0b3dc
commit
4177e794c4
@ -70,4 +70,8 @@ public class LLMBackendProperties {
|
||||
|
||||
@NotNull(message = "创建微调任务 POST")
|
||||
private String finetuningCreate;
|
||||
|
||||
private String finetuningDetail;
|
||||
|
||||
private String finetuningFileList;
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package cn.iocoder.yudao.module.llm.service.async;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.finetuningtask.FineTuningTaskDO;
|
||||
import cn.iocoder.yudao.module.llm.dal.mysql.finetuningtask.FineTuningTaskMapper;
|
||||
import cn.iocoder.yudao.module.llm.service.http.TrainHttpService;
|
||||
import cn.iocoder.yudao.module.llm.service.http.vo.AigcFineTuningCreateReqVO;
|
||||
import cn.iocoder.yudao.module.llm.service.http.vo.AigcFineTuningCreateRespVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -10,6 +13,7 @@ import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AsyncFineTuningTaskService {
|
||||
|
||||
@Resource
|
||||
@ -22,9 +26,10 @@ public class AsyncFineTuningTaskService {
|
||||
@Async
|
||||
public void createTuning(FineTuningTaskDO fineTuningTask) {
|
||||
try {
|
||||
trainHttpService.finetuningCreate(new HashMap<>(),new String());
|
||||
}catch(Exception e){
|
||||
|
||||
AigcFineTuningCreateReqVO req = new AigcFineTuningCreateReqVO();
|
||||
AigcFineTuningCreateRespVO resp = trainHttpService.finetuningCreate(new HashMap<>(), req);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.common.util.http.HttpUtils;
|
||||
import cn.iocoder.yudao.module.llm.framework.backend.config.LLMBackendProperties;
|
||||
import cn.iocoder.yudao.module.llm.service.http.vo.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -137,9 +136,51 @@ public class TrainHttpService {
|
||||
/**
|
||||
* 创建微调任务 POST
|
||||
*/
|
||||
public String finetuningCreate(Map<String, String> headers, String body){
|
||||
public AigcFineTuningCreateRespVO finetuningCreate(Map<String, String> headers, AigcFineTuningCreateReqVO req){
|
||||
login(headers);
|
||||
String finetuningCreate = llmBackendProperties.getFinetuningCreate();
|
||||
String res = HttpUtils.post(finetuningCreate, headers, body);
|
||||
// TODO: 暂时先固定一个微调文件ID
|
||||
String fileId = "5c4e33fb-7ae2-4a48-9a78-fb74e4634d16";
|
||||
req.setFileId(fileId);
|
||||
String res = HttpUtils.post(finetuningCreate, headers, JSON.toJSONString(req));
|
||||
log.info(" finetuningCreate:{}", res);
|
||||
AigcRespVO aigcRespVO = JSON.parseObject(res, AigcRespVO.class);
|
||||
if (aigcRespVO.isSuccess() && aigcRespVO.getData() != null){
|
||||
AigcFineTuningCreateRespVO aigcFineTuningCreateRespVO = JSON.parseObject(aigcRespVO.getData().toString(), AigcFineTuningCreateRespVO.class);
|
||||
log.info(" finetuningCreate:{}", aigcFineTuningCreateRespVO);
|
||||
return aigcFineTuningCreateRespVO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public AigcFineTuningDetailRespVO finetuningDetail(Map<String, String> headers, String jobId){
|
||||
login(headers);
|
||||
String finetuningDetail = llmBackendProperties.getFinetuningDetail();
|
||||
String res = HttpUtils.get(finetuningDetail + "/" + jobId, headers);
|
||||
log.info(" finetuningDetail:{}", res);
|
||||
AigcRespVO aigcRespVO = JSON.parseObject(res, AigcRespVO.class);
|
||||
if (aigcRespVO.isSuccess() && aigcRespVO.getData() != null){
|
||||
AigcFineTuningDetailRespVO aigcFineTuningDetailRespVO = JSON.parseObject(aigcRespVO.getData().toString(), AigcFineTuningDetailRespVO.class);
|
||||
log.info(" finetuningDetail:{}", aigcFineTuningDetailRespVO);
|
||||
return aigcFineTuningDetailRespVO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public AigcRespVO finetuningDelete(Map<String, String> headers, String jobId) {
|
||||
login(headers);
|
||||
String finetuningDetail = llmBackendProperties.getFinetuningDetail();
|
||||
String res = HttpUtils.del(finetuningDetail + "/" + jobId, headers);
|
||||
log.info(" finetuningDelete:{}", res);
|
||||
AigcRespVO aigcRespVO = JSON.parseObject(res, AigcRespVO.class);
|
||||
log.info(" finetuningDelete:{}", aigcRespVO);
|
||||
return aigcRespVO;
|
||||
}
|
||||
|
||||
public String finetuningFileList(Map<String, String> headers) {
|
||||
String finetuningFileList = llmBackendProperties.getFinetuningFileList();
|
||||
String res = HttpUtils.get(finetuningFileList, headers);
|
||||
log.info(" finetuningFileList:{}", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -3,15 +3,13 @@ package cn.iocoder.yudao.module.llm.service.http.vo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FineTuningCreateVO {
|
||||
public class AigcFineTuningCreateReqVO {
|
||||
|
||||
private String scenario = "faq";
|
||||
private String scenario = "general";
|
||||
private String fileId = "48fac97c-5a69-4fde-9f77-86f4de2e91eb";
|
||||
private String baseModel;
|
||||
private int trainEpoch;
|
@ -0,0 +1,69 @@
|
||||
package cn.iocoder.yudao.module.llm.service.http.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AigcFineTuningCreateRespVO {
|
||||
private int id;
|
||||
private String jobId;
|
||||
private String baseModel;
|
||||
private int trainEpoch;
|
||||
private String trainStatus;
|
||||
private String trainDuration;
|
||||
private int process;
|
||||
private String fineTunedModel;
|
||||
private String remark;
|
||||
private String finishedAt;
|
||||
private ZonedDateTime createdAt;
|
||||
private String trainPublisher;
|
||||
private String trainLog;
|
||||
private String errorMessage;
|
||||
private boolean lora;
|
||||
private TrainAnalysis trainAnalysis;
|
||||
private String suffix;
|
||||
private int modelMaxLength;
|
||||
private int trainBatchSize;
|
||||
private String learningRate; // Note: This is a string to preserve precision or format
|
||||
private String fileUrl;
|
||||
private String fileId;
|
||||
private String startTrainTime;
|
||||
private int procPerNode;
|
||||
private int evalBatchSize;
|
||||
private int accumulationSteps;
|
||||
private String scenario;
|
||||
private Map<String, Object> diagnosis;
|
||||
|
||||
|
||||
public static class TrainAnalysis {
|
||||
private EpochAnalysis epoch;
|
||||
private LossAnalysis loss;
|
||||
private LearningRateAnalysis learningRate;
|
||||
}
|
||||
|
||||
// Nested class for EpochAnalysis
|
||||
public static class EpochAnalysis {
|
||||
private List<Integer> list;
|
||||
}
|
||||
|
||||
// Nested class for LossAnalysis
|
||||
public static class LossAnalysis {
|
||||
private List<Double> list;
|
||||
|
||||
}
|
||||
|
||||
// Nested class for LearningRateAnalysis
|
||||
public static class LearningRateAnalysis {
|
||||
|
||||
private List<Double> list; // Or String list if learning rates are represented as strings
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package cn.iocoder.yudao.module.llm.service.http.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AigcFineTuningDetailReqVO {
|
||||
private String jobId;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package cn.iocoder.yudao.module.llm.service.http.vo;
|
||||
|
||||
public class AigcFineTuningDetailRespVO {
|
||||
}
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FineTuningFileListRespVO {
|
||||
public class AigcFineTuningFileListRespVO {
|
||||
private boolean success;
|
||||
private int code;
|
||||
private ListData data;
|
@ -241,6 +241,8 @@ llm:
|
||||
login_password: admin
|
||||
# 创建微调任务 POST
|
||||
finetuning_create: http://aigc.xhllm.xinnuojinzhi.com/api/finetuning
|
||||
# 微调任务详情 GET
|
||||
finetuning_detail: http://aigc.xhllm.xinnuojinzhi.com/api/finetuning/
|
||||
# 微调文件列表 GET
|
||||
finetuning_file_list: http://aigc.xhllm.xinnuojinzhi.com/api/files?purpose=fine-tune
|
||||
|
||||
|
@ -284,6 +284,8 @@ llm:
|
||||
login_password: admin
|
||||
# 创建微调任务 POST
|
||||
finetuning_create: http://aigc.xhllm.xinnuojinzhi.com/api/finetuning
|
||||
# 微调任务详情 GET
|
||||
finetuning_detail: http://aigc.xhllm.xinnuojinzhi.com/api/finetuning/
|
||||
# 微调文件列表 GET
|
||||
finetuning_file_list: http://aigc.xhllm.xinnuojinzhi.com/api/files?purpose=fine-tune
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user