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 32cbe842..b7eb5177 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 @@ -1,6 +1,5 @@ using System.Collections.Concurrent; using System.Diagnostics; -using System.Net; using System.Runtime.CompilerServices; using System.Text; using System.Text.Json; @@ -93,14 +92,12 @@ public class AiGateWayManager : DomainService { throw new UserFriendlyException($"【{modelId}】模型当前版本【{modelApiType}】格式不支持"); } - // ✅ 统一处理 yi- 后缀(网关层模型规范化) if (!string.IsNullOrEmpty(aiModelDescribe.ModelId) && aiModelDescribe.ModelId.StartsWith("yi-", StringComparison.OrdinalIgnoreCase)) { aiModelDescribe.ModelId = aiModelDescribe.ModelId[3..]; } - return aiModelDescribe; } @@ -546,11 +543,11 @@ public class AiGateWayManager : DomainService { request.Model = request.Model[3..]; } - + var chatService = LazyServiceProvider.GetRequiredKeyedService(modelDescribe.HandlerName); var data = await chatService.ChatCompletionsAsync(modelDescribe, request, cancellationToken); - + data.SupplementalMultiplier(modelDescribe.Multiplier); if (userId is not null) @@ -620,7 +617,7 @@ public class AiGateWayManager : DomainService { request.Model = request.Model[3..]; } - + var completeChatResponse = chatService.StreamChatCompletionsAsync(modelDescribe, request, cancellationToken); ThorUsageResponse? tokenUsage = null; StringBuilder backupSystemContent = new StringBuilder(); @@ -980,7 +977,6 @@ public class AiGateWayManager : DomainService } private const string ImageStoreHost = "http://localhost:19001/api/app"; - /// /// Gemini 生成(Image)-非流式-缓存处理 /// 返回图片绝对路径 @@ -1017,13 +1013,7 @@ public class AiGateWayManager : DomainService var uploadUrl = $"{ImageStoreHost}/ai-image/upload-base64"; var content = new StringContent(JsonSerializer.Serialize(imagePrefixBase64), Encoding.UTF8, "application/json"); var uploadResponse = await httpClient.PostAsync(uploadUrl, content, cancellationToken); - // uploadResponse.EnsureSuccessStatusCode(); - if (uploadResponse.StatusCode != HttpStatusCode.OK) - { - var errorMessage = await uploadResponse.Content.ReadAsStringAsync(cancellationToken); - throw new UserFriendlyException($"{errorMessage}"); - } - + uploadResponse.EnsureSuccessStatusCode(); var storeUrl = await uploadResponse.Content.ReadAsStringAsync(cancellationToken); var tokenUsage = new ThorUsageResponse