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