2024-06-27 23:26:53 -05:00
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
|
|
|
|
using AnthropicClient.Utils;
|
|
|
|
|
|
|
|
|
|
namespace AnthropicClient.Models;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-07-03 16:57:27 -05:00
|
|
|
/// Represents text content that is part of a message.
|
2024-06-27 23:26:53 -05:00
|
|
|
/// </summary>
|
|
|
|
|
public class TextContent : Content
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the text of the content.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Text { get; init; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[JsonConstructor]
|
|
|
|
|
internal TextContent() : base(ContentType.Text)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="TextContent"/> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="text">The text of the content.</param>
|
|
|
|
|
/// <exception cref="ArgumentNullException">Thrown when the text is null.</exception>
|
|
|
|
|
/// <returns>A new instance of the <see cref="TextContent"/> class.</returns>
|
|
|
|
|
public TextContent(string text) : base(ContentType.Text)
|
|
|
|
|
{
|
|
|
|
|
ArgumentValidator.ThrowIfNull(text, nameof(text));
|
|
|
|
|
|
|
|
|
|
Text = text;
|
|
|
|
|
}
|
2024-08-15 23:04:45 -05:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="TextContent"/> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="text">The text of the content.</param>
|
|
|
|
|
/// <param name="cacheControl">The cache control to be used for the content.</param>
|
|
|
|
|
/// <returns>A new instance of the <see cref="TextContent"/> class.</returns>
|
|
|
|
|
/// <exception cref="ArgumentNullException">Thrown when the text or cache control is null.</exception>
|
|
|
|
|
public TextContent(string text, CacheControl cacheControl) : base(ContentType.Text, cacheControl)
|
|
|
|
|
{
|
|
|
|
|
ArgumentValidator.ThrowIfNull(text, nameof(text));
|
|
|
|
|
|
|
|
|
|
Text = text;
|
|
|
|
|
}
|
2024-06-27 23:26:53 -05:00
|
|
|
}
|