diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Model/ModelLibraryDto.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Model/ModelLibraryDto.cs
index 07cb12d2..9edf05f8 100644
--- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Model/ModelLibraryDto.cs
+++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Model/ModelLibraryDto.cs
@@ -1,4 +1,5 @@
using Yi.Framework.AiHub.Domain.Shared.Enums;
+using Yi.Framework.AiHub.Domain.Shared.Extensions;
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Model;
@@ -30,18 +31,14 @@ public class ModelLibraryDto
///
/// 模型类型名称
///
- public string ModelTypeName { get; set; }
+ public string ModelTypeName => ModelType.GetDescription();
///
- /// 模型API类型
+ /// 模型支持的API类型
///
- public ModelApiTypeEnum ModelApiType { get; set; }
-
- ///
- /// 模型API类型名称
- ///
- public string ModelApiTypeName { get; set; }
+ public List ModelApiTypes { get; set; }
+
///
/// 模型显示倍率
///
@@ -61,4 +58,22 @@ public class ModelLibraryDto
/// 是否为尊享模型(PremiumChat类型)
///
public bool IsPremium { get; set; }
+
+ ///
+ /// 排序
+ ///
+ public int OrderNum { get; set; }
}
+
+public class ModelApiTypeOutput
+{
+ ///
+ /// 模型类型
+ ///
+ public ModelApiTypeEnum ModelApiType { get; set; }
+
+ ///
+ /// 模型类型名称
+ ///
+ public string ModelApiTypeName => ModelApiType.GetDescription();
+}
\ No newline at end of file
diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiChatService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiChatService.cs
index 1c328039..5444ee05 100644
--- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiChatService.cs
+++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiChatService.cs
@@ -73,7 +73,7 @@ public class AiChatService : ApplicationService
{
var output = await _aiModelRepository._DbQueryable
.Where(x => x.ModelType == ModelTypeEnum.Chat)
- .Where(x=>x.ModelApiType==ModelApiTypeEnum.OpenAi)
+ .Where(x => x.ModelApiType == ModelApiTypeEnum.OpenAi)
.OrderByDescending(x => x.OrderNum)
.Select(x => new ModelGetListOutput
{
diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/ModelService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/ModelService.cs
index 21f574d1..98faf61c 100644
--- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/ModelService.cs
+++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/ModelService.cs
@@ -32,8 +32,7 @@ public class ModelService : ApplicationService, IModelService
RefAsync total = 0;
// 查询所有未删除的模型,使用WhereIF动态添加筛选条件
- var models = await _modelRepository._DbQueryable
- .Where(x => !x.IsDeleted)
+ var modelIds = (await _modelRepository._DbQueryable
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), x =>
x.Name.Contains(input.SearchKey) || x.ModelId.Contains(input.SearchKey))
.WhereIF(input.ProviderNames is not null, x =>
@@ -44,27 +43,29 @@ public class ModelService : ApplicationService, IModelService
input.ModelApiTypes.Contains(x.ModelApiType))
.WhereIF(input.IsPremiumOnly == true, x =>
PremiumPackageConst.ModeIds.Contains(x.ModelId))
+ .GroupBy(x => x.ModelId)
+ .Select(x => x.ModelId)
+ .ToPageListAsync(input.SkipCount, input.MaxResultCount, total));
+
+ var entities = await _modelRepository._DbQueryable.Where(x => modelIds.Contains(x.ModelId))
.OrderBy(x => x.OrderNum)
- .OrderBy(x => x.Name)
- .ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
+ .OrderBy(x => x.Name).ToListAsync();
- // 转换为DTO
- var result = models.Select(model => new ModelLibraryDto
+ var output= entities.GroupBy(x => x.ModelId).Select(x => new ModelLibraryDto
{
- ModelId = model.ModelId,
- Name = model.Name,
- Description = model.Description,
- ModelType = model.ModelType,
- ModelTypeName = model.ModelType.GetDescription(),
- ModelApiType = model.ModelApiType,
- ModelApiTypeName = model.ModelApiType.GetDescription(),
- MultiplierShow = model.MultiplierShow,
- ProviderName = model.ProviderName,
- IconUrl = model.IconUrl,
- IsPremium = PremiumPackageConst.ModeIds.Contains(model.ModelId)
+ ModelId = x.First().ModelId,
+ Name = x.First().Name,
+ Description = x.First().Description,
+ ModelType = x.First().ModelType,
+ ModelApiTypes = x.Select(y => new ModelApiTypeOutput { ModelApiType = y.ModelApiType }).ToList(),
+ MultiplierShow = x.First().MultiplierShow,
+ ProviderName = x.First().ProviderName,
+ IconUrl = x.First().IconUrl,
+ IsPremium = PremiumPackageConst.ModeIds.Contains(x.First().ModelId),
+ OrderNum = x.First().OrderNum
}).ToList();
-
- return new PagedResultDto(total, result);
+
+ return new PagedResultDto(total, output);
}
///