using System.Text.Json.Serialization; namespace AIStudio.Provider.OpenAI; /// /// The OpenAI's legacy chat completion request model. /// /// Which model to use for chat completion. /// The chat messages. /// Whether to stream the chat completion. public record ChatCompletionAPIRequest( string Model, IList Messages, bool Stream ) { public ChatCompletionAPIRequest() : this(string.Empty, [], true) { } [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public IList? Tools { get; init; } [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public bool? ParallelToolCalls { get; init; } /// /// Asks a streamed request to end with what it cost. /// /// /// Derived rather than set, so that every provider which builds one of these asks for it /// without having to know that it exists. A request which is not streamed carries no such /// line, and then the block would only be a field the provider has to ignore. /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public ChatCompletionStreamOptions? StreamOptions => this.Stream ? ChatCompletionStreamOptions.INCLUDE_USAGE : null; // Attention: The "required" modifier is not supported for [JsonExtensionData]. [JsonExtensionData] public IDictionary AdditionalApiParameters { get; init; } = new Dictionary(); }