From cf137f6307c602626c63c8fbd6f96163c28b32d0 Mon Sep 17 00:00:00 2001 From: chenchun Date: Wed, 29 Oct 2025 22:23:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E7=A9=BA=E5=80=BC=EF=BC=8CContents=20=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E6=97=B6=E8=BF=94=E5=9B=9E=20"=5F"=20=E5=B9=B6?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20Content=20=E5=88=A4=E7=A9=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 AnthropicMessageInput 中对 Content/Contents 的判空处理: - 当 Contents 为 null 或 Count==0 时返回 "_",以兼容客户端对空值的特殊处理。 - 修正对 Content 的判空逻辑,使用 !string.IsNullOrEmpty(...) 确保非空字符串优先返回,避免将空字符串当作有效内容。 --- .../Dtos/Anthropic/AnthropicMessageInput.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/Anthropic/AnthropicMessageInput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/Anthropic/AnthropicMessageInput.cs index 8242f251..6ea5a867 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/Anthropic/AnthropicMessageInput.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/Anthropic/AnthropicMessageInput.cs @@ -22,11 +22,15 @@ public class AnthropicMessageInput throw new ValidationException("Messages 中 Content 和 Contents 字段不能同时有值"); } - if (Content is not null) + if (!string.IsNullOrEmpty(Content)) { return Content; } - + // 如果 Contents 为空或 null,返回空字符串而不是 null + if (Contents == null || Contents.Count == 0) + { + return "_"; // 兼容客户端空值问题 + } return Contents!; } set