mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 15:13:55 +08:00
添加了修改模型配置验证
--ModelConfigServiceImpl.java 修改模型,jsonConfig 里包括llm,校验一下llm是否时在LLM模型里,并且这个模型的供应器类型只能是openai和ollama类型
This commit is contained in:
+14
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -110,6 +111,19 @@ public class ModelConfigServiceImpl extends BaseServiceImpl<ModelConfigDao, Mode
|
||||
if (CollectionUtil.isEmpty(providerList)) {
|
||||
throw new RenException("供应器不存在");
|
||||
}
|
||||
if(modelConfigBodyDTO.getConfigJson().containsKey("llm")){
|
||||
String llm = modelConfigBodyDTO.getConfigJson().get("llm").toString();
|
||||
ModelConfigEntity modelConfigEntity = modelConfigDao.selectOne(new LambdaQueryWrapper<ModelConfigEntity>()
|
||||
.eq(ModelConfigEntity::getId, llm));
|
||||
if(modelConfigEntity == null){
|
||||
throw new RenException("设置的LLM不存在");
|
||||
}
|
||||
String type = modelConfigEntity.getConfigJson().get("type").toString();
|
||||
// 如果查询大语言模型是openai或者ollama,意图识别选参数都可以
|
||||
if(!"openai".equals(type) && !"ollama".equals(type)){
|
||||
throw new RenException("设置的LLM不是openai和ollama");
|
||||
}
|
||||
}
|
||||
|
||||
// 再更新供应器提供的模型
|
||||
ModelConfigEntity modelConfigEntity = ConvertUtils.sourceToTarget(modelConfigBodyDTO, ModelConfigEntity.class);
|
||||
|
||||
Reference in New Issue
Block a user