chat角色增加,角色列表
This commit is contained in:
parent
c75e415b61
commit
410893bc29
|
@ -0,0 +1,29 @@
|
|||
package cn.iocoder.yudao.module.ai.convert;
|
||||
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatRoleDO;
|
||||
import cn.iocoder.yudao.module.ai.vo.ChatRoleListRes;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 聊天 对话 convert
|
||||
*
|
||||
* @author fansili
|
||||
* @time 2024/4/18 16:39
|
||||
* @since 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface ChatRoleConvert {
|
||||
|
||||
ChatRoleConvert INSTANCE = Mappers.getMapper(ChatRoleConvert.class);
|
||||
|
||||
/**
|
||||
* 转换 - ChatRoleListRes
|
||||
*
|
||||
* @param roleList
|
||||
* @return
|
||||
*/
|
||||
List<ChatRoleListRes> convertChatRoleListRes(List<AiChatRoleDO> roleList);
|
||||
}
|
|
@ -1,8 +1,11 @@
|
|||
package cn.iocoder.yudao.module.ai.service;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.ai.vo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* chat 角色
|
||||
*
|
||||
|
@ -17,7 +20,7 @@ public interface ChatRoleService {
|
|||
* @param req
|
||||
* @return
|
||||
*/
|
||||
CommonResult<ChatRoleListRes> list(ChatRoleListReq req);
|
||||
PageResult<ChatRoleListRes> list(ChatRoleListReq req);
|
||||
|
||||
/**
|
||||
* chat角色 - 添加
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
package cn.iocoder.yudao.module.ai.service.impl;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.ai.convert.ChatRoleConvert;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatRoleDO;
|
||||
import cn.iocoder.yudao.module.ai.mapper.AiChatRoleMapper;
|
||||
import cn.iocoder.yudao.module.ai.service.ChatRoleService;
|
||||
import cn.iocoder.yudao.module.ai.vo.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* chat 角色
|
||||
*
|
||||
|
@ -18,10 +25,25 @@ import org.springframework.stereotype.Service;
|
|||
@Slf4j
|
||||
public class ChatRoleServiceImpl implements ChatRoleService {
|
||||
|
||||
private final AiChatRoleMapper aiChatRoleMapper;
|
||||
|
||||
@Override
|
||||
public CommonResult<ChatRoleListRes> list(ChatRoleListReq req) {
|
||||
return null;
|
||||
public PageResult<ChatRoleListRes> list(ChatRoleListReq req) {
|
||||
// 查询条件
|
||||
LambdaQueryWrapperX<AiChatRoleDO> queryWrapperX = new LambdaQueryWrapperX<>();
|
||||
// search 查询
|
||||
if (!StrUtil.isBlank(req.getSearch())) {
|
||||
queryWrapperX.eq(AiChatRoleDO::getRoleName, req.getSearch());
|
||||
}
|
||||
// 默认排序id desc
|
||||
queryWrapperX.orderByDesc(AiChatRoleDO::getId);
|
||||
//
|
||||
PageResult<AiChatRoleDO> aiChatRoleDOPageResult = aiChatRoleMapper.selectPage(req, queryWrapperX);
|
||||
Long total = aiChatRoleDOPageResult.getTotal();
|
||||
List<AiChatRoleDO> roleList = aiChatRoleDOPageResult.getList();
|
||||
// 换货res
|
||||
List<ChatRoleListRes> chatRoleListResList = ChatRoleConvert.INSTANCE.convertChatRoleListRes(roleList);
|
||||
return new PageResult<>(chatRoleListResList, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.ai.vo;
|
|||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
@ -15,6 +16,39 @@ import lombok.experimental.Accessors;
|
|||
@Accessors(chain = true)
|
||||
public class ChatRoleAddReq extends PageParam {
|
||||
|
||||
@Schema(description = "查询")
|
||||
private String search;
|
||||
@NotNull
|
||||
@Schema(description = "模型编号,关联到角色使用的特定模型")
|
||||
private String modelId;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "角色名,角色的显示名称")
|
||||
private String roleName;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "角色介绍,详细描述角色的功能或用途")
|
||||
private String roleIntroduce;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "角色来源,如 system(系统预置)、customer(用户自定义)")
|
||||
private String roleSource;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "分类,角色所属的类别,如娱乐、创作等")
|
||||
private String classify;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "发布状态,0表示仅自己可见,1表示公开,2表示禁用")
|
||||
private String visibility;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "生成时的Top-K采样候选集大小")
|
||||
private Double topK;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "生成时使用的核采样方法的概率阈值")
|
||||
private Double topP;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "用于控制随机性和多样性的温度参数")
|
||||
private Double temperature;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.iocoder.yudao.module.ai.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
@ -12,4 +13,40 @@ import lombok.experimental.Accessors;
|
|||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ChatRoleListRes {
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "模型id")
|
||||
private String modelId;
|
||||
|
||||
@Schema(description = "角色名字")
|
||||
private String roleName;
|
||||
|
||||
@Schema(description = "角色介绍,详细描述角色的功能或用途")
|
||||
private String roleIntroduce;
|
||||
|
||||
@Schema(description = "角色来源,如 system(系统预置)、customer(用户自定义)")
|
||||
private String roleSource;
|
||||
|
||||
@Schema(description = "分类,角色所属的类别,如娱乐、创作等")
|
||||
private String classify;
|
||||
|
||||
@Schema(description = "发布状态,0表示仅自己可见,1表示公开,2表示禁用")
|
||||
private String visibility;
|
||||
|
||||
@Schema(description = "生成时的Top-K采样候选集大小")
|
||||
private Double topK;
|
||||
|
||||
@Schema(description = "生成时使用的核采样方法的概率阈值")
|
||||
private Double topP;
|
||||
|
||||
@Schema(description = "用于控制随机性和多样性的温度参数")
|
||||
private Double temperature;
|
||||
|
||||
@Schema(description = "角色的使用次数统计")
|
||||
private Integer useCount;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue