mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-03-13 20:53:42 +08:00
Merge pull request #175 from LM20230311/feat-model-priority
Feat model priority:支持自动选择模型;支持模型的重试;
This commit is contained in:
@@ -76,6 +76,11 @@ public class ChatModel extends BaseEntity {
|
||||
*/
|
||||
private String apiKey;
|
||||
|
||||
/**
|
||||
* 优先级
|
||||
*/
|
||||
private Integer priority;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
@@ -74,6 +74,11 @@ public class ChatModelBo extends BaseEntity {
|
||||
@NotBlank(message = "请求地址不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String apiHost;
|
||||
|
||||
/**
|
||||
* 优先级
|
||||
*/
|
||||
private Integer priority;
|
||||
|
||||
/**
|
||||
* 密钥
|
||||
*/
|
||||
|
||||
@@ -90,6 +90,12 @@ public class ChatModelVo implements Serializable {
|
||||
@ExcelProperty(value = "密钥")
|
||||
private String apiKey;
|
||||
|
||||
/**
|
||||
* 优先级(值越大优先级越高)
|
||||
*/
|
||||
@ExcelProperty(value = "优先级")
|
||||
private Integer priority;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
@@ -57,6 +57,17 @@ public interface IChatModelService {
|
||||
* 通过模型分类获取模型信息
|
||||
*/
|
||||
ChatModelVo selectModelByCategory(String image);
|
||||
|
||||
/**
|
||||
* 通过模型分类获取优先级最高的模型信息
|
||||
*/
|
||||
ChatModelVo selectModelByCategoryWithHighestPriority(String category);
|
||||
|
||||
/**
|
||||
* 在同一分类下,查找优先级小于当前优先级的最高优先级模型(用于降级)。
|
||||
*/
|
||||
ChatModelVo selectFallbackModelByCategoryAndLessPriority(String category, Integer currentPriority);
|
||||
|
||||
/**
|
||||
* 获取ppt模型信息
|
||||
*/
|
||||
|
||||
@@ -136,6 +136,33 @@ public class ChatModelServiceImpl implements IChatModelService {
|
||||
public ChatModelVo selectModelByCategory(String category) {
|
||||
return baseMapper.selectVoOne(Wrappers.<ChatModel>lambdaQuery().eq(ChatModel::getCategory, category));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过模型分类获取优先级最高的模型信息
|
||||
*/
|
||||
@Override
|
||||
public ChatModelVo selectModelByCategoryWithHighestPriority(String category) {
|
||||
return baseMapper.selectVoOne(
|
||||
Wrappers.<ChatModel>lambdaQuery()
|
||||
.eq(ChatModel::getCategory, category)
|
||||
.orderByDesc(ChatModel::getPriority)
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在同一分类下,查找优先级小于当前优先级的最高优先级模型(用于降级)。
|
||||
*/
|
||||
@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() {
|
||||
|
||||
Reference in New Issue
Block a user