feat: add constructor to allow setting cache control on tool result content
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ToolResultContent"/> class.
|
||||
/// </summary>
|
||||
@@ -32,10 +38,26 @@ public class ToolResultContent : Content
|
||||
/// <returns>A new instance of the <see cref="ToolResultContent"/> class.</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ToolResultContent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="toolUseId">The tool use ID of the content.</param>
|
||||
/// <param name="content">The content of the tool result.</param>
|
||||
/// <param name="cacheControl">The cache control to be used for the content.</param>
|
||||
/// <exception cref="ArgumentNullException">Thrown when the tool use ID or content is null.</exception>
|
||||
/// <returns>A new instance of the <see cref="ToolResultContent"/> class.</returns>
|
||||
public ToolResultContent(string toolUseId, string content, CacheControl cacheControl) : base(ContentType.ToolResult)
|
||||
{
|
||||
Validate(toolUseId, content);
|
||||
|
||||
ToolUseId = toolUseId;
|
||||
Content = content;
|
||||
CacheControl = cacheControl;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user