From a3fafcf0a4e3e637e0b275632826818807b9144f Mon Sep 17 00:00:00 2001 From: luyie Date: Tue, 10 Sep 2024 15:01:47 +0800 Subject: [PATCH] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E6=A0=87=E6=B3=A8=E5=A2=9E=E5=8A=A0=E5=AD=97=E6=AE=B5=E5=92=8C?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maintenance/controller/AgentLogController.java | 13 +++++- .../maintenance/entity/AgentLogEntity.java | 47 +++++++++++++++------- .../maintenance/service/AgentLogService.java | 6 +++ .../service/impl/AgentLogServiceImpl.java | 44 ++++++++++++++++++++ .../hzims/bigmodel/maintenance/vo/IdsRequest.java | 4 ++ .../bigmodel/maintenance/vo/LabelRequest.java | 19 +++++++++ 6 files changed, 118 insertions(+), 15 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/LabelRequest.java 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; +}