From 5440b226c4b80f9885ed1f4c5ddc9495a3c025d1 Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Sat, 27 Dec 2025 23:49:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=20yi-=20=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=89=8D=E7=BC=80=E6=88=AA=E5=8F=96=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 统一将模型 ID 和请求 Model 的前缀去除逻辑由错误的尾部截取改为正确的从索引 3 开始截取,避免模型名称被截断导致调用异常 --- .../Managers/AiGateWayManager.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 7377423a..9a07479a 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 @@ -96,7 +96,7 @@ public class AiGateWayManager : DomainService if (!string.IsNullOrEmpty(aiModelDescribe.ModelId) && aiModelDescribe.ModelId.StartsWith("yi-", StringComparison.OrdinalIgnoreCase)) { - aiModelDescribe.ModelId = aiModelDescribe.ModelId[^3..]; + aiModelDescribe.ModelId = aiModelDescribe.ModelId[3..]; } return aiModelDescribe; } @@ -518,7 +518,11 @@ public class AiGateWayManager : DomainService var chatService = LazyServiceProvider.GetRequiredKeyedService(modelDescribe.HandlerName); var data = await chatService.ChatCompletionsAsync(modelDescribe, request, cancellationToken); - + if (!string.IsNullOrEmpty(request.Model) && + request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase)) + { + request.Model = request.Model[3..]; + } data.SupplementalMultiplier(modelDescribe.Multiplier); if (userId is not null) @@ -585,7 +589,7 @@ public class AiGateWayManager : DomainService if (!string.IsNullOrEmpty(request.Model) && request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase)) { - request.Model = request.Model[^3..]; + request.Model = request.Model[3..]; } var completeChatResponse = chatService.StreamChatCompletionsAsync(modelDescribe, request, cancellationToken);