From 76554ae9b4c48c00e574a3ad9868b7fedeec8d06 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 9 May 2025 10:36:44 -0400 Subject: [PATCH] Fix call id argument validation Some "OpenAI compatible" endpoints use empty tool call IDs. --- src/Custom/Chat/ChatToolCall.cs | 2 +- src/Custom/Chat/Messages/ToolChatMessage.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Custom/Chat/ChatToolCall.cs b/src/Custom/Chat/ChatToolCall.cs index 2f4b4e115..23aa229ba 100644 --- a/src/Custom/Chat/ChatToolCall.cs +++ b/src/Custom/Chat/ChatToolCall.cs @@ -50,7 +50,7 @@ public partial class ChatToolCall /// or is an empty string, and was expected to be non-empty. public static ChatToolCall CreateFunctionToolCall(string id, string functionName, BinaryData functionArguments) { - Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNull(id, nameof(id)); Argument.AssertNotNullOrEmpty(functionName, nameof(functionName)); Argument.AssertNotNull(functionArguments, nameof(functionArguments)); diff --git a/src/Custom/Chat/Messages/ToolChatMessage.cs b/src/Custom/Chat/Messages/ToolChatMessage.cs index 78acec671..038d6355f 100644 --- a/src/Custom/Chat/Messages/ToolChatMessage.cs +++ b/src/Custom/Chat/Messages/ToolChatMessage.cs @@ -37,7 +37,7 @@ public partial class ToolChatMessage : ChatMessage public ToolChatMessage(string toolCallId, IEnumerable contentParts) : base(ChatMessageRole.Tool, contentParts) { - Argument.AssertNotNullOrEmpty(toolCallId, nameof(toolCallId)); + Argument.AssertNotNull(toolCallId, nameof(toolCallId)); Argument.AssertNotNullOrEmpty(contentParts, nameof(contentParts)); ToolCallId = toolCallId; @@ -56,7 +56,7 @@ public ToolChatMessage(string toolCallId, IEnumerable co public ToolChatMessage(string toolCallId, params ChatMessageContentPart[] contentParts) : base(ChatMessageRole.Tool, contentParts) { - Argument.AssertNotNullOrEmpty(toolCallId, nameof(toolCallId)); + Argument.AssertNotNull(toolCallId, nameof(toolCallId)); Argument.AssertNotNullOrEmpty(contentParts, nameof(contentParts)); ToolCallId = toolCallId; @@ -72,7 +72,7 @@ public ToolChatMessage(string toolCallId, params ChatMessageContentPart[] conten public ToolChatMessage(string toolCallId, string content) : base(ChatMessageRole.Tool, content) { - Argument.AssertNotNullOrEmpty(toolCallId, nameof(toolCallId)); + Argument.AssertNotNull(toolCallId, nameof(toolCallId)); Argument.AssertNotNull(content, nameof(content)); ToolCallId = toolCallId;