fix: 兼容客户端空值,Contents 为空时返回 "_" 并修正 Content 判空逻辑
修复 AnthropicMessageInput 中对 Content/Contents 的判空处理: - 当 Contents 为 null 或 Count==0 时返回 "_",以兼容客户端对空值的特殊处理。 - 修正对 Content 的判空逻辑,使用 !string.IsNullOrEmpty(...) 确保非空字符串优先返回,避免将空字符串当作有效内容。
This commit is contained in:
@@ -22,11 +22,15 @@ public class AnthropicMessageInput
|
|||||||
throw new ValidationException("Messages 中 Content 和 Contents 字段不能同时有值");
|
throw new ValidationException("Messages 中 Content 和 Contents 字段不能同时有值");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Content is not null)
|
if (!string.IsNullOrEmpty(Content))
|
||||||
{
|
{
|
||||||
return Content;
|
return Content;
|
||||||
}
|
}
|
||||||
|
// 如果 Contents 为空或 null,返回空字符串而不是 null
|
||||||
|
if (Contents == null || Contents.Count == 0)
|
||||||
|
{
|
||||||
|
return "_"; // 兼容客户端空值问题
|
||||||
|
}
|
||||||
return Contents!;
|
return Contents!;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
|
|||||||
Reference in New Issue
Block a user