diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelCreateInput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelCreateInput.cs index 9e956c52..05197d1e 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelCreateInput.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelCreateInput.cs @@ -93,4 +93,9 @@ public class AiModelCreateInput /// 是否为尊享模型 /// public bool IsPremium { get; set; } + + /// + /// 是否启用 + /// + public bool IsEnabled { get; set; } = true; } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelDto.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelDto.cs index 3b93b680..834d72fb 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelDto.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelDto.cs @@ -81,4 +81,9 @@ public class AiModelDto /// 是否为尊享模型 /// public bool IsPremium { get; set; } + + /// + /// 是否启用 + /// + public bool IsEnabled { get; set; } } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelUpdateInput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelUpdateInput.cs index b35065d9..d8665253 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelUpdateInput.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelUpdateInput.cs @@ -99,4 +99,9 @@ public class AiModelUpdateInput /// 是否为尊享模型 /// public bool IsPremium { get; set; } + + /// + /// 是否启用 + /// + public bool IsEnabled { get; set; } } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ChannelService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ChannelService.cs index 750603d4..5a609297 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ChannelService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ChannelService.cs @@ -181,6 +181,7 @@ public class ChannelService : ApplicationService, IChannelService ProviderName = input.ProviderName, IconUrl = input.IconUrl, IsPremium = input.IsPremium, + IsEnabled = input.IsEnabled, IsDeleted = false }; @@ -222,6 +223,7 @@ public class ChannelService : ApplicationService, IChannelService entity.ProviderName = input.ProviderName; entity.IconUrl = input.IconUrl; entity.IsPremium = input.IsPremium; + entity.IsEnabled = input.IsEnabled; await _modelRepository.UpdateAsync(entity); return entity.Adapt(); 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 957931e8..af9bcb00 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 @@ -35,8 +35,9 @@ public class ModelService : ApplicationService, IModelService { RefAsync total = 0; - // 查询所有未删除的模型,使用WhereIF动态添加筛选条件 + // 查询所有未删除且已启用的模型,使用WhereIF动态添加筛选条件 var modelIds = (await _modelRepository._DbQueryable + .Where(x => x.IsEnabled) .WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), x => x.Name.Contains(input.SearchKey) || x.ModelId.Contains(input.SearchKey)) .WhereIF(input.ProviderNames is not null, x => @@ -51,6 +52,7 @@ public class ModelService : ApplicationService, IModelService .ToPageListAsync(input.SkipCount, input.MaxResultCount, total)); var entities = await _modelRepository._DbQueryable.Where(x => modelIds.Contains(x.ModelId)) + .Where(x => x.IsEnabled) .OrderBy(x => x.OrderNum) .OrderBy(x => x.Name).ToListAsync(); @@ -77,7 +79,7 @@ public class ModelService : ApplicationService, IModelService public async Task> GetProviderListAsync() { var providers = await _modelRepository._DbQueryable - .Where(x => !x.IsDeleted) + .Where(x => !x.IsDeleted && x.IsEnabled) .Where(x => !string.IsNullOrEmpty(x.ProviderName)) .GroupBy(x => x.ProviderName) .OrderBy(x => x.OrderNum) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/Model/AiModelEntity.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/Model/AiModelEntity.cs index ef0f1ebd..c04c8193 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/Model/AiModelEntity.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/Model/AiModelEntity.cs @@ -85,4 +85,9 @@ public class AiModelEntity : Entity, IOrderNum, ISoftDelete /// 是否为尊享模型 /// public bool IsPremium { get; set; } + + /// + /// 是否启用 + /// + public bool IsEnabled { get; set; } = true; } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs index d5ab1499..b2fa19d5 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs @@ -71,6 +71,7 @@ public class AiGateWayManager : DomainService .LeftJoin((model, app) => model.AiAppId == app.Id) .Where((model, app) => model.ModelId == modelId) .Where((model, app) => model.ModelApiType == modelApiType) + .Where((model, app) => model.IsEnabled) .Select((model, app) => new AiModelDescribe { diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/ModelManager.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/ModelManager.cs index e3a0df3a..1bbe0ea7 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/ModelManager.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/ModelManager.cs @@ -38,7 +38,7 @@ public class ModelManager : DomainService { // 从数据库查询 var premiumModelIds = await _aiModelRepository._DbQueryable - .Where(x => x.IsPremium) + .Where(x => x.IsPremium && x.IsEnabled) .Select(x => x.ModelId) .ToListAsync(); return premiumModelIds; diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs index 06f01662..33e89ad6 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs @@ -360,7 +360,7 @@ namespace Yi.Abp.Web var app = context.GetApplicationBuilder(); app.UseRouting(); - // app.ApplicationServices.GetRequiredService().SqlSugarClient.CodeFirst.InitTables(); + //app.ApplicationServices.GetRequiredService().SqlSugarClient.CodeFirst.InitTables(); // app.ApplicationServices.GetRequiredService().SqlSugarClient.CodeFirst.InitTables(); // app.ApplicationServices.GetRequiredService().SqlSugarClient.CodeFirst.InitTables(); diff --git a/Yi.Ai.Vue3/src/api/channel/index.ts b/Yi.Ai.Vue3/src/api/channel/index.ts index cd31154f..154bf6de 100644 --- a/Yi.Ai.Vue3/src/api/channel/index.ts +++ b/Yi.Ai.Vue3/src/api/channel/index.ts @@ -98,3 +98,8 @@ export function updateModel(data: AiModelUpdateInput) { export function deleteModel(id: string) { return del(`/channel/model/${id}`).json(); } + +// 清除尊享模型ID缓存 +export function clearPremiumModelCache() { + return post('/model/clear-premium-cache').json(); +} diff --git a/Yi.Ai.Vue3/src/api/channel/types.ts b/Yi.Ai.Vue3/src/api/channel/types.ts index 76a6306a..96fb710e 100644 --- a/Yi.Ai.Vue3/src/api/channel/types.ts +++ b/Yi.Ai.Vue3/src/api/channel/types.ts @@ -66,6 +66,7 @@ export interface AiModelDto { providerName?: string; iconUrl?: string; isPremium: boolean; + isEnabled: boolean; } // 创建AI模型输入 @@ -84,6 +85,7 @@ export interface AiModelCreateInput { providerName?: string; iconUrl?: string; isPremium: boolean; + isEnabled: boolean; } // 更新AI模型输入 @@ -103,6 +105,7 @@ export interface AiModelUpdateInput { providerName?: string; iconUrl?: string; isPremium: boolean; + isEnabled: boolean; } // 获取AI模型列表输入 diff --git a/Yi.Ai.Vue3/src/pages/console/channel/index.vue b/Yi.Ai.Vue3/src/pages/console/channel/index.vue index 318a79f2..a09b18e3 100644 --- a/Yi.Ai.Vue3/src/pages/console/channel/index.vue +++ b/Yi.Ai.Vue3/src/pages/console/channel/index.vue @@ -12,6 +12,7 @@ import { createModel, updateModel, deleteModel, + clearPremiumModelCache, } from '@/api/channel'; // ==================== 应用管理 ==================== @@ -182,6 +183,7 @@ function openModelDialog(type: 'create' | 'edit', row?: AiModelDto) { providerName: '', iconUrl: '', isPremium: false, + isEnabled: true, }; } else { @@ -228,6 +230,17 @@ async function handleDeleteModel(row: AiModelDto) { } } +// 清理尊享模型缓存 +async function handleClearCache() { + try { + await clearPremiumModelCache(); + ElMessage.success('缓存清理成功'); + } + catch (error: any) { + ElMessage.error(error.message || '缓存清理失败'); + } +} + // 初始化 onMounted(() => { fetchAppList(); @@ -306,6 +319,9 @@ onMounted(() => { clearable @keyup.enter="fetchModelList" /> + + 清理缓存 + 新建 @@ -338,6 +354,13 @@ onMounted(() => { + + + @@ -415,6 +438,9 @@ onMounted(() => { + + + diff --git a/Yi.Ai.Vue3/types/import_meta.d.ts b/Yi.Ai.Vue3/types/import_meta.d.ts index c98d612e..8f2a798b 100644 --- a/Yi.Ai.Vue3/types/import_meta.d.ts +++ b/Yi.Ai.Vue3/types/import_meta.d.ts @@ -7,7 +7,6 @@ interface ImportMetaEnv { readonly VITE_WEB_BASE_API: string; readonly VITE_API_URL: string; readonly VITE_FILE_UPLOAD_API: string; - readonly VITE_BUILD_COMPRESS: string; readonly VITE_SSO_SEVER_URL: string; readonly VITE_APP_VERSION: string; }