mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 17:43:55 +08:00
fix:python config api no need maskSensitive
This commit is contained in:
+3
-3
@@ -377,7 +377,7 @@ public class ConfigServiceImpl implements ConfigService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 关键:第三个参数传false,确保获取原始密钥
|
// 关键:第三个参数传false,确保获取原始密钥
|
||||||
ModelConfigEntity model = modelConfigService.getModelById(modelIds[i], isCache, false);
|
ModelConfigEntity model = modelConfigService.getModelByIdFromCache(modelIds[i]);
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -426,7 +426,7 @@ public class ConfigServiceImpl implements ConfigService {
|
|||||||
if (StringUtils.isNotBlank(intentLLMModelId)) {
|
if (StringUtils.isNotBlank(intentLLMModelId)) {
|
||||||
if (!typeConfig.containsKey(intentLLMModelId)) {
|
if (!typeConfig.containsKey(intentLLMModelId)) {
|
||||||
// 修改这里:添加isMaskSensitive=false参数
|
// 修改这里:添加isMaskSensitive=false参数
|
||||||
ModelConfigEntity intentLLM = modelConfigService.getModelById(intentLLMModelId, isCache, false);
|
ModelConfigEntity intentLLM = modelConfigService.getModelByIdFromCache(intentLLMModelId);
|
||||||
typeConfig.put(intentLLM.getId(), intentLLM.getConfigJson());
|
typeConfig.put(intentLLM.getId(), intentLLM.getConfigJson());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -434,7 +434,7 @@ public class ConfigServiceImpl implements ConfigService {
|
|||||||
if (!typeConfig.containsKey(memLocalShortLLMModelId)) {
|
if (!typeConfig.containsKey(memLocalShortLLMModelId)) {
|
||||||
// 修改这里:添加isMaskSensitive=false参数
|
// 修改这里:添加isMaskSensitive=false参数
|
||||||
ModelConfigEntity memLocalShortLLM = modelConfigService
|
ModelConfigEntity memLocalShortLLM = modelConfigService
|
||||||
.getModelById(memLocalShortLLMModelId, isCache, false);
|
.getModelByIdFromCache(memLocalShortLLMModelId);
|
||||||
typeConfig.put(memLocalShortLLM.getId(), memLocalShortLLM.getConfigJson());
|
typeConfig.put(memLocalShortLLM.getId(), memLocalShortLLM.getConfigJson());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-15
@@ -36,27 +36,16 @@ public interface ModelConfigService extends BaseService<ModelConfigEntity> {
|
|||||||
/**
|
/**
|
||||||
* 根据ID获取模型配置
|
* 根据ID获取模型配置
|
||||||
*
|
*
|
||||||
* @param id 模型ID
|
* @param id 模型ID
|
||||||
* @param isCache 是否缓存
|
|
||||||
* @param isMaskSensitive 是否掩码敏感信息
|
|
||||||
* @return 模型配置实体
|
* @return 模型配置实体
|
||||||
*/
|
*/
|
||||||
ModelConfigEntity getModelById(String id, boolean isCache, boolean isMaskSensitive);
|
ModelConfigEntity getModelByIdFromCache(String id);
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据ID获取模型配置(默认掩码敏感信息)
|
|
||||||
*
|
|
||||||
* @param id 模型ID
|
|
||||||
* @param isCache 是否缓存
|
|
||||||
* @return 模型配置实体
|
|
||||||
*/
|
|
||||||
ModelConfigEntity getModelById(String id, boolean isCache);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置默认模型
|
* 设置默认模型
|
||||||
*
|
*
|
||||||
* @param modelType 模型类型
|
* @param modelType 模型类型
|
||||||
* @param isDefault 是否默认(1:是,0:否)
|
* @param isDefault 是否默认(1:是,0:否)
|
||||||
*/
|
*/
|
||||||
void setDefaultModel(String modelType, int isDefault);
|
void setDefaultModel(String modelType, int isDefault);
|
||||||
|
|
||||||
|
|||||||
+4
-33
@@ -211,44 +211,15 @@ public class ModelConfigServiceImpl extends BaseServiceImpl<ModelConfigDao, Mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelConfigEntity getModelById(String id, boolean isCache) {
|
public ModelConfigEntity getModelByIdFromCache(String id) {
|
||||||
return getModelById(id, isCache, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ModelConfigEntity getModelById(String id, boolean isCache, boolean isMaskSensitive) {
|
|
||||||
if (StringUtils.isBlank(id)) {
|
if (StringUtils.isBlank(id)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelConfigEntity entity = null;
|
|
||||||
String cacheKey = RedisKeys.getModelConfigById(id);
|
String cacheKey = RedisKeys.getModelConfigById(id);
|
||||||
|
ModelConfigEntity entity = (ModelConfigEntity) redisUtils.get(cacheKey);
|
||||||
if (isCache) {
|
if (entity == null) {
|
||||||
// 从缓存获取
|
entity = modelConfigDao.selectById(id);
|
||||||
entity = (ModelConfigEntity) redisUtils.get(cacheKey);
|
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
// 修改:根据isMaskSensitive参数重新处理敏感信息
|
|
||||||
if (!isMaskSensitive && entity.getConfigJson() != null) {
|
|
||||||
// 如果需要获取原始配置,但缓存的是掩码后的配置,则从数据库重新获取
|
|
||||||
ModelConfigEntity originalEntity = modelConfigDao.selectById(id);
|
|
||||||
if (originalEntity != null) {
|
|
||||||
entity.setConfigJson(originalEntity.getConfigJson());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 从数据库获取数据
|
|
||||||
entity = modelConfigDao.selectById(id);
|
|
||||||
if (entity != null) {
|
|
||||||
// 根据isMaskSensitive参数决定是否掩码敏感信息
|
|
||||||
if (isMaskSensitive && entity.getConfigJson() != null) {
|
|
||||||
entity.setConfigJson(maskSensitiveFields(entity.getConfigJson()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isCache) {
|
|
||||||
redisUtils.set(cacheKey, entity);
|
redisUtils.set(cacheKey, entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user