AI-Studio/app/MindWork AI Studio/Provider/Anthropic/ResponseStreamLine.cs
2026-09-10 17:32:38 +02:00

38 lines
1.2 KiB
C#

// ReSharper disable NotAccessedPositionalProperty.Global
namespace AIStudio.Provider.Anthropic;
/// <summary>
/// Represents a response stream line.
/// </summary>
/// <param name="Type">The type of the response line.</param>
/// <param name="Index">The index of the response line.</param>
/// <param name="Delta">The delta of the response line.</param>
public readonly record struct ResponseStreamLine(string Type, int Index, Delta Delta) : IResponseStreamLine
{
/// <inheritdoc />
public bool ContainsContent() => this != default &&
(!string.IsNullOrEmpty(this.Delta.Text) || !string.IsNullOrEmpty(this.Delta.Thinking));
/// <inheritdoc />
public ContentStreamChunk GetContent() => this.Delta.Type switch
{
"thinking_delta" => new(string.Empty, [], this.Delta.Thinking),
_ => new(this.Delta.Text, []),
};
#region Implementation of IAnnotationStreamLine
//
// Please note: Anthropic's API does not currently support sources in their
// OpenAI-compatible response stream.
//
/// <inheritdoc />
public bool ContainsSources() => false;
/// <inheritdoc />
public IList<ISource> GetSources() => [];
#endregion
}