diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Consts/PremiumPackageConst.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Consts/PremiumPackageConst.cs index cc857e19..235f9055 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Consts/PremiumPackageConst.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Consts/PremiumPackageConst.cs @@ -21,5 +21,11 @@ public class PremiumPackageConst "yi-claude-sonnet-4-5-20250929", "yi-claude-haiku-4-5-20251001", "yi-claude-opus-4-5-20251101", + + "yi-gpt-5.2", + "yi-gpt-5.2-codex", + "yi-gemini-3-pro-high", + "yi-gemini-3-pro", + ]; } \ 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 971fef75..5a1590ed 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 @@ -126,6 +126,14 @@ public class AiGateWayManager : DomainService var modelDescribe = await GetModelAsync(ModelApiTypeEnum.OpenAi, request.Model); var chatService = LazyServiceProvider.GetRequiredKeyedService(modelDescribe.HandlerName); + + var sourceModelId = request.Model; + if (!string.IsNullOrEmpty(request.Model) && + request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase)) + { + request.Model = request.Model[3..]; + } + var data = await chatService.CompleteChatAsync(modelDescribe, request, cancellationToken); data.SupplementalMultiplier(modelDescribe.Multiplier); if (userId is not null) @@ -134,7 +142,7 @@ public class AiGateWayManager : DomainService new MessageInputDto { Content = sessionId is null ? "不予存储" : request.Messages?.LastOrDefault().Content ?? string.Empty, - ModelId = request.Model, + ModelId = sourceModelId, TokenUsage = data.Usage, }, tokenId); @@ -143,14 +151,14 @@ public class AiGateWayManager : DomainService { Content = sessionId is null ? "不予存储" : data.Choices?.FirstOrDefault()?.Delta.Content ?? string.Empty, - ModelId = request.Model, + ModelId = sourceModelId, TokenUsage = data.Usage }, tokenId); - await _usageStatisticsManager.SetUsageAsync(userId.Value, request.Model, data.Usage, tokenId); + await _usageStatisticsManager.SetUsageAsync(userId.Value, sourceModelId, data.Usage, tokenId); // 扣减尊享token包用量 - if (PremiumPackageConst.ModeIds.Contains(request.Model)) + if (PremiumPackageConst.ModeIds.Contains(sourceModelId)) { var totalTokens = data.Usage?.TotalTokens ?? 0; if (totalTokens > 0) @@ -194,6 +202,13 @@ public class AiGateWayManager : DomainService var chatService = LazyServiceProvider.GetRequiredKeyedService(modelDescribe.HandlerName); + var sourceModelId = request.Model; + if (!string.IsNullOrEmpty(request.Model) && + request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase)) + { + request.Model = request.Model[3..]; + } + var completeChatResponse = chatService.CompleteChatStreamAsync(modelDescribe, request, cancellationToken); var tokenUsage = new ThorUsageResponse(); @@ -285,7 +300,7 @@ public class AiGateWayManager : DomainService new MessageInputDto { Content = sessionId is null ? "不予存储" : request.Messages?.LastOrDefault()?.MessagesStore ?? string.Empty, - ModelId = request.Model, + ModelId = sourceModelId, TokenUsage = tokenUsage, }, tokenId); @@ -293,14 +308,14 @@ public class AiGateWayManager : DomainService new MessageInputDto { Content = sessionId is null ? "不予存储" : backupSystemContent.ToString(), - ModelId = request.Model, + ModelId = sourceModelId, TokenUsage = tokenUsage }, tokenId); - await _usageStatisticsManager.SetUsageAsync(userId, request.Model, tokenUsage, tokenId); + await _usageStatisticsManager.SetUsageAsync(userId, sourceModelId, tokenUsage, tokenId); // 扣减尊享token包用量 - if (userId is not null && PremiumPackageConst.ModeIds.Contains(request.Model)) + if (userId is not null && PremiumPackageConst.ModeIds.Contains(sourceModelId)) { var totalTokens = tokenUsage.TotalTokens ?? 0; if (totalTokens > 0) @@ -677,6 +692,13 @@ public class AiGateWayManager : DomainService var chatService = LazyServiceProvider.GetRequiredKeyedService(modelDescribe.HandlerName); + var sourceModelId = request.Model; + if (!string.IsNullOrEmpty(request.Model) && + request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase)) + { + request.Model = request.Model[3..]; + } + var data = await chatService.ResponsesAsync(modelDescribe, request, cancellationToken); data.SupplementalMultiplier(modelDescribe.Multiplier); @@ -693,7 +715,7 @@ public class AiGateWayManager : DomainService new MessageInputDto { Content = "不予存储", - ModelId = request.Model, + ModelId = sourceModelId, TokenUsage = tokenUsage, }, tokenId); @@ -701,11 +723,11 @@ public class AiGateWayManager : DomainService new MessageInputDto { Content = "不予存储", - ModelId = request.Model, + ModelId = sourceModelId, TokenUsage = tokenUsage }, tokenId); - await _usageStatisticsManager.SetUsageAsync(userId.Value, request.Model, tokenUsage, tokenId); + await _usageStatisticsManager.SetUsageAsync(userId.Value, sourceModelId, tokenUsage, tokenId); // 扣减尊享token包用量 var totalTokens = tokenUsage.TotalTokens ?? 0; @@ -746,7 +768,12 @@ public class AiGateWayManager : DomainService var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Response, request.Model); var chatService = LazyServiceProvider.GetRequiredKeyedService(modelDescribe.HandlerName); - + var sourceModelId = request.Model; + if (!string.IsNullOrEmpty(request.Model) && + request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase)) + { + request.Model = request.Model[3..]; + } var completeChatResponse = chatService.ResponsesStreamAsync(modelDescribe, request, cancellationToken); ThorUsageResponse? tokenUsage = null; try @@ -786,7 +813,7 @@ public class AiGateWayManager : DomainService new MessageInputDto { Content = "不予存储", - ModelId = request.Model, + ModelId = sourceModelId, TokenUsage = tokenUsage, }, tokenId); @@ -794,11 +821,11 @@ public class AiGateWayManager : DomainService new MessageInputDto { Content = "不予存储", - ModelId = request.Model, + ModelId = sourceModelId, TokenUsage = tokenUsage }, tokenId); - await _usageStatisticsManager.SetUsageAsync(userId, request.Model, tokenUsage, tokenId); + await _usageStatisticsManager.SetUsageAsync(userId, sourceModelId, tokenUsage, tokenId); // 扣减尊享token包用量 if (userId.HasValue && tokenUsage is not null) diff --git a/Yi.Ai.Vue3/types/components.d.ts b/Yi.Ai.Vue3/types/components.d.ts index 9a5e6203..16d28441 100644 --- a/Yi.Ai.Vue3/types/components.d.ts +++ b/Yi.Ai.Vue3/types/components.d.ts @@ -49,6 +49,7 @@ declare module 'vue' { ElSegmented: typeof import('element-plus/es')['ElSegmented'] ElSelect: typeof import('element-plus/es')['ElSelect'] ElSkeleton: typeof import('element-plus/es')['ElSkeleton'] + ElSubMenu: typeof import('element-plus/es')['ElSubMenu'] ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTable: typeof import('element-plus/es')['ElTable'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn']