mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-02 03:34:58 +08:00
【调整】根据api调整ai角色,删除对modal关联 和 modal topK 相关设置。简单改为只是一个角色的预设
This commit is contained in:
parent
3d7c994bf9
commit
2b7e7763bf
@ -12,10 +12,10 @@ import lombok.Getter;
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum AiChatRoleVisibilityEnum {
|
||||
public enum AiChatRoleEnableEnum {
|
||||
|
||||
PUBLIC("public", "公开"),
|
||||
PRIVATE("private", "私有的"),
|
||||
OPEN("open", "公开"),
|
||||
CLOSE("close", "关闭"),
|
||||
|
||||
;
|
||||
|
||||
@ -24,8 +24,8 @@ public enum AiChatRoleVisibilityEnum {
|
||||
private String name;
|
||||
|
||||
|
||||
public static AiChatRoleVisibilityEnum valueOfType(String type) {
|
||||
for (AiChatRoleVisibilityEnum itemEnum : AiChatRoleVisibilityEnum.values()) {
|
||||
public static AiChatRoleEnableEnum valueOfType(String type) {
|
||||
for (AiChatRoleEnableEnum itemEnum : AiChatRoleEnableEnum.values()) {
|
||||
if (itemEnum.getType().equals(type)) {
|
||||
return itemEnum;
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package cn.iocoder.yudao.module.ai.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* chat角色 source
|
||||
*
|
||||
* @author fansili
|
||||
* @time 2024/4/24 16:37
|
||||
* @since 1.0
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum AiChatRoleSourceEnum {
|
||||
|
||||
SYSTEM("system", "系统"),
|
||||
CUSTOMER("customer", "用户自定义"),
|
||||
|
||||
|
||||
;
|
||||
|
||||
private String type;
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
public static AiChatRoleSourceEnum valueOfType(String type) {
|
||||
for (AiChatRoleSourceEnum itemEnum : AiChatRoleSourceEnum.values()) {
|
||||
if (itemEnum.getType().equals(type)) {
|
||||
return itemEnum;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid MessageType value: " + type);
|
||||
}
|
||||
}
|
@ -48,10 +48,10 @@ public class AiChatRoleController {
|
||||
}
|
||||
|
||||
@Operation(summary = "chat角色 - 修改可见性")
|
||||
@PostMapping("/role/{id}/update-visibility")
|
||||
public CommonResult<Void> updateVisibility(@PathVariable("id") Long id,
|
||||
@Validated @RequestBody AiChatRoleUpdateVisibilityReq req) {
|
||||
chatRoleService.updateVisibility(id, req);
|
||||
@PostMapping("/role/{id}/update-enable")
|
||||
public CommonResult<Void> updateEnable(@PathVariable("id") Long id,
|
||||
@Validated @RequestBody AiChatRoleUpdateVisibilityReq req) {
|
||||
chatRoleService.updateEnable(id, req);
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
|
@ -28,25 +28,15 @@ public class AiChatRoleDO extends BaseDO {
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 模型编号,关联到角色使用的特定模型
|
||||
*/
|
||||
private String modelId;
|
||||
|
||||
/**
|
||||
* 角色名,角色的显示名称
|
||||
*/
|
||||
private String roleName;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色介绍,详细描述角色的功能或用途
|
||||
*/
|
||||
private String roleIntroduce;
|
||||
|
||||
/**
|
||||
* 角色来源,如 system(系统预置)、customer(用户自定义)
|
||||
*/
|
||||
private String roleSource;
|
||||
private String introduce;
|
||||
|
||||
/**
|
||||
* 分类,角色所属的类别,如娱乐、创作等
|
||||
@ -54,24 +44,9 @@ public class AiChatRoleDO extends BaseDO {
|
||||
private String classify;
|
||||
|
||||
/**
|
||||
* 发布状态,private 表示仅自己可见,public表示公开,disable表示禁用
|
||||
* 是否开启 open、close
|
||||
*/
|
||||
private String visibility;
|
||||
|
||||
/**
|
||||
* 生成时的Top-K采样候选集大小
|
||||
*/
|
||||
private Double topK;
|
||||
|
||||
/**
|
||||
* 生成时使用的核采样方法的概率阈值
|
||||
*/
|
||||
private Double topP;
|
||||
|
||||
/**
|
||||
* 用于控制随机性和多样性的温度参数
|
||||
*/
|
||||
private Double temperature;
|
||||
private String enable;
|
||||
|
||||
/**
|
||||
* 角色的使用次数统计
|
||||
|
@ -42,7 +42,7 @@ public interface AiChatRoleService {
|
||||
* @param id
|
||||
* @param req
|
||||
*/
|
||||
void updateVisibility(Long id, AiChatRoleUpdateVisibilityReq req);
|
||||
void updateEnable(Long id, AiChatRoleUpdateVisibilityReq req);
|
||||
|
||||
/**
|
||||
* chat角色 - 删除
|
||||
|
@ -65,7 +65,7 @@ public class AiChatConversationServiceImpl implements AiChatConversationService
|
||||
AiChatRoleDO aiChatRoleDO = aiChatRoleMapper.selectById(req.getChatRoleId());
|
||||
// 创建新的 Conversation
|
||||
AiChatConversationDO insertConversation = saveConversation(req.getTitle(), loginUserId,
|
||||
req.getChatRoleId(), aiChatRoleDO.getRoleName(), AiChatConversationTypeEnum.ROLE_CHAT);
|
||||
req.getChatRoleId(), aiChatRoleDO.getName(), AiChatConversationTypeEnum.ROLE_CHAT);
|
||||
// 转换 res
|
||||
return AiChatConversationConvert.INSTANCE.covnertChatConversationRes(insertConversation);
|
||||
}
|
||||
|
@ -9,8 +9,7 @@ import cn.iocoder.yudao.module.ai.ErrorCodeConstants;
|
||||
import cn.iocoder.yudao.module.ai.convert.AiChatRoleConvert;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatRoleDO;
|
||||
import cn.iocoder.yudao.module.ai.enums.AiChatRoleClassifyEnum;
|
||||
import cn.iocoder.yudao.module.ai.enums.AiChatRoleSourceEnum;
|
||||
import cn.iocoder.yudao.module.ai.enums.AiChatRoleVisibilityEnum;
|
||||
import cn.iocoder.yudao.module.ai.enums.AiChatRoleEnableEnum;
|
||||
import cn.iocoder.yudao.module.ai.mapper.AiChatRoleMapper;
|
||||
import cn.iocoder.yudao.module.ai.service.AiChatRoleService;
|
||||
import cn.iocoder.yudao.module.ai.vo.*;
|
||||
@ -39,7 +38,7 @@ public class AiChatRoleServiceImpl implements AiChatRoleService {
|
||||
LambdaQueryWrapperX<AiChatRoleDO> queryWrapperX = new LambdaQueryWrapperX<>();
|
||||
// search 查询
|
||||
if (!StrUtil.isBlank(req.getSearch())) {
|
||||
queryWrapperX.eq(AiChatRoleDO::getRoleName, req.getSearch());
|
||||
queryWrapperX.eq(AiChatRoleDO::getName, req.getSearch());
|
||||
}
|
||||
// 默认排序id desc
|
||||
queryWrapperX.orderByDesc(AiChatRoleDO::getId);
|
||||
@ -56,8 +55,7 @@ public class AiChatRoleServiceImpl implements AiChatRoleService {
|
||||
public void add(AiChatRoleAddReq req) {
|
||||
// 转换enum,并校验enum
|
||||
AiChatRoleClassifyEnum.valueOfClassify(req.getClassify());
|
||||
AiChatRoleVisibilityEnum.valueOfType(req.getVisibility());
|
||||
AiChatRoleSourceEnum.valueOfType(req.getRoleSource());
|
||||
AiChatRoleEnableEnum.valueOfType(req.getEnable());
|
||||
// 转换do
|
||||
AiChatRoleDO insertAiChatRoleDO = AiChatRoleConvert.INSTANCE.convertAiChatRoleDO(req);
|
||||
insertAiChatRoleDO.setUserId(SecurityFrameworkUtils.getLoginUserId());
|
||||
@ -70,8 +68,7 @@ public class AiChatRoleServiceImpl implements AiChatRoleService {
|
||||
public void update(Long id, AiChatRoleUpdateReq req) {
|
||||
// 转换enum,并校验enum
|
||||
AiChatRoleClassifyEnum.valueOfClassify(req.getClassify());
|
||||
AiChatRoleVisibilityEnum.valueOfType(req.getVisibility());
|
||||
AiChatRoleSourceEnum.valueOfType(req.getRoleSource());
|
||||
AiChatRoleEnableEnum.valueOfType(req.getEnable());
|
||||
// 检查角色是否存在
|
||||
validateChatRoleExists(id);
|
||||
// 转换do
|
||||
@ -82,15 +79,15 @@ public class AiChatRoleServiceImpl implements AiChatRoleService {
|
||||
|
||||
|
||||
@Override
|
||||
public void updateVisibility(Long id, AiChatRoleUpdateVisibilityReq req) {
|
||||
public void updateEnable(Long id, AiChatRoleUpdateVisibilityReq req) {
|
||||
// 转换enum,并校验enum
|
||||
AiChatRoleVisibilityEnum.valueOfType(req.getVisibility());
|
||||
AiChatRoleEnableEnum.valueOfType(req.getEnable());
|
||||
// 检查角色是否存在
|
||||
validateChatRoleExists(id);
|
||||
// 更新
|
||||
aiChatRoleMapper.updateById(new AiChatRoleDO()
|
||||
.setId(id)
|
||||
.setVisibility(req.getVisibility())
|
||||
.setEnable(req.getEnable())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -16,39 +16,19 @@ import lombok.experimental.Accessors;
|
||||
@Accessors(chain = true)
|
||||
public class AiChatRoleAddReq extends PageParam {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "模型编号,关联到角色使用的特定模型")
|
||||
private String modelId;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "角色名,角色的显示名称")
|
||||
private String roleName;
|
||||
private String name;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "角色介绍,详细描述角色的功能或用途")
|
||||
private String roleIntroduce;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "角色来源,如 system(系统预置)、customer(用户自定义)")
|
||||
private String roleSource;
|
||||
private String introduce;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "分类,角色所属的类别,如娱乐、创作等")
|
||||
private String classify;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "发布状态,private 表示仅自己可见,public表示公开,disable表示禁用\n")
|
||||
private String visibility;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "生成时的Top-K采样候选集大小")
|
||||
private Double topK;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "生成时使用的核采样方法的概率阈值")
|
||||
private Double topP;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "用于控制随机性和多样性的温度参数")
|
||||
private Double temperature;
|
||||
@Schema(description = "开启状态 open、close")
|
||||
private String enable;
|
||||
}
|
||||
|
@ -20,32 +20,17 @@ public class AiChatRoleListRes {
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "模型id")
|
||||
private String modelId;
|
||||
|
||||
@Schema(description = "角色名字")
|
||||
private String roleName;
|
||||
private String name;
|
||||
|
||||
@Schema(description = "角色介绍,详细描述角色的功能或用途")
|
||||
private String roleIntroduce;
|
||||
|
||||
@Schema(description = "角色来源,如 system(系统预置)、customer(用户自定义)")
|
||||
private String roleSource;
|
||||
private String introduce;
|
||||
|
||||
@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 = "状态 open、close")
|
||||
private String enable;
|
||||
|
||||
@Schema(description = "角色的使用次数统计")
|
||||
private Integer useCount;
|
||||
|
@ -16,39 +16,19 @@ import lombok.experimental.Accessors;
|
||||
@Accessors(chain = true)
|
||||
public class AiChatRoleUpdateReq extends PageParam {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "模型编号,关联到角色使用的特定模型")
|
||||
private String modelId;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "角色名,角色的显示名称")
|
||||
private String roleName;
|
||||
private String name;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "角色介绍,详细描述角色的功能或用途")
|
||||
private String roleIntroduce;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "角色来源,如 system(系统预置)、customer(用户自定义)")
|
||||
private String roleSource;
|
||||
private String introduce;
|
||||
|
||||
@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;
|
||||
@Schema(description = "开启状态 open、close")
|
||||
private String enable;
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ import lombok.experimental.Accessors;
|
||||
public class AiChatRoleUpdateVisibilityReq extends PageParam {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "发布状态,0表示仅自己可见,1表示公开,2表示禁用")
|
||||
private String visibility;
|
||||
@Schema(description = "开启状态 open、close")
|
||||
private String enable;
|
||||
}
|
||||
|
@ -11,41 +11,33 @@ Authorization: {{token}}
|
||||
|
||||
{
|
||||
"modelId": 1,
|
||||
"roleName": "小红书写作v1",
|
||||
"roleIntroduce": "采用gpt3.5模型,拥有小红书优质作者写作经验。",
|
||||
"roleSource": "system",
|
||||
"name": "小红书写作v1",
|
||||
"introduce": "采用gpt3.5模型,拥有小红书优质作者写作经验。",
|
||||
"classify": "writing",
|
||||
"visibility": "public",
|
||||
"topK": 0.2,
|
||||
"topP": 0.4,
|
||||
"temperature": 0.7
|
||||
"enable": "open"
|
||||
}
|
||||
|
||||
|
||||
### chat update
|
||||
POST {{baseUrl}}/ai/chat/role/1
|
||||
POST {{baseUrl}}/ai/chat/role/6
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
"modelId": 1,
|
||||
"roleName": "小红书写作v1---hh😄",
|
||||
"roleIntroduce": "采用gpt3.5模型,拥有小红书优质作者写作经验。",
|
||||
"roleSource": "system",
|
||||
"name": "小红书写作v1---hh😄",
|
||||
"introduce": "采用gpt3.5模型,拥有小红书优质作者写作经验。",
|
||||
"classify": "writing",
|
||||
"visibility": "public",
|
||||
"topK": 0.2,
|
||||
"topP": 0.4,
|
||||
"temperature": 0.7
|
||||
"enable": "close"
|
||||
}
|
||||
|
||||
### chat update
|
||||
POST {{baseUrl}}/ai/chat/role/1/update-visibility
|
||||
POST {{baseUrl}}/ai/chat/role/6/update-visibility
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
"visibility": "private"
|
||||
"enable": "open"
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user