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]
|
[JsonConstructor]
|
||||||
internal ToolResultContent() : base(ContentType.ToolResult) { }
|
internal ToolResultContent() : base(ContentType.ToolResult) { }
|
||||||
|
|
||||||
|
private void Validate(string toolUseId, string content)
|
||||||
|
{
|
||||||
|
ArgumentValidator.ThrowIfNull(toolUseId, nameof(toolUseId));
|
||||||
|
ArgumentValidator.ThrowIfNull(content, nameof(content));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ToolResultContent"/> class.
|
/// Initializes a new instance of the <see cref="ToolResultContent"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -32,10 +38,26 @@ public class ToolResultContent : Content
|
|||||||
/// <returns>A new instance of the <see cref="ToolResultContent"/> class.</returns>
|
/// <returns>A new instance of the <see cref="ToolResultContent"/> class.</returns>
|
||||||
public ToolResultContent(string toolUseId, string content) : base(ContentType.ToolResult)
|
public ToolResultContent(string toolUseId, string content) : base(ContentType.ToolResult)
|
||||||
{
|
{
|
||||||
ArgumentValidator.ThrowIfNull(toolUseId, nameof(toolUseId));
|
Validate(toolUseId, content);
|
||||||
ArgumentValidator.ThrowIfNull(content, nameof(content));
|
|
||||||
|
|
||||||
ToolUseId = toolUseId;
|
ToolUseId = toolUseId;
|
||||||
Content = content;
|
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