Made ChatCompletionAPIRequest a record

This commit is contained in:
Thorsten Sommer 2025-09-01 22:41:51 +02:00
parent 1725339d26
commit 4711262920
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -9,10 +9,15 @@ namespace AIStudio.Provider.OpenAI;
/// <param name="Model">The model used for the response.</param> /// <param name="Model">The model used for the response.</param>
/// <param name="SystemFingerprint">The system fingerprint; together with the seed, this allows you to reproduce the response.</param> /// <param name="SystemFingerprint">The system fingerprint; together with the seed, this allows you to reproduce the response.</param>
/// <param name="Choices">The choices made by the AI.</param> /// <param name="Choices">The choices made by the AI.</param>
public readonly record struct ChatCompletionResponseStreamLine(string Id, string Object, uint Created, string Model, string SystemFingerprint, IList<Choice> Choices) : IResponseStreamLine public record ChatCompletionResponseStreamLine(string Id, string Object, uint Created, string Model, string SystemFingerprint, IList<Choice> Choices) : IResponseStreamLine
{ {
public ChatCompletionResponseStreamLine() : this(string.Empty, string.Empty, 0, string.Empty, string.Empty, [])
{
}
/// <inheritdoc /> /// <inheritdoc />
public bool ContainsContent() => this != default && this.Choices.Count > 0; public bool ContainsContent() => this.Choices.Count > 0;
/// <inheritdoc /> /// <inheritdoc />
public ContentStreamChunk GetContent() => new(this.Choices[0].Delta.Content, []); public ContentStreamChunk GetContent() => new(this.Choices[0].Delta.Content, []);
@ -23,10 +28,20 @@ public readonly record struct ChatCompletionResponseStreamLine(string Id, string
/// </summary> /// </summary>
/// <param name="Index">The index of the choice.</param> /// <param name="Index">The index of the choice.</param>
/// <param name="Delta">The delta text of the choice.</param> /// <param name="Delta">The delta text of the choice.</param>
public readonly record struct Choice(int Index, Delta Delta); public record Choice(int Index, Delta Delta)
{
public Choice() : this(0, new (string.Empty))
{
}
}
/// <summary> /// <summary>
/// The delta text of a choice. /// The delta text of a choice.
/// </summary> /// </summary>
/// <param name="Content">The content of the delta text.</param> /// <param name="Content">The content of the delta text.</param>
public readonly record struct Delta(string Content); public record Delta(string Content)
{
public Delta() : this(string.Empty)
{
}
}