diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/OpenApiService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/OpenApiService.cs index 105a2c50..19c99e29 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/OpenApiService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/OpenApiService.cs @@ -21,6 +21,7 @@ public class OpenApiService : ApplicationService private readonly AiGateWayManager _aiGateWayManager; private readonly ISqlSugarRepository _aiModelRepository; private readonly AiBlacklistManager _aiBlacklistManager; + public OpenApiService(IHttpContextAccessor httpContextAccessor, ILogger logger, TokenManager tokenManager, AiGateWayManager aiGateWayManager, ISqlSugarRepository aiModelRepository, AiBlacklistManager aiBlacklistManager) @@ -69,11 +70,12 @@ public class OpenApiService : ApplicationService public async Task ImagesGenerationsAsync([FromBody] ImageCreateRequest input, CancellationToken cancellationToken) { var httpContext = this._httpContextAccessor.HttpContext; + Intercept(httpContext); var userId = await _tokenManager.GetUserIdAsync(GetTokenByHttpContext(httpContext)); await _aiBlacklistManager.VerifiyAiBlacklist(userId); await _aiGateWayManager.CreateImageForStatisticsAsync(httpContext, userId, null, input); } - + /// /// 向量生成 /// @@ -83,6 +85,7 @@ public class OpenApiService : ApplicationService public async Task EmbeddingAsync([FromBody] ThorEmbeddingInput input, CancellationToken cancellationToken) { var httpContext = this._httpContextAccessor.HttpContext; + Intercept(httpContext); var userId = await _tokenManager.GetUserIdAsync(GetTokenByHttpContext(httpContext)); await _aiBlacklistManager.VerifiyAiBlacklist(userId); await _aiGateWayManager.EmbeddingForStatisticsAsync(httpContext, userId, null, input); @@ -127,4 +130,12 @@ public class OpenApiService : ApplicationService return null; } + + private void Intercept(HttpContext httpContext) + { + if (httpContext.Request.Host.Value == "yxai.chat") + { + throw new UserFriendlyException("当前海外站点不支持大流量接口,请使用转发站点:https://ai.ccnetcore.com"); + } + } } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiGateWay/Impl/ThorAzureOpenAI/Images/AzureOpenAIServiceImageService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiGateWay/Impl/ThorAzureOpenAI/Images/AzureOpenAIServiceImageService.cs index 09e05c9a..7511ddff 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiGateWay/Impl/ThorAzureOpenAI/Images/AzureOpenAIServiceImageService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiGateWay/Impl/ThorAzureOpenAI/Images/AzureOpenAIServiceImageService.cs @@ -13,7 +13,7 @@ public class AzureOpenAIServiceImageService : IImageService var createClient = AzureOpenAIFactory.CreateClient(options); var client = createClient.GetImageClient(imageCreate.Model); - + imageCreate.Size??="1024x1024"; // 将size字符串拆分为宽度和高度 var size = imageCreate.Size.Split('x'); if (size.Length != 2) diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json b/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json index e4f4be08..744b05ba 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json @@ -21,7 +21,7 @@ //应用启动 "App": { "SelfUrl": "http://*:19001", - "CorsOrigins": "http://localhost:19001;http://localhost:18000;vscode-file://vscode-app;https://web.chatboxai.app;capacitor://localhost;http://codegeex" + "CorsOrigins": "http://localhost:19001;http://localhost:18000;vscode-file://vscode-app;https://web.chatboxai.app;capacitor://localhost;http://codegeex;https://yxai.chat" }, //配置 "Settings": {