Browse Source

add:大模型,标注增加字段和逻辑

zhongwei
luyie 3 months ago
parent
commit
a3fafcf0a4
  1. 13
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/AgentLogController.java
  2. 47
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java
  3. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/AgentLogService.java
  4. 44
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java
  5. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdsRequest.java
  6. 19
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/LabelRequest.java

13
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/AgentLogController.java

@ -1,10 +1,13 @@
package com.hnac.hzims.bigmodel.maintenance.controller; package com.hnac.hzims.bigmodel.maintenance.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity; import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity;
import com.hnac.hzims.bigmodel.maintenance.service.AgentLogService; import com.hnac.hzims.bigmodel.maintenance.service.AgentLogService;
import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest; import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest;
import com.hnac.hzims.bigmodel.maintenance.vo.LabelRequest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -14,6 +17,7 @@ import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
/** /**
@ -32,7 +36,7 @@ public class AgentLogController {
@ApiOperation(value = "分页查询") @ApiOperation(value = "分页查询")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
public R<IPage<AgentLogEntity>> listPage(Query query, AgentLogEntity req) { public R<IPage<AgentLogEntity>> listPage(Query query, AgentLogEntity req) {
return R.data(agentLogService.page(Condition.getPage(query), Condition.getQueryWrapper(new AgentLogEntity(), req))); return R.data(agentLogService.listPage(Condition.getPage(query), req));
} }
@GetMapping("/detail") @GetMapping("/detail")
@ -69,4 +73,11 @@ public class AgentLogController {
public R BatchLabel(@RequestBody IdsRequest ids) { public R BatchLabel(@RequestBody IdsRequest ids) {
return R.status(agentLogService.BatchLabel(ids)); return R.status(agentLogService.BatchLabel(ids));
} }
@PutMapping("/label")
@ApiOperation(value = "标注")
@ApiOperationSupport(order = 7)
public R label(@RequestBody LabelRequest req) {
return R.status(agentLogService.label(req));
}
} }

47
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java

@ -11,6 +11,7 @@ import org.springblade.core.mp.support.SqlCondition;
import org.springblade.core.tenant.mp.TenantEntity; import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* @Author: ypj * @Author: ypj
@ -23,16 +24,21 @@ public class AgentLogEntity extends TenantEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty("对话id") @ApiModelProperty("对话id")
@TableField("CHAT_ID") @TableField("chat_id")
@QueryField(condition = SqlCondition.EQUAL) @QueryField(condition = SqlCondition.EQUAL)
private String chatId; private String chatId;
@ApiModelProperty("问题id") @ApiModelProperty("问题id")
@TableField("Q_ID") @TableField("q_id")
@QueryField(condition = SqlCondition.EQUAL) @QueryField(condition = SqlCondition.EQUAL)
@JSONField(name = "qId") @JSONField(name = "qId")
private String qId; private String qId;
@ApiModelProperty("模型名称")
@QueryField(condition = SqlCondition.EQUAL)
@TableField("model_name")
private String modelName;
@ApiModelProperty("问题来源") @ApiModelProperty("问题来源")
@QueryField(condition = SqlCondition.EQUAL) @QueryField(condition = SqlCondition.EQUAL)
private String agent; private String agent;
@ -43,33 +49,46 @@ public class AgentLogEntity extends TenantEntity implements Serializable {
@ApiModelProperty("问题提示") @ApiModelProperty("问题提示")
@QueryField(condition = SqlCondition.LIKE) @QueryField(condition = SqlCondition.LIKE)
@TableField("Q_HINT") @TableField("prompt")
@JSONField(name = "qHint") @JSONField(name = "prompt")
private String qHint; private String prompt;
@ApiModelProperty("系统提示")
@QueryField(condition = SqlCondition.LIKE)
@TableField("system")
private String system;
@ApiModelProperty("答案") @ApiModelProperty("答案")
@QueryField(condition = SqlCondition.LIKE) @QueryField(condition = SqlCondition.LIKE)
private String a; private String a;
@ApiModelProperty("答案类型")
@QueryField(condition = SqlCondition.EQUAL)
@TableField("A_TYPE")
@JSONField(name = "aType")
private String aType;
@ApiModelProperty("用户结论,0为错误,1为正确") @ApiModelProperty("用户结论,0为错误,1为正确")
@QueryField(condition = SqlCondition.EQUAL) @QueryField(condition = SqlCondition.EQUAL)
@TableField("USER_CONCLUSION") @TableField("user_conclusion")
private int userConclusion; private int userConclusion;
@ApiModelProperty("标注状态,0为未标注,1为已标注") @ApiModelProperty("标注状态,0为未标注,1为已标注")
@QueryField(condition = SqlCondition.EQUAL) @QueryField(condition = SqlCondition.EQUAL)
@TableField("LABEL_STATUS") @TableField("label_status")
private int labelStatus; private int labelStatus;
@ApiModelProperty("标注结果,0为错误,1为正确")
@QueryField(condition = SqlCondition.EQUAL)
@TableField("label_result")
private int labelResult;
@ApiModelProperty("标注内容,json字符串,答案类型不一样格式不一样") @ApiModelProperty("标注内容,json字符串,答案类型不一样格式不一样")
@QueryField(condition = SqlCondition.LIKE) @QueryField(condition = SqlCondition.LIKE)
@TableField("LABEL_CONTENT") @TableField("label_content")
private String labelContent; private String labelContent;
@ApiModelProperty("标注人名称")
@QueryField(condition = SqlCondition.LIKE)
@TableField("label_operator")
private String labelOperator;
@ApiModelProperty("标注时间")
@QueryField(condition = SqlCondition.EQUAL)
@TableField("label_time")
private Date labelTime;
} }

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/AgentLogService.java

@ -1,8 +1,10 @@
package com.hnac.hzims.bigmodel.maintenance.service; package com.hnac.hzims.bigmodel.maintenance.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity; import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity;
import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest; import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest;
import com.hnac.hzims.bigmodel.maintenance.vo.LabelRequest;
/** /**
* @Author: ypj * @Author: ypj
@ -10,4 +12,8 @@ import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest;
*/ */
public interface AgentLogService extends IService<AgentLogEntity> { public interface AgentLogService extends IService<AgentLogEntity> {
Boolean BatchLabel(IdsRequest ids); Boolean BatchLabel(IdsRequest ids);
Boolean label(LabelRequest req);
IPage<AgentLogEntity> listPage(IPage<AgentLogEntity> page, AgentLogEntity req);
} }

44
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java

@ -1,16 +1,24 @@
package com.hnac.hzims.bigmodel.maintenance.service.impl; package com.hnac.hzims.bigmodel.maintenance.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity; import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity;
import com.hnac.hzims.bigmodel.maintenance.mapper.AgentLogMapper; import com.hnac.hzims.bigmodel.maintenance.mapper.AgentLogMapper;
import com.hnac.hzims.bigmodel.maintenance.service.AgentLogService; import com.hnac.hzims.bigmodel.maintenance.service.AgentLogService;
import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest; import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest;
import com.hnac.hzims.bigmodel.maintenance.vo.LabelRequest;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
/** /**
* @Author: ypj * @Author: ypj
* @Date: 2024/9/9 11:10 * @Date: 2024/9/9 11:10
@ -21,11 +29,47 @@ import org.springframework.stereotype.Service;
@DS("hznlm") @DS("hznlm")
public class AgentLogServiceImpl extends ServiceImpl<AgentLogMapper, AgentLogEntity> implements AgentLogService { public class AgentLogServiceImpl extends ServiceImpl<AgentLogMapper, AgentLogEntity> implements AgentLogService {
@Override @Override
public Boolean BatchLabel(IdsRequest ids) { public Boolean BatchLabel(IdsRequest ids) {
Date now = new Date();
return this.update(Wrappers.<AgentLogEntity>lambdaUpdate() return this.update(Wrappers.<AgentLogEntity>lambdaUpdate()
.set(AgentLogEntity::getLabelStatus, 1) .set(AgentLogEntity::getLabelStatus, 1)
.set(AgentLogEntity::getLabelResult, 1)
.set(AgentLogEntity::getLabelOperator, AuthUtil.getUserName())
.set(AgentLogEntity::getLabelTime, now)
.set(AgentLogEntity::getUpdateTime, now)
.in(AgentLogEntity::getId, ids.getIds())); .in(AgentLogEntity::getId, ids.getIds()));
} }
@Override
public Boolean label(LabelRequest req) {
AgentLogEntity entity = this.getById(req.getId());
if (entity != null) {
int labelResult = StringUtil.isBlank(req.getLabelContent()) || req.getLabelContent().equals(entity.getA()) ? 1 : 0;
Date now = new Date();
return this.update(Wrappers.<AgentLogEntity>lambdaUpdate()
.set(AgentLogEntity::getLabelStatus, 1)
.set(AgentLogEntity::getLabelResult, labelResult)
.set(StringUtil.isNotBlank(req.getLabelContent()), AgentLogEntity::getLabelContent, req.getLabelContent())
.set(AgentLogEntity::getLabelOperator, AuthUtil.getUserName())
.set(AgentLogEntity::getLabelTime, now)
.set(AgentLogEntity::getUpdateTime, now)
.eq(AgentLogEntity::getId, req.getId()));
}
return false;
}
@Override
public IPage<AgentLogEntity> listPage(IPage<AgentLogEntity> page, AgentLogEntity req) {
LambdaQueryWrapper<AgentLogEntity> queryWrapper = Wrappers.<AgentLogEntity>lambdaQuery()
.eq(ObjectUtil.isNotEmpty(req.getId()), AgentLogEntity::getId, req.getId())
.eq(ObjectUtil.isNotEmpty(req.getChatId()), AgentLogEntity::getChatId, req.getChatId())
.eq(ObjectUtil.isNotEmpty(req.getQId()), AgentLogEntity::getQId, req.getQId())
.eq(ObjectUtil.isNotEmpty(req.getModelName()), AgentLogEntity::getModelName, req.getModelName())
.orderByDesc(AgentLogEntity::getCreateTime)
.orderByAsc(AgentLogEntity::getChatId);
return this.page(page, queryWrapper);
}
} }

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdsRequest.java

@ -1,5 +1,7 @@
package com.hnac.hzims.bigmodel.maintenance.vo; package com.hnac.hzims.bigmodel.maintenance.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
@ -9,7 +11,9 @@ import java.util.List;
* @Date: 2024/9/7 11:04 * @Date: 2024/9/7 11:04
*/ */
@Data @Data
@ApiModel("批量操作请求")
public class IdsRequest { public class IdsRequest {
@ApiModelProperty("主键ID,按逗号分隔")
private List<Long> ids; private List<Long> ids;
} }

19
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/LabelRequest.java

@ -0,0 +1,19 @@
package com.hnac.hzims.bigmodel.maintenance.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author: ypj
* @Date: 2024/9/10 14:04
*/
@Data
@ApiModel("标注")
public class LabelRequest {
@ApiModelProperty("主键ID")
private Long id;
@ApiModelProperty("标注内容,json字符串,答案类型不一样格式不一样")
private String labelContent;
}
Loading…
Cancel
Save