feat: 完成ai网关改造

This commit is contained in:
ccnetcore
2025-06-25 22:41:32 +08:00
parent 695aaedfba
commit c5037ea397
5 changed files with 32 additions and 31 deletions

View File

@@ -83,22 +83,22 @@ public class AiChatService : ApplicationService
public async Task PostSendAsync(SendMessageInput input, CancellationToken cancellationToken)
{
//除了免费模型,其他的模型都要校验
if (input.Model != "DeepSeek-R1-0528")
{
//有token需要黑名单校验
if (CurrentUser.IsAuthenticated)
{
await _aiBlacklistManager.VerifiyAiBlacklist(CurrentUser.GetId());
if (!CurrentUser.Roles.Contains("YiXinAi-Vip"))
{
throw new UserFriendlyException("该模型需要VIP用户才能使用请购买VIP后重新登录重试");
}
}
else
{
throw new UserFriendlyException("未登录用户只能使用未加速的DeepSeek-R1请登录后重试");
}
}
// if (input.Model != "DeepSeek-R1-0528")
// {
// //有token需要黑名单校验
// if (CurrentUser.IsAuthenticated)
// {
// await _aiBlacklistManager.VerifiyAiBlacklist(CurrentUser.GetId());
// if (!CurrentUser.Roles.Contains("YiXinAi-Vip"))
// {
// throw new UserFriendlyException("该模型需要VIP用户才能使用请购买VIP后重新登录重试");
// }
// }
// else
// {
// throw new UserFriendlyException("未登录用户只能使用未加速的DeepSeek-R1请登录后重试");
// }
// }
//前面都是校验,后面才是真正的调用
var httpContext = this._httpContextAccessor.HttpContext;