定时维护,基础模型表信息
This commit is contained in:
parent
d941d753a5
commit
cfed3d4d8e
@ -49,4 +49,6 @@ public class BaseModelPageReqVO extends PageParam {
|
||||
@Schema(description = "代理")
|
||||
private String proxy;
|
||||
|
||||
@Schema(description = "aigc平台id")
|
||||
private Long aigcId;
|
||||
}
|
||||
|
@ -58,4 +58,7 @@ public class BaseModelRespVO {
|
||||
@Schema(description = "代理")
|
||||
private String proxy;
|
||||
|
||||
@Schema(description = "aigc平台id")
|
||||
private Long aigcId;
|
||||
|
||||
}
|
||||
|
@ -48,4 +48,6 @@ public class BaseModelSaveReqVO {
|
||||
@Schema(description = "代理")
|
||||
private String proxy;
|
||||
|
||||
@Schema(description = "aigc平台id")
|
||||
private Long aigcId;
|
||||
}
|
||||
|
@ -68,4 +68,9 @@ public class BaseModelDO extends BaseDO {
|
||||
*/
|
||||
private String proxy;
|
||||
|
||||
/**
|
||||
* augc平台的id
|
||||
*/
|
||||
private Long aigcId;
|
||||
|
||||
}
|
||||
|
@ -54,4 +54,6 @@ public interface BaseModelService {
|
||||
|
||||
List<BaseModelDO> getBaseModelList();
|
||||
|
||||
BaseModelDO getByAigcId(Long id);
|
||||
|
||||
}
|
||||
|
@ -1,22 +1,20 @@
|
||||
package cn.iocoder.yudao.module.llm.service.basemodel;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.basemodel.vo.BaseModelPageReqVO;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.basemodel.vo.BaseModelSaveReqVO;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.basemodel.BaseModelDO;
|
||||
import cn.iocoder.yudao.module.llm.dal.mysql.basemodel.BaseModelMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.basemodel.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.basemodel.BaseModelDO;
|
||||
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.basemodel.BaseModelMapper;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.llm.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.llm.enums.ErrorCodeConstants.BASE_MODEL_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 基座模型 Service 实现类
|
||||
@ -81,4 +79,11 @@ public class BaseModelServiceImpl implements BaseModelService {
|
||||
return baseModelDOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseModelDO getByAigcId(Long id) {
|
||||
LambdaQueryWrapper<BaseModelDO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(BaseModelDO::getAigcId,id);
|
||||
return baseModelMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
package cn.iocoder.yudao.module.llm.service.basemodel;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.basemodel.vo.BaseModelSaveReqVO;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.basemodel.BaseModelDO;
|
||||
import cn.iocoder.yudao.module.llm.service.basemodel.vo.ModelListRes;
|
||||
import cn.iocoder.yudao.module.llm.service.http.TrainHttpService;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class BaseModelTaskService {
|
||||
|
||||
@Resource
|
||||
TrainHttpService trainHttpService;
|
||||
|
||||
@Resource
|
||||
BaseModelService baseModelService;
|
||||
|
||||
|
||||
@Scheduled(cron ="0 0 0/1 * * ?")
|
||||
public void updateBaseModel() {
|
||||
Log.info("定时任务启动");
|
||||
String resStr = trainHttpService.modelsList();
|
||||
Log.info("获取aicg模型列表返回数据内容{}",resStr);
|
||||
JSONObject jsonObject = JSONObject.parseObject(resStr);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
JSONArray list = data.getJSONArray("list");
|
||||
String s = list.toJSONString();
|
||||
List<ModelListRes> modelListRes = JSONObject.parseArray(s, ModelListRes.class);
|
||||
for (ModelListRes modelListRe : modelListRes) {
|
||||
Long id = modelListRe.getId();
|
||||
BaseModelDO byAigcId = baseModelService.getByAigcId(id);
|
||||
if(byAigcId == null){
|
||||
BaseModelSaveReqVO baseModelSaveReqVO = new BaseModelSaveReqVO();
|
||||
baseModelSaveReqVO.setAigcId(id);
|
||||
baseModelSaveReqVO.setModelName(modelListRe.getModelName());
|
||||
baseModelSaveReqVO.setModelType(modelListRe.getModelType());
|
||||
baseModelSaveReqVO.setMaxContextLength(modelListRe.getMaxTokens());
|
||||
baseModelSaveReqVO.setIsActive(modelListRe.getEnabled());
|
||||
baseModelSaveReqVO.setIsFinetuned(modelListRe.getIsFineTuning());
|
||||
baseModelSaveReqVO.setNotes(modelListRe.getRemark());
|
||||
baseModelSaveReqVO.setParameterCount(1);
|
||||
baseModelService.createBaseModel(baseModelSaveReqVO);
|
||||
}else{
|
||||
BaseModelSaveReqVO baseModelSaveReqVO = new BaseModelSaveReqVO();
|
||||
baseModelSaveReqVO.setId(byAigcId.getId());
|
||||
baseModelSaveReqVO.setParameterCount(1);
|
||||
baseModelSaveReqVO.setModelName(modelListRe.getModelName());
|
||||
baseModelSaveReqVO.setModelType(modelListRe.getModelType());
|
||||
baseModelSaveReqVO.setMaxContextLength(modelListRe.getMaxTokens());
|
||||
baseModelSaveReqVO.setIsActive(modelListRe.getEnabled());
|
||||
baseModelSaveReqVO.setIsFinetuned(modelListRe.getIsFineTuning());
|
||||
baseModelSaveReqVO.setNotes(modelListRe.getRemark());
|
||||
baseModelService.updateBaseModel(baseModelSaveReqVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.llm.service.basemodel.vo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ModelListRes {
|
||||
|
||||
private Long id;
|
||||
|
||||
//模型名称
|
||||
private String modelName;
|
||||
|
||||
//最长上下文长度
|
||||
private Integer maxTokens;
|
||||
|
||||
//模型类型
|
||||
private String modelType;
|
||||
|
||||
//备注
|
||||
private String remark;
|
||||
|
||||
//是否启用
|
||||
private Boolean enabled;
|
||||
|
||||
//是否微调
|
||||
private Boolean isFineTuning;
|
||||
|
||||
//部署状态
|
||||
private String deployStatus;
|
||||
}
|
@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -80,7 +81,9 @@ public class TrainHttpService {
|
||||
/**
|
||||
* 大模型列表 GET
|
||||
*/
|
||||
public String modelsList(Map<String, String> headers){
|
||||
public String modelsList(){
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
login(headers);
|
||||
String modelsList = llmBackendProperties.getModelsList();
|
||||
String res = HttpUtils.get(modelsList, headers);
|
||||
return res;
|
||||
|
@ -233,7 +233,7 @@ llm:
|
||||
# 保存标注 POST
|
||||
annotation_task_save: http://localhost:8123/api/mgr/annotation/task/task-6025001b-692c-44a1-9bc7-2a34bd7c0efe/segment/das-2eedd7bf-3770-4816-a961-b30c446b7a4f/mark
|
||||
# 大模型列表 GET
|
||||
models_list: http://localhost:8123/api/models
|
||||
models_list: http://aigc.xhllm.xinnuojinzhi.com/api/models
|
||||
# 登录 POST
|
||||
login: http://aigc.xhllm.xinnuojinzhi.com/api/auth/login
|
||||
account: http://aigc.xhllm.xinnuojinzhi.com/api/auth/account
|
||||
|
@ -276,7 +276,7 @@ llm:
|
||||
# 保存标注 POST
|
||||
annotation_task_save: http://localhost:8123/api/mgr/annotation/task/task-6025001b-692c-44a1-9bc7-2a34bd7c0efe/segment/das-2eedd7bf-3770-4816-a961-b30c446b7a4f/mark
|
||||
# 大模型列表 GET
|
||||
models_list: http://localhost:8123/api/models
|
||||
models_list: http://aigc.xhllm.xinnuojinzhi.com/api/models
|
||||
# 登录 POST
|
||||
login: http://aigc.xhllm.xinnuojinzhi.com/api/auth/login
|
||||
account: http://aigc.xhllm.xinnuojinzhi.com/api/auth/account
|
||||
|
Loading…
x
Reference in New Issue
Block a user