diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/AgentLogController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/AgentLogController.java index fc81a73..32b9fa6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/AgentLogController.java +++ b/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; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity; import com.hnac.hzims.bigmodel.maintenance.service.AgentLogService; 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.ApiOperation; 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.tool.api.R; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; import org.springframework.web.bind.annotation.*; /** @@ -32,7 +36,7 @@ public class AgentLogController { @ApiOperation(value = "分页查询") @ApiOperationSupport(order = 1) public R> 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") @@ -69,4 +73,11 @@ public class AgentLogController { public R BatchLabel(@RequestBody IdsRequest 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)); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java index 119cc4b..fd1d6dc 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java +++ b/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 java.io.Serializable; +import java.util.Date; /** * @Author: ypj @@ -23,16 +24,21 @@ public class AgentLogEntity extends TenantEntity implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty("对话id") - @TableField("CHAT_ID") + @TableField("chat_id") @QueryField(condition = SqlCondition.EQUAL) private String chatId; @ApiModelProperty("问题id") - @TableField("Q_ID") + @TableField("q_id") @QueryField(condition = SqlCondition.EQUAL) @JSONField(name = "qId") private String qId; + @ApiModelProperty("模型名称") + @QueryField(condition = SqlCondition.EQUAL) + @TableField("model_name") + private String modelName; + @ApiModelProperty("问题来源") @QueryField(condition = SqlCondition.EQUAL) private String agent; @@ -43,33 +49,46 @@ public class AgentLogEntity extends TenantEntity implements Serializable { @ApiModelProperty("问题提示") @QueryField(condition = SqlCondition.LIKE) - @TableField("Q_HINT") - @JSONField(name = "qHint") - private String qHint; + @TableField("prompt") + @JSONField(name = "prompt") + private String prompt; + + @ApiModelProperty("系统提示") + @QueryField(condition = SqlCondition.LIKE) + @TableField("system") + private String system; @ApiModelProperty("答案") @QueryField(condition = SqlCondition.LIKE) private String a; - @ApiModelProperty("答案类型") - @QueryField(condition = SqlCondition.EQUAL) - @TableField("A_TYPE") - @JSONField(name = "aType") - private String aType; - @ApiModelProperty("用户结论,0为错误,1为正确") @QueryField(condition = SqlCondition.EQUAL) - @TableField("USER_CONCLUSION") + @TableField("user_conclusion") private int userConclusion; @ApiModelProperty("标注状态,0为未标注,1为已标注") @QueryField(condition = SqlCondition.EQUAL) - @TableField("LABEL_STATUS") + @TableField("label_status") private int labelStatus; + @ApiModelProperty("标注结果,0为错误,1为正确") + @QueryField(condition = SqlCondition.EQUAL) + @TableField("label_result") + private int labelResult; + @ApiModelProperty("标注内容,json字符串,答案类型不一样格式不一样") @QueryField(condition = SqlCondition.LIKE) - @TableField("LABEL_CONTENT") + @TableField("label_content") 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; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/AgentLogService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/AgentLogService.java index 35bc35a..00da361 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/AgentLogService.java +++ b/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; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity; import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest; +import com.hnac.hzims.bigmodel.maintenance.vo.LabelRequest; /** * @Author: ypj @@ -10,4 +12,8 @@ import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest; */ public interface AgentLogService extends IService { Boolean BatchLabel(IdsRequest ids); + + Boolean label(LabelRequest req); + + IPage listPage(IPage page, AgentLogEntity req); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java index 85c3e40..558dfc0 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java +++ b/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; 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.extension.service.impl.ServiceImpl; import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity; import com.hnac.hzims.bigmodel.maintenance.mapper.AgentLogMapper; import com.hnac.hzims.bigmodel.maintenance.service.AgentLogService; import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest; +import com.hnac.hzims.bigmodel.maintenance.vo.LabelRequest; import lombok.AllArgsConstructor; 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 java.util.Date; + /** * @Author: ypj * @Date: 2024/9/9 11:10 @@ -21,11 +29,47 @@ import org.springframework.stereotype.Service; @DS("hznlm") public class AgentLogServiceImpl extends ServiceImpl implements AgentLogService { + @Override public Boolean BatchLabel(IdsRequest ids) { + Date now = new Date(); return this.update(Wrappers.lambdaUpdate() .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())); } + @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.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 listPage(IPage page, AgentLogEntity req) { + LambdaQueryWrapper queryWrapper = Wrappers.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); + } + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdsRequest.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdsRequest.java index 122aa7c..af3b60f 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdsRequest.java +++ b/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; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; @@ -9,7 +11,9 @@ import java.util.List; * @Date: 2024/9/7 11:04 */ @Data +@ApiModel("批量操作请求") public class IdsRequest { + @ApiModelProperty("主键ID,按逗号分隔") private List ids; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/LabelRequest.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/LabelRequest.java new file mode 100644 index 0000000..6389578 --- /dev/null +++ b/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; +}