using System.Text.Json.Serialization; using AnthropicClient.Utils; namespace AnthropicClient.Models; /// /// Represents content from a document that is part of a message. /// public class DocumentContent : Content { /// /// Gets the source of the document. /// public DocumentSource Source { get; init; } = new(); public string Title { get; init; } = string.Empty; public string Context { get; init; } = string.Empty; public CitationOption Citations { get; init; } = new CitationOption(); [JsonConstructor] internal DocumentContent() { } private void Validate(string mediaType, string data) { ArgumentValidator.ThrowIfNull(mediaType, nameof(mediaType)); ArgumentValidator.ThrowIfNull(data, nameof(data)); } /// /// Initializes a new instance of the class. /// /// The media type of the document. /// The data of the document. /// Thrown when the media type or data is null. /// A new instance of the class. public DocumentContent(string mediaType, string data) : base(ContentType.Document) { Validate(mediaType, data); Source = new(mediaType, data); } /// /// Initializes a new instance of the class. /// /// The media type of the document. /// The data of the document. /// The cache control to be used for the content. /// A new instance of the class. /// Thrown when the media type, data, or cache control is null. public DocumentContent(string mediaType, string data, CacheControl cacheControl) : base(ContentType.Document, cacheControl) { Validate(mediaType, data); Source = new(mediaType, data); } public DocumentContent(DocumentSource source) : base(ContentType.Document) { ArgumentValidator.ThrowIfNull(source, nameof(source)); Source = source; } public DocumentContent(DocumentSource source, CacheControl cacheControl) : base(ContentType.Document, cacheControl) { ArgumentValidator.ThrowIfNull(source, nameof(source)); Source = source; } } public class CitationOption { public bool Enabled { get; init; } }