Skip to content

Commit

Permalink
fix: 修复房间创建配置项校验失效
Browse files Browse the repository at this point in the history
  • Loading branch information
hncboy committed Jul 9, 2023
1 parent 552d6d8 commit 7c2245d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class RoomConfigParamDO {
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
private Integer id;
private Long id;

/**
* 用户 ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ default void afterPermissionBoToVo(CellConfigPermissionBO cellConfigPermissionBO
}

// 默认值不可见
if (cellConfigPermissionBO.getIsUserValueVisible()) {
if (!cellConfigPermissionBO.getIsUserValueVisible()) {
// 默认值值置为空
cellConfigVO.setDefaultValue(null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hncboy.beehive.cell.core.hander.converter;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.hncboy.beehive.base.domain.entity.RoomConfigParamDO;
import com.hncboy.beehive.base.util.FrontUserUtil;
import com.hncboy.beehive.cell.core.domain.bo.CellConfigPermissionBO;
Expand Down Expand Up @@ -44,6 +45,7 @@ public interface RoomConfigParamConverter {
*/
default RoomConfigParamDO boToEntity(RoomConfigParamBO roomConfigParamBO, Long roomId) {
RoomConfigParamDO roomConfigParamDO = new RoomConfigParamDO();
roomConfigParamDO.setId(IdWorker.getId());
roomConfigParamDO.setUserId(FrontUserUtil.getUserId());
roomConfigParamDO.setRoomId(roomId);
roomConfigParamDO.setCellConfigCode(roomConfigParamBO.getCellConfigCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public void compositeValidate(List<RoomConfigParamBO> roomConfigParamBOList) {
RoomConfigParamBO roomConfigParamBO = entry.getValue();
ICellConfigCodeEnum cellConfigCodeEnum = entry.getKey();

// 单个校验参数
singleValidate(cellConfigCodeEnum, new DataWrapper(roomConfigParamBO.getValue()));

// 复合校验所有的参数
cellConfigCodeEnum.compositeValidate(roomConfigParamBoMap, getCellCode());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hncboy.beehive.cell.openai.enums;

import cn.hutool.core.util.NumberUtil;
import com.hncboy.beehive.base.enums.CellCodeEnum;
import com.hncboy.beehive.base.exception.ServiceException;
import com.hncboy.beehive.base.util.ThrowExceptionUtil;
Expand Down Expand Up @@ -49,7 +50,9 @@ public void singleValidate(DataWrapper dataWrapper) {
if (dataWrapper.isNull()) {
return;
}

if (!NumberUtil.isInteger(dataWrapper.asString())) {
throw new ServiceException("maxTokens 限制范围是 [100, 10000]");
}
int maxTokens = dataWrapper.asInt();
if (maxTokens < 100 || maxTokens > 10000) {
throw new ServiceException("maxTokens 限制范围是 [100, 10000]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ public void compositeValidate(Map<ICellConfigCodeEnum, RoomConfigParamBO> roomCo

// GPT 4 图纸无法使用 GPT 3.5 模型
if (cellCode == CellCodeEnum.OPENAI_CHAT_WEB_4) {
if (ObjectUtil.notEqual(OpenAiChatWebModeEnum.GPT_4.getName(), defaultValue)
&& ObjectUtil.notEqual(OpenAiChatWebModeEnum.GPT_4_BROWSING.getName(), defaultValue)) {
throw new ServiceException("模型参数错误,该图纸无法使用 GPT-3.5");
if (ObjectUtil.equals(OpenAiChatWebModeEnum.GPT_4.getName(), defaultValue)) {
throw new ServiceException("模型参数错误,该图纸必须使用 GPT-4");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ public enum OpenAiChatWebModeEnum {
* 目前限制 3 小时 25 条消息,超过限制报什么错还没测试
* ChatGPT Plus
*/
GPT_4("gpt-4"),

/**
* 对应官网 GPT-4 Browsing with bing
* 有什么限制还不知道
* ChatGPT Plus
*/
GPT_4_BROWSING("gpt-4-browsing");
GPT_4("gpt-4");

@Getter
private final String name;
Expand Down

0 comments on commit 7c2245d

Please sign in to comment.