feat: add support for citations

BREAKING CHANGE: Changed type of public Source properties.
Updated `Source` property on `DocumentContent` and `ImageContent`
types to use base `Source` type

- include support for citing custom sources
- include support for citing PDF sources
- include support for citing text sources
This commit is contained in:
Stevan Freeborn
2025-06-14 13:44:10 -05:00
parent d50989833e
commit 5b8d88a01d
21 changed files with 450 additions and 123 deletions
+33
View File
@@ -0,0 +1,33 @@
using System.Text.Json.Serialization;
namespace AnthropicClient.Models;
/// <summary>
/// Represents a text document source.
/// </summary>
public class TextSource : Source
{
/// <summary>
/// Gets the media type of the source.
/// </summary>
[JsonPropertyName("media_type")]
public string MediaType { get; } = "text/plain";
/// <summary>
/// Gets the data of the source.
/// </summary>
public string Data { get; init; } = string.Empty;
/// <summary>
/// Initializes a new instance of the <see cref="TextSource"/> class.
/// </summary>
/// <param name="data">The data of the document.</param>
/// <exception cref="ArgumentNullException">Thrown when the data is null.</exception>
/// <returns>A new instance of the <see cref="TextSource"/> class.</returns>
public TextSource(string data) : base(SourceType.Text)
{
Data = data;
}
}