feat: 问答时添加统一重试和降级逻辑;

This commit is contained in:
likunlong
2025-08-19 16:46:25 +08:00
committed by Administrator
parent a0d029c142
commit aa11c1f233
10 changed files with 240 additions and 4 deletions

View File

@@ -90,6 +90,12 @@ public class ChatModelVo implements Serializable {
@ExcelProperty(value = "密钥")
private String apiKey;
/**
* 优先级(值越大优先级越高)
*/
@ExcelProperty(value = "优先级")
private Integer priority;
/**
* 备注
*/

View File

@@ -63,6 +63,11 @@ public interface IChatModelService {
*/
ChatModelVo selectModelByCategoryWithHighestPriority(String category);
/**
* 在同一分类下,查找优先级小于当前优先级的最高优先级模型(用于降级)。
*/
ChatModelVo selectFallbackModelByCategoryAndLessPriority(String category, Integer currentPriority);
/**
* 获取ppt模型信息
*/

View File

@@ -150,6 +150,20 @@ public class ChatModelServiceImpl implements IChatModelService {
);
}
/**
* 在同一分类下,查找优先级小于当前优先级的最高优先级模型(用于降级)。
*/
@Override
public ChatModelVo selectFallbackModelByCategoryAndLessPriority(String category, Integer currentPriority) {
return baseMapper.selectVoOne(
Wrappers.<ChatModel>lambdaQuery()
.eq(ChatModel::getCategory, category)
.lt(ChatModel::getPriority, currentPriority)
.orderByDesc(ChatModel::getPriority)
.last("LIMIT 1")
);
}
@Override
public ChatModel getPPT() {
return baseMapper.selectOne(Wrappers.<ChatModel>lambdaQuery().eq(ChatModel::getModelName, "ppt"));