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 d85ec770..971fef75 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 @@ -515,6 +515,8 @@ public class AiGateWayManager : DomainService // 设置响应头,声明是 json //response.ContentType = "application/json; charset=UTF-8"; var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Claude, request.Model); + + var sourceModelId = request.Model; if (!string.IsNullOrEmpty(request.Model) && request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase)) { @@ -533,7 +535,7 @@ public class AiGateWayManager : DomainService new MessageInputDto { Content = "不予存储", - ModelId = request.Model, + ModelId = sourceModelId, TokenUsage = data.TokenUsage, }, tokenId); @@ -541,11 +543,11 @@ public class AiGateWayManager : DomainService new MessageInputDto { Content = "不予存储", - ModelId = request.Model, + ModelId = sourceModelId, TokenUsage = data.TokenUsage }, tokenId); - await _usageStatisticsManager.SetUsageAsync(userId.Value, request.Model, data.TokenUsage, tokenId); + await _usageStatisticsManager.SetUsageAsync(userId.Value, sourceModelId, data.TokenUsage, tokenId); // 扣减尊享token包用量 var totalTokens = data.TokenUsage.TotalTokens ?? 0; @@ -588,6 +590,7 @@ 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)) { @@ -616,7 +619,7 @@ public class AiGateWayManager : DomainService catch (Exception e) { _logger.LogError(e, $"Ai对话异常"); - var errorContent = $"对话Ai异常,异常信息:\n当前Ai模型:{request.Model}\n异常信息:{e.Message}\n异常堆栈:{e}"; + var errorContent = $"对话Ai异常,异常信息:\n当前Ai模型:{sourceModelId}\n异常信息:{e.Message}\n异常堆栈:{e}"; throw new UserFriendlyException(errorContent); } @@ -624,7 +627,7 @@ public class AiGateWayManager : DomainService new MessageInputDto { Content = "不予存储", - ModelId = request.Model, + ModelId = sourceModelId, TokenUsage = tokenUsage, }, tokenId); @@ -632,11 +635,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)