From a3c7e9073465a0db3a69927f0b8361e9b670266d Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sat, 17 Aug 2024 18:08:22 -0500 Subject: [PATCH] feat: add constructor to allow setting cache control on tool result content --- .../Models/ToolResultContent.cs | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/AnthropicClient/Models/ToolResultContent.cs b/src/AnthropicClient/Models/ToolResultContent.cs index 1ada98c..634ac87 100644 --- a/src/AnthropicClient/Models/ToolResultContent.cs +++ b/src/AnthropicClient/Models/ToolResultContent.cs @@ -23,6 +23,12 @@ public class ToolResultContent : Content [JsonConstructor] internal ToolResultContent() : base(ContentType.ToolResult) { } + private void Validate(string toolUseId, string content) + { + ArgumentValidator.ThrowIfNull(toolUseId, nameof(toolUseId)); + ArgumentValidator.ThrowIfNull(content, nameof(content)); + } + /// /// Initializes a new instance of the class. /// @@ -32,10 +38,26 @@ public class ToolResultContent : Content /// A new instance of the class. public ToolResultContent(string toolUseId, string content) : base(ContentType.ToolResult) { - ArgumentValidator.ThrowIfNull(toolUseId, nameof(toolUseId)); - ArgumentValidator.ThrowIfNull(content, nameof(content)); + Validate(toolUseId, content); ToolUseId = toolUseId; Content = content; } + + /// + /// Initializes a new instance of the class. + /// + /// The tool use ID of the content. + /// The content of the tool result. + /// The cache control to be used for the content. + /// Thrown when the tool use ID or content is null. + /// A new instance of the class. + public ToolResultContent(string toolUseId, string content, CacheControl cacheControl) : base(ContentType.ToolResult) + { + Validate(toolUseId, content); + + ToolUseId = toolUseId; + Content = content; + CacheControl = cacheControl; + } } \ No newline at end of file