using System.Text.Json.Serialization; using AnthropicClient.Utils; namespace AnthropicClient.Models; /// /// Represents a request to count the number of tokens in a message. /// public class CountMessageTokensRequest { /// /// Gets the model ID to be used for the request. /// public string Model { get; init; } = string.Empty; /// /// Gets the messages to count the number of tokens in. /// public List Messages { get; init; } = []; /// /// Gets the tool choice mode to use for the request. /// [JsonPropertyName("tool_choice")] public ToolChoice? ToolChoice { get; init; } = null; /// /// Gets the tools to use for the request. /// public List? Tools { get; init; } = null; /// /// Gets the system prompt to use for the request. /// [JsonPropertyName("system")] public List? SystemPrompt { get; init; } = null; /// /// Initializes a new instance of the class. /// /// The model ID to use for the request. /// The messages to count the number of tokens in. /// The tool choice mode to use for the request. /// The tools to use for the request. /// The system prompt to use for the request. /// Thrown when or is null. /// Thrown when is empty. /// A new instance of the class. public CountMessageTokensRequest( string model, List messages, ToolChoice? toolChoice = null, List? tools = null, List? systemPrompt = null ) { ArgumentValidator.ThrowIfNull(model, nameof(model)); ArgumentValidator.ThrowIfNull(messages, nameof(messages)); if (messages.Count < 1) { throw new ArgumentException("Messages must contain at least one message"); } Model = model; Messages = messages; ToolChoice = toolChoice; Tools = tools; SystemPrompt = systemPrompt; } }